- State Initialization: Before making predictions on new data, try updating the LSTM’s state using a short “warm-up” sequence from your test data. In MATLAB, you can use the predictAndUpdateState function with a few initial timesteps before starting your actual prediction.
- Try Including Time as a Feature: If there are trends or seasonality, adding a time or sequence index as an input feature can help the model with initial predictions.
- Expand Training Data: Include more varied starting points or sequences in your training set so the model can generalize better to unseen initial conditions.
Difference in initial predicition for LSTM Training matlab
16 views (last 30 days)
Show older comments
I have done timeseries training with LSTM in matlab. Once i am doing prediction for data apart from training i am observing difference in initial timestep then its matching quite well with actual test data. Is there any way to improve it?
Dataset has two input and one output. i have normalised dataset and havent considered time as feature in the dataset.

0 Comments
Answers (1)
Ayush
on 9 Dec 2025 at 8:14
Hi Ranjith,
I understand you’re seeing a mismatch at the initial timestep when using your trained LSTM for prediction, but the model aligns well with actual test data after that.
You can try the following recommendations to improve the initial prediction:
You can refer to the following documentation to know more about "predictAndUpdateState" function:
Hope this helps!
0 Comments
See Also
Categories
Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!