Space-time diagram convolution traffic flow prediction method based on multi-view attention
By constructing the MASTGCN model, using the multi-view attention mechanism to integrate spatiotemporal features, the problem of failing to make full use of multi-view information in the existing methods is solved, and efficient and accurate prediction of traffic flow is achieved.
Patent Information
- Application Number
- CN202510409559.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-02
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2045-04-02
AI Technical Summary
Existing traffic flow prediction methods fail to make full use of multi-view information, resulting in low prediction accuracy in traffic data with complex nonlinear and dynamic spatiotemporal dependence.
Using a spatiotemporal graph convolutional traffic flow prediction method based on multi-view attention, the MASTGCN model is constructed, and the spatiotemporal features of multiple views are fused with the spatiotemporal features of multiple views, including ASTGCN, SASTT, LSTGCN, AFF and Cross-Attention, to capture the dynamic spatiotemporal correlation of traffic data.
It improves the accuracy and generalization ability of traffic flow prediction, can effectively process high-dimensional dynamic spatiotemporal data, and achieve efficient prediction of future traffic states.
Smart Images

Figure CN120340248A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of spatio-temporal convolutional prediction of traffic flow, and particularly to a spatio-temporal graph convolutional traffic flow prediction method based on multi-view attention. Background Art
[0002] In the past few decades, a large amount of research work has been done to improve the accuracy of traffic flow prediction. Early methods mainly relied on statistical models and machine learning algorithms such as autoregressive integrated moving average (ARIMA), vector autoregression (VAR), support vector regression (SVR), and Kalman filtering to predict future traffic flow. These methods did not consider spatial features and were difficult to model non-linear spatio-temporal data, so the prediction accuracy was often low. In recent years, with the rapid development of deep learning, deep learning-based models have shown significant advantages in traffic flow prediction. There have been studies attempting to apply deep recurrent neural networks (RNNs) and convolutional neural networks (CNNs) to predict traffic flow; Yao et al. proposed a traffic prediction method that integrates CNN and long short-term memory (LSTM) to jointly model spatio-temporal dependencies; Han et al. proposed a framework that involves deep clustering methods and convolutional neural networks for short-term traffic prediction of large-scale road networks; Chen et al. proposed a multi-gated spatio-temporal CNN for city-wide traffic flow prediction by simultaneously extracting spatio-temporal features from low to high levels; Pu et al. developed a lightweight traffic flow prediction encoder-decoder framework that improves the prediction speed while ensuring the prediction accuracy. However, the methods studied above are all based on CNNs, and these methods are only applicable to spatial relationships in Euclidean spaces represented by two-dimensional matrices or images and are not applicable to non-Euclidean spaces of traffic road topologies.
[0003] Traffic flow prediction, as an important part of the intelligent transportation system (ITS), plays an indispensable role in the construction of smart cities. Real-time and accurate traffic flow prediction can effectively alleviate traffic congestion, optimize traffic management, and improve travel efficiency. Traffic flow prediction is the process of analyzing road network traffic conditions, including flow, speed, and density, mining traffic patterns, and predicting road traffic trends. Its goal is to predict the future road network traffic state based on historical observation data collected by sensors and other devices. Currently, using spatio-temporal data to accurately predict traffic flow has become an important research area in the intelligent transportation system; however, due to the complex non-linearity and dynamic spatio-temporal dependence of traffic data, accurate traffic flow prediction still poses great challenges.
[0004] Generally, the spatio-temporal characteristics of traffic flow data can be learned from the graph topology, global spatio-temporal domain, and local spatio-temporal domain. Early traffic flow prediction methods were mainly based on statistical learning and machine learning, which only modeled the time dependence and could not effectively capture the spatio-temporal dependence of non-linear traffic data. Therefore, to capture the complex spatio-temporal correlations in traffic data, popular deep learning models such as convolutional neural networks (CNNs), recurrent neural networks (RNNs), graph convolutional networks (GCNs), and their variants have been widely applied to traffic flow prediction tasks and achieved remarkable results. In recent years, many works have started to focus on spatio-temporal graph convolutional models for prediction tasks. However, most existing methods tend to focus on learning from a single or dual perspective and do not fully utilize multi-view information to fuse features at different scales, which limits the learning of knowledge from multiple spatio-temporal domains and results in a low accuracy of the final prediction. Summary of the Invention
[0005] Aiming at the above problems existing in the prior art, the technical problem to be solved by the present invention is: how to improve the accuracy of traffic flow prediction using a multi-view spatio-temporal framework.
[0006] To solve the above technical problems, the present invention adopts the following technical solutions:
[0007] A spatio-temporal graph convolutional traffic flow prediction method based on multi-view attention, comprising the following steps:
[0008] S100: Select the traffic network topology graph G of Region B and set traffic sensors on each road in G. The installation positions of the traffic sensors are used as data collection nodes, where the specific expression of G is as follows:
[0009] G = (V, E, A)
[0010] V = {v1, v2,..., v n ,..., v N}
[0011] where E is the set of edges in G, representing the physical connections between data collection nodes, A ∈ R N×N represents the adjacency matrix of G, v n represents the nth data collection node, V represents the set of all data collection nodes, and N represents the total number of data collection nodes; the adjacency matrix refers to A ∈ R N×N is the adjacency matrix of graph G, representing the connection relationship table between data collection nodes. In GCN, the element of the adjacency matrix A is 1 indicating the connection between two data collection nodes and 0 indicating no connection; however, in actual situations, the connection information refers to the distance between the actual road nodes corresponding to the data collection nodes. Therefore, the Gaussian kernel function is usually used to define the adjacency matrix A based on the actual road network ij :
[0012]
[0013] Among them, A ij represents the connection weight between nodes ν i and node ν j ; d(ν i , ν j ) represents the road network distance between nodes; k represents the threshold.
[0014] Construct the historical traffic flow sequence of Area B Among them, represents the true traffic flow value of the nth data collection node at each time step t, F represents the number of traffic data feature dimensions, and the feature dimensions are such as flow, speed, and occupancy rate; among them, T represents the time interval and T≥1, t∈[0, T];
[0015] S200: Construct the MASTGCN model M, and M includes a data conversion layer, a spatio-temporal fusion layer, and a data output layer;
[0016] The data conversion layer is used to convert the traffic flow sequence into the data format required by M;
[0017] The main function of the data conversion layer is to convert the dimensions of various data; if it is necessary to divide the data, such as dividing the training set, validation set, and test set according to a ratio, it can also be processed through the data conversion layer;
[0018] The spatio-temporal fusion layer sequentially includes two modules M1 and M2. M1 includes three information transfer modules, namely the attention-based spatio-temporal graph convolution module ASTGCN, the self-attention-based spatio-temporal module SASTT, and the long-term spatio-temporal graph convolution module LSTGCN;
[0019] M2 includes an attention feature fusion module AFF and a cross-attention module Cross-Attention;
[0020] ASTGCN uses spatio-temporal attention and spatio-temporal convolution mechanisms to capture dynamic spatio-temporal correlations. STSA and LSTGCN focus on extracting spatio-temporal information from local and global scales. The spatio-temporal fusion module is used to fuse the spatio-temporal features extracted from multiple perspectives.
[0021] Both AFF and Cross-Attention are prior arts. The AFF module is adopted to achieve the effective fusion of local features and global features, which can enhance the comprehensive spatio-temporal feature expression ability of the model, dynamically adjust the importance degrees of local features and global features, realize the adaptive fusion of features, and improve the generalization ability and robustness of the model at different spatial scales. Because there are complex spatial and temporal correlations in the actual traffic road network, the result of AFF is fused with the output tensor of the spatio-temporal graph convolution module through the cross-attention module (Cross-Attention). The cross-attention module dynamically adjusts the importance weights of features by calculating the correlations between different features, so as to capture key features. Through the cross-attention mechanism, the model can dynamically capture the complex dependence relationships between different features, thereby enhancing the representation ability of features.
[0022] The data output layer is the fully connected layer in the deep learning model; the fully connected layer in the deep learning model is a prior art.
[0023] S300: Combine G and Perform a data fusion operation to obtain a traffic flow fusion feature tensor. The specific steps are as follows:
[0024] S310: Input to the input data conversion layer, and output a traffic flow data tensor after data format conversion;
[0025] S320: Input G and the traffic flow data tensor into the spatio-temporal fusion layer together:
[0026] Input G and the traffic flow data tensor into the ASTGCN in M1 together, and the ASTGCN outputs a tensor Q;
[0027] Input the traffic flow data tensor into STSA, and the output of STSA is used as the input of AFF in M2, and AFF outputs a tensor K;
[0028] Input the traffic flow data tensor into LSTGCN, and the output of LSTGCN is used as the input of AFF in M2, and AFF outputs a tensor V;
[0029] S330: Use Q, K, and V as the input of Cross-Attention, and output a traffic flow fusion feature tensor;
[0030] S400: Input the traffic flow fusion feature tensor obtained in S330 into concat, perform operations of splicing and conversion on the traffic flow fusion feature tensor, and output a new fusion feature tensor; concat means splicing in the channel dimension and belongs to the prior art;
[0031] S500: The new fused feature tensor is used as the input of the data output layer, and the predicted traffic flow values of all roads at time step t in area B are obtained as the output.
[0032] S600: Use the Adam optimizer to train M, calculate the model loss function L(Θ) and optimize the parameters of M through backpropagation. Stop training when the value of L(Θ) no longer changes, and obtain the trained MASTGCN model M'. The expression of the loss function is as follows:
[0033]
[0034] where Θ represents the learnable parameters; P represents the predicted time step; Y tn represents the true traffic flow value at node n at time step t, and the value of Y tn is the true traffic flow value of the nth node in; represents the predicted traffic flow value of node n at time step t, and the value of is equal to the predicted traffic flow value of the nth node in;
[0035] During training, all learning models were trained for 100 epochs, the batch size was 32, and the learning rate was 0.001. The graph convolution kernel size and the temporal convolution kernel size of G were both set to 3. During the training process of the traffic flow prediction model, the mean squared error (MSE) was used to construct the loss function to measure the deviation between the traffic flow predicted by the model and the real observed data, and the model parameters were optimized through backpropagation. When the loss value reached the minimum or no longer changed after training, the training was completed, which could make the prediction result closer to the real value.
[0036] S700: Input the traffic network topology graph G' of the area Q to be predicted and the historical traffic flow sequence of this area into the trained M', and obtain the predicted future traffic flow value
[0037] Preferably, in the S200, ASTGCN includes a number of serially stacked spatio-temporal blocks STblock, SASTT includes a spatio-temporal attention mechanism and Norm&Dropout, and LSTGCN includes 1 graph convolution network layer, 2 long-order temporal convolution layers, 2 activation functions and Norm&Dropout. Norm&Dropout represents a normalization and overfitting data processing method, which belongs to the prior art; the graph convolution network layer and the temporal convolution neural network layer belong to the prior art.
[0038] Preferably, in the S200, the ASTGCN is composed of a number of spatio-temporal blocks STblock, and each STblock includes a spatial attention mechanism SAtt, a temporal attention mechanism TAtt, a convolutional network GCN, and a multi-scale convolutional network MConv. The attention-based spatio-temporal graph convolutional module can effectively capture the dynamic spatio-temporal features of traffic data and enhance the expression ability of the network through the spatio-temporal attention block and the spatio-temporal convolutional block; by stacking multiple spatio-temporal attention convolutional blocks (ST block), a larger range of dynamic spatio-temporal correlations can be further captured, so as to better predict the accuracy of future traffic flow; the model will capture the dynamic spatio-temporal correlations between the nodes of the traffic network through the spatio-temporal attention mechanism, and can effectively extract the spatio-temporal features in the traffic flow data through the convolutional network. SAtt, TAtt, GCN, and MConv all belong to the prior art.
[0039] Preferably, in the S200, the AFF is composed of two branches: local attention and global attention; each branch contains a convolutional layer, a batch normalization layer, and an activation function.
[0040] The local attention and the global attention are respectively used to capture the correlations between local features and between global features. Then, the outputs of these two attentions pass through the Sigmoid function to generate a fusion weight, and are normalized, and then pass through the ReLU activation to generate a fusion feature; then, as the input vectors K and V of the cross-Attention, they are fused with the output Q of the ASTGCN.
[0041] Preferably, in the S320, the specific content of the corresponding tensors Q, K, and V output is as follows:
[0042] Taking G and the traffic flow data tensor as the input of the ASTGCN, the output tensor Q, and the calculation expression is:
[0043] Q = Conv 1×1 x cat
[0044] where Conv 1×1 represents a 1×1 convolution operation, and x cat represents the feature tensor output after several STblocks;
[0045] Taking the traffic flow data tensor as the input of the SASTT, the output tensor K, and the calculation expression is:
[0046]
[0047] Q t = X :t: W Q
[0048] K t = X :t: W K
[0049] V t = X :t: W V
[0050] Among them, Q t , K t , V t represent the traffic flow matrix after X :t: linear transformation, is a trainable weight matrix; X :t: represents three consecutive traffic data tensor slices;
[0051] Taking the traffic flow data tensor as the input of the LSTGCN, the output tensor V is calculated by the following expression:
[0052] V = Y1 ⊙ σ(Y2)
[0053] Among them, ⊙ represents the Hadamard product, σ represents the Sigmoid activation function, Y1 and Y2 represent the output feature tensors after the traffic flow data tensor is processed by the graph convolutional network layer and the long-term time convolutional layer, and the graph convolutional network layer and the long-term time convolutional layer are prior arts.
[0054] Compared with the prior art, the present invention has at least the following advantages:
[0055] 1. The present invention designs a multi-view spatio-temporal prediction framework. The framework includes a unified spatio-temporal data input layer, a spatio-temporal block, and an output prediction layer. The spatio-temporal block includes three information propagation modules for capturing spatio-temporal correlations in different views and an attention-based spatio-temporal feature fusion module. The dynamic spatio-temporal correlations are effectively extracted from multiple views, such as graph structure, local spatio-temporal correlation, global spatio-temporal correlation, etc. The spatio-temporal correlations are deeply fused through the spatio-temporal how module. The MASTGCN framework consists of an input layer, two stacked spatio-temporal blocks, and an output layer. The overall framework implements the traffic flow prediction task in an end-to-end manner, can efficiently process high-dimensional dynamic spatio-temporal data, and complete the prediction of future traffic states. The training process is relatively fast, and the prediction accuracy is relatively high.
[0056] 2. The spatio-temporal attention mechanism is used in this framework to learn the dynamic spatio-temporal correlations of traffic data (spatial attention learns the dynamic correlations between nodes, and temporal attention learns the dynamic correlations between time steps). Graph convolution is used to capture spatial features, and convolutional methods are used to extract temporal dependencies. Spatio-temporal correlations are extracted from multiple perspectives. The local spatio-temporal dependencies in traffic data are captured by a module based on the self-attention mechanism, and the global spatio-temporal correlations in traffic data are captured by a module based on the graph convolutional network (GCN) and long-term temporal modeling.
[0057] 3. The feature fusion module contains two different attention mechanisms. The attention feature fusion module (AFF) is used to integrate local and global features, and the cross-attention mechanism further deeply fuses the feature tensor after AFF fusion and the features output by ASTGCN.
[0058] 4. Extensive experiments were conducted on real traffic datasets to evaluate the model of the present invention. The experimental results show that the MASTGCN model has the best prediction performance compared with existing baseline methods. Brief Description of the Drawings
[0059] Figure 1 It is the basic framework diagram of the MASTGCN model of the present invention.
[0060] Figure 2 It is the prediction results of different methods for West_flow (left); the visualization results of the flow prediction of a random node in West_flow (right).
[0061] Figure 3 It is the ranking of the prediction effects of the nodes in the West Station road network.
[0062] Figure 4 It is a partial sensor distribution diagram of the road network around Chongqing West Station.
[0063] Figure 5 It is the data results of ablation experiments conducted on the datasets PeMS08 and PeMS04.
[0064] Figure 6 It is the comparison of the performance metrics of the MASTGCN model with other models at 15 minutes, 30 minutes, and 60 minutes respectively. Detailed Description of the Invention
[0065] The present invention will be further described in detail below.
[0066] See Figures 1-6 , a spatio-temporal graph convolutional traffic flow prediction method based on multi-view attention, including the following steps:
[0067] S100: Select the traffic network topology graph G of region B, and set traffic sensors on each road in G. The installation locations of the traffic sensors serve as data collection nodes. The specific expression of G is as follows:
[0068] G = (V, E, A)
[0069] V = {v1, v2, …, v n , …, v N}
[0070] where E is the set of edges in G, representing the physical connections between data collection nodes, A ∈ R N×N represents the adjacency matrix of G, v n represents the nth data collection node, V represents the set of all data collection nodes, and N represents the total number of data collection nodes;
[0071] Construct the historical traffic flow sequence of region B where, represents the true traffic flow value of the nth data collection node at each time step t, F represents the number of traffic data feature dimensions. Among them, T represents the time interval and T ≥ 1, t ∈ [0, T];
[0072] S200: Construct the MASTGCN model M. M includes a data conversion layer, a spatio-temporal fusion layer, and a data output layer;
[0073] The data conversion layer is used to convert the traffic flow sequence into the data format required by M;
[0074] The spatio-temporal fusion layer sequentially includes two modules M1 and M2. M1 includes three information transfer modules, namely the attention-based spatio-temporal graph convolution module ASTGCN, the self-attention-based spatio-temporal module SASTT, and the long-term spatio-temporal graph convolution module LSTGCN;
[0075] M2 includes an attention feature fusion module AFF and a cross-attention module Cross-Attention;
[0076] The data output layer is the fully connected layer in the deep learning model;
[0077] In the above S200, ASTGCN includes several serially stacked spatio-temporal blocks STblock, SASTT includes a spatio-temporal attention mechanism and Norm&Dropout, and LSTGCN includes 1 graph convolution network layer, 2 long-order time convolution layers, 2 activation functions, and Norm&Dropout.
[0078] In the above S200, the ASTGCN consists of several spatio-temporal blocks STblock. Each STblock includes a spatial attention mechanism SAtt, a temporal attention mechanism TAtt, a convolutional network GCN, and a multi-scale convolutional network MConv.
[0079] In the above S200, the AFF consists of two branches: local attention and global attention; each branch contains a convolutional layer, a batch normalization layer, and an activation function.
[0080] S300: Perform a data fusion operation on G and to obtain a traffic flow fusion feature tensor. The specific steps are as follows:
[0081] S310: Input the into the data conversion layer, and output a traffic flow data tensor after data format conversion;
[0082] S320: Input G and the traffic flow data tensor into the spatio-temporal fusion layer:
[0083] Input G and the traffic flow data tensor into the ASTGCN in M1, and the ASTGCN outputs a tensor Q;
[0084] Input the traffic flow data tensor into STSA, and the output of STSA is used as the input of AFF in M2, and AFF outputs a tensor K;
[0085] Input the traffic flow data tensor into LSTGCN, and the output of LSTGCN is used as the input of AFF in M2, and AFF outputs a tensor V;
[0086] In the above S320, the specific content of the corresponding tensors Q, K, and V output is as follows:
[0087] Input G and the traffic flow data tensor as the input of ASTGCN, and output tensor Q. The calculation expression is:
[0088] Q = Conv 1×1 x cat
[0089] where Conv 1×1 represents a 1×1 convolution operation, and x cat represents the tensor output after passing through several STblocks;
[0090] Input the traffic flow data tensor as the input of SASTT, and output tensor K. The calculation expression is:
[0091]
[0092] Q t = X:t: W Q
[0093] K t = X :t: W K
[0094] V t = X :t: W V
[0095] where Q t , K t , V t represent the traffic flow matrix after linear transformation of X :t: ; and is a trainable weight matrix; X :t: represents three consecutive traffic data tensor slices;
[0096] Taking the traffic flow data tensor as the input of LSTGCN, the output tensor V is calculated by the expression:
[0097] V = Y1 ⊙ σ(Y2)
[0098] where ⊙ represents the Hadamard product, σ represents the Sigmoid activation function, and Y1, Y2 represent the output feature tensors after the traffic flow data tensor is processed by the graph convolutional network layer and the long-term temporal convolutional layer;
[0099] S330: Taking Q, K, V as the Cross-Attention input, the traffic flow fusion feature tensor is output;
[0100] S400: Inputting the traffic flow fusion feature tensor obtained by S330 into concat, performing operations of splicing and transformation on the traffic flow fusion feature tensor, and outputting a new fusion feature tensor;
[0101] S500: Taking the new fusion feature tensor as the input of the data output layer, the traffic flow prediction values of all roads at time step t in area B are output
[0102] S600: Training M using the Adam optimizer, calculating the model loss function L(Θ) and optimizing the parameters of M through backpropagation. Stop training when the value of L(Θ) no longer changes, and obtain the trained MASTGCN model M'. The expression of the loss function is as follows:
[0103]
[0104] where Θ represents the learnable parameters; P represents the predicted time step; Y tn represents the true traffic flow value at node n at time step t, Ytn The value of is the true traffic flow value of the nth node in denotes the traffic flow prediction value of node n at time step t, and the value of is equal to the traffic flow prediction value of the nth node in
[0105] S700: Input the traffic network topology graph G’ of the area Q to be predicted and the historical traffic flow sequence of this area into the trained M’ to obtain the future traffic flow prediction value of Q Experiments and Results
[0106] This invention uses three real-world datasets to evaluate the performance of the traffic flow prediction model proposed in this paper. In addition, to evaluate the effectiveness of the designed module, ablation experiments are also conducted in this experiment. Finally, the visualization of the prediction effect is also provided.
[0107] 1. Dataset Introduction
[0108] The basic statistical information of the datasets is shown in Table 1. Among them, the PeMS04 and PeMS08 datasets come from areas in California and are collected in real time every 30 seconds by the California Department of Transportation Performance Measurement System (PeMS); these datasets are different in time, location, and scale and are summarized every 5 minutes. The private dataset West_flow is provided by the traffic-related department of Chongqing West Station and has been processed to match the format of the PeMS dataset. The data collection points at the west station are as Figure 3 and Figure 4 shown.
[0109] Table 1: Dataset Details
[0110]
[0111] 2. Experimental Settings
[0112] 2.1 Baseline Methods
[0113] The traffic flow prediction model of this invention is compared with the following ten state-of-the-art baseline methods.
[0114] HA: Historical Average is a traditional statistical method that makes predictions based on the mean of historical data.
[0115] ARIMA: Autoregressive Integrated Moving Average Model is a prediction method widely used in time series analysis.
[0116] VAR: Vector Autoregression is a classical time series model that can extract pairwise correlations of traffic flows.
[0117] LSTM: Long Short-Term Memory network is used to capture and model long-term temporal dependencies.
[0118] DCRNN: Diffusion Convolutional Recurrent Neural Network models spatial and temporal dependencies by leveraging the diffusion process on a directed graph.
[0119] STGCN: Spatio-Temporal Graph Convolutional Network captures spatio-temporal dependencies through graph convolution and gated causal convolution.
[0120] Graph WaveNet: Graph WaveNet uses an adaptive adjacency matrix for spatio-temporal graph modeling.
[0121] STSGCN: Spatio-Temporal Synchronized Graph Convolutional Network can capture spatio-temporal relationships simultaneously.
[0122] ASTGCN: Attention-based Spatio-Temporal Graph Convolutional Network combines the attention mechanism with graph convolution for modeling dynamic spatio-temporal relationships.
[0123] STFGNN: Spatio-Temporal Fusion Graph Neural Network generates temporal graphs and studies the fusion process to capture latent spatio-temporal correlations.
[0124] The model of the present invention is implemented using the PyTorch framework: Each dataset is divided into a training set, a test set, and a validation set in a ratio of 6:2:2. The model is trained using the Adam optimizer. All learning models are trained for 100 epochs with a batch size of 32 and a learning rate of 0.001. The graph convolution kernel size and the temporal convolution kernel size are both set to 3. Traffic flow data is aggregated at each sensor node every 5 minutes. With a 1-hour historical time window, the traffic conditions for the next hour are predicted based on 12 observation data points within the window. The comparative experiment is conducted on a Windows server with the following configuration: Intel(R) Core(TM) i7-12700 @ 2.10GHz processor, 32GB of memory, and an NVIDIA GeForce RTX 3060Ti GPU.
[0125] 2.2 Evaluation Metrics
[0126] The evaluation metrics for model performance include Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), and Root Mean Square Error (RMSE). The smaller the values of these three evaluation metrics, the more accurate the model's prediction. These three specific evaluation metrics can be expressed as:
[0127] 1) MAE:
[0128]
[0129] 2) RMSE:
[0130]
[0131] 3) MAPE:
[0132]
[0133] Among them, y t is the actual traffic flow, is the predicted traffic flow.
[0134] 3. Experimental results
[0135] The MASTGCN model is compared with ten baseline methods on PeMS04 and PeMS08. Table 2 shows the average results of the traffic flow prediction performance within the next hour, that is, all the experimental results in the table are the average values of the prediction accuracies of 12 time steps.
[0136] Table 2: Comparison of average performance of different methods on PeMS04 and PeMS08 (Note: The evaluation index is the average value of 12 prediction time steps)
[0137]
[0138] From Table 2 and Figure 6 it can be seen that MASTGCN shows the optimal performance in all evaluation indexes of the two datasets. It can be seen that the prediction results of traditional time series analysis methods are usually poor, which indicates that these methods have limited ability to model non-linear and complex traffic data. In contrast, deep learning-based methods generally can provide more accurate prediction results than traditional time series analysis methods. Among them, models that consider both time and space correlations, such as STGCN and STSGCN, have better prediction effects than traditional deep learning models, such as LSTM. In addition, the performance of ASTGCN is better than that of STGCN, indicating that the attention mechanism it adopts can effectively capture the dynamic changes of traffic data.
[0139] Table 3: Comparison of average performance of different methods on West_flow
[0140]
[0141] To more deeply evaluate the generalization ability of the model, the MASTGCN model was also tested on the private dataset West_flow. This dataset contains traffic flow data for a specific area around the Chongqing West Station transportation hub, with unique traffic patterns and characteristics. As shown in the experimental results in Table 3, in addition to achieving good performance on the widely used PeMS04 and PeMS08 datasets, even on such a challenging dataset, the MASTGCN model also demonstrated good prediction ability, proving that the proposed model has good generalization performance. As Figure 2 shown, the model also has good prediction performance on the private dataset. The true values and predicted values of the sensor nodes have a high degree of consistency over a one-day period and can capture the changing trends of traffic flow. The consistent performance of the model on public and private datasets indicates that our model is not only applicable to specific scenarios but also has broad application potential.
[0142] 4. Ablation Experiments
[0143] This invention uses a novel spatio-temporal attention mechanism and a spatio-temporal fusion module to capture and fuse spatio-temporal features from different views to address the dynamic spatio-temporal dependencies of traffic data. To further evaluate the roles of different components in MASTGCN, we conducted ablation experiments and analyzed the experimental results on the PeMS08 and PeMS04 datasets. We designed 3 variant versions of MASTGCN, including:
[0144] MASTGCN-noSATtt: The spatio-temporal attention mechanism was removed to verify its effectiveness in learning the dynamic spatio-temporal correlations of traffic data.
[0145] MASTGCN-noSTF: The spatio-temporal fusion module was replaced with a traditional concatenation fusion operation to study the effectiveness of comprehensively aggregating spatio-temporal context information from different perspectives.
[0146] MASTGCN-ST: Both the spatio-temporal attention and spatio-temporal convolution modules were removed, leaving only the basic spatio-temporal convolution network module.
[0147] The results of the ablation experiments are as Figure 5 shown. The complete prediction model performs best in all cases, which verifies the effectiveness and necessity of each component in the model. The performance of the model with the SATtt or STF module removed decreases, indicating that these components can capture complex spatio-temporal dynamic features and play an important role in improving the model's prediction accuracy. On both datasets, the performance of the complete model (MASTGCN) is consistent, indicating its good generalization ability and robustness.
[0148] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the purpose and scope of the technical solutions of the present invention, and they should all be covered within the scope of the claims of the present invention.
Claims
1. A spatio-temporal graph convolutional traffic flow prediction method based on multi-view attention, characterized in that: It includes the following steps: S100: Select the traffic network topology graph G of region B, and set traffic sensors on each road in G. The installation positions of the traffic sensors are used as data collection nodes. The specific expression of G is as follows: G = (V, E, A) V={v1,v2,…,v n ,…,v N } Among them, \(E\) is the set of edges in \(G\), representing the physical connections between data collection nodes, and \(A\in R\) N×N represents the adjacency matrix of \(G\), \(v\) n represents the \(n\)-th data collection node, \(V\) represents the set of all data collection nodes, and \(N\) represents the total number of data collection nodes; Construct the historical traffic flow sequence of Region B Among them, represents the true traffic flow value of the nth data collection node at each time step t, F represents the number of traffic data feature dimensions, where T represents the time interval and T≥1, t∈[0,T]; S200: Construct the MASTGCN model M, which includes a data conversion layer, a spatio-temporal fusion layer, and a data output layer; The data conversion layer is used to convert the traffic flow sequence into the data format required by M; The spatio-temporal fusion layer sequentially includes two modules M1 and M2. M1 includes three information transfer modules, namely the attention-based spatio-temporal graph convolution module ASTGCN, the self-attention-based spatio-temporal module SASTT, and the long-term spatio-temporal graph convolution module LSTGCN; M2 includes an attention feature fusion module AFF and a cross-attention module Cross-Attention; The data output layer is the fully connected layer in the deep learning model; S300: Combine G and Perform a data fusion operation to obtain a traffic flow fusion feature tensor. The specific steps are as follows: S310: Convert the input data conversion layer, and output traffic flow data tensors after data format conversion; S320: Input G and the traffic flow data tensor into the spatio-temporal fusion layer: Input G and the traffic flow data tensor into ASTGCN in M1, and ASTGCN outputs to obtain the tensor Q; Input the traffic flow data tensor into STSA, and the output of STSA is used as the input of AFF in M2, and AFF outputs to obtain the tensor K; Input the traffic flow data tensor into LSTGCN, and the output of LSTGCN is used as the input of AFF in M2, and AFF outputs to obtain the tensor V; S330: Input Q, K, and V into Cross-Attention, and output to obtain the traffic flow fusion feature tensor; S400: Input the traffic flow fusion feature tensor obtained in S330 into concat, perform operations of splicing and conversion on the traffic flow fusion feature tensor, and output to obtain a new fusion feature tensor; S500: The new fused feature tensor serves as the input to the data output layer, and the predicted traffic flow values of all roads at time step t in Region B are obtained as the output. S600: Use the Adam optimizer to train M, calculate the model loss function L(Θ) and optimize the parameters of M through backpropagation. Stop training when the value of L(Θ) no longer changes to obtain the trained MASTGCN model M'. The expression of the loss function is as follows: where Θ represents learnable parameters; P represents the predicted time step; Y tn represents the true traffic flow value at node n at time step t, and Y tn takes the value of the true traffic flow value of the nth node in represents the traffic flow prediction value of node n at time step t, and takes the value equal to the traffic flow prediction value of the nth node in S700: Input the traffic network topology graph G' of the area Q to be predicted and the historical traffic flow sequence of this area into the trained M' to obtain the predicted value of the future traffic flow in Q 2. The spatio-temporal graph convolutional traffic flow prediction method based on multi-view attention according to claim 1, characterized in that: In S200, ASTGCN includes several serially stacked spatio-temporal blocks STblock, SASTT includes a spatio-temporal attention mechanism and Norm&Dropout, and LSTGCN includes 1 graph convolution network layer, 2 long-order time convolution layers, 2 activation functions, and Norm&Dropout.
3. The spatio-temporal graph convolutional traffic flow prediction method based on multi-view attention according to claim 2, wherein: In S200, ASTGCN is composed of several spatio-temporal blocks STblock. Each STblock includes a spatial attention mechanism SAtt, a temporal attention mechanism TAtt, a convolution network GCN, and a multi-scale convolution network MConv.
4. The spatio-temporal graph convolutional traffic flow prediction method based on multi-view attention according to claim 3, wherein: In S200, AFF is composed of two branches of local attention and global attention; each branch contains a convolution layer, a batch normalization layer, and an activation function.
5. The spatio-temporal graph convolutional traffic flow prediction method based on multi-view attention according to claim 4, characterized in that: In S320, the specific content of the corresponding tensors Q, K, and V output is as follows: Input G and the traffic flow data tensor into ASTGCN, and output the tensor Q. The calculation expression is: Q = Conv 1×1 x cat Among them, Conv 1×1 represents a 1×1 convolution operation, and x cat represents the tensor output after passing through several STblocks; Input the traffic flow data tensor into SASTT, and output the tensor K. The calculation expression is: Q t = X :t: W Q K t = X :t: W K V t = X :t: W V Among them, Q t , K t , V t represent the traffic flow matrix after X :t: linear transformation, is a trainable weight matrix; X :t: represents three consecutive traffic data tensor slices; Taking the traffic flow data tensor as the input of the LSTGCN, the output tensor V is calculated by the following expression: V = Y1 ⊙ σ(Y2) where ⊙ represents the Hadamard product, σ represents the Sigmoid activation function, and Y1 and Y2 represent the output tensors after the traffic flow data tensor is processed by the graph convolutional network layer and the long short-term convolutional layer.
Citation Information
Patent Citations
Traffic flow prediction method based on improved space-time Transform
CN115273464A
Traffic flow prediction method and device
CN116246464A
Multi-scale multi-granularity spatial-temporal traffic volume prediction
US20210064999A1