3
votes

In Keras, if I want to predict on my LSTM model for multiple instances, that are based on independent and new data from the training data, does the input array need to include the amount of time steps used in training? And, if so, can I expect that the shape of the input array for model.predict to be the same as the training data? (Ie [number of samples to be predicted on, their timesteps, their features])?

Thank you :)

1

1 Answers

0
votes

You need to distinguish between the 'sample' or 'batch' axis and the time steps and features dimensions.

The number of samples is variable - you can train (fit) your model on thousands of samples, and make a prediction for a single sample.

The times steps and feature dimensions have to be identical for fit and predict - that is because the weights etc. have the same dimensions for the input layer.

In that, an LSTM is not that much different from a DNN.

There are cases (eg. one-to-many models) in which the application is different, but the formal design (i.e. input shape, output shape) is the same.