Last active
August 15, 2018 02:40
-
-
Save yaroslavvb2/abbfc45fc178e4f304a784daba88bb01 to your computer and use it in GitHub Desktop.
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
@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