Timeseries prediction using LSTM

10 ビュー (過去 30 日間)
Milton Logothetis
Milton Logothetis 2021 年 1 月 21 日
回答済み: Vineet Joshi 2021 年 4 月 22 日
Hello everyone,
I am trying to implement MATLAB's LSTM example for timeseries forecasting.
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.

回答 (2 件)

Arthur B
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?

Vineet Joshi
Vineet Joshi 2021 年 4 月 22 日
Hi
You can refer to the following answer for more information on this.
Hope this helps.

カテゴリ

Help Center および File ExchangeSequence and Numeric Feature Data Workflows についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by