Hi Foysol,
I understand that you want to train a LSTM model to predict output 5 steps ahead. The example you are currently referring to shows how to train an LSTM model to predict a single element ahead in the sequence.
You can predict next 5 outputs by utilizing the “Closed loop forecasting” method where in order to predict output for time steps t to t + k, you need to have true value for the time step t - 1 only. Then, to make prediction for step i, use the predicted value for time step i – 1 as input.
numPredictionTimeSteps = 5; %Predict for next 5 time steps
Y = zeros(numPredictionTimeSteps,numChannels);
Y(1,:) = Z(end,:);
for t = 2:numPredictionTimeSteps
[Y(t,:),state] = predict(net,Y(t-1,:));
net.State = state;
end
You can refer to the “Closed loop forecasting” section of the “Sequence Forecasting Using Deep Learning Example” by following the below link:
I hope this resolves the issue!
