Can I define a loss function where the truth is network's previous time step?

1 vue (au cours des 30 derniers jours)
Emirhan INANC
Emirhan INANC le 18 Nov 2022
Réponse apportée : Rijuta le 22 Fév 2023
I wonder, is it possible to define a loss function in matlab such that the truth of the loss function is the previous time step output of the LSTM. The aim is to backpropagate through both y_1 and y_2. The figure below may help.

Réponses (1)

Rijuta
Rijuta le 22 Fév 2023
Hi Emirhan,
I understand that you are trying to define a loss function in MATLAB such that the truth of the loss function is the previous time step output of an LSTM.
This can be achieved by defining a custom loss function that takes as inputs both the predicted output at time step ‘t’ and the true output at time step ‘t-1’. Make sure that this loss function considers two predicted outputs and two true outputs as inputs to backpropagate through both ‘y_1’ and ‘y_2’.
Please follow the below mentioned steps for the same:
  1. Define the custom loss function that uses the previous time step output as truth
  2. Shift the true output by one time step
  3. Define the loss as the mean squared error between the predicted outputs and the shifted true outputs
  4. Combine the losses

Catégories

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

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by