# Research on Multi-Port Ship Traffic Prediction Method Based on Spatiotemporal Graph Neural Networks
## 2 Methods
### Temporal Layer  
The fundamental concept behind the temporal layer is based on dilated convolution. By incorporating dilated convolution, the model can effectively expand its receptive field while maintaining the sequential nature of data modeling. This allows the model to capture longer temporal feature patterns with fewer computational costs, thereby capturing temporal dependencies over a larger time span.  
Dilated convolution is a convolutional operation. As shown in Figure 3(a), during the convolution process, fixed-sized \"holes\" are introduced between the elements of the convolution kernel, expanding the kernel. This means that, with the same computational cost, a larger effective filter size is used for convolution. Compared to a convolutional kernel of the same size, dilated convolution offers higher computational efficiency. In particular, dilated convolution with a dilation factor of 1 is equivalent to a regular convolution.  
To accommodate different time step lengths, this paper adopts a dilation factor pattern of \"1, 2, 4, 8\" as the base and cycles through it as the model's hidden layers increase. Let us apply this to the scenario of port traffic flow prediction, assuming that the input historical flow data have a time step length of 14 and the convolution kernel size is 3.  
In the first layer of the temporal layer, the dilation factor is 1, which means that fine-grained time feature processing is performed at the level of 1 time step. As the network goes deeper, the second layer of the temporal layer has a dilation factor of 2; the process of applying time convolutions involves making leapfrog-like strides over the input sequence. This approach results in less fine-grained time feature processing, but, correspondingly, the same-sized convolutional kernel can handle twice the length of time steps.  
By repeating this process, the temporal convolutional layer with a dilation factor of 8 can cover the entire input sequence, thereby extracting long-term historical features. This enables the model to capture temporal dependencies over a larger time span.  
On the other hand, as a key to the success of recurrent neural networks, gating mechanisms preserve the non-linear capabilities while addressing the vanishing gradient problem, leading to better performance in tasks involving long-term dependencies. WaveNet [9] incorporates gating activation structures into causal convolutions, proposing the WaveNet structure shown in Figure 3(b). The formula can be represented as  
\[h_{l}(X)=tanh(X*W)\odot\delta(X*V)\]  
Figure 4: Structure of temporal layer. (**a**) Stacked dilated convolutional layers; (**b**) WaveNet structure with gating mechanism.  
where \(X\) represents the feature tensor, and \(l\) denotes the current layer. \(W\) and \(V\) represent two dilated convolution kernels, \(\delta(*)\) represents the _sigmoid_ function, and \(\odot\) denotes the element-wise multiplication operator.  
Based on this gating structure, the temporal layer can easily perform feature selection on the input data. Compared to linear processing methods, this nonlinear structure possesses stronger modeling capabilities for time series features.