## 2 Methodology
### EnGS-DGR Model
#### 2.2.3 Seq2 Seq Modular  
Seq2 Seq modular is proposed based on the encoder-decoder architecture in the EnGS-DGR model to extract temporal characteristics. The encoder and decoder in the Seq2 Seq modular generally adopt the recurrent neural network (RNN), the gated recurrent unit network (GRU), and the long short term memory network (LSTM).  
In the problem of traffic flow forecasting, the output of the current moment is not only related to the previous state, but also related perhaps to the future state. Therefore, we choose bidirectional LSTM (BiLSTM) network as encoder. BiLSTM is a variant of LSTM [33], in which two separated LSTM are employed to process input sequences from both directions, then the past and future contexts could be fruitfully exploited. The input of LSTM is a variable-length time series \(IN=\{in_{1},in_{2},\cdots,in_{n}\}\), where \(in_{i}\in R^{in}\) and \(d_{m}\) represent the number of features in each time index \(i\), \(n\) is the input LSTM time series length, \(in_{i}\) is the combination of the output \(H^{(L)}{}_{i}\) of GCN at moment \(i\) and the traffic characteristic \(Tr_{i}\) of the target node at moment \(i\), \(in_{i}=\left[H^{(L)}{}_{i};Tr_{i}\right]\). The updated status of the hidden vector at time \(t\) is as follows:\[\begin{split} i_{t}&=\sigma(W_{xi}x_{t}+W_{hi}h_{t-1}+b_{i }),\\ f_{t}&=\sigma\left(W_{xf}x_{t}+W_{hf}h_{t-1}+b_{f} \right),\\ c_{t}&=f_{t}\otimes c_{t-1}+i_{t}\otimes\tanh(W_{xc}x_{t}+W_{ hc}h_{t-1}+b_{c}),\\ o_{t}&=\sigma(W_{xx}x_{t}+W_{ho}h_{t-1}+b_{o}),\\ h_{t}&=o_{t}\otimes\tanh(c_{t}),\end{split} \tag{8}\]  
where \(i_{t}\), \(f_{t}\) and \(o_{t}\) represent input gate, forgetting gate and output gate at time \(t\), respectively; \(c_{t}\), \(\sigma\) and \(\otimes\) represent cell state vector at time \(t\), the sigmoid function and the element multiplication, respectively.  
By employing two LSTM in two directions, BiLSTM can read the input sequence of traffic flow from the forward and backward directions and the output has hidden states in two directions, the forward state is \(\overrightarrow{h}=\left\{\overrightarrow{h_{1}},\overrightarrow{h_{2}}, \ldots,\overrightarrow{h_{n}}\right\}\), and the backward state denotes \(\overleftarrow{h}=\left\{\overleftarrow{h_{1}},\overleftarrow{h_{2}}, \ldots,\overleftarrow{h_{n}}\right\}\), where \(\overrightarrow{h_{i}}\) and \(\overleftarrow{h_{i}}\) represent the hidden vectors of forward and reverse LSTM outputs, respectively. The hidden vector at the moment \(i\) can be expressed as:  
\[h_{i}=\left[\overrightarrow{h_{i}};\overleftarrow{h_{i}}\right]. \tag{9}\]  
Decoder with the global attention mechanism generates the traffic flow output sequence of EnGS-DGR model \(y=\left\{y_{1},y_{2},\ldots,y_{T}\right\}\), where \(T\) is the length of the forecasting sequence. Because the traffic flow forecasting requires outputs with continuous values, a fully connected layer with linear activation function is used to generate continuous outputs. The calculation formula for traffic flow output \(y_{t}\) at time \(t\) in decoder is described as:  
\[\begin{split} y_{t}&=Linear(W[s_{t};c_{t}]+b),\\ s_{t}&=LSTM(y_{t-1},s_{t-1},c_{t}),\end{split} \tag{10}\]  
where \(s_{t}\) represents the hidden state of the decoder at time \(t\); \(c_{t}\) represents the attention context vector; \(W\) and \(b\) are the trained parameters. Moreover, the attention context vector \(c_{t}\) is expressed as the weighted sum of the hidden state \(h_{i}\) of the encoder at time \(t\), which is given by:  
\[c_{t}=\sum_{i=1}^{n}\alpha_{ti}h_{i}, \tag{11}\]  
where the weight \(\alpha_{ti}\) of hidden state \(h_{i}\) is described as:  
\[\alpha_{ti}=\text{soft}\max(e_{ti}), \tag{12}\]  
in which \(e_{ti}=a(s_{t-1},h_{i})\) represents the correlation between the hidden state around \(h_{i}\) and the output at time \(t\); \(soft\max\) function ensures that the attention weight is normalized to one.