Borrar filtros
Borrar filtros

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

6 visualizaciones (últimos 30 días)
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.

Respuestas (1)

Sanjana
Sanjana el 31 de Oct. de 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!

Categorías

Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by