Short-term traffic congestion prediction method based on CATST network
By constructing the CATST network and combining the spatiotemporal attention module and the convolutional attention Transformer module, the problem of insufficient time and space dependence of the existing model in processing traffic data is solved, and the accuracy of traffic congestion prediction is significantly improved.
Patent Information
- Application Number
- CN202411255469.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-10-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing traffic prediction models have shortcomings in processing time and space dependent data, especially convolutional neural networks that lack time dependence. LSTM is mainly designed to capture time dependence and is not good at spatial feature extraction. Transformer is good at processing spatial information. It is relatively weak and prone to overfitting.
A short-term traffic congestion prediction method based on the CATST network is proposed. By constructing a network containing a spatiotemporal attention module and a convolutional attention Transformer spatiotemporal module, combined with spatial and temporal feature extraction, the mean square error and the average absolute percentage error are used as evaluation Indicators enhance the model’s ability to process traffic data.
The CATST network improves the accuracy of traffic congestion prediction without significantly increasing the model complexity, and can capture temporal and spatial dependencies more effectively, significantly better than CNN, GMAN, STGCN and ConvLSTM models.
Smart Images

Figure CN118762528A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of traffic prediction, and in particular to a short-term traffic congestion prediction method based on a CATST network. Background Art
[0002] Short-term traffic congestion prediction refers to using the current traffic data to make real-time predictions of traffic conditions at the next moment. Many scholars at home and abroad have been committed to the research in the field of traffic prediction, such as spectral analysis in statistics and K-neighbor algorithm based on machine learning. Although the use of these methods to predict traffic flow has improved the accuracy of short-term traffic predictions to a certain extent, it is not enough to cope with the current complex traffic congestion scenarios. In recent years, with the development of deep learning, models such as RNN and LSTM have been applied to the prediction of short-term traffic, greatly improving its prediction effect.
[0003] Although convolutional neural networks (CNNs) excel in spatially correlated data such as image processing and computer vision, they lack the temporal dependencies required when processing time series data. For time series data, CNNs have no built-in memory capabilities and ignore global temporal dependencies, while short-term predictions usually require a good understanding of such temporal dependencies.
[0004] Long short-term memory network (LSTM) improves the long-term dependency information problem of traditional RNN model. However, traffic data not only has time dependency, but also has significant spatial dependency (i.e., the mutual influence between different roads and regions). LSTM is mainly designed to capture time dependency, but is not good at processing spatial dependency. Therefore, LSTM has the problem of insufficient spatial feature extraction when processing traffic flow data with multiple dimensions of time and space.
[0005] Although the Transformer's self-attention mechanism can capture long-range dependencies, it is relatively weak in processing spatial information, and often suffers from overfitting or gradient vanishing problems in long-sequence spatiotemporal prediction tasks, making it impossible for the model to effectively learn the true long-term dependency features. Although the Transformer can process sequence data, it does not directly use the temporal structure of the sequence, but explicitly introduces position encoding to identify the time step, so it is insufficient in modeling complex temporal dependencies. Summary of the invention
[0006] Purpose of the invention: The purpose of the present invention is to provide a short-term traffic congestion prediction method based on a CATST network to solve the problems existing in the background technology.
[0007] Technical solution: The short-term traffic congestion prediction method based on the CATST network described in the present invention comprises the following steps: (1) Obtain real-time traffic maps from open source website maps and perform preprocessing; (2) Construct a convolutional attention transformer spatiotemporal network, namely CATST network, and input the preprocessed data for training; the CATST network includes: 2 spatiotemporal attention modules, 2 convolutional attention transformer spatiotemporal modules, 2 batch normalization layers and 3D convolution layers; (3) Use mean square error and mean absolute percentage error as evaluation indicators to evaluate the accuracy of CATST network in traffic congestion prediction.
[0008] Furthermore, step (1) is specifically as follows: the real-time traffic condition map of the map is spliced, cut and processed to obtain the original data, and the preprocessed data set is obtained after removing redundant information through a mask layer. The data set is a picture with three RGB channels and an image resolution of 512*512.
[0009] Furthermore, in step (2), the spatiotemporal attention module is used for feature extraction in the spatial dimension, which consists of a maximum pooling layer, an average pooling layer, a convolutional layer, and a sigmoid activation function; specifically, as follows: First, the traffic congestion prediction problem is regarded as a prediction problem of spatiotemporal series, and the formula is as follows: ; in, represents the actual value at time t, Indicates the predicted value at time t; J indicates the size setting value of the historical time window; K indicates the time step to be predicted, that is, the traffic information of the next K time steps is predicted based on the traffic data information of the previous J time windows; argmax indicates obtaining the maximum value of the sequence; In the spatial dimension, the channel information of the feature map is aggregated through the maximum pooling layer and the average pooling layer to obtain two 1*H*W feature maps. The formula is as follows: ; ; in, represents the maximum pooling layer, represents the average pooling layer, MaxPool represents the maximum pooling operation, and F represents the channel information of the feature map; Secondly, the pooling results are spliced in the spatial dimension, and the spliced information is convolved to extract features, and converted into a feature map with a channel number of 1 through a 7*7 convolution operation. Finally, the generated spatial attention feature is obtained through the sigmoid function and multiplied with the input feature map to obtain a feature map with spatial attention; the calculation formula is: ; in, Represents a convolution operation with a convolution kernel of 7*7. represents the sigmoid activation function, represents the maximum pooling layer, represents the average pooling layer, Represents a feature map with spatial attention.
[0010] Furthermore, in step (2), the convolutional attention Transformer spatiotemporal module, i.e., the LSFormer module, is used for temporal feature extraction, as follows: each layer of the LSFormer module uses 40 3x3 convolution kernels, and the optimizer uses Adam. At the same time, a batch normalization layer is introduced in each LSFormer module to extract representative spatial and temporal information.
[0011] Furthermore, in step (2), three 3*3 convolution kernels are used to output the RGB three-layer channels of the image; specifically, RELU is used as the activation function and AdaDelta is used as the optimizer; the input of the model is the traffic data information of the previous eight minutes, and the output is the road congestion prediction of the next eight minutes.
[0012] Beneficial effects: Compared with the prior art, the present invention has the following significant advantages: Use of spatial attention mechanism. While taking into account the advantages of LSTM and Transformer, the CATST network enhances the extraction and processing capabilities of LSTM and Transformer for spatial image information to a certain extent by adding convolution operations; at the same time, the introduction of the attention mechanism is more advantageous in processing data with both temporal correlation and spatial correlation, making the model more sensitive to data changes in spatial and temporal dimensions. The CATST network can improve the predictive ability of the model without significantly increasing the complexity of the model. It is not only suitable for the spatial structure of traffic data sets, but also has the ability to predict the future state of the point based on the state and past state of the input data. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 is a schematic diagram of the present invention; Figure 2 Schematic diagram of the convolutional attention Transformer spatiotemporal module of the present invention. DETAILED DESCRIPTION
[0014] The technical solution of the present invention is further described below in conjunction with the accompanying drawings.
[0015] like Figure 1As shown, the embodiment of the present invention provides a short-term traffic congestion prediction method based on a CATST network, comprising the following steps: (1) Obtain a real-time traffic map from an open source website map and perform preprocessing; Step (1) is as follows: splice, cut and process the real-time traffic map to obtain the original data, and remove redundant information through a mask layer to obtain a preprocessed data set, which is a picture with three RGB channels and a resolution of 512 * 512.
[0016] (2) Construct a convolutional attention transformer spatiotemporal network, namely CATST network, and input the preprocessed data for training; the CATST network includes: 2 spatiotemporal attention modules, 2 convolutional attention transformer spatiotemporal modules, 2 batch normalization layers and 3D convolution layers; Among them, the spatiotemporal attention module is used for feature extraction in the spatial dimension, which consists of a maximum pooling layer, an average pooling layer, a convolutional layer, and a sigmoid activation function; the details are as follows: First, the traffic congestion prediction problem is regarded as a prediction problem of spatiotemporal series, and the formula is as follows: ; in, represents the actual value at time t, Indicates the predicted value at time t; J indicates the size setting value of the historical time window; K indicates the time step to be predicted, that is, the traffic information of the next K time steps is predicted based on the traffic data information of the previous J time windows; argmax indicates obtaining the maximum value of the sequence; In the spatial dimension, the channel information of the feature map is aggregated through the maximum pooling layer and the average pooling layer to obtain two 1*H*W feature maps. The formula is as follows: ; ; in, represents the maximum pooling layer, represents the average pooling layer, MaxPool represents the maximum pooling operation, and F represents the channel information of the feature map; Secondly, the pooling results are spliced in the spatial dimension, and the spliced information is convolved to extract features, and converted into a feature map with a channel number of 1 through a 7*7 convolution operation. Finally, the generated spatial attention feature is obtained through the sigmoid function and multiplied with the input feature map to obtain a feature map with spatial attention; the calculation formula is: ; in, Represents a convolution operation with a convolution kernel of 7*7. represents the sigmoid activation function, represents the maximum pooling layer, represents the average pooling layer, Represents a feature map with spatial attention.
[0017] The convolutional attention Transformer spatiotemporal module, i.e., the LSFormer module, is used for temporal feature extraction, such as Figure 2 As shown in the figure, the details are as follows: Each layer of LSFormer module uses 40 3x3 convolution kernels, and the optimizer uses Adam. At the same time, a batch normalization layer is introduced in each LSFormer module to extract representative spatial and temporal information. The formula is as follows: ; ; ; ; ; in, represents the input gate; represents the forget gate; represents the output gate; Indicates the state at this moment; Indicates the state at the previous moment; Indicates the status of the output; represents the weight value; b represents the bias coefficient; Represents the sigmoid activation function; Represents the added convolution operation.
[0018] Three 3*3 convolution kernels are used to output the RGB three-layer channels of the image; the details are as follows: RELU is used as the activation function and AdaDelta is used as the optimizer; the input of the model is the traffic data information of the previous eight minutes, and the output is the road congestion prediction of the next eight minutes.
[0019] (3) Use mean square error and mean absolute percentage error as evaluation indicators to evaluate the accuracy of CATST network in traffic congestion prediction.
[0020] The deep network model based on the CATST network proposed in the present invention is used to predict traffic conditions, and the results are compared with the prediction results of the four networks of CNN, GMAN, STGCN, and ConvLSTM. Table 1 is a comparison of the MSE results of the CNN, GMAN, STGCN, ConvLSTM and CATST network models. As can be seen from Table 1, whether it is the MSE of a single test set or the mean and variance of the MSE, the performance of the model based on the CATST network is better than that of CNN, GMAN, STGCN and ConvLSTM. Therefore, it can be preliminarily concluded that the CATST network improves the accuracy of traffic congestion prediction compared with CNN, GMAN, STGCN and ConvLSTM.
[0021] In order to further evaluate the prediction accuracy of the model, the MAPE (Mean Absolute Percentage Error) predicted by the CATST network is compared with CNN, GMAN, STGCN, and ConvLSTM. It can be seen from Table 2 that the predicted MAPE indicators based on the CATST network are better than those of CNN, GMAN, STGCN, and ConvLSTM. This shows that the model proposed in this patent not only has the performance of spatiotemporal fusion, but also enhances the model's attention to congestion information without significantly increasing the time complexity. Table 2 shows the overall performance comparison of the MAPE of the five models. Whether it is the average value of MAPE or the variance of MAPE, the results of the CATST network are better than those of CNN, GMAN, STGCN, and ConvLSTM. The present invention is compared with the other four models, as shown in Tables 1 and 2.
[0022] Table 1 MSE comparison of CNN, GMAN, STGCN, ConvLSTM and CATST ; Table 2 Overall MAPE performance of CNN, GMAN, STGCN, ConvLSTM and CATST .
Claims
1. A short-term traffic congestion prediction method based on CATST network, characterized in that: The following steps are involved: (1) Obtain real-time traffic maps from open source website maps and perform preprocessing; (2) Construct a convolutional attention transformer spatiotemporal network, namely CATST network, and input the preprocessed data for training; the CATST network includes: 2 spatiotemporal attention modules, 2 convolutional attention transformer spatiotemporal modules, 2 batch normalization layers and 3D convolution layers; (3) Use mean square error and mean absolute percentage error as evaluation indicators to evaluate the accuracy of CATST network in traffic congestion prediction.
2. A short-term traffic congestion prediction method based on CATST network according to claim 1, characterized in that: Step (1) is as follows: the real-time traffic map is spliced, cut and processed to obtain the original data, and the preprocessed data set is obtained by removing redundant information through a mask layer. The data set is a picture with three RGB channels and an image resolution of 512*512.
3. A short-term traffic congestion prediction method based on CATST network according to claim 1, characterized in that: In step (2), the spatiotemporal attention module is used for feature extraction in the spatial dimension and consists of a maximum pooling layer, an average pooling layer, a convolutional layer, and a sigmoid activation function; the details are as follows: First, the traffic congestion prediction problem is regarded as a prediction problem of spatiotemporal series, and the formula is as follows: ; in, represents the actual value at time t, Indicates the predicted value at time t; J indicates the size setting value of the historical time window; K indicates the time step to be predicted, that is, the traffic information of the next K time steps is predicted based on the traffic data information of the previous J time windows; argmax indicates obtaining the maximum value of the sequence; In the spatial dimension, the channel information of the feature map is aggregated through the maximum pooling layer and the average pooling layer to obtain two 1*H*W feature maps. The formula is as follows: ; ; in, represents the maximum pooling layer, represents the average pooling layer, MaxPool represents the maximum pooling operation, and F represents the channel information of the feature map; Secondly, the pooling results are spliced in the spatial dimension, and the spliced information is convolved to extract features, and converted into a feature map with a channel number of 1 through a 7*7 convolution operation. Finally, the generated spatial attention feature is obtained through the sigmoid function and multiplied with the input feature map to obtain a feature map with spatial attention; the calculation formula is: ; in, Represents a convolution operation with a convolution kernel of 7*7. represents the sigmoid activation function, represents the maximum pooling layer, represents the average pooling layer, Represents a feature map with spatial attention.
4. A short-term traffic congestion prediction method based on CATST network according to claim 1, characterized in that: In step (2), the convolutional attention Transformer spatiotemporal module, i.e., the LSFormer module, is used for temporal feature extraction, as follows: each layer of the LSFormer module uses 40 3x3 convolution kernels, and the optimizer uses Adam. At the same time, a batch normalization layer is introduced in each LSFormer module to extract representative spatial and temporal information.
5. The method for predicting short-term traffic congestion based on CATST network according to claim 1, characterized in that: In step (2), three 3*3 convolution kernels are used to output the RGB three-layer channels of the image; specifically, RELU is used as the activation function and AdaDelta is used as the optimizer; the input of the model is the traffic data information of the previous eight minutes, and the output is the road congestion prediction of the next eight minutes.
Citation Information
Patent Citations
Rolling bearing fault diagnosis method
CN118133132A
Quantitative rainfall estimation method based on three-dimensional radar reflectivity data
CN118311520A
