Hello Theano users,
can anybody tell me what am I doing wrong? My problem is best illustrated
by simplified code at the end.
I get 1.15s for theano code, while weave and numpy take 0.0076 and 0.0019s
respectively.
In reality I try to integrate ODE using Euler steps. My state is vector of
length 4 (scalar in example),
I have nontrivial step function, and parameters.
First I've build an expression to compute single step. Then I used
scan(lambda a,b,c: clone(new_state,
replace={state=b, control=a, params=c},
outputs_info = [init_state],
sequences = [controls],
non_sequences = [params])
to get a time evolution.
Any help would be appreciated, thanks
Jozef Vesely
#!/usr/bin/env python
import time
import numpy as np
from scipy import weave
import theano
from theano import tensor
xinit = theano.tensor.dscalar("xinit")
y = theano.tensor.dvector("y")
c,u = theano.scan( lambda x,y: x+y, outputs_info = [xinit], sequences = [y])
f = theano.function(inputs=[xinit,y], outputs=c)
y = np.ones(100000)
started = time.time()
x = f(0, y)
print time.time() - started, x
started = time.time()
x = np.zeros_like(y)
weave.inline("for (int i=1; i<Nx[0]; i++){ X1(i) = X1(i-1) + Y1(i);}",
["x","y"])
print time.time() - started, x
started = time.time()
x = np.cumsum(y)
print time.time() - started, x
--
---
You received this message because you are subscribed to the Google Groups
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.