How to Update LSTM Network State with Observed Values using "Stateful Predict" block in SIMULINK?

6 vues (au cours des 30 derniers jours)
Hello everyone,
I am simulating an LSTM in Simulink using "Stateful Predict" block. In help of this block mentioned "This block updates the state of the network with every prediction."
I would like to know if it is possible to update the sataes of the network with observed value instead of every prediction.
Similar work to this example https://uk.mathworks.com/help/deeplearning/ug/time-series-forecasting-using-deep-network-designer.html that has two parts after training network. 1) Forecast Future Time Steps 2) Update Network State with Observed Values
I would be grateful if you could please advise me how to simulate this.

Réponses (1)

Sanjana
Sanjana le 31 Oct 2023
Hi Leila.
I understand that you are trying to achieve predictions and update the network State based on Observed values instead of predicted values as mentioned in the attached example in Simulink.
YPred = [];
numTimeStepsTest = numel(XTest);
for i = 1:numTimeStepsTest
[net,YPred(:,i)] = predictAndUpdateState(net,XTest(:,i),'ExecutionEnvironment','cpu');
end
As mentioned in the above code, “predictAndUpdateState” is used to update the state of the network and based on the observed values.
The same is achieved through “Stateful Predict” block. If you check the implementation inside the mask of the “Stateful Predict”,
“SequenceNetworkPredict” internally uses “dlnetworkPredictAndUpdateState”, and thereby the state of the network can be easily obtained by passing the “XTest” values as the input to “StatefulPredict” block.
Please refer to the following documentation for further information,
Hope this helps!

Catégories

En savoir plus sur Sequence and Numeric Feature Data Workflows dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by