Skip to content

Instantly share code, notes, and snippets.

@vinhkhuc
Last active January 14, 2018 23:59
Show Gist options
  • Save vinhkhuc/fb9cd4d551045b726689 to your computer and use it in GitHub Desktop.
Save vinhkhuc/fb9cd4d551045b726689 to your computer and use it in GitHub Desktop.
from theano import tensor as T, function
x = T.dscalar('x')
y = x ** 2
dy = T.grad(cost=y, wrt=x) # Preparing symbolic gradient
df = function(inputs=[x], outputs=dy)
print(df(4)) # Output: 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment