Created
January 7, 2019 15:12
-
-
Save vaibkumr/7c8a47abdd02629db652b313c76a0290 to your computer and use it in GitHub Desktop.
backward function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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