# STA-GCN: Spatial-Temporal Self-Attention Graph Convolutional Networks for Traffic-Flow Prediction
## 3 Dataset and Methodology
### Symbols and Feature Encoding  
In this section, we introduce some necessary symbols and definitions that are used in this article. Next, we provide some relevant knowledge about the theoretical traffic-flow-prediction model in this article. Table 1 summarizes the main symbols.  
In order to reflect the daily periodicity of traffic-flow changes in the training dataset, the method of cosine decomposition [34] was used to map the daily periodicity features to two dimensions separately, as shown in Equations (1) and (2). The heterogeneity of traffic conditions between working days and weekends was differentiated by using one-hot encoding, with weekends coded as 0 and working days coded as 1. As a result, the input data had 4 channels: traffic speed, time sine component, time cosine component, and heterogeneity components for working days and weekends.  
\[X_{s}=\sin(2\pi\times\frac{t}{T}) \tag{1}\]  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Notation** & **Description** \\ \hline \(N\) & Number of traffic nodes on the road network \\ \(S\) & Historical sequence length \\ \(P\) & Future sequence length \\ \(d\) & The dimensionality of the traffic-node attributes mapped by the input layer \\ \(d^{\prime}\) & The dimensionality of the node attributes after passing through a temporal gated convolutional layer \\ \(d^{*}\) & The dimensionality of the node attributes after passing through a graph convolutional layer \\ \(\chi\in\mathbb{R}^{5\times N\times 4}\) & The spatial-temporal information of the input \\ \(f\in\mathbb{R}^{5\times d}\) & The information from the self-attention layer of an input time for a single transportation node \\ \(W^{\mathcal{T}}\in\mathbb{R}^{5\times S}\) & Self-attention matrix for time \\ \(f^{\mathcal{T}}\in\mathbb{R}^{5\times d}\) & The information from a single traffic node after passing through self-attention for time \\ \(F^{T}\in\mathbb{R}^{N\times S\times d}\) & The information from all traffic nodes after passing through self-attention for time \\ \(F^{c}\in\mathbb{R}^{N\times S\times d}\) & The information after passing through a temporal gated convolutional layer \\ \(f^{c}\in\mathbb{R}^{N\times d^{\prime}}\) & The information of the input space attention for a single time slice \\ \(f^{\mathcal{S}}\in\mathbb{R}^{N\times d^{\prime}}\) & The information after passing through a spatial attention layer for a single time slice \\ \(F\in\mathbb{R}^{5\times N\times d^{\prime}}\) & Information from the spatial self-attention layer across all time series \\ \(F^{G}\in\mathbb{R}^{5\times N\times d^{\prime}}\) & Information from the spatial graph convolutional layer across all time series \\ \(y\in\mathbb{R}^{P\times N\times 1}\) & The final output of spatial-temporal prediction information \\ \hline \hline \end{tabular}
\end{table}
Table 1: Symbols.  
\[X_{c}=\cos(2\pi\times\frac{t}{T}) \tag{2}\]  
The \(X_{s}\) and \(X_{c}\) are the sequences of cosine and sine components, respectively, for a time series. The \(T\) is the length of the period, and \(\{0,1,\cdots T-1\}\) is a set of integer sequences starting from 0.