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

  • Encoder:

  •   1:

    E←LinearEncoder(Flatten(X))            ▹(B×T,Dr)

  •   2:

    E←Reshape(E,(B,T,Dr))⊺              ▹(T,B,Dr)

  •   3:

    Initialize h0∈RL×B×H

  •   4:

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

  • Attention:

  •   5:

    A←Oe⊺                        ▹(B,T,H)

  •   6:

    Q,K,V←A·Wq,A·Wk,A·Wv            ▹W·∈RH×d

  •   7:

    Attn←softmax(QK⊤d)V               ▹(B,T,H)

  •   8:

    S←Attn⊺                       ▹(T,B,H)

  • Decoder:

  •   9:

    Od←LSTMDecoder(S)                ▹(T,B,H)

  • 10:

    Yr←LinearDecoder(Od)                  ▹(T,B,Dd)

  • 11:

    Ym←MLP(Flatten(S))

  • Fusion:

  • 12:

    Y←12(Yr+Ym)

  • 13:

    if use_residual then

  • 14:

        Y←Y+X⊺

  • 15:

    end if

  • 16:

    Y←Y⊺                          ▹(B,T,Dd)

  •    Output: Prediction Y∈RB×T×Dd