1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
from keras.models import Sequential
from keras.layers import Conv1D, MaxPooling1D, Flatten, Dense, RepeatVector, TimeDistributed
from keras.layers import Dense, LSTM
n = 1000
X,Y,_,_,_ = test_set2(1234,n)
X = X.reshape(X.shape[0], X.shape[1], 1)
Y = Y.reshape(Y.shape[0],Y.shape[1],1)
from keras.model import Model
from keras.layers import Input
model =Sequential()
model.add(LSTM(100, activation='relu', input_shape=(X.shape[1], X.shape[2])))
model.add(RepeatVector(3))
model.add(LSTM(100, return_sequences=True,activation='relu'))
model.add(TimeDistributed(Dense(1)))
model.compile(optimizer='adam', loss='mse')
model.summary()
model.fit(X,Y, epochs=100)
n = 100
X,Y,,,_ = test_set2(4321,n)
X = X.reshape(X.shape[0], X.shape[1], 1)
Y = Y.reshape(Y.shape[0],Y.shape[1],1)
model.evaluate(X,Y)
y_pred = model.predict(X)
y_pred.shape
plt.scatter(y_pred[:,0,:], Y[:,0,:])
plt.show()
plt.scatter(y_pred[:,1,:], Y[:,1,:])
plt.show()
plt.scatter(y_pred[:,2,:], Y[:,2,:])
plt.show()
|