Skip to content

Instantly share code, notes, and snippets.

@yaroslavvb2
Last active August 15, 2018 02:40
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 yaroslavvb2/abbfc45fc178e4f304a784daba88bb01 to your computer and use it in GitHub Desktop.
Save yaroslavvb2/abbfc45fc178e4f304a784daba88bb01 to your computer and use it in GitHub Desktop.
@tfe.custom_gradient
def noisy_square(x):
  def grad(b):
 true_grad = 2*b*x
  return true_grad+tf.random_uniform(())
  return (x*x), grad
grad = tfe.gradients_function(noisy_square)
x = 2.
points = []
for i in range(20):
  x -= .9*grad(x)[0]
  print(x, loss(x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment