Skip to content

Instantly share code, notes, and snippets.

@alexbw
Created January 28, 2017 01:30
Show Gist options
  • Save alexbw/b4986ea9dfdd2407530b7a8472572d77 to your computer and use it in GitHub Desktop.
Save alexbw/b4986ea9dfdd2407530b7a8472572d77 to your computer and use it in GitHub Desktop.
def f(params,image):
h1 = layer1(params,image)
h2 = layer2(params,h1)
with gradsthru(h2) as gh2:
print("Only evaluated in the backwards pass!")
print(np.linalg.norm(gh2))
print("Clipping just this gradient!")
gh2 = np.clip(gh2,-10,10)
return softmax(h2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment