Research Article

Complexity to Forecast Flood: Problem Definition and Spatiotemporal Attention LSTM Solution

Algorithm 1

Pseudocode of STA-LSTM for implementation.
Input: Input dataset X with n samples, each sample refers to a hydrological feature set collected from total τ states, input initial super-parameters θ.
Output: Run-off value Prediction Y.
(1)Initialize STA-LSTM model with initial super-parameters θ and random network weights W1.
(2) Set sample index i = 1;
(3)for i ≤ n do
(4)  Set current state t = 2, hidden output in the first state , weighted hidden output in the first state ;
(5)  for t ≤ τ do
(6)    Input into t − 1th spatial attention module to calculate spatial attention weight by ;
(7)    Refine current input with spatial attention weight αt by ;
(8)    Input and into tth LSTM cell to compute current hidden output by ;
(9)    Input and into t − 1th temporal attention module to compute temporal attention weight by ;
(10)    Refine current hidden output with spatial attention weight βt by .
(11)    t ++;
(12)  end for
(13)  Increase or Decrease value in Run-off Yi = Outlayer(, …, )
(14)  Calculate RMSE with Yi and ground-truth value.
(15)  if RMSE decreases then
(16)   Update model weights with: ;
(17)  else
(18)   Continue;
(19)  end if
(20)  i ++;
(21)end for
(22)End training process and Save model parameters.
(23)Input testing samples to output corresponding prediction value Y.
(24)Calculate RMSE, DC and MAPE for testing samples.