Welcome back. In the last session, we computed the number of parameters. And now, we're going to show how to train a stateful LSTM network. Here, you see a loop, which is going to the number of epochs. We have defined the number of epochs as 120. And within this loop, we are calling the fit method of the regressor. So, for the short reminder, we have defined the regressor. This is the model action. Then we compiled this model, and this model class has a method fit. We pass as arguments the train set, X train. These are the input values. Y train, these are the output values. And then we have to say shuffle, false. Why? This is why because we're dealing with sequences and if we would shuffle, we would break the whole order of measurements, so it will not shuffle. Now, we have to define the number of epochs. And here, we have to set the epochs equal to one because we will call this fit method for all 120 epochs. And then we have to say batch size equals batch size. Batch size, in our case, 64. And then also very important, we say, reset states. So if the training is finished for an epoch, we need to reset all states which are the hidden state and cell state. We would not do this. We would take the states to the next epoch, but we don't want this. We want to start a new epoch freshly. We want to initialize the states with a zeroth. I will not call this method because I have already trained the model and it would take some minutes but we don't need this. I have stored the model on the system here and I can see where it's stored. I can call exclamation mark and then I immediately have accessed one line bash. And as I call this. I see, okay, I have a folder called Models, and in this folder, I have two models. One where I have used mean absolute error as a loss function and another one with a mean squared error. So, in the later sessions, we will see what is the difference in the prediction accuracy between those two. And Keras provides the method, load model. With this method, I can load the stored model, which I will do now. It will take some seconds and we see the model is loaded now. So, stay tuned. See you next time. Enjoy. Bye bye.
The initial lectures series on this topic can find in the below links:
Introduction to Anomaly Detection
• Introduction to Anomaly Detection
How to implement an anomaly detector (1/2)
• How to implement an anomaly detector (1/2)
How to implement an anomaly detector (2/2)
• How to implement an anomaly detector (2/2)
How to deploy a real-time anomaly detector
• How to deploy a real-time anomaly detector
Introduction to Time Series Forecasting
• Introduction to Time Series Forecasting
Stateful vs. Stateless LSTMs
• Stateful vs. Stateless LSTMs
Batch Size! Which batch size is to choose?
• Batch Size! which batch size is to choose?
Number of Time Steps, Epochs, Training, and Validation
• Number of Time Steps, Epochs, Training and...
Batch size and Training Set Size
• Batch size and Trainin Set Size
Input and Output Data Construction
• Input and Output Data Construction
Designing the LSTM network in Keras
• Designing the LSTM network in Keras
Anatomy of an LSTM Node
• Anatomy of a LSTM Node
Number of Parameters: How LSTM Parmeter Num is Computed.
• Number of Parameters:How LSTM Parmeter Num...
Информация по комментариям в разработке