## 1 Node attention module
#### 2.2.4 Temporal Feature Extraction  
From the perspective of time, the data measured by the hydrological station at the current time and the data measured at different times in the past are time-dependent and will change with time. An attention mechanism can find more influential and relevant spatiotemporal features of the target object, so as to better mine temporal features. This section establishes an attention layer to process the output of the above spatiotemporal feature mining model, as shown in Figure 7 below.  
First, the spatiotemporal tensor \(x^{\prime}_{tensor_{1}}=\left[u_{1}^{t}r_{1}^{t},\mu_{2}^{t}r_{2}^{t},\cdots, \mu_{m}^{t}r_{m}^{t}\right]_{m\times 1}=\left\{x_{1},x_{2},\cdots x_{m}\right\}\), \(E^{(1)}_{tensor_{n}}=Encoder\left(x^{\prime}_{tensor_{1}}\right)\) is input, where m represents the sequence length and 1 represents the hidden layer of the first layer input, dilated convolutions with different kernel sizes as hidden layers across L layers. By stacking L layers of advanced causal dilated blocks across depth and time, a complete TCN-AM network is built and is called dilated convolution. Furthermore, dilated convolutions are used to give the network a sufficient receptive field, thus maintaining the computational efficiency of the network. The size of the dilation grows exponentially with the depth of the network (d = 2\({}^{l}\) for the l-th layer in the network).  
The calculation steps of the temporal attention modules are defined as follows.  
Step 1: Calculate the time self-attention importance of \(E^{(l)}_{tensor_{n}}:\ E^{l}_{tensor_{m}}=S_{spatial}\left(E^{l}_{tensor_{m}}\right)\), where \(EA^{l}_{tensor_{n}}\) is an intermediate variable containing information before time step t. The temporal self-attention module utilizes the information of all-time steps, including past and future information of time step t. However, for time-series data, only past information can be processed; thus, the processing of weight matrix is refined to meet their sequence characteristics.  
Step 2: In the first step, three linear transformations \(Q^{\prime}_{tensor}\), \(K^{\prime}_{tensor_{n}}\), and \(V^{\prime}_{tensor_{n}}\) are used to map \(E^{(l)}_{tensor_{m}}\) to three different vectors of dimension \(d_{k}\), namely, \(k^{l}_{n}=K^{\prime}_{tensor_{n}}\left(E^{(l)}_{tensor_{m}}\right)\), \(q^{l}_{n}=Q^{\prime}_{tensor_{m}}\left(E^{(l)}_{tensor_{n}}\right)\), and \(v^{l}_{n}=V^{\prime}_{tensor_{n}}\left(E^{(l)}_{tensor_{n}}\right)\). The dot product of \(q^{l}_{n}\) and \(k^{l}_{n}\) is calculated and divided by \(\sqrt{d_{k}}\) to obtain the weight matrix \(W^{l}_{a}=\frac{k^{l}_{a}\sqrt{d_{k}}}{\sqrt{d_{k}}}\), where \(e,s=1,2,\cdots,m\). The lower triangular part of \(W^{l}_{a}\) is extracted: \(W^{l}_{a,e}\ (e\geq s)\), and the remaining  
Figure 7: Schematic of temporal attention module.  
part of the weight matrix is set to 0, which can mask the weight of future time steps, such that future information is not used. Finally, normalization is performed with softmax. \(EA^{l}_{tensor_{l}}\) is calculated as follows: \(EA^{l}_{tensor_{l}}=\frac{fA^{l}_{tensor_{n}}}{\sum_{l}/fA^{l}_{n}}\), where \(fA^{l}_{n}=\sum_{i=0}^{t}W^{l}_{ae}\cdot E^{(l)}_{tensor_{n}}\), and t is the time step (t = 1,2, \(\cdots\), m).  
Step 3: A causal dilation convolution operation is performed on \(EA^{l}_{tensor_{n}}\) to obtain \(EC^{l}_{tensor_{n}}=conv1d\left(EA^{l}_{tensor_{n}}\right)\), where \(EC^{l}_{tensor_{n}}\) represents the output of causal convolution, and causal dilation blocks can be stacked into many layers. To ensure each layer is of the same length, zero padding is added to the left so that the input information on the left gradually accumulates to the right.