# Dynamic Graph Convolutional Crowd Flow Prediction Model Based on Residual Network Structure
## 3 Proposed Method
### Spatial Attention Module  
There may be some problems in using GCN alone to model the adjacency relationships between nodes in each irregular region (node). For instance, in a large city, there may be several indirect nodes between adjacent nodes, but the traditional GCN cannot capture the relationship between these indirect nodes. This paper proposes a spatial attention module (Figure 2b) to capture the spatial dependence of second-order and higher-order neighboring nodes, where the attention mechanism adaptively assigns different weight information to learn node spatial correlations, and the SA module improves the model's ability to perceive spatial information.  
Figure 3 is a schematic of node weight assignment. The multi-order surrounding nodes of the target node cannot be covered by graph convolution alone, but when used in combination with the spatial attention module, weights can be applied to the multi-order adjacent nodes to achieve coverage of the multi-order nearby nodes. The feature matrix \(A\in R^{N*N*K}\) in Figure 2b was generated by fusing the crowd flow path matrix with POI features, which was obtained after node partitioning. The value of the matrix represents not only the correlation between two nodes, but also the strength of that correlation. Due to the certain discreteness of OD data, there are large differences in the influence factors between target nodes and different adjacent nodes. Therefore, it is first necessary to focus on key spatial features. Inspired by the above, SA firstly does the maximum and mean operations on the first dimension of the feature matrix, respectively, through which the mean and maximum values of each node on the dynamic changes of the human flow of the remaining N nodes (including its own node) can be obtained, which can make the model pay more attention to those neighboring nodes that are more relevant and important to the prediction results of the target node. Secondly, the two are combined to obtain the feature matrix after the focusing process and use it for the convolution operation. The reason for combining the two here is that the combination can generate connections that do not exist in the first place, and thus assign weights to the indirect neighbor nodes of the target node. In this paper, adaptive weight learning is performed through a convolution layer, which is the equivalent to using a convolution kernel for each node in the graph to extract the weights of nodes of order 0 to 3 centered on that node and rescaling the features by convolving the layer to produce a feature matrix of the specified dimension. The result is then added to the LeakyRelu activation function, which outputs non-zero values in the negative region and can retain the negatively correlated features in the feature matrix. Finally, a residual connection is applied, which enables the model to better learn the differences in the feature matrix before and after being processed by the SA module. The entire process can be summarized by Equation (4):  
\[\hat{A}_{t}=LeakyRelu(f^{xy}([Max(A_{t});Avg(A_{t})]))+A_{t} \tag{4}\]  
where \(A_{t}\in R^{N*N*K}\) represents the feature matrix, and \(Max\) and \(Avg\) denote the operations of taking the maximum and average values along the first dimension of the matrix, respectively. The function \(f^{xy}\) corresponds to a convolutional layer with a kernel size of \(y*y\), in this experiment, y is 9.  
In the original model, the DGCN module captures the spatio-temporal dependencies between nodes, while the SA module enhances the node features for each time period to improve the model's perception of multi-order neighboring nodes. Additionally, the spatial attention module helps the model handle spatial noise and irregularities present in the spatio-temporal graph, thereby further enhancing the model's stability and robustness.