LSTM network time series prediction error occurs at the initial time step
Show older comments
I have trained a LSTM network for time series regression. After training, I want to test its performance based on the test dataset. The testing result of one single sample (extracted from minibatch results) is shown as follows:

The prediction result has a transient response process. I think this issue is caused by the zero states (CellStates and HiddenStates) of LSTM netweok. How to resolve this zero states problem when predicting time sreries ?
2 Comments
xingxingcui
on 4 Apr 2026
@Chuguang PanCould you share your original files, including the code that produced this figure? Please include the minimal code needed to reproduce it.
Answers (1)
Ritam
on 16 Apr 2026
0 votes
I observed from the code that your “modelLoss” returns states, but you don’t write them back to the network. You are essentially reshaping the long sequence into [C × T × numWindows] and feeding each window as a separate sequence. That means each window begins with an implicit reset to initial state (zeros), unless you explicitly carry state across windows.
In Time Series Forecasting Using Deep Learning - MATLAB & Simulink, the model states are explicitly updated in each iteration. It may resolve the issue that you are encountering.
1 Comment
Chuguang Pan
on 17 Apr 2026
Categories
Find more on Image 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!
