Skip to content

Instantly share code, notes, and snippets.

@ahmadyan
Created November 12, 2018 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmadyan/19f49e26d8b24ec024951e25b0ac6c33 to your computer and use it in GitHub Desktop.
Save ahmadyan/19f49e26d8b24ec024951e25b0ac6c33 to your computer and use it in GitHub Desktop.
Autodiff Rosenbrock function using PyTorch
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