Skip to main content
. 2023 Sep 1;23(17):7583. doi: 10.3390/s23177583
Algorithm 2 Boosted LSTM algorithm for ET forecasting.
  •  

    Require:

  •    Temperature sequence T=[T1,T2,,Tn]

  •    Humidity sequence Hm=[Hm1,Hm2,,Hmn]

  •    Wind speed sequence Ws=[Ws1,Ws2,,Wsn]

  •    Output sequence ET=[ET1,ET2,,ETn]

  •    Number of LSTM models M

  •    Number of epochs E

  • Ensure:

  •    Boosted LSTM model weights W=[w1,w2,,wM]

  •  1:

    Initialize empty list W

  •  2:

    for m in range(M) do

  •  3:

        Initialize LSTM model LSTMm

  •  4:

        Randomly split the data into training and validation sets

  •  5:

        Initialize input sequence X=[(T1,Hm1,Ws1),(T2,Hm2,Ws2),,(Tn,Hmn,Wsn)]

  •  6:

        Initialize output sequence Y=[ET1,ET2,,ETn]

  •  7:

        Train LSTMm 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 xi=(Ti,Hmi,Wsi)

  •  11:

               Set the LSTM target output yi=ETi

  •  12:

               Calculate the LSTM hidden state hi and cell state ci using the LSTM equations:

  •  13:

               fi=σ(Wf·[hi1,xi]+bf)

  •  14:

               ii=σ(Wi·[hi1,xi]+bi)

  •  15:

               oi=σ(Wo·[hi1,xi]+bo)

  •  16:

               c˜i=tanh(Wc·[hi1,xi]+bc)

  •  17:

               ci=fi·ci1+ii·c˜i

  •  18:

               hi=oi·tanh(ci)

  •  19:

               Calculate the LSTM output ypredi using the output equation:

  •  20:

               ypredi=Wy·hi+by

  •  21:

               Calculate the LSTM loss Li using a suitable loss function (e.g., mean squared error):

  •  22:

               Li=12(yprediyi)2

  •  23:

               Update the LSTM model parameters Wf,Wi,Wo,Wc,Wy,bf,bi,bo,bc,by using back-propagation and gradient descent:

  •  24:

               Wf=Wfα·LiWf

  •  25:

               Wi=Wiα·LiWi

  •  26:

               Wo=Woα·LiWo

  •  27:

               Wc=Wcα·LiWc

  •  28:

               Wy=Wyα·LiWy

  •  29:

               bf=bfα·Libf

  •  30:

               bi=biα·Libi

  •  31:

               bo=boα·Libo

  •  32:

               bc=bcα·Libc

  •  33:

               by=byα·Liby

  •  34:

        Evaluate the performance of LSTMm on the validation set

  •  35:

        Calculate the weight wm based on the validation performance of LSTMm

  •  36:

        wm=ValidationAccuracyofLSTMmTotalValidationAccuracy

  •  37:

        Store the weight wm in the list W

  •  38:

    Normalize the weights in W

  •  39:

    return W