1

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)
Amir
  • 16,067
  • 10
  • 80
  • 119
Nav
  • 78
  • 10

1 Answers1

2

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.

Ankish Bansal
  • 1,827
  • 3
  • 15
  • 25
  • I had return_sequence set in the previos version of what i have (it didn't worked for other reasons) but for current version this was the missing puzzle. Thanks – Nav Jan 14 '19 at 01:33