How to make predictions using an already-trained LSTM model?

23 次查看(过去 30 天)
Hello everyone,
I have the attached example LSTM code with the data file (omni.txt: hourly data).
I would like to know how to use the trained LSTM model to make a prediction for new data.
I think the answer lies within the lines starting from line 113, but I'm a novice with LSTM.
----------------------------------------------------------------------------------------------------------------------------------
A side question:
This code is dealing with only one input (feature) to predict its own evolution with time, How can we transform it to deal with several inputs at once?
How can we transform this code to take several inputs and predict the temporal evolution of another output?
For instance, like the feedforward backpropagation network in which it can take several inputs to predict a single output (or several outputs).
I appreciate your help!
Thank you,

采纳的回答

Hiro Yoshino
Hiro Yoshino 2020-5-7
It seems you are predicting the data based on the training data.
That's why the prediction stays unchange after the end of training data.
If you want to make predictions following the test data, you should take either way
  1. feed the test data up to x_{t-1} to predict x_t
  2. feed the predicted test data up to x_{t-1} to predict x_t
you may want to make a referenct to
Good luck!
  3 个评论
Hiro Yoshino
Hiro Yoshino 2020-5-8
I guess you're doing right.
Why don't you test the model using the training data first to see how good it is.
by the way, I wonder how many pairs of data (x, y) do you have to train the model?
I'll try to take a look at your code when I have free time.
Mohamed Nedal
Mohamed Nedal 2020-5-9
编辑:Mohamed Nedal 2020-5-9
The dataset has 16,071 pairs of (x,y), that means 16,071 days.
Ok great, that would be much appreciated. Thanks!

请先登录,再进行评论。

更多回答(2 个)

Hiro Yoshino
Hiro Yoshino 2020-1-17
I took a look at your script.
in the line 131, you actually update the network together with getting the prediction out of it:
[net,YPred(:,i)] = predictAndUpdateState(net,XTest(:,i),'ExecutionEnvironment','cpu');
  10 个评论
Mohamed Nedal
Mohamed Nedal 2020-5-3
Hello Mr. Yoshino, I hope you're fine
I finally managed to make forecasting on new data, but the forecasting of the test data seems very inaccurate.
Kindly find the attached code with the dataset.
Any suggestions to improve the accuracy please?
comparison
prediction
forecast

请先登录,再进行评论。


NGR MNFD
NGR MNFD 2021-7-2
Hello . I hope you have a good day. I sent the article to your service. I implemented the coding part in the MATLAB software, but to implement my network, two lines of setlayers, training MATLAB 2014 give me an error. What other function do you think I should replace? Do you think the codes I wrote are correct?( I used gait-in-neurodegenerative-disease-database in physionet website.) Thanks a lot

类别

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

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by