Theano SDE example -
Theano SDE example -
i'm trying work through illustration on solving sdes on gpu using theano found here
i'm stuck gpudimshuffle error, i'm not seeing how of dims don't match...
import theano import theano.tensor t theano.tensor.shared_randomstreams import randomstreams import numpy np import matplotlib.pyplot plt import time #define ode function #dc/dt = f(c, lambda) #c vector n components def evolve(c, n, k, l): homecoming t.pow(c, n)/(t.pow(c, n)+t.pow(k,n)) - l*c def euler(c, n, k, l, dt): homecoming t.cast(c + dt*evolve(c, n, k, l) + t.sqrt(dt)*c*rv_n, 'float32') def rk4(c, n, k, l, dt): ''' adapted http://people.sc.fsu.edu/~jburkardt/c_src/stochastic_rk/stochastic_rk.html ''' a21 = 2.71644396264860 a31 = - 6.95653259006152 a32 = 0.78313689457981 a41 = 0.0 a42 = 0.48257353309214 a43 = 0.26171080165848 a51 = 0.47012396888046 a52 = 0.36597075368373 a53 = 0.08906615686702 a54 = 0.07483912056879 q1 = 2.12709852335625 q2 = 2.73245878238737 q3 = 11.22760917474960 q4 = 13.36199560336697 x1 = c k1 = dt * evolve(x1, n, k, l) + t.sqrt(dt) * c * rv_n x2 = x1 + a21 * k1 k2 = dt * evolve(x2, n, k, l) + t.sqrt(dt) * c * rv_n x3 = x1 + a31 * k1 + a32 * k2 k3 = dt * evolve(x3, n, k, l) + t.sqrt(dt) * c * rv_n x4 = x1 + a41 * k1 + a42 * k2 k4 = dt * evolve(x4, n, k, l) + t.sqrt(dt) * c * rv_n homecoming t.cast(x1 + a51 * k1 + a52 * k2 + a53 * k3 + a54 * k4, 'float32') #random srng = randomstreams(seed=31415) #define symbolic variables dt = t.fscalar("dt") k = t.fscalar("k") l = t.fscalar("l") n = t.fscalar("n") c = t.fvector("c") #define numeric variables num_samples = 50000 c0 = theano.shared(0.5*np.ones(num_samples, dtype='float32')) n0 = 6 k0 = 0.5 l0 = 1/(1+np.power(k0, n0)) dt0 = 0.1 total_time = 8 total_steps = int(total_time/dt0) rv_n = srng.normal(c.shape, std=0.05) #is shared variable #create loop #first symbolic loop (cout, updates) = theano.scan(fn=rk4, outputs_info=[c], #output shape non_sequences=[n, k, l, dt], #fixed parameters n_steps=total_steps) #compile sim = theano.function(inputs=[n, k, l, dt],givens={c:c0}, outputs=cout,updates=updates,allow_input_downcast=true) yielding:
typeerror: ('the next error happened while compiling node', rebroadcast{0(gpudimshuffle{x,0}.0), '\n', 'super(type, obj): obj must instance or subtype of type')
i'm on theano 0.6.0
if update development version, work me:
http://www.deeplearning.net/software/theano/install.html#bleeding-edge-install-instructions
we seek maintain development version stable , recomment utilize it, since contain many fixes since lastly release.
if don't prepare it, error specific os or python version. need more info it. provide total error message traceback. provide much more debugging information.
theano
Comments
Post a Comment