Skip to main content
. 2025 Jul 28;25(15):4663. doi: 10.3390/s25154663
Algorithm 1 LSTM-based Encoder–Attention–Decoder.
  • Input: Input sequence XRB×T×De

  • Encoder:

  •   1:

    ELinearEncoder(Flatten(X))            ▹(B×T,Dr)

  •   2:

    EReshape(E,(B,T,Dr))              ▹(T,B,Dr)

  •   3:

    Initialize h0RL×B×H

  •   4:

    (Oe,h1)LSTM(E,h0)                ▹(T,B,H)

  • Attention:

  •   5:

    AOe                        ▹(B,T,H)

  •   6:

    Q,K,VA·Wq,A·Wk,A·Wv            ▹W·RH×d

  •   7:

    Attnsoftmax(QKd)V               ▹(B,T,H)

  •   8:

    SAttn                       ▹(T,B,H)

  • Decoder:

  •   9:

    OdLSTMDecoder(S)                ▹(T,B,H)

  • 10:

    YrLinearDecoder(Od)                  ▹(T,B,Dd)

  • 11:

    YmMLP(Flatten(S))

  • Fusion:

  • 12:

    Y12(Yr+Ym)

  • 13:

    if use_residual then

  • 14:

        YY+X

  • 15:

    end if

  • 16:

    YY                          ▹(B,T,Dd)

  •    Output: Prediction YRB×T×Dd