< This article is translated from matlab Help document , It is my understanding and summary of this method >
This example shows how to use LSTM Network prediction of time series data . In order to predict the future time step value of a sequence , You can train one sequence-to-sequence
LSTM Return to the Internet , among [2] The response of the network is that the training sequence value moves one time step . in other words , At each time step of the input sequence ,LSTM Network learning to predict the value of the next time step . In order to predict multiple times in the future [2] The value of the step size , use predictAndUpdateState Function to predict and update the network state . This example uses chickenpox_dataset data set . This example builds a LSTM network , In the known [3] In the case of the number of samples in the previous months , To predict future values .

( stay Matlab2018a of use LSTM There are two methods of time series prediction based on network model .
The first kind :
For example, known [x1,x2,...x10] This sequence , use [x1,x2,...x9] As input , obtain [x2,x3,...x10],
Then use x10 obtain x11', use x11' obtain x12', and so on , Complete the forecast .
The second kind :
For example, known [x1,x2,...x10,x11,...x20] This sequence , use [x1,x2,...x9] As input , obtain [x2,x3,...x10],
Then use x10 obtain x11', use x11 obtain x12', and so on , obtain [x11',x12',...x20'] Complete the forecast .
Personal understanding , The second method may only be used to detect the model , It's not predictable in practice , Because if you know x11, And then to predict x11’, It doesn't seem to make sense .
)

* Download sequence data
The time steps in the sequence represent months , The value corresponds to the number of samples . Turn the dataset into a row vector .

Decomposing a data set : Training accounts for 90%, Test accounted for 10%. meanwhile , As described above , The response of the network is that the training sequence moves one time step .

* Standardized data
In order to better fit and prevent divergence during training , The training data are normalized to zero mean and unit variance . Use the same parameters to format the test data .

* definition LSTM network
Create a LSTM Return to the Internet , appoint LSTM There are layers 200 A hidden neuron .


Specify training parameters . Set solution function “adam”, train 250 second . In order to prevent gradient explosion , Set the gradient threshold to 1. Specify the initial learning rate as 0.005, And in 125 After three iterations, multiply the learning rate by 0.2 To reduce the learning rate .

* train LSTM network
use trainNetwork And the specified training parameters LSTM network .

* Forecast future value
In order to predict the value of multiple time steps in the future , use predictAndUpdateState function .

To initialize the network state , First, predict the training data XTrain, next , Use the last value of the training response YTrain(end) Make predictions . Cycle the remaining predictions and enter the previous predictions predictAndUpdateState.(PS:‘ I feel that I have some problems with the part of predicting the future value ’)

Technology