A traffic flow prediction method based on a dynamic spatio-temporal similar pyramid network
By using a dynamic spatiotemporal similarity pyramid network, combined with multi-head spatiotemporal self-attention, spatial pyramid, and temporal pyramid modules, the problem of capturing global structure and spatiotemporal correlation in traffic flow prediction is solved, achieving efficient and accurate traffic flow prediction and anomaly detection.
Patent Information
- Application Number
- CN202410318557.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-19
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2044-03-19
AI Technical Summary
Existing traffic flow prediction models struggle to effectively capture the global structure and spatiotemporal correlations of traffic networks. In particular, when dealing with large-scale traffic data and high-dimensional features, local neighborhood information limits the model's perception capabilities, making it unable to accurately predict dynamic changes in traffic flow.
A method based on dynamic spatiotemporal similarity pyramid network is adopted. The dynamic long-term features of traffic flow are extracted through an improved multi-head spatiotemporal self-attention mechanism. The spatial pyramid module captures global spatial information, and the temporal pyramid module extracts time dependencies at different granularities. These features are then passed to the prediction layer through residual connections to obtain the final traffic flow prediction results.
It improves the accuracy and efficiency of traffic flow forecasting, enabling accurate detection of abnormal congestion or traffic flow problems on roads, and helping traffic management departments to develop effective scheduling and control strategies.
Smart Images

