Timeseries prediction using LSTM
조회 수: 10 (최근 30일)
이전 댓글 표시
Hello everyone,
While I got the code to run on my univariate data, I receive undesired results.
I have seen it is general practise when training LSTM's to create a feature vector of the responses (YTrain) such that the network tries to predict the next datapoint from the previous "n" (e.g. 6) timeseries datapoints.
MATLAB's example uses the observations and the responses lagged by 1 unit apart, such that the previous datapoint predicts the next:
XTrain = dataTrainStandardized(1:end-1);
YTrain = dataTrainStandardized(2:end);
I tried creating my response matrix such that:
lookback = 6;
lag = 1;
XTrain = dataTrainStandardized(1:end-1)
YTrain = zeros(length(dataTrainStandardized)-lag,lookback);
for i = 1+lag:length(dataTrainStandardized)-lookback
YTrain(i-1,:) = dataTrainStandardized(i:i+lookback-1);
end
However I get the error:
Error using trainNetwork (line 183)
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that
dimension.
Which is reasonable since XTrain is a [1 x i] vector and YTrain is a [i x lookback] matrix .
Can anyone help? How can I train my LSTM to derive the predictions from the previous "n" datapoints and not just the last?Maybe this isn't possible with MATLAB's Deep Learning Toolbox.
댓글 수: 0
답변 (2개)
Arthur B
2021년 3월 8일
Hi Milton,
Same issue here : I'd like to perform sequence-to-sequence regression or classification, but I beleive that the LSTM looks back at ALL the previous timesteps, and I would like to limit it looking at only a few (say 10) timesteps.
My timeserie is thousands of timesteps long, but I know that those older than 10 timesteps have no effect on the output.
Since I found no option to limit the number of lookback timesteps, I thought like you I could duplicate my timeserie into multiple features which would just represent a window of 10 running timesteps, with one output (and therefore perform a sequence-to-one regression).
Have you been able to progress with your problem?
Can anyone confirm the proposed way forward is the best, or if there is better?
댓글 수: 0
Vineet Joshi
2021년 4월 22일
Hi
You can refer to the following answer for more information on this.
Hope this helps.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!