A spatio-temporal graph convolution traffic flow prediction method based on multi-view attention
By constructing the MASTGCN model and using a multi-view attention mechanism to fuse spatiotemporal features, the problem of existing traffic flow prediction methods failing to fully utilize multi-view information is solved, achieving more efficient and accurate traffic flow prediction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHONGQING UNIV
- Filing Date
- 2025-04-02
- Publication Date
- 2026-04-21
AI Technical Summary
Existing traffic flow prediction methods fail to fully utilize multi-view information, resulting in low prediction accuracy and difficulty in effectively capturing the complex spatiotemporal correlations of traffic data.
A spatiotemporal graph convolutional traffic flow prediction method based on multi-view attention is proposed. By constructing the MASTGCN model, the spatiotemporal features of multiple views are fused using spatiotemporal attention and cross-attention mechanisms, including ASTGCN, STSA and LSTGCN modules, to capture the dynamic spatiotemporal correlation of traffic data and output it through a fully connected layer.
It improves the accuracy and generalization ability of traffic flow prediction, and can better handle high-dimensional dynamic spatiotemporal data, enabling efficient prediction of future traffic conditions.
Smart Images

Figure CN120340248B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of spatiotemporal convolutional traffic flow prediction, and in particular to a spatiotemporal graph convolutional traffic flow prediction method based on multi-view attention. Background Technology
[0002] Over the past few decades, extensive research has been conducted to improve the accuracy of traffic flow prediction. Early methods primarily 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. However, these methods did not consider spatial characteristics and struggled to model nonlinear spatiotemporal data, resulting in often low prediction accuracy. In recent years, with the rapid development of deep learning, deep learning-based models have demonstrated significant advantages in traffic flow prediction. Research has attempted 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 CNNs and Long Short-Term Memory (LSTM) to jointly model spatiotemporal dependencies. Han et al. proposed a framework involving deep clustering methods and convolutional neural networks for short-term traffic prediction of large-scale road networks. Chen et al. proposed a multi-gated spatiotemporal CNN that extracts spatiotemporal features simultaneously from low to high layers for city-wide traffic flow prediction. Pu et al. developed a lightweight traffic flow prediction encoding and decoding framework that improves prediction speed while maintaining accuracy. However, the methods studied above are all based on CNNs, which are only applicable to spatial relationships in Euclidean space represented by two-dimensional matrices or images, and not to non-Euclidean space of traffic road topology.
[0003] Traffic flow prediction, as a crucial component of Intelligent Transportation Systems (ITS), plays an indispensable role in smart city construction. 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 rate, speed, and density, identifying traffic patterns, and predicting road traffic trends. Its goal is to predict future road network traffic conditions based on historical observation data collected by sensors and other devices. Currently, utilizing spatiotemporal data to accurately predict traffic flow has become an important research area in intelligent transportation systems; however, due to the complex nonlinearity and dynamic spatiotemporal dependence of traffic data, accurate traffic flow prediction remains extremely challenging.
[0004] Typically, the spatiotemporal features of traffic flow data can be learned from graph topology, global spatiotemporal domain, and local spatiotemporal domain. Early traffic flow prediction methods were mainly based on statistical learning and machine learning, which only modeled temporal dependencies. This modeling could not effectively capture the spatiotemporal dependencies of nonlinear traffic data. Therefore, to capture the complex spatiotemporal correlations in traffic data, popular deep learning models such as Convolutional Neural Networks (CNNs), Recurrent Neural Networks (RNNs), and Graph Convolutional Networks (GCNs) and their variants have been widely applied to traffic flow prediction tasks and have achieved significant results. In recent years, many works have begun to focus on spatiotemporal graph convolutional models for prediction tasks. However, most existing methods tend to focus on learning from a single or dual perspective, failing to fully utilize multi-view information to fuse features at different scales. This limits the learning of knowledge from multiple spatiotemporal domains, resulting in lower accuracy of the final prediction results. Summary of the Invention
[0005] In view of the above-mentioned problems in the existing technology, the technical problem to be solved by the present invention is: how to improve the accuracy of traffic flow prediction by using a multi-view spatiotemporal framework.
[0006] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:
[0007] A spatiotemporal graph convolutional traffic flow prediction method based on multi-view attention includes the following steps:
[0008] S100: Select the traffic network topology map G of region B, and set up traffic sensors on each road in G. The locations of the traffic sensors are used as data collection nodes. The specific expression of G is as follows:
[0009]
[0010]
[0011] Here, E is the set of edges in G, representing the physical connections between data collection nodes. Let G be the adjacency matrix. Let V represent the nth data collection node, V represent the set of all data collection nodes, and N represent the total number of data collection nodes; the adjacency matrix refers to... Let A be the adjacency matrix of graph G, representing the connection relationships between data collection nodes. In GCN, an element of adjacency matrix A is 1 to indicate a connection between two data collection nodes, and 0 to indicate no connection. However, in reality, connection information refers to the distance between the actual road nodes corresponding to the data collection nodes. Therefore, a Gaussian kernel function is usually chosen to define the adjacency matrix based on the actual road network. :
[0012]
[0013] in, Represents a node and nodes The connection weights; Indicates the road network distance between nodes; This represents the threshold.
[0014] Constructing historical traffic flow sequences for region B ,in, This represents the actual traffic flow value of the nth data collection node at each time step t. F represents the number of traffic data feature dimensions, such as flow rate, speed, and occupancy rate; where T represents the time interval and T≥1. ;
[0015] S200: Construct the MASTGCN model M, which includes a data transformation layer, a spatiotemporal fusion layer, and a data output layer;
[0016] The data conversion layer is used to convert traffic flow sequences into the data format required by M;
[0017] The main function of the data transformation layer is to transform 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 certain ratio, it can also be processed through the data transformation layer.
[0018] The spatiotemporal fusion layer consists of two modules. and , It includes three information delivery modules: attention-based spatiotemporal graph convolution module ASTGCN, self-attention-based spatiotemporal module STSA, and long-term spatiotemporal graph convolution module LSTGCN.
[0019] It includes an attention feature fusion module (AFF) and a cross-attention module (Cross-Attention);
[0020] ASTGCN utilizes spatiotemporal attention and spatiotemporal convolution mechanisms to capture dynamic spatiotemporal correlations, while STSA and LSTGCN focus on extracting spatiotemporal information at both local and global scales. The spatiotemporal fusion module is used to fuse spatiotemporal features extracted from multiple perspectives.
[0021] Both AFF and Cross-Attention are existing technologies. The AFF module is used to effectively fuse local and global features, enhancing the model's comprehensive spatiotemporal feature representation ability. It dynamically adjusts the importance of local and global features, achieving adaptive feature fusion to improve the model's generalization ability and robustness across different spatial scales. Because real-world traffic networks exhibit complex spatial and temporal correlations, the Cross-Attention module fuses the AFF results with the output tensor of the spatiotemporal graph convolution module. By calculating the correlations between different features and dynamically adjusting the importance weights of features, the Cross-Attention module captures key features. Through this mechanism, the model can dynamically capture complex dependencies between different features, thereby enhancing feature representation capabilities.
[0022] The data output layer is a fully connected layer in the deep learning model; the fully connected layer in the deep learning model is a current technology.
[0023] S300: G and The traffic flow fusion feature tensor is obtained by performing data fusion operations. The specific steps are as follows:
[0024] S310: Will Input data transformation layer, After data format conversion, the output is a traffic flow data tensor;
[0025] S320: Input the G and traffic flow data tensors together into the spatiotemporal fusion layer:
[0026] Input both G and the traffic flow data tensor. In the ASTGCN, the output of ASTGCN is the tensor Q;
[0027] Input the traffic flow data tensor into STSA, and use the output of STSA as... The input to the AFF is the tensor K, and the output of the AFF is the tensor K.
[0028] Input the traffic flow data tensor into LSTGCN, and use the output of LSTGCN as... The input to the AFF is the tensor V, and the output of the AFF is the tensor V.
[0029] S330: Using Q, K, and V as inputs to Cross-Attention, the output is the traffic flow fusion feature tensor;
[0030] S400: Input the traffic flow fusion feature tensor obtained from S330 into concat, perform traffic flow fusion feature tensor splicing and transformation operations, and output a new fusion feature tensor; concat means splicing in the channel dimension, which is an existing technology.
[0031] S500: The newly fused feature tensor serves as the input to the data output layer, and the output yields the traffic flow prediction values for all roads in region B at time step t. ;
[0032] S600: Train M using the Adam optimizer and calculate the model loss function. And optimize the M parameters through backpropagation, when Training stops when the value no longer changes, resulting in the trained MASTGCN model M'. The loss function expression is as follows:
[0033]
[0034] in, Indicates learnable parameters; Indicates the time step of the forecast; Indicates time step Time node The actual traffic flow value at the location, The value is The actual traffic flow value of the nth node; Indicates time step The predicted traffic flow at time node n The value of is equal to Traffic flow prediction value for the nth node;
[0035] During training, all learning models were trained for 100 epochs with a batch size of 32 and a learning rate of 0.001. The graph convolution kernel size and temporal convolution kernel size of G were both set to 3. During the training of the traffic flow prediction model, the mean squared error (MSE) was used to construct the loss function to measure the deviation between the model's predicted traffic flow and the actual observed data. The model parameters were optimized through backpropagation. Training was completed when the loss value reached its minimum or stopped changing. This approach allows the prediction results to be closer to the actual values.
[0036] S700: The traffic network topology map G' of the region Q to be predicted and the historical traffic flow sequence of the region. Input the trained M' to obtain the predicted future traffic flow value for Q. .
[0037] Preferably, in S200, ASTGCN includes several cascaded stacked spatiotemporal blocks (STblocks), STSA includes a spatiotemporal attention mechanism and Norm & Dropout, and LSTGCN includes one graph convolutional network layer, two long-order temporal convolutional layers, two activation functions, and Norm & Dropout. Norm & Dropout represents a normalization and overfitting data processing method, which is existing technology; the graph convolutional network layer and the temporal convolutional neural network layer are also existing technologies.
[0038] Preferably, in S200, the ASTGCN consists of several spatiotemporal blocks (STblocks). 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 spatiotemporal graph convolutional module effectively captures the dynamic spatiotemporal features of traffic data through spatiotemporal attention blocks and spatiotemporal convolutional blocks, enhancing the network's expressive power. By stacking multiple spatiotemporal attention convolutional blocks (STblocks), a wider range of dynamic spatiotemporal correlations can be captured, thereby improving the accuracy of future traffic flow prediction. The model uses spatiotemporal attention mechanisms to capture the dynamic spatiotemporal correlations between traffic network nodes, and the convolutional network effectively extracts spatiotemporal features from traffic flow data. SAtt, TAtt, GCN, and MConv are all existing technologies.
[0039] Preferably, in S200, AFF consists of two branches: local attention and global attention; each branch includes a convolutional layer, a batch normalization layer, and an activation function.
[0040] Local attention and global attention are used to capture the correlation between local features and between global features, respectively. The outputs of these two attentions are then processed by the Sigmoid function to generate fusion weights, which are then normalized and activated by ReLU to generate fusion features. These fusion features are then used as cross-attention input vectors K and V and fused with the output Q of ASTGCN.
[0041] Preferably, in step S320, the specific contents of the corresponding tensors Q, K, and V output are as follows:
[0042] Using G and the traffic flow data tensor as inputs to ASTGCN, the output tensor Q is calculated as follows:
[0043]
[0044] in, This represents a 1×1 convolution operation. This represents the feature tensor output after passing through several ST blocks;
[0045] Using the traffic flow data tensor as input to STSA, the output tensor K is calculated as follows:
[0046]
[0047]
[0048]
[0049]
[0050] in, , , express Traffic flow matrix after linear transformation , , It is a trainable weight matrix; Represents a slice of three consecutive traffic data tensors;
[0051] Using the traffic flow data tensor as input to LSTGCN, the output tensor V is calculated as follows:
[0052]
[0053] Where ⨀ represents the Hadamard product, This represents the Sigmoid activation function. , This represents the output feature tensor after the traffic flow data tensor has been processed by a graph convolutional network layer and a long-sequence temporal convolutional layer. The graph convolutional network layer and the long-sequence temporal convolutional layer are existing technologies.
[0054] Compared with the prior art, the present invention has at least the following advantages:
[0055] 1. This invention designs a multi-view spatiotemporal prediction framework. The framework includes a unified spatiotemporal data input layer, spatiotemporal blocks, and an output prediction layer. Each spatiotemporal block contains three information propagation modules for capturing spatiotemporal correlations in different views, and an attention-based spatiotemporal feature fusion module. Dynamic spatiotemporal correlations are effectively extracted from multiple views, such as graph structures, local spatiotemporal correlations, and global spatiotemporal correlations. These correlations are deeply fused through the spatiotemporal feature fusion module. The MASTGCN framework consists of an input layer, two stacked spatiotemporal blocks, and an output layer. The overall framework adopts an end-to-end approach to implement traffic flow prediction tasks, efficiently processing high-dimensional dynamic spatiotemporal data and predicting future traffic conditions. The training process is fast, and the prediction accuracy is high.
[0056] 2. This framework uses a spatiotemporal attention mechanism to learn the dynamic spatiotemporal correlations of traffic data (spatial attention learns the dynamic correlations between nodes, and temporal attention learns the dynamic correlations between time steps). It utilizes graph convolution to capture spatial features and convolutional methods to extract temporal dependencies. Spatiotemporal correlations are extracted from multiple perspectives: a module based on a self-attention mechanism captures local spatiotemporal dependencies in traffic data, while a module based on a graph convolutional network (GCN) and long-term temporal modeling captures global spatiotemporal correlations in traffic data.
[0057] 3. The feature fusion module includes two different attention mechanisms. The attention feature fusion module (AFF) is used to integrate local and global features, and the cross-attention mechanism further fuses the feature tensor fused by AFF with the features output by ASTGCN.
[0058] 4. Extensive experiments were conducted on real traffic datasets to evaluate the model of this invention. Experimental results show that the MASTGCN model has the best prediction performance compared with existing baseline methods. Attached Figure Description
[0059] Figure 1 This is a basic framework diagram of the MASTGCN model of this invention.
[0060] Figure 2 The prediction results of West_flow by different methods (left); the visualization results of the traffic prediction of a random node in West_flow (right).
[0061] Figure 3 Rank the prediction results of road network nodes in a certain region.
[0062] Figure 4 This is a map showing the distribution of sensors in the road network surrounding a certain area.
[0063] Figure 5 The data results are from ablation experiments performed on datasets PeMS08 and PeMS04.
[0064] Figure 6 The performance metrics of the MASTGCN model were compared with those of other models at 15 min, 30 min, and 60 min. Detailed Implementation
[0065] The present invention will now be described in further detail.
[0066] See Figures 1-6 A spatiotemporal graph convolutional traffic flow prediction method based on multi-view attention includes the following steps:
[0067] S100: Select the traffic network topology map G of region B, and set up traffic sensors on each road in G. The locations of the traffic sensors are used as data collection nodes. The specific expression of G is as follows:
[0068]
[0069]
[0070] Here, E is the set of edges in G, representing the physical connections between data collection nodes. Let G be the adjacency matrix. Let V represent the nth data collection node, V represent the set of all data collection nodes, and N represent the total number of data collection nodes.
[0071] Constructing historical traffic flow sequences for region B ,in, This represents the actual traffic flow value of the nth data collection node at each time step t. F represents the number of feature dimensions of the traffic data, where T represents the time interval and T≥1. ;
[0072] S200: Construct the MASTGCN model M, which includes a data transformation layer, a spatiotemporal fusion layer, and a data output layer;
[0073] The data conversion layer is used to convert traffic flow sequences into the data format required by M;
[0074] The spatiotemporal fusion layer consists of two modules. and , It includes three information delivery modules: attention-based spatiotemporal graph convolution module ASTGCN, self-attention-based spatiotemporal module STSA, and long-term spatiotemporal graph convolution module LSTGCN.
[0075] It includes an attention feature fusion module (AFF) and a cross-attention module (Cross-Attention);
[0076] The data output layer is a fully connected layer in a deep learning model;
[0077] In S200, ASTGCN includes several spatiotemporal blocks STblocks stacked in series, STSA includes a spatiotemporal attention mechanism and Norm & Dropout, and LSTGCN includes one graph convolutional network layer, two long-order temporal convolutional layers, two activation functions, and Norm & Dropout.
[0078] In S200, ASTGCN consists of several spatiotemporal 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 S200, 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: G and The traffic flow fusion feature tensor is obtained by performing data fusion operations. The specific steps are as follows:
[0081] S310: Will Input data transformation layer, After data format conversion, the output is a traffic flow data tensor;
[0082] S320: Input the G and traffic flow data tensors together into the spatiotemporal fusion layer:
[0083] Input both G and the traffic flow data tensor. In the ASTGCN, the output of ASTGCN is the tensor Q;
[0084] Input the traffic flow data tensor into STSA, and use the output of STSA as... The input to the AFF is the tensor K, and the output of the AFF is the tensor K.
[0085] Input the traffic flow data tensor into LSTGCN, and use the output of LSTGCN as... The input to the AFF is the tensor V, and the output of the AFF is the tensor V.
[0086] In step S320, the specific contents of the corresponding tensors Q, K, and V are output as follows:
[0087] Using G and the traffic flow data tensor as inputs to ASTGCN, the output tensor Q is calculated as follows:
[0088]
[0089] in, This represents a 1×1 convolution operation. This represents the tensor output after passing through several STblocks;
[0090] Using the traffic flow data tensor as input to STSA, the output tensor K is calculated as follows:
[0091]
[0092]
[0093]
[0094]
[0095] in, , , express Traffic flow matrix after linear transformation , , It is a trainable weight matrix; Represents a slice of three consecutive traffic data tensors;
[0096] Using the traffic flow data tensor as input to LSTGCN, the output tensor V is calculated as follows:
[0097]
[0098] Where ⨀ represents the Hadamard product, This represents the Sigmoid activation function. , This represents the output feature tensor after the traffic flow data tensor has been processed by a graph convolutional network layer and a long-sequence temporal convolutional layer.
[0099] S330: Using Q, K, and V as inputs to Cross-Attention, the output is the traffic flow fusion feature tensor;
[0100] S400: Input the traffic flow fusion feature tensor obtained in S330 into concat, perform traffic flow fusion feature tensor splicing and transformation operations, and output a new fusion feature tensor;
[0101] S500: The newly fused feature tensor serves as the input to the data output layer, and the output yields the traffic flow prediction values for all roads in region B at time step t. ;
[0102] S600: Train M using the Adam optimizer and calculate the model loss function. And optimize the M parameters through backpropagation, when Training stops when the value no longer changes, resulting in the trained MASTGCN model M'. The loss function expression is as follows:
[0103]
[0104] in, Indicates learnable parameters; Indicates the time step of the forecast; Indicates time step Time node The actual traffic flow value at the location, The value is The actual traffic flow value of the nth node; Indicates time step The predicted traffic flow at time node n The value of is equal to Traffic flow prediction value for the nth node;
[0105] S700: The traffic network topology map G' of the region Q to be predicted and the historical traffic flow sequence of the region. Input the trained M' to obtain the predicted future traffic flow value for Q. .
[0106] Experiments and Results
[0107] This invention uses three real-world datasets to evaluate the performance of the proposed traffic flow prediction model. Furthermore, ablation experiments were conducted to assess the effectiveness of the design modules. Finally, visualizations of the prediction results are provided.
[0108] 1. Introduction to the dataset
[0109] Basic statistical information of the datasets is shown in Table 1. The PeMS04 and PeMS08 datasets originate from California and are collected in real-time every 30 seconds by the California Department of Transportation Performance Measurement System (PeMS). These datasets differ in time, location, and size, and are aggregated every 5 minutes. The private dataset West_flow was provided by a local transportation department and has been processed to match the PeMS dataset format. Data collection points for the region are shown below. Figure 3 and Figure 4 As shown.
[0110] Table 1: Dataset Details
[0111]
[0112] 2. Experimental Setup
[0113] 2.1 Benchmark Method
[0114] The traffic flow prediction model of this invention is compared with the following ten state-of-the-art baseline methods.
[0115] HA: Historical average is a traditional statistical method that uses the mean of historical data to make predictions.
[0116] ARIMA: Autoregressive Integral Moving Average model is a forecasting method widely used in time series analysis.
[0117] VAR: Vector Autoregression is a classic time series model that can extract pairwise correlations in traffic flow.
[0118] LSTM: Long Short-Term Memory network is used to capture and model long-term temporal dependencies.
[0119] DCRNN: Diffusion Convolutional Recurrent Neural Network models directed graphs by utilizing the diffusion process in conjunction with spatial and temporal dependencies.
[0120] STGCN: Spatiotemporal Graph Convolutional Network captures spatiotemporal dependencies through graph convolution and gated causal convolution.
[0121] Graph WaveNet: Graph WaveNet uses an adaptive adjacency matrix for spatiotemporal graph modeling.
[0122] STSGCN: Spatiotemporal Synchronous Graph Convolutional Network can capture spatiotemporal relationships simultaneously.
[0123] ASTGCN: Attention-based Spatiotemporal Graph Convolutional Network combines attention mechanisms with graph convolution to model dynamic spatiotemporal relationships.
[0124] STFGNN: Spatiotemporal fusion graph neural network generates time graphs and studies the fusion process to capture potential spatiotemporal correlations.
[0125] The model in this invention is implemented using the PyTorch framework: each dataset is divided into training, testing, and validation sets in a 6:2:2 ratio. The model is trained using the Adam optimizer, with all learned models trained for 100 epochs, a batch size of 32, and a learning rate of 0.001. The graph convolution kernel size and temporal convolution kernel size are both set to 3. Each sensor node aggregates traffic flow data every 5 minutes, using a 1-hour historical time window, and predicts the traffic conditions for the next hour based on 12 observation data points within the window. Comparative experiments were conducted on a Windows server with the following configuration: Intel(R) Core(TM) i7-12700 @2.10 GHz processor, 32GB of RAM, and an NVIDIA GeForce RTX 3060 Ti GPU.
[0126] 2.2 Evaluation Indicators
[0127] Model performance evaluation metrics include Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), and Root Mean Square Error (RMSE). The smaller the values of these three metrics, the more accurate the model's predictions. These three specific evaluation metrics can be expressed as:
[0128] 1) MAE:
[0129]
[0130] 2) RMSE:
[0131]
[0132] 3) MAPE:
[0133]
[0134] in, This refers to the actual traffic flow. It is the predicted traffic flow.
[0135] 3. Experimental Results
[0136] The MASTGCN model was compared with ten baseline methods on PeMS04 and PeMS08. Table 2 shows the average results of traffic flow prediction performance for the next hour, i.e., all experimental results in the table are the average prediction accuracy over 12 time steps.
[0137] Table 2: Comparison of average performance of different methods on PeMS04 and PeMS08
[0138] (Note: The evaluation metric is the average of 12 prediction time steps.)
[0139]
[0140] From Table 2 and Figure 6 As can be seen, MASTGCN exhibits optimal performance across all evaluation metrics in both datasets. Traditional time series analysis methods typically produce poor predictions, indicating their limited ability to model nonlinear and complex traffic data. In contrast, deep learning-based methods generally provide more accurate predictions than traditional time series analysis methods. Models that simultaneously consider temporal and spatial correlations, such as STGCN and STSGCN, outperform traditional deep learning models like LSTM. Furthermore, ASTGCN's superior performance compared to STGCN demonstrates that its attention mechanism effectively captures the dynamic changes in traffic data.
[0141] Table 3: Comparison of average performance of different methods on Westflow
[0142]
[0143] To further evaluate the model's generalization ability, the MASTGCN model was also tested on the private dataset West_flow. This dataset contains traffic flow data for a specific area surrounding a transportation hub in a certain region, exhibiting unique traffic patterns and characteristics. As shown in Table 3, the experimental results demonstrate that, in addition to achieving good performance on the widely used PeMS04 and PeMS08 datasets, the MASTGCN model also demonstrates good predictive ability even on this challenging dataset, proving that the proposed model has good generalization performance. Figure 2 As shown, the model also exhibits good predictive performance on private datasets, with high consistency between the actual and predicted values of sensor nodes throughout the day, demonstrating its ability to capture traffic flow trends. The consistent performance of the model on both public and private datasets indicates that our model is not only suitable for specific scenarios but also has broad application potential.
[0144] 4. Ablation test
[0145] This invention employs a novel spatiotemporal attention mechanism and a spatiotemporal fusion module to capture and fuse spatiotemporal features from different views, addressing the dynamic spatiotemporal dependencies of traffic data. To further evaluate the roles of different components of MASTGCN, we conducted ablation experiments and analyzed the results on the PeMS08 and PeMS04 datasets. We designed three variant versions of MASTGCN, including:
[0146] MASTGCN-noSATtt: The spatiotemporal attention mechanism was removed to verify its effectiveness in learning the dynamic spatiotemporal correlation of traffic data.
[0147] MASTGCN-noSTF: This study replaces the spatiotemporal fusion module with traditional splicing and fusion operations to investigate the effectiveness of comprehensively aggregating spatiotemporal context information from different perspectives.
[0148] MASTGCN-ST: Simultaneously removes the spatiotemporal attention and spatiotemporal convolution modules, leaving only the basic spatiotemporal convolution network module.
[0149] Ablation test results as follows Figure 5 As shown, the complete prediction model performs best in all cases, validating the effectiveness and necessity of each component in the model. The model with the SATtt or STF modules removed exhibits a performance decrease, indicating that these components can capture complex spatiotemporal dynamic features and play a crucial role in improving the model's prediction accuracy. On both datasets, the complete model (MASTGCN) demonstrates consistent performance, indicating its good generalization ability and robustness.
[0150] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A spatiotemporal graph convolutional traffic flow prediction method based on multi-view attention, characterized in that: Includes the following steps: S100: Select the traffic network topology map G of region B, and set up traffic sensors on each road in G. The locations of the traffic sensors are used as data collection nodes. The specific expression of G is as follows: Here, E is the set of edges in G, representing the physical connections between data collection nodes. Let G be the adjacency matrix. Let V represent the nth data collection node, V represent the set of all data collection nodes, and N represent the total number of data collection nodes. Constructing historical traffic flow sequences for region B ,in, This represents the actual traffic flow value of the nth data collection node at each time step t. F represents the number of feature dimensions of the traffic data, where T represents the time interval and T≥1. ; S200: Construct the MASTGCN model M, which includes a data transformation layer, a spatiotemporal fusion layer, and a data output layer; The data conversion layer is used to convert traffic flow sequences into the data format required by M; The spatiotemporal fusion layer consists of two modules. and , It includes three information delivery modules: attention-based spatiotemporal graph convolution module ASTGCN, self-attention-based spatiotemporal module STSA, and long-term spatiotemporal graph convolution module LSTGCN. It includes an attention feature fusion module (AFF) and a cross-attention module (Cross-Attention); The data output layer is a fully connected layer in a deep learning model; In S200, ASTGCN includes several spatiotemporal blocks STblocks stacked in series, STSA includes a spatiotemporal attention mechanism and Norm & Dropout, and LSTGCN includes one graph convolutional network layer, two long-order temporal convolutional layers, two activation functions and Norm & Dropout. S300: G and The traffic flow fusion feature tensor is obtained by performing data fusion operations. The specific steps are as follows: S310: Will Input data transformation layer, After data format conversion, the output is a traffic flow data tensor; S320: Input the G and traffic flow data tensors together into the spatiotemporal fusion layer: Input both G and the traffic flow data tensor. In the ASTGCN, the output of ASTGCN is the tensor Q; Input the traffic flow data tensor into STSA, and use the output of STSA as... The input to the AFF is the tensor K, and the output of the AFF is the tensor K. Input the traffic flow data tensor into LSTGCN, and use the output of LSTGCN as... The input to the AFF is the tensor V, and the output of the AFF is the tensor V. In step S320, the specific contents of the corresponding tensors Q, K, and V are output as follows: in, This represents a 1×1 convolution operation. This represents the tensor output after several STblocks are stacked in series. in, , , express Traffic flow matrix after linear transformation , , It is a trainable weight matrix; Represents a slice of three consecutive traffic data tensors; Where ⨀ represents the Hadamard product, This represents the Sigmoid activation function. , This represents the output tensor of the traffic flow data tensor after processing through a graph convolutional network layer and a long-sequence temporal convolutional layer. S330: Using Q, K, and V as inputs to Cross-Attention, the output is the traffic flow fusion feature tensor; S400: Input the traffic flow fusion feature tensor obtained in S330 into concat, perform traffic flow fusion feature tensor splicing and transformation operations, and output a new fusion feature tensor; S500: The newly fused feature tensor serves as the input to the data output layer, and the output yields the traffic flow prediction values for all roads in region B at time step t. ; S600: Train M using the Adam optimizer and calculate the model loss function. And optimize the M parameters through backpropagation, when Training stops when the value no longer changes, resulting in the trained MASTGCN model M'. The loss function expression is as follows: in, Indicates learnable parameters; Indicates the time step of the forecast; Indicates time step Time node The actual traffic flow value at the location, The value is The actual traffic flow value of the nth node; Indicates time step The predicted traffic flow at time node n The value of is equal to Traffic flow prediction value for the nth node; S700: The traffic network topology map G' of the region Q to be predicted and the historical traffic flow sequence of the region. Input the trained M' to obtain the predicted future traffic flow value for Q. .
2. The spatiotemporal graph convolutional traffic flow prediction method based on multi-view attention as described in claim 1, characterized in that: In S200, each STblock includes a spatial attention mechanism SAtt, a temporal attention mechanism TAtt, a convolutional network GCN, and a multi-scale convolutional network MConv.
3. The spatiotemporal graph convolutional traffic flow prediction method based on multi-view attention as described in claim 2, characterized in that: In S200, AFF consists of two branches: local attention and global attention; each branch contains a convolutional layer, a batch normalization layer, and an activation function.
Citation Information
Patent Citations
Traffic flow prediction method based on improved space-time Transform
CN115273464A
Traffic flow prediction method and device
CN116246464A