简体   繁体   中英

How do I predict on multiple samples on an LSTM model?

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:)

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 (ie input shape, output shape) is the same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM