0
votes

I have trained my LSTM with 3 time steps. Following is the Keras LSTM layer.

model.add(LSTM(32, return_sequences=True, input_shape=(None, 3))).

ex:

   X                           Y
   [[1,2,3],[2,3,4],[4,5,6]]   [[4],[5],[7]]

Now I need to predict the next value of a sequence with different time_steps (ex: 2)

  X= [[1,2]]

When I use X= [[1,2]] I am getting following error

ValueError: Error when checking input: expected lstm_1_input to have shape (None, 3) 
but got array with shape (1, 2)

Should I provide the same shape while I used for training.

Or can I still use a different timesteps (input shape) for predicting.

Appreciate your help on this issue.

1

1 Answers

0
votes

I believe you need to use the same shape when using your model to predict on new data. Your data was trained with 3 timesteps (train_X), so you should feed it a 3-timesteps input when you model.predict your test data (test_X).