필터 지우기
필터 지우기

Is there a method to predict one point in the future based on multiple point of past prediction? (LSTM univariate)

조회 수: 2 (최근 30일)
To explain the title above, how do i get prediction for i+1 based on i and i-1 combined?
I had already done the training and got the training info inside variable net.
This is an example of the code for LSTM trained net to predict 1 value into the future from Mathworks website.
for i=1:numTimeStepsTest
[net,YPred(:,i)] = predictAndUpdateState(net,YPred(:,i-1));
end
I appreciate if anyone can help direct me to any forum/article regarding this matter if it has been answered previously.
Thank you.

답변 (1개)

Aman Banthia
Aman Banthia 2023년 9월 22일
Hi Revaldo,
I understand that you want to obtain a prediction for the next time step (i+1) based on the previous two time steps (i and i-1) using a trained LSTM network in MATLAB.
To get a prediction for ‘i+1’ based on ‘i’ and ‘i-1’ combined using a trained LSTM network in MATLAB, you can modify the code you provided as follows:
% Assuming you have already trained the LSTM network and have it stored in the variable 'net'
% Initialize variables
numTimeStepsTest = ...; % Specify the number of time steps for testing
YPred = zeros(...); % Initialize the prediction array
% Perform prediction for each time step
for i = 2:numTimeStepsTest
% Combine inputs for prediction
combinedInput = [YPred(:, i-1), YPred(:, i-2)]; % Combine previous predictions
% Predict the next time step and update the network state
[net, YPred(:, i)] = predictAndUpdateState(net, combinedInput);
end
Please refer to the following MATLAB File Exchange link for more information:
Please refer to the following MATLAB Documentation link to know more about LSTM:
Hope the above solution helps.
Best Regards,
Aman Banthia

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by