Figure CN118230548B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of information technology, traffic flow prediction and the like, and in particular to a traffic flow prediction method based on a dynamic spatiotemporal similarity pyramid network. Background Art
[0002] Traffic data prediction is a fundamental task in spatiotemporal data mining and a crucial component of intelligent transportation systems. Accurate traffic forecasts can help transportation management departments develop more effective traffic scheduling and control strategies. By predicting future traffic flows, intelligent transportation systems can optimize signal timing, adjust lane planning, and more, thereby reducing congestion and improving traffic flow. Traffic flow forecasting involves analyzing historical traffic data and other relevant information to predict traffic flow on specific road sections. This requires in-depth modeling of spatiotemporal correlations.
[0003] Early researchers applied classical statistical models to predict future traffic conditions, but these models were limited by assumptions about data linearity and smoothness. Machine learning-based methods can capture nonlinear patterns and interactions in traffic flow data, but they struggle to handle the temporal correlations and dynamic variations of traffic flow and can face challenges when processing large-scale data and high-dimensional features. Deep learning methods based on recurrent neural networks (RNNs) do not suffer from these limitations and have therefore been widely used to extract both long-term and short-term dependencies in time series. However, they are unable to model spatial correlations in traffic networks. Subsequent research has introduced CNN-based methods to capture spatial correlations. However, these methods divide the road network into a regular grid structure, fail to reflect the irregular graph structure of the traffic network, and struggle to extract the complex spatial correlations between traffic nodes. With the development of graph deep learning, graph convolutional networks (GCNs) and their variants have also been widely applied to spatiotemporal data prediction tasks. These methods typically use sensors deployed in the traffic network as nodes and construct a traffic graph using the road network or the distances between nodes as edges. Node features are updated through inter-node information transfer. However, existing graph convolutional networks mostly use local neighborhood information for message passing. This limitation of local information can lead to insufficient perception of global structure. In the temporal dimension, traffic patterns vary significantly across time periods. For example, traffic congestion often occurs at specific times, and it is unreasonable to use data patterns from congested periods to predict other periods. Existing graph convolutional methods mostly share weights across all time steps, ignoring the differences in spatiotemporal correlations between different time steps in traffic data. Summary of the Invention
[0004] Traffic flow data is typically collected on road networks, and traditional neural networks struggle to directly process graph-structured data. Existing research has mostly used graph neural networks (GCNs) to extract traffic flow features. However, most GCN-based methods rely on local neighborhood information for message passing, resulting in insufficient global structure perception. Furthermore, due to the limitations of the graph structure, it is difficult to extract spatiotemporal similarities. Furthermore, existing models often fail to simultaneously capture both the short-term and long-term dynamic temporal dependencies of traffic flow data.
[0005] Therefore, in response to the defects and shortcomings of the existing technology, the purpose of the present invention is to provide a traffic flow prediction method based on a dynamic spatiotemporal similarity pyramid network to effectively support traffic management and decision-making by traffic management departments. This method includes using an improved multi-head spatiotemporal self-attention to extract the dynamic long-term characteristics of traffic flow, using a spatial pyramid module to capture global spatial information and spatial similarity, using a temporal pyramid module to extract temporal dependencies of different granularities, and passing the output of the spatiotemporal block to the prediction layer via a residual connection, ultimately obtaining a traffic flow prediction result. The results obtained based on this method can efficiently and accurately predict traffic flow information on urban roads, accurately detect abnormal congestion or abnormal unblocking on urban roads, and provide assistance to traffic management departments in formulating traffic scheduling and control strategies.
[0006] The specific technical solutions adopted are as follows:
[0007] A traffic flow prediction method based on dynamic spatiotemporal similarity pyramid network:
[0008] By using historical vehicle information recorded by road sensors, and considering the spatiotemporal similarity of global dynamic spatiotemporal information and traffic data, we can predict future road traffic flow.
[0009] The improved multi-head spatiotemporal self-attention is used to extract the dynamic long-term features of traffic flow, the spatial pyramid module is used to capture global spatial information and spatial similarity, the temporal pyramid module is used to extract temporal dependencies of different granularities, and the output of the spatiotemporal block is passed to the prediction layer through the residual connection to finally obtain the traffic flow prediction result.
[0010] Further, the following steps are included:
[0011] Step S1: Use improved multi-head spatiotemporal self-attention to extract dynamic long-term features of traffic flow;
[0012] Step S2: Use the spatial pyramid module to capture global spatial information and spatial similarity;
[0013] Step S3: Use the time pyramid module to extract time dependencies of different granularities;
[0014] Step S4: The output of the spatiotemporal block is passed to the prediction layer through the residual connection to obtain the traffic flow prediction result.
[0015] Furthermore,
[0016] Step S1 specifically includes:
[0017] Step S1.1: Use multi-head temporal self-attention to capture the temporal correlation of traffic flow;
[0018] Step S1.2: Connect the output of the temporal attention module with the output of the temporal attention module in the previous spatiotemporal block through a residual connection to transfer and preserve historical information;
[0019] Step S1.3: Calculate the correlation score of multi-head spatial self-attention to adjust the weight of each layer of the spatial pyramid;
[0020] Step S2 specifically includes:
[0021] Step S2.1: Use adaptive diffusion graph convolution to capture local neighborhood information as the first layer of the spatial pyramid;
[0022] Step S2.2: Calculate the spatiotemporal global correlation matrix of each time step and extract the edge features of the graph;
[0023] Step S2.3: Calculate the similarity of the spatiotemporal global correlation matrix between each time slice and its adjacent time slices, and use the mean as the weight of the time slice;
[0024] Step S2.4: concatenate the results as the second layer of the spatial pyramid to capture the global information of the nodes;
[0025] Step S2.5: The output of the spatiotemporal global similarity module is subjected to average pooling and 1×1 convolution to extract road network-level features as the third layer of the spatial pyramid;
[0026] Step S2.6: Combine low-resolution, semantically strong features with high-resolution, semantically weak features through top-down pathways and lateral connections to form a spatial pyramid.
[0027] Step S2.7: Use the spatial attention score calculated in step S1.3 to adjust the weight of each pyramid layer; Step S3 specifically includes:
[0028] Step S3.1: Use pyramid-gated Tanh units to capture dynamic temporal information of traffic flow data;
[0029] Step S3.2: Use trainable parameters to modify the weights of each temporal pyramid layer.
[0030] Furthermore, the traffic network is defined as a directed graph in For nodes in the road network such as sensor collection ε represents the set of edges (|ε|=M), is the adjacency matrix of the road network graph At each time slice, each node collects D node features at the same sampling frequency; traffic signal Represents the traffic network The observation values of all sensors at time step t; given the historical traffic signal Traffic forecasting problems aim to predict Where P is the given historical time step and Q is the predicted time step; the traffic prediction problem can be described as learning the mapping function f from the historical time step P to the next time step Q:
[0031]
[0032] For a set of m independent and identically distributed observations {(x1,y1),(x2,y2),…(x m ,y m )}, assuming the matrix Represents the Euclidean distance matrix calculated based on the observation value X, and calculates the Euclidean distance matrix in Then the Brown distance covariance (BDC) metric has a closed form expression:
[0033] ρ(X,Y)=tr(A T B) (2)
[0034] A=(a kl ) is the spatiotemporal global correlation STGC matrix, where The last three items represent the lth column, the Kth row, and The average value of all values in ; and the matrix B is obtained by the same calculation method;
[0035] Since the STGC matrix is symmetric, ρ(X,Y) is expressed as the inner product of two STGC vectors a and b.
[0036] ρ(X,Y)=<a,b> =a T b (3)
[0037] Where a and b are obtained by extracting the upper triangular parts of A and B respectively and then vectorizing them.
[0038] Furthermore, the improved multi-head spatiotemporal self-attention is specifically:
[0039] For H-head multi-head temporal attention, define the variables:
[0040]
[0041] in, represents the output of the l-1th layer of space-time block after dimension transformation, as the input of the lth layer of space-time block, is a learnable parameter;
[0042] The attention score of each head is calculated, and the output of the temporal attention module is connected with the output of the temporal attention module in the previous spatiotemporal block through a residual connection to transfer and retain historical information, as shown in the following formula:
[0043]
[0044] The matrices of all attention heads are spliced together and normalized to obtain It is passed as input to the spatial attention module as shown below:
[0045] M=LayerNorm(MLP(Concat(Head (1) ,…,Head (H) ))) (6)
[0046] Use one-dimensional convolution to map the temporal dimension P of the output M of the temporal attention module to dimension d E And aggregate feature dimension D (l-1) , then through the spatial embedding operation, we get
[0047] Define variables:
[0048]
[0049] Calculate the spatial attention score as shown below:
[0050]
[0051] Represents the query vector Q' (h) With the key vector K' (h) The correlation between them; among them, the obtained attention score is used to adjust the weight of each layer of the spatial pyramid.
[0052] Furthermore, in the spatial pyramid module:
[0053] First, the proximity of different nodes is expressed according to whether there is a connection between them, as shown in the following formula:
[0054]
[0055] Randomly initialize two learnable node embedding matrices E1, E2∈R N×c Implement an adaptive adjacency matrix as shown below:
[0056]
[0057] The state transition between nodes is described as a spatial diffusion process of nodes and simulated by performing random walks on the graph. By combining the predefined spatial dependencies and the self-learned hidden graph dependencies, the adaptive diffusion graph convolution layer is calculated as shown in the following formula:
[0058]
[0059] Among them C k represents the power series of the transfer matrix; in the case of a directed graph, the diffusion process has two directions, forward and backward, where the forward transfer matrix Backward transfer matrix represents the input signal, Indicates output, Represents the model parameter matrix; it is used as the first layer of the spatial pyramid to capture local neighborhood information;
[0060] The data processed by diffusion graph convolution is sliced according to the time dimension, as shown in the following formula:
[0061]
[0062] Consider As random observations, calculate the squared Euclidean distance matrix in turn in It's Z (i) The squared Euclidean distance between the kth column and the lth column, the Euclidean distance matrix as well as The STGC matrix A obtained by subtracting its row mean, column mean and all element means:
[0063]
[0064]
[0065]
[0066] Among them, J N ∈R N×N is a matrix where every element is 1, I is the identity matrix, represents the Hadamard product; represents
[0067] Then calculate A(i) With A (j) The BDC metric between time slices i and j is the similarity of traffic flow characteristics between time slices i and j:
[0068]
[0069] where a (i) ,a (j) A (i) ,A (j) Vector representation of ;
[0070] The greater the similarity between the current time slice and its adjacent time slices, the greater the influence of its characteristics on traffic prediction. The average of the similarity between the current time slice and its adjacent time slice characteristics is used as the weight of the time slice, and finally the concatenation is performed:
[0071] Z S =ReLU(Concat(A (1) S 1 ,A (2) S 2 ,…,A (P) S P )) (17)
[0072] Among them, S (i) It's Z (i) The mean of the BDC metrics of adjacent time slices is used as the second layer of the spatial pyramid to capture the global information of the node;
[0073] The output of the spatiotemporal global similarity module is average pooled and passed through a layer of 1×1 convolution to extract the road network level features, which are used as the third layer of the spatial pyramid; as shown in the following formula:
[0074] Z L =Conv2D (1,1) (GlobalMeanPool(Z S )) (18)
[0075] Finally, low-resolution, semantically strong features are combined with high-resolution, semantically weak features through top-down paths and lateral connections to form a spatial pyramid.
[0076] The calculated spatial attention score adjusts the weight of each layer of the pyramid; assuming that the output of each layer of the pyramid is Z j ,but
[0077]
[0078] Where J is the number of layers of the spatial pyramid.
[0079] Furthermore, in the time pyramid module:
[0080] First, a pyramid level is defined for each stage, and the input of the i-th pyramid level is represented as Set the convolution kernel to 1×S, then:
[0081]
[0082] in,* τ is the gated convolution operator, E and F are k is the reduction factor of the time dimension in each pyramid level relative to the first and second halves of the channel dimension, Through a bottom-up approach, temporal dependencies at different scales are extracted;
[0083] Except for the topmost pyramid, a GTU with a convolution kernel of 1×1 is applied to each pyramid layer; through a top-down path, the lower pyramids fuse the spatially coarser but semantically stronger feature maps from higher pyramid levels and produce features with higher resolution through upsampling operations;
[0084] Secondly, through lateral connections, the feature map is fused with the bottom-up path as the output of the pyramid layer;
[0085] Finally, the trainable parameters are used to correct the weights of each time pyramid layer, as shown in the following formula:
[0086]
[0087] Where I is the number of layers of the time pyramid, is the output of each layer of the time pyramid, and W is a trainable parameter.
[0088] Compared with the prior art, the present invention and its preferred embodiments have at least the following outstanding beneficial effects:
[0089] The STGC matrix is innovatively proposed to capture global spatial information, and the spatial similarity between adjacent time steps in the road network is captured through the similarity of the STGC matrix at each time step.
[0090] Converting multivariate time series into a multi-layer pyramid structure can effectively extract spatiotemporal features at different scales.
[0091] By improving the multi-head self-attention mechanism to mine spatiotemporal dependencies and adaptively adjust the weights of local, global, and graph-level spatiotemporal features, the model can further enhance its perception of the dynamic temporal dependencies of the road network. BRIEF DESCRIPTION OF THE DRAWINGS
[0092] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments:
[0093] Figure 1 Graph showing the performance comparison between the embodiment of the present invention and the baseline model on the PEMS03 and PEMS04 datasets;
[0094] Figure 2 Graph showing the performance comparison between the embodiment of the present invention and the baseline model on the PEMS07 and PEMS088 datasets;
[0095] Figure 3 This is a comparison chart of short-term prediction performance on the PEMS04 dataset according to an embodiment of the present invention;
[0096] Figure 4 This is a comparison chart of short-term prediction performance on the PEMS08 dataset according to an embodiment of the present invention;
[0097] Figure 5 Comparison of the 5-minute and 60-minute prediction curves of DSTAGNN and DSTSPYN on the PEMS03 test data snapshots according to an embodiment of the present invention: (a) is node 115, (b) is node 24, and (c) shows the location of the node in the road network;
[0098] Figure 6 This is a diagram showing the ablation experiment results according to an embodiment of the present invention;
[0099] Figure 7 The spatiotemporal dependency obtained by DSTSPYN on the PEMS03 dataset in the embodiment of the present invention is
[0100] Figure 8 Visualization of node attention and traffic flow curves in the embodiment of the present invention
[0101] Figure 9 Detailed framework diagram of the DSTSPYN model of an embodiment of the present invention; (a) is the overall structure of DSTSPYN, (b) shows the details of the spatial pyramid module, and (c) shows the structure of the temporal pyramid block.
[0102] Figure 10 This is a detailed diagram of the spatiotemporal global similarity module of an embodiment of the present invention. DETAILED DESCRIPTION
[0103] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0104] In order to facilitate the detailed description of the present invention, the relevant basic concepts are first described in a unified manner.
[0105] Definition 1 (Definition of Traffic Flow Prediction Problem) In this invention, the traffic network is defined as a directed graph in A collection of nodes (such as sensors) in the road network ε represents the set of edges (|ε|=M), is the adjacency matrix of the road network graph At each time slice, each node collects D node features at the same sampling frequency, such as traffic flow, speed, etc. Traffic Signal Represents the traffic network The observation values of all sensors in time step t. Given the historical traffic signal Traffic forecasting problems aim to predict Where P is the given historical time step and Q is the predicted time step. The traffic prediction problem can be described as learning the mapping function f from the historical time step P to the next time step Q:
[0106]
[0107] Definition 2 (Spatiotemporal Global Correlation Matrix) Brownian distance covariance (BDC) is established according to the characteristic function theory and can measure the dependency between two random vectors by comparing their characteristic functions. For a set of m independent and identically distributed observations {(x1,y1),(x2,y2),…(x m ,y m )}, assuming the matrix Represents the Euclidean distance matrix calculated based on the observation value X. Similarly, the Euclidean distance matrix is calculated in Then the BDC metric has a closed-form expression:
[0108] ρ(X,Y)=tr(A T B) (2)
[0109] A=(a kl ) is the spatiotemporal global correlation (STGC) matrix, where The last three items represent the lth column, the Kth row, and The matrix B can be obtained by similar calculations.
[0110] Since the STGC matrix is symmetric, ρ(X,Y) can be expressed as the inner product of two STGC vectors a and b,
[0111] ρ(X,Y)=<a,b> =a T b (3)
[0112] Where a and b are obtained by extracting the upper triangular parts of A and B respectively and then vectorizing them.
[0113] Next, we will introduce the structure of DSTSPYN and its functional modules in detail. Figure 9 -(a). It mainly includes improved multi-head spatiotemporal self-attention, spatial pyramid module and temporal pyramid module.
[0114] (1) Improved multi-head spatiotemporal self-attention
[0115] In this step, we provide a detailed calculation process for an improved multi-head spatiotemporal self-attention algorithm, which is used to extract dynamic, long-term features of traffic flow. Spatiotemporal attention automatically learns the dependencies between different time points and spatial locations, helping the model better understand the evolution of traffic data.
[0116] Step 1: The multi-head attention mechanism can consider multiple attention heads at the same time, and each attention head can focus on different temporal and spatial features, thereby improving the model's expressiveness and prediction performance. For H heads of multi-head temporal attention, define the variables:
[0117]
[0118] in, represents the output of the l-1th layer of space-time block after dimension transformation, as the input of the lth layer of space-time block, is a learnable parameter.
[0119] Step 2: Calculate the attention score of each head and connect the output of the temporal attention module with the output of the temporal attention module in the previous spatiotemporal block through a residual connection to transfer and retain historical information, so that the model can better capture the long-term dependencies in the time series, as shown in the following formula:
[0120]
[0121] Step 3: Concatenate the matrices of all attention heads together to obtain a richer and more comprehensive feature representation. It is passed as input to the spatial attention module as shown below:
[0122] M=LayerNorm(MLP(Concat(Head (1) ,…,Head (H) ))) (6)
[0123] Step 4: Use one-dimensional convolution to map the temporal dimension P of the output M of the temporal attention module to dimension d. E And aggregate feature dimension D (l-1) , then through the spatial embedding operation, we get
[0124] Step 5: Similar to step 1, define the variables:
[0125]
[0126] Step 6: Calculate the spatial attention score as follows:
[0127]
[0128] Represents the query vector Q' (h) With the key vector K' (h) Unlike traditional Transformers, the obtained attention score is not used to embed the vector M'V' (h) Instead of weighting, it is used to adjust the weight of each layer of the spatial pyramid.
[0129] (2) Spatial Pyramid Module
[0130] Step 1: Represent the proximity of different nodes based on whether there is a connection between them, as shown in the following formula:
[0131]
[0132] Step 2: Randomly initialize two learnable node embedding matrices E1, E2∈R N×c Implement an adaptive adjacency matrix as follows:
[0133]
[0134] Step 3: Describe the state transition between nodes as a spatial diffusion process of nodes, and simulate this process by performing random walks on the graph. By combining the predefined spatial dependencies and the self-learned hidden graph dependencies, the adaptive diffusion graph convolution layer is calculated as shown in the following formula:
[0135]
[0136] Among them C k represents the power series of the transfer matrix. In the case of a directed graph, the diffusion process has two directions, forward and backward, where the forward transfer matrix Backward transfer matrix represents the input signal, Indicates output, Represents the model parameter matrix. It is used as the first layer of the spatial pyramid to capture local neighborhood information.
[0137] Step 4: Slice the data processed by the diffusion graph convolution according to the time dimension, as shown in the following formula:
[0138]
[0139] Step 5: Take Z (i) For example, consider the spatial similarity of two adjacent time steps. The details of the spatiotemporal global similarity module are as follows: Figure 10 As shown. As random observations, calculate the squared Euclidean distance matrix in turn in It's Z (i) The squared Euclidean distance between the kth column and the lth column, the Euclidean distance matrix as well as The STGC matrix A obtained by subtracting its row mean, column mean and all element means:
[0140]
[0141]
[0142]
[0143] Here J N ∈R N×N is a matrix where every element is 1, I is the identity matrix, represents the Hadamard product.
[0144] Step 6: Calculate A (i) With A (j) The BDC metric between time slices i and j is the similarity of traffic flow characteristics between time slices i and j:
[0145]
[0146] where a (i) ,a (j) A (i) ,A (j) The vector representation of .
[0147] Step 7: The greater the similarity between the current time slice and its adjacent time slices, the greater the impact of its characteristics on traffic prediction. The average of the similarity between the current time slice and its adjacent time slices is used as the weight of the time slice, and finally the concatenation is performed:
[0148] Z S =ReLU(Concat(A (1) S 1 ,A (2) S 2 ,…,A (P) SP )) (17)
[0149] Among them, S (i) It's Z (i) The average of the BDC metrics of adjacent time slices is used as the second layer of the spatial pyramid to capture the global information of the node.
[0150] Step 8: The output of the spatiotemporal global similarity module is average pooled and passed through a layer of 1×1 convolution to extract the road network level features, which are used as the third layer of the spatial pyramid.
[0151] Z L =Conv2D (1,1) (GlobalMeanPool(Z S )) (18)
[0152] Step 9: Combine low-resolution, semantically strong features with high-resolution, semantically weak features through top-down paths and lateral connections to form a spatial pyramid.
[0153] Step 10: The spatial attention score calculated in step 6 in (1) is used to adjust the weight of each pyramid layer. Assume that the output of each pyramid layer is Z j ,but
[0154]
[0155] Where J is the number of layers of the spatial pyramid.
[0156] (3) Time pyramid module
[0157] Step 1: Define a pyramid level for each stage. The input of the i-th pyramid level is represented as Set the convolution kernel to 1×S, then:
[0158]
[0159] in,* τ is the gated convolution operator, E and F are k is the reduction factor of the time dimension in each pyramid level relative to the first and second halves of the channel dimension, Through a bottom-up pathway, temporal dependencies at different scales are extracted.
[0160] Step 2: Except for the topmost pyramid, a GTU with a convolution kernel of 1×1 is applied to each pyramid layer. Through the top-down path, the lower pyramid level is able to fuse the spatially coarser but semantically stronger feature maps from the higher pyramid levels and produce features with higher resolution through upsampling operations. Secondly, through lateral connections, these feature maps are fused with the bottom-up path as the output of the pyramid layer. Figure 9 -(c) shows.
[0161] Step 3: Use trainable parameters to modify the weights of each temporal pyramid layer as shown below:
[0162]
[0163] Where I is the number of layers of the time pyramid, is the output of each layer of the time pyramid, and W is a trainable parameter.
[0164] The following is a further introduction and demonstration of the present invention through verification experiments:
[0165] The experiment of this invention takes the California highway data as an example, and selects the "PEMS03", "PEMS04", "PEMS07", and "PEMS08" data sets. The specific information is shown in Table 1. The effects of parameter selection and optimization methods are tested from the aspects of prediction accuracy, method efficiency, and robustness.
[0166] Table 1 Dataset description
[0167] Dataset Number of nodes Number of edges Time Range PEMS03 358 547 9 / 1 / 2018-11 / 30 / 2018 PEMS04 307 340 1 / 1 / 2018-2 / 28 / 2018 PEMS07 883 866 5 / 1 / 2017-8 / 31 / 2017 PEMS08 170 295 7 / 1 / 2016-8 / 31 / 2016
[0168] Model performance testing
[0169] Table 2 and Figure 1 , Figure 2 The performance of the baseline model and the model proposed in the present invention is shown. Compared with the traditional model-driven method, the deep learning method has higher prediction accuracy. This result proves that the deep learning method is more suitable for the prediction task of nonlinear traffic data. On the other hand, the prediction accuracy data of GRU for processing time series are not as good as other spatiotemporal prediction models, which shows that the spatial correlation in traffic data will affect the traffic prediction results. In some indicators of the PSME03 and PSME07 data sets, the model of the present invention is slightly inferior to DSTAGNN. The possible reason is that there are more nodes in these data sets, and the STGS module in DSTSPYN has a higher complexity in calculating spatial similarity. In addition, the data set itself may have a more complex spatial structure and mutual relationship, which poses a greater challenge to DSTSPYN in spatial similarity modeling. In addition, the models of the present invention have achieved the best performance.
[0170] Table 2 Performance comparison on the PEMS dataset
[0171]
[0172]
[0173] In order to further evaluate the performance of DSTSPYN in short-term prediction, the present invention predicts the traffic data for the next 5 minutes, 15 minutes, 30 minutes and 45 minutes on the PEMS04 and PEMS08 datasets. The results are shown in Table 3. Figure 3 , Figure 4 The figure shows a comparison of the prediction performance of DSTSPYN and baseline methods at different prediction horizons. For short-term predictions of 5 minutes, DSTSPYN performs slightly worse than Graph WaveNet. However, as the prediction horizon increases, the proposed model maintains high prediction accuracy, achieving the best performance for 15-minute, 30-minute, and 45-minute predictions. This demonstrates that the pyramid architecture, which considers dynamic spatiotemporal dependencies, is adaptable to traffic flow predictions at different time horizons.
[0174] Table 3 Comparison of short-term prediction performance
[0175]
[0176] We select node 115 located on the central road and node 24 located on the edge road, and plot the predicted values and actual results of DSTSPYN and DSTAGNN on the test data snapshot 5 minutes and 60 minutes in advance, as shown in Figure 2. Figure 5 As shown in the figure, DSTSPYN predicts the dynamic changes of peak traffic more accurately than the baseline method. Especially for edge nodes, DSTAGNN produces multiple blue spikes that deviate significantly from the true values, while the DSTSPYN curve always stays in the middle of the actual values.
[0177] Ablation experiments
[0178] To verify the effectiveness of each component in DSTSPYN, this example makes the following variants of DSTSPYN:
[0179] (1) re-sta: Completely remove the spatiotemporal attention mechanism. The weights of each layer of the spatial pyramid are calculated using learnable weight parameters.
[0180] (2) only-gtu: The temporal pyramid module uses only a single GTU to compute temporal dependencies.
[0181] (3) re-tpy: The temporal pyramid module uses a three-layer GTU series structure of different scales instead of a pyramid structure.
[0182] (4) re-stgs: remove the spatiotemporal global similarity module.
[0183] (5) re-GF: removes the spatial pyramid layer that extracts graph-level features.
[0184] (6) re-spy: The spatial pyramid module does not use the pyramid structure.
[0185] This example conducts ablation experiments on the above variants on the PEMS04 dataset. Figure 6 The measurement results of MAE, RMSE and MAPE are shown. It can be seen that the multi-head spatiotemporal attention mechanism models the long-term dependence of traffic flow and the spatial dependencies at different scales, enabling the model to extract richer spatiotemporal features, thus contributing the most to the performance improvement. The time pyramid module has the second largest effect. It verifies that the use of a pyramid structure for temporal feature transfer and fusion helps to improve the model's understanding and modeling capabilities of temporal dynamics. The third is the STGS module, which can effectively extract edge node features and calculate the similarity between time slices, thereby achieving overall performance improvement. In general, DSTSPYN performs better than other variants, which confirms the effectiveness of each component in the model of the present invention.
[0186] Table 4 Ablation experiment results
[0187]
[0188] Spatial-temporal attention visualization
[0189] To enhance the interpretability of DSTSPYN and show the details of its attention module, this example visualizes the spatiotemporal dependencies it obtains. The color depth of the point represents the attention strength of the corresponding node. Figure 7 (a) shows the local and edge attention of the first and second attention heads. It can be observed that the first attention head focuses on the spatiotemporal dependencies of the central streets, while the second attention head pays more attention to the spatiotemporal dependencies of the edge streets. This shows that our model is able to distinguish and capture the specific spatiotemporal patterns of different street areas. Figure 7 -(b) shows the global spatiotemporal dependencies captured by the third attention head. It can be clearly observed that this attention head has the ability to identify complex traffic conditions (such as road intersections).
[0190] To further demonstrate the effectiveness of spatiotemporal attention, a visualization experiment was conducted on the PEMS03 dataset, showing the attention distribution between the first 25 nodes. The color depth of the points is proportional to the attention score between the nodes. This example selects three nodes with the shallowest to deepest attention relative to node 10 and compares them with the traffic flow curve of node 10 throughout the day, as shown in Figure 2. Figure 8 As shown in the figure. Observing the results in the figure, we can see that the attention between nodes 10 and 4 is the strongest, and their traffic flow dynamics are highly consistent during the morning and evening rush hours. Node 10's attention to node 16 is slightly less, and their daily traffic flows are almost identical except during the morning rush hour. Node 10's attention to node 21 is the weakest, and it can be seen that their traffic flow correlation does not seem to be obvious enough. This shows that the improved attention mechanism of the present invention can help the model effectively capture the spatiotemporal dependencies between nodes in traffic flow prediction.
[0191] In summary, the proposed model demonstrates promising performance in traffic flow forecasting and is able to extract complex information from road networks. This provides deeper insights into understanding and predicting traffic flow behavior, and provides valuable information for decision-makers in fields such as traffic management and planning.
[0192] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0193] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0194] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0195] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.
[0196] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any other manner. Any person skilled in the art may utilize the above-disclosed technical content to modify or modify the present invention into equivalent embodiments. However, any simple modifications, equivalent variations, and modifications to the above embodiments that do not depart from the technical content of the present invention and are based on the technical essence of the present invention remain within the scope of protection of the present invention.
[0197] This patent is not limited to the above-mentioned best implementation mode. Anyone can derive various other forms of traffic flow prediction methods based on dynamic spatiotemporal similarity pyramid networks based on the inspiration of this patent. All equal changes and modifications made according to the scope of the patent application of this invention should be covered by this patent.
Claims
1. A traffic flow prediction method based on a dynamic spatiotemporal similarity pyramid network, characterized by: By using historical vehicle information recorded by road sensors, and considering the spatiotemporal similarity of global dynamic spatiotemporal information and traffic data, we can predict future road traffic flow. The specific steps include: Step S1: Use improved multi-head spatiotemporal self-attention to extract dynamic long-term features of traffic flow: Step S1.1: Use multi-head temporal self-attention to capture the temporal correlation of traffic flow; Step S1.2: Connect the output of the temporal attention module with the output of the temporal attention module in the previous spatiotemporal block through a residual connection to transfer and preserve historical information; Step S1.3: Calculate the correlation score of multi-head spatial self-attention to adjust the weight of each layer of the spatial pyramid; Step S2: Use the spatial pyramid module to capture global spatial information and spatial similarity: Step S2.1: Use adaptive diffusion graph convolution to capture local neighborhood information as the first layer of the spatial pyramid; Step S2.2: Calculate the spatiotemporal global correlation matrix of each time step and extract the edge features of the graph; Step S2.3: Calculate the similarity of the spatiotemporal global correlation matrix between each time slice and its adjacent time slices, and use the mean as the weight of the time slice; Step S2.4: concatenate the results as the second layer of the spatial pyramid to capture the global information of the nodes; Step S2.5: The output of the spatiotemporal global similarity module is subjected to average pooling and 1×1 convolution to extract road network-level features as the third layer of the spatial pyramid; Step S2.6: Combine low-resolution, semantically strong features with high-resolution, semantically weak features through top-down pathways and lateral connections to form a spatial pyramid. Step S2.7: Use the spatial attention score calculated in step S1.3 to adjust the weight of each pyramid layer; Step S3: Use the time pyramid module to extract time dependencies of different granularities: Step S3.1: Use pyramid-gated Tanh units to capture dynamic temporal information of traffic flow data; Step S3.2: Modify the weights of each temporal pyramid layer using trainable parameters; Step S4: The output of the spatiotemporal block is passed to the prediction layer through the residual connection to obtain the traffic flow prediction result.
2. The traffic flow prediction method based on a dynamic spatiotemporal similarity pyramid network according to claim 1, characterized in that: Define the traffic network as a directed graph in is the set of sensors in the road network, ε represents the set of edges, |ε|=M, is the adjacency matrix of the road network graph, At each time slice, each node collects D node features at the same sampling frequency; traffic signals Represents the traffic network The observation values of all sensors in at time step t; Given historical traffic signals Traffic forecasting problems aim to predict Where P is the given historical time step and Q is the predicted time step; the traffic prediction problem is described as learning the mapping function f from the historical time step P to the next time step Q: For a set of m independent and identically distributed observations {(x1,y1),(x2,y2),…(x m ,y m )}, assuming the matrix Represents the Euclidean distance matrix calculated based on the observation value X, and calculates the Euclidean distance matrix in Then the BDC metric has a closed-form expression: ρ(X,Y)=tr(A T B) (2) A=(a kl ) is the spatiotemporal global correlation STGC matrix, where The last three items represent the lth column, kth row, and The average value of all values in ; and the matrix B is obtained by the same calculation method; Since the STGC matrix is symmetric, ρ(X,Y) is expressed as the inner product of two STGC vectors a and b. p(X,Y)=<a,b> =a T b (3) Where a and b are obtained by extracting the upper triangular parts of A and B respectively and then vectorizing them.
3. The traffic flow prediction method based on a dynamic spatiotemporal similarity pyramid network according to claim 2, characterized in that: The improved multi-head spatiotemporal self-attention is specifically: For H-head multi-head temporal attention, define the variables: in, represents the output of the l-1th layer of space-time block after dimension transformation, as the input of the lth layer of space-time block, is a learnable parameter; The attention score of each head is calculated, and the output of the temporal attention module is connected with the output of the temporal attention module in the previous spatiotemporal block through a residual connection to transfer and retain historical information, as shown in the following formula: The matrices of all attention heads are spliced together and normalized to obtain It is passed as input to the spatial attention module as shown below: M=LayerNorm(MLP(Concat(Head (1) ,…,Head (H )))) (6) Use one-dimensional convolution to map the temporal dimension P of the output M of the temporal attention module to dimension d E And aggregate feature dimension D (l-1) , then through the spatial embedding operation, we get Define variables: Calculate the spatial attention score as shown below: Denotes the query vector Q′ (h) With the key vector K′ (h) The correlation between them; among them, the obtained attention score is used to adjust the weight of each layer of the spatial pyramid.
4. The traffic flow prediction method based on a dynamic spatiotemporal similarity pyramid network according to claim 3 is characterized by: In the spatial pyramid module: First, the proximity of different nodes is expressed according to whether there is a connection between them, as shown in the following formula: Randomly initialize two learnable node embedding matrices E1, E2∈R N×c Implement an adaptive adjacency matrix as shown below: The state transition between nodes is described as a spatial diffusion process of nodes and simulated by performing random walks on the graph. By combining the predefined spatial dependencies and the self-learned hidden graph dependencies, the adaptive diffusion graph convolution layer is calculated as shown in the following formula: Among them C k represents the power series of the transfer matrix; in the case of a directed graph, the diffusion process has two directions, forward and backward, where the forward transfer matrix Backward transfer matrix represents the input signal, Indicates output, Represents the model parameter matrix; it is used as the first layer of the spatial pyramid to capture local neighborhood information; The data processed by diffusion graph convolution is sliced according to the time dimension, as shown in the following formula: Consider As random observations, calculate the squared Euclidean distance matrix in turn in It's Z (i) The squared Euclidean distance between the kth column and the lth column, the Euclidean distance matrix as well as The STCG matrix A obtained by subtracting its row mean, column mean and all element means: Among them, J N ∈R N×N is a matrix where every element is 1, I is the identity matrix, represents the Hadamard product; Then calculate A (i) With A (j) The BDC metric between time slices i and j is the similarity of traffic flow characteristics between time slices i and j: where a (i) ,a (j) A (i) ,A (j) Vector representation of ; The greater the similarity between the current time slice and its adjacent time slices, the greater the influence of its characteristics on traffic prediction. The average of the similarity between the current time slice and its adjacent time slice characteristics is used as the weight of the time slice, and finally the concatenation is performed: From S =ReLU(Concat(A (1) With 1 ,A (2) With 2 ,…,A (P) With P )) (17) Among them, S i It's Z (i) The mean of the BDC metrics of adjacent time slices is used as the second layer of the spatial pyramid to capture the global information of the node; The output of the spatiotemporal global similarity module is average pooled and passed through a layer of 1×1 convolution to extract the road network level features, which are used as the third layer of the spatial pyramid; as shown in the following formula: Z L =Conv2D (1,1) (GlobalMeanPool(Z S )) (18) Finally, low-resolution, semantically strong features are combined with high-resolution, semantically weak features through top-down paths and lateral connections to form a spatial pyramid. The calculated spatial attention score adjusts the weight of each layer of the pyramid; assuming that the output of each layer of the pyramid is Z j ,but Where J is the number of layers of the spatial pyramid.
5. The traffic flow prediction method based on a dynamic spatiotemporal similarity pyramid network according to claim 4 is characterized in that: In the time pyramid module: First, a pyramid level is defined for each stage, and the input of the i-th pyramid level is represented as Set the convolution kernel to 1×S, then: Among them, Γ* τ is the gated convolution operator, E and F are k is the reduction factor of the time dimension in each pyramid level relative to the first and second halves of the channel dimension, Through a bottom-up approach, temporal dependencies at different scales are extracted; Except for the topmost pyramid, a GTU with a convolution kernel of 1×1 is applied to each pyramid layer; through a top-down path, the lower pyramids fuse the spatially coarser but semantically stronger feature maps from higher pyramid levels and produce features with higher resolution through upsampling operations; Secondly, through lateral connections, the feature map is fused with the bottom-up path as the output of the pyramid layer; Finally, the trainable parameters are used to correct the weights of each time pyramid layer, as shown in the following formula: Where I is the number of layers of the time pyramid, is the output of each layer of the time pyramid, and W is a trainable parameter.
Citation Information
Patent Citations
Automatic driving track prediction method based on space-time pyramid
CN115049130A
Public traffic flow prediction method combining urban interest points and space-time causal relationship
CN115204478A