input_dim, output_dim not working in updated keras tensorflow version
Hi,
I am working on a stock prediction assignment and was trying to get some help from your script. But I am facing some issues in updated keras / tensorflow version. Seems like input_dim, output_dim functions has deprecated. Could you help me to update that code for updated version.
Also, as I can see in your code, you are sending 3 dimensional input data like (None, 20, 6) for model training. When I use same approach, I am getting 0.000 accuracy in every epoch. I do not understand what I am doing wrong.
Please have a look at my model code and correct me if anything wrong:
model = Sequential()
model.add(LSTM(512, input_shape=(X_train.shape[1], X_train.shape[2]), return_sequences=True))
model.add(Dropout(0.4))
model.add(LSTM(256, return_sequences=True))
model.add(Dropout(0.3))
model.add(LSTM(128, return_sequences=True))
model.add(Dropout(0.2))
model.add(LSTM(64, return_sequences=True))
model.add(Dropout(0.2))
model.add(LSTM(32))
model.add(Dense(1, activation='linear'))
model.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])
model.summary()
history = model.fit(X_train, y_train, epochs=5, batch_size=64, validation_split=0.10)
Train on 3458 samples, validate on 385 samples Epoch 1/5 3458/3458 [==============================]3458/3458 [==============================] - 93s 27ms/step - loss: 0.0753 - acc: 0.0000e+00 - val_loss: 0.4183 - val_acc: 0.0000e+00
Epoch 2/5 3458/3458 [==============================]3458/3458 [==============================] - 78s 22ms/step - loss: 0.0145 - acc: 0.0000e+00 - val_loss: 0.1113 - val_acc: 0.0000e+00
Epoch 3/5 3458/3458 [==============================]3458/3458 [==============================] - 80s 23ms/step - loss: 0.0114 - acc: 0.0000e+00 - val_loss: 0.1157 - val_acc: 0.0000e+00
Epoch 4/5 3458/3458 [==============================]3458/3458 [==============================] - 97s 28ms/step - loss: 0.0097 - acc: 0.0000e+00 - val_loss: 0.0560 - val_acc: 0.0000e+00
Epoch 5/5 3458/3458 [==============================]3458/3458 [==============================] - 79s 23ms/step - loss: 0.0097 - acc: 0.0000e+00 - val_loss: 0.0951 - val_acc: 0.0000e+00
Regards, Ankit Aggarwal
it work confirm. The last item sholud be :
if using within a jupyter notebook
%matplotlib inline
import matplotlib import matplotlib.pyplot as plt2
plt2.plot(pred, color='red', label='Prediction') plt2.plot(y_test, color='blue', label='Ground Truth') plt2.legend(loc='upper left') plt2.show()