Created
June 21, 2015 17:57
-
-
Save xiangze/da0786739c323806fb13 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 numpy | |
import theano | |
import theano.tensor as T | |
rng = numpy.random | |
N = 20 | |
dt= theano.shared(0.1, name="dt") | |
x = theano.shared(rng.randn(N), name="x") | |
y = theano.shared(rng.randn(N), name="y") | |
z = theano.shared(rng.randn(N), name="z") | |
p=T.scalar("p") | |
b=T.scalar("b") | |
r=T.scalar("r") | |
#lorenz | |
xn=x+dt*(y-x)*p | |
yn=y+dt*(-x*z+r*x-y) | |
zn=z+dt*(x*y-b*z) | |
lorenz = theano.function( | |
inputs=[p,b,r], | |
outputs=[xn,yn,zn], | |
updates={x:xn,y:yn,z:zn}) | |
for i in xrange(10): | |
print lorenz(10,28,8./3) | |
#rossler | |
a=T.scalar("a") | |
b=T.scalar("b") | |
c=T.scalar("c") | |
rossler_param=[a,b,c] | |
rossler_out=[ | |
x+dt*(-y-z), | |
x+dt*(x+a*y), | |
z+dt*z*(x-c) | |
] | |
rossler = theano.function( | |
inputs=rossler_param, | |
outputs=[xn,yn,zn], | |
updates=tuple(zip(*[[x,y,z],rossler_out]))) | |
for i in xrange(10): | |
print rossler(0.2,0.2,5.7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment