Difference in initial predicition for LSTM Training matlab

16 views (last 30 days)
Ranjith
Ranjith on 2 Dec 2025 at 4:48
Answered: Ayush on 9 Dec 2025 at 8:14
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.

Answers (1)

Ayush
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:
  1. 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.
  2. 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.
  3. Expand Training Data: Include more varied starting points or sequences in your training set so the model can generalize better to unseen initial conditions.
You can refer to the following documentation to know more about "predictAndUpdateState" function:
Hope this helps!

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!