LSTM RNN predictions dependant on more variables?

2 次查看(过去 30 天)
I have built a RNN with a LSTM layer to predict a spectral evolution (i.e. each step is a wavelengh vs. energy plot). The it works fine but it is not dependent on the distance propagated. My question is this: how can my neural network, at each step of the prediction, take another input other than the previous step, which in my case would be the distance travelled? Obviously I would have to include it in the training as well. As far as I can tell I can only predict the next array from the previous one. Could anyone help? Thanks

回答(1 个)

Ayush Anand
Ayush Anand 2023-11-21
Hi Simone,
I understand you have a RNN model with an LSTM layer and you want to incorporate the distance travelled as an input at every step along with the output from the previous layer. You can do this using the concept of “Teacher Forcing”. Teacher forcing allows you to provide additional input at each step of the prediction, such as the distance travelled, while still training the network to predict the next spectral evolution based on the previous step.
Here's a high-level approach to incorporate the distance travelled as an input to your RNN:
  1. Data Preparation: Prepare the training data to include the distance travelled alongside the spectral evolution data. Each input sample should consist of the spectral evolution at a particular distance and the corresponding distance travelled.
  2. Update Model Inputs: Modify the input layer of your RNN to accept both the spectral evolution and the distance travelled as inputs at each step. This can be achieved by concatenating both the data for each step.
  3. Training: During training, use the concept of teacher forcing. At each step of the training sequence, provide the spectral evolution data and the corresponding distance travelled as inputs to the network. This allows the network to learn the relationship between the spectral evolution and the distance travelled.
  4. Prediction: When making predictions using the trained RNN, provide the spectral evolution at the current distance travelled as the initial input. Then, at each subsequent step, provide the predicted spectral evolution from the previous step and the corresponding distance travelled as inputs to predict the next spectral evolution.
You can refer to the following answer for reading more on how to implement the concept of Teacher Forcing in MATLAB:
I hope this helps!

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by