Reputation: 82
I want to make an LSTM neural net using Keras which gets as input some length of four features and predicts 10 following values. And I can't manage to set proper input dimensions. X_train
is an array of shape (34,5,4) (repeated observations, the sequence of observations, features) y_train
is an array of shape(34,10). I can't manage to satisfy the required dimensions.
Any ideas what am I doing wrong?
X_train = X_train.reshape((X_train.shape[0], X_train.shape[1], 4))
model.add(LSTM(30, dropout=0.2, batch_size=window_size))
model.add(LSTM(10, activation=None))
model.compile(optimizer='adam',loss='mse')
model.fit(X_train,y_train,epochs= epochs,validation_split=0.2,shuffle=True)
Upvotes: 1
Views: 303
Reputation: 1902
If you are stacking two lstm
layer, you need to use return_sequence
for first layer, which return output for each time step, which will be feed into 2nd lstm
layer.
Here is explained example, by which you can solve your problem.
Upvotes: 2