Skip to content

Instantly share code, notes, and snippets.

@vaibkumr
Created January 7, 2019 15:12
Show Gist options
  • Select an option

  • Save vaibkumr/7c8a47abdd02629db652b313c76a0290 to your computer and use it in GitHub Desktop.

Select an option

Save vaibkumr/7c8a47abdd02629db652b313c76a0290 to your computer and use it in GitHub Desktop.
backward function
import torch
# Creating the graph
x = torch.tensor(1.0, requires_grad = True)
z = x ** 3
z.backward() #Computes the gradient
print(x.grad.data) #Prints '3' which is dz/dx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment