Algorithm 2 Boosted LSTM algorithm for forecasting. |
-
Require:
Temperature sequence
Humidity sequence
Wind speed sequence
Output sequence
Number of LSTM models M
Number of epochs E
Ensure:
Boosted LSTM model weights
-
1:
Initialize empty list W
-
2:
for m in range(M) do
-
3:
Initialize LSTM model
-
4:
Randomly split the data into training and validation sets
-
5:
Initialize input sequence
-
6:
Initialize output sequence
-
7:
Train on the training set for E epochs using the following equations:
-
8:
for each epoch e in range(E) do
-
9:
for i in range(n) do
-
10:
Set the LSTM input sequence
-
11:
Set the LSTM target output
-
12:
Calculate the LSTM hidden state and cell state using the LSTM equations:
-
13:
-
14:
-
15:
-
16:
-
17:
-
18:
-
19:
Calculate the LSTM output using the output equation:
-
20:
-
21:
Calculate the LSTM loss using a suitable loss function (e.g., mean squared error):
-
22:
-
23:
Update the LSTM model parameters using back-propagation and gradient descent:
-
24:
-
25:
-
26:
-
27:
-
28:
-
29:
-
30:
-
31:
-
32:
-
33:
-
34:
Evaluate the performance of on the validation set
-
35:
Calculate the weight based on the validation performance of
-
36:
-
37:
Store the weight in the list W
-
38:
Normalize the weights in W
-
39:
return W
|