Last active
September 9, 2016 04:39
-
-
Save yukoba/5c643f70587f84e4ec7f9e7221cfc710 to your computer and use it in GitHub Desktop.
Steepest descent method using theano.scan()
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
import theano | |
import theano.tensor as T | |
# Steepest descent method using theano.scan() | |
def fn(x, learning_rate): | |
y = x ** 2 - x | |
return x - learning_rate * T.grad(y, x) | |
init_x = T.dscalar() | |
result, updates = theano.scan(fn=fn, | |
outputs_info=init_x, | |
non_sequences=0.3, | |
n_steps=100) | |
f2 = theano.function([init_x], result[-1], updates=updates) | |
print(f2(1)) # 0.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment