Closed hfl15 closed 7 years ago
Can you provide a minimal piece of code that demonstrates this error, please?
dt = 0.1
x0=2
coef = -0.2
t = np.arange(0,30,dt)
x = odeint(lambda x,t:coef*x,x0,t)
plt.plot(t,x)
train_x = t
test_x = t
train_y = x
test_y = x
varnames = 't'
models = ffx.run(train_x,train_y,test_x,test_y,varnames)
The is a same error with the code above.
For the problem I face with before as follow. I got a time series 'x', and value as follow: array([ 0.46434198, 0.77793332, 0.88606827, 0.88066152, 0.70944786, 0.61392865, 0.38864751, -0.58096251, 0.08406741, 2.10258643, 0.96176274, -0.14662048, 0.99420322, -0.24394193, 1.29698107, 1.50604197, 0.68782087, 0.03901118, 0.14354163, 0.92031101, 0.26969907, -0.18266546, 0.89507952, 1.38709353, 0.40306551, 1.02484145, -0.29080041, 0.74729509, 1.61237467, -0.65485473, 0.14173938, 0.99240097, -0.41515559, 2.02869422, 0.64276464, 0.54724544, 1.38709353, 0.52201395, 0.38143852, 1.65202415, 0.35440478, -0.3052184 , 0.45713298, -0.10877324, -0.03668328, -0.48724556, 0.19400461, 1.18343938, -0.29080041])
I want to learn dx/dt = f(x), and the code is :
dt = 1
dx = np.gradient(x,dt)
train_x = x
test_x = x
train_y = dx
test_y = dx
varnames = 'x'
dxdt_fitted_result = run_ffx(train_x,train_y,test_x,test_y,varnames)
The IndexError is: too many indices for array. I don't know what's wrong happen so turn to your help. Very appreciate !
Yes, your arrays are the wrong shape. If you look at the x_square_test.py
file, in /tests
, you'll see that train_X
and train_y
have shapes (4, 1) and (4,) respectively. Yours are the other way around, i.e. (300,) and (300, 1).
(BTW use three backquotes to format blocks of code, and BTW run_ffx
should be ffx.run
.)
Thank you very much.
Hello. I have a time series 'x', I use np.gradient to calculate dx/dt, then I want to learn a function like that dx/dt=f(x). In this case here, for the FFX, target is the dx/dt, and trainx, testx is the original time series. But I face with the problem as follow. It is no problem to do the same things with the model dx/dt = 0.2x.
The problem as follow:
IndexError Traceback (most recent call last)