Created
November 12, 2018 04:17
-
-
Save ahmadyan/19f49e26d8b24ec024951e25b0ac6c33 to your computer and use it in GitHub Desktop.
Autodiff Rosenbrock function using PyTorch
This file contains 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
x = [Variable(FloatTensor([1]), requires_grad=True), | |
Variable(FloatTensor([3]), requires_grad=True)] | |
y = rosenbrock(x) | |
y.backward() | |
print(y, x[0].grad, x[1].grad) | |
#Expect to see 400, -800, 400 as a result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment