Space-time convolution traffic flow prediction method and system based on R-C-R structure
The spatiotemporal convolutional traffic flow prediction method with RCR structure combines GCN and CNN for feature extraction and uses ConvLSTM and ResNet modules to solve the gradient vanishing problem, achieving more accurate traffic flow prediction and solving the problems of insufficient temporal feature extraction and gradient vanishing in existing methods.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHENGZHOU UNIV
- Filing Date
- 2023-07-29
- Publication Date
- 2026-05-12
AI Technical Summary
Existing traffic flow prediction methods suffer from insufficient extraction of time features and the gradient vanishing and gradient exploding problems in RNN networks, which limit the accuracy of traffic flow prediction.
A spatiotemporal convolutional traffic flow prediction method with RCR structure is proposed. It combines GCN and CNN for shallow spatiotemporal feature extraction, uses ConvLSTM and ResNet modules to construct residual structure to enhance network memory capacity and reduce the impact of gradient vanishing, and improves model convergence through spatiotemporal attention mechanism.
It improves the accuracy of traffic flow prediction, can better extract the spatiotemporal features of traffic flow data, solves the problem that the dynamic correlation between time and space is not fully considered in existing methods, and achieves faster model convergence and more accurate prediction results.
Smart Images

Figure CN116959252B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of traffic flow prediction technology, and more specifically to a spatiotemporal convolutional traffic flow prediction method and system based on RCR structure. Background Technology
[0002] Intelligent Traffic Systems (ITS) are comprehensive transportation management systems that effectively integrate advanced information technology, data communication and transmission technology, electronic sensing technology, control technology, and computer technology into the entire ground traffic management system. They function in a wide-ranging, all-encompassing manner, providing real-time, accurate, and efficient services. Traffic flow prediction is a crucial component of ITS, playing a significant role in alleviating traffic congestion, improving road efficiency, planning urban construction, and providing navigation services. Traffic data is a data type influenced by both temporal and spatial factors; considering both simultaneously is more reasonable. Therefore, using recurrent neural networks such as RNNs, LSTMs, and GRUs to extract temporal information while simultaneously using CNNs or GCNs to extract spatial correlations has become the preferred strategy for traffic flow prediction. Consequently, many scholars have used various combinations of CNNs, GCNs, and RNNs to analyze existing traffic flow data to predict traffic flow at the next moment, leading to the development of numerous hybrid neural networks.
[0003] LI M et al. proposed a Spatiotemporal Fusion Graph Neural Network (STFGNN) model, which consists of two sub-modules: a spatiotemporal feature extraction module based on graph convolution and gated recurrent units (GRUs), and a spatiotemporal feature fusion module based on multi-head self-attention and fully connected layers. T. Qi et al. proposed a novel deep learning-based Asynchronous Dilated Graph Convolutional Network (ADGCN) to model spatial-temporal graphs, mining asynchronous spatial-temporal correlations in traffic networks, and proposed the Asynchronous Spatial-Temporal Graph Convolution (ASTGC) operation to extract these special relationships. Z. LI et al. proposed a hybrid deep neural network based on Graph Convolutional Neural Network (GCN) and Long Short-Term Memory (LSTM), which consists of two sub-networks: a spatial feature extraction sub-network based on GCN and a temporal feature extraction sub-network based on LSTM. All of the above methods are hybrid neural networks constructed by combining multiple neural networks, and all of these methods have achieved good results on specific datasets.
[0004] However, current methods also have shortcomings. For example, the ASTGCN method in existing technologies does not fully extract the characteristics of the time dimension. Existing technologies all use RNN series networks to capture time features, but the problems of RNN networks are also obvious. Gradient vanishing and gradient exploding limit the network's ability to achieve better traffic flow prediction results.
[0005] Therefore, how to provide a spatiotemporal convolutional traffic flow prediction method and system based on RCR structure, extract the spatiotemporal features of shallow and deep traffic flow data, reduce the limitations of gradient vanishing on network functions, and improve the accuracy of traffic flow prediction is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0006] In view of this, the present invention provides a spatiotemporal convolutional traffic flow prediction method and system based on the RCR structure. Addressing the problems of existing methods' insufficient learning of spatiotemporal features of traffic flow, their separation of temporal and spatial features, and their failure to fully consider the dynamic correlation between time and space, the present invention proposes the ASTR-CR model. An attention mechanism is used to accelerate model convergence. A spatiotemporal convolutional module combining GCN and CNN is employed for shallow spatiotemporal feature extraction. A ResNet-ConvLSTM-ResNet (RCR) residual structure, composed of a bilateral ResNet module and a ConvLSTM module, is designed to strengthen the network's memory, reducing the limitations of gradient vanishing on network functionality. This residual structure is then used as a deep spatiotemporal feature extraction layer to further obtain deeper spatiotemporal features, better capturing the temporal-spatial characteristics of traffic flow and improving the accuracy of traffic flow prediction.
[0007] To achieve the above objectives, the present invention adopts the following technical solution: a spatiotemporal convolutional traffic flow prediction method based on RCR structure, comprising:
[0008] Obtain a training set of traffic flow data;
[0009] Develop traffic flow prediction models;
[0010] The training set is input into the traffic flow prediction model, and the training set is preprocessed to obtain preprocessed data.
[0011] Spatiotemporal convolution is performed on the preprocessed data to initially extract the spatial and temporal features of the data.
[0012] A ConvLSTM network is used as the core module, supplemented by a ResNet network, to construct a spatiotemporal feature extraction layer with an RCR structure, thereby obtaining the dynamic correlation between spatial and temporal features.
[0013] After multiple iterations, a prediction dataset is generated. The prediction dataset is then compared with the actual values to obtain the optimal traffic flow prediction model.
[0014] Based on the optimal traffic flow prediction model, input the traffic flow data for the first time period to obtain the optimal prediction result for the traffic flow data for the second time period;
[0015] The first time period is earlier than the second time period.
[0016] Preferably, it also includes: constructing a traffic network map G based on traffic flow data.<V,E,A> ;
[0017] Where V is the set of nodes in the traffic network graph, |V|=N represents the total number of nodes; E represents the set of edges in the traffic network graph; A∈R N×N Let G be the adjacency matrix; detectors irregularly distributed in the traffic network graph G detect the measurement value F at the same sampling frequency, and each node generates a feature vector of length F in each time slice.
[0018] Preferably, preprocessing the training set includes: performing initial weight allocation on the training set based on spatial and temporal attention mechanisms;
[0019] The spatial dimension attention mechanism is represented as follows:
[0020]
[0021]
[0022] in, It is the input of the r-th spatiotemporal module; C r-1 To represent the number of input data channels at the r-th layer, when r = 1, C0 = F; T r-1 The time series length of the output data of the (r-1)th spatiotemporal module; when r=1, T0=T, where T is the time series length of the current data; V s b s ∈R N×N , W1, W2, and W3 are all learnable parameters; σ is the sigmoid activation function, S∈R N×N Let S be the spatial attention matrix. i,j S' represents the dependency strength between spatial node i and spatial node j; i,j ∈R N ×N This represents the spatial node correlation weight matrix calculated using the softmax function;
[0023] The time-dimensional attention mechanism is represented as follows:
[0024]
[0025]
[0026] in, U1∈R N , U1, U2, and U3 are all learnable parameters; E is the temporal attention matrix; E i,j E' represents the dependency strength between time node i and time node j; i,j This represents the correlation weight matrix between time points calculated using the softmax function.
[0027] Preferably, the preprocessed data undergoes spatiotemporal convolution processing to initially extract the spatial and temporal features of the data, including: based on graph theory, performing convolution operations on the traffic network map to obtain the following definition of graph convolution:
[0028]
[0029] in, This represents a graph convolution operation, where Θ is the convolution kernel, Λ is the eigenvalue diagonal matrix, and U is the Laplacian eigenvalue decomposition L = UΛU. T The obtained Fourier base, This represents a projection transformation of the signal x onto the basis, and its inverse transform is:
[0030] The above equation is processed using Chebyshev polynomials, through convolution kernel g. θ Extracting information about the neighbors of order 0 to (K-1)th centered on each node in the graph, and initially extracting the spatial features of the data, we obtain the following formula:
[0031]
[0032] Where, θ m ∈R m It is a polynomial coefficient vector. For the calculated Chebyshev polynomials, ⊙ represents the Hadamard product, M is the size of the convolution kernel, and m represents the m-th order Chebyshev polynomial;
[0033] After initially extracting the spatial features of the data, a convolution operation is performed again to initially extract the temporal features of the data. The formula after the convolution operation is as follows:
[0034]
[0035] Where Ψ is the convolution kernel of the convolution operation, ReLU is the activation function, and r represents the r-th time step.
[0036] Preferably, the formula for the spatiotemporal feature extraction layer of the RCR structure is expressed as follows:
[0037] F(x)=ConvLSTM(F(x)+μ1x)+μ2x;
[0038] Here, μ1 and μ2 are learnable and adjustable parameters. The adjustment of μ1 and μ2 is automatically adjusted by the neural network to obtain the prediction result.
[0039] Preferably, the ConvLSTM network processes the data as follows:
[0040] i t =σ(W xi *x t +W hi *h t-1 +W ci ⊙c t-1 +b i );
[0041] f t =σ(W xf *x t +W hf *h t-1 +W cf ⊙c t-1 +b f );
[0042] c t =f t ⊙c t-1 +i t ⊙tanh(W xc *x t +W hc *h t-1 +b c );
[0043] o t =σ(W xo *x t +W ho *h t-1 +W co ⊙c t +b o );
[0044] h t =o t ⊙tanh(c t );
[0045] In the formula, * represents convolution, ⊙ represents Hadamard product, and it Indicates the input gate, f t Represents the forget gate, c t h represents long memory. t Represents short memory, o t Indicates the output gate; σ is the Sigmoid activation function; x t Input at time t; W *i and b i These are the weights and threshold of the input gate, respectively; W *f and b f These are the weights and threshold of the forget gate, respectively; W *c and b c These are the weights and thresholds of the state gate, respectively; W *o and b o These represent the weights and thresholds of the output gate, respectively. The * denotes the convolution operation, a significant change made by ConvLSTM compared to traditional LSTM. It replaces the input gate-state gate transition with convolution, and uses a feedforward neural network between state gates to improve the model's ability to extract local features from spatial data.
[0046] Preferably, the ResNet network processes the data as follows:
[0047] F(x) = F(x) + x;
[0048] In the formula, x represents the input data.
[0049] Preferably, mean absolute error (MAE), root mean square error (RMSE), and mean percentage error (MAPE) are used as evaluation metrics, as shown in the following formulas:
[0050]
[0051]
[0052]
[0053] Where N is the total number of data points in the test dataset. and Y n These are the predicted results calculated by the model and the actual values at the corresponding times in the dataset, respectively.
[0054] Preferably, a spatiotemporal convolutional traffic flow prediction system based on an RCR structure includes:
[0055] The data acquisition module is used to acquire the training set of traffic flow data;
[0056] The model building module is used to build a traffic flow prediction model, which includes an input module, a spatiotemporal attention module, a spatiotemporal convolution module, an RCR network module, a processing module, and an output module connected in sequence.
[0057] The input module is used to input the training set and the traffic flow data for the first time period;
[0058] The spatiotemporal attention module is used to preprocess the training set to obtain preprocessed data;
[0059] The spatiotemporal convolution module is used to perform spatiotemporal convolution processing on the preprocessed data to initially extract the spatial and temporal features of the data.
[0060] The RCR network module is used to obtain the dynamic correlation between spatial features and temporal features;
[0061] The processing module is used to generate a prediction dataset and compare the prediction dataset with the actual values to obtain the optimal traffic flow prediction model.
[0062] The output module is used to output the optimal prediction result of traffic flow data in the second time period based on the optimal traffic flow prediction model and the traffic flow data in the first time period; the first time period is earlier than the second time period.
[0063] As can be seen from the above technical solution, compared with the prior art, the present invention discloses a spatiotemporal convolutional traffic flow prediction method and system based on RCR structure, including: acquiring a training set of traffic flow data; constructing a traffic flow prediction model; inputting the training set into the traffic flow prediction model, preprocessing the training set to obtain preprocessed data; performing spatiotemporal convolution processing on the preprocessed data to initially extract the spatial and temporal features of the data; using a ConvLSTM network as the core module, supplemented by a ResNet network, to construct a spatiotemporal feature extraction layer of RCR structure to obtain the dynamic correlation between spatial and temporal features; after multiple iterations, generating a prediction dataset, comparing the prediction dataset with the true values to obtain the optimal traffic flow prediction model; according to the optimal traffic flow prediction model, inputting traffic flow data for a first time period to obtain the optimal prediction result for traffic flow data for a second time period; the first time period is earlier than the second time period.
[0064] This invention offers the following advantages: its spatial-temporal feature extraction module comprises two layers: a deep spatial-temporal feature extraction layer and a shallow spatial-temporal feature extraction layer. The deep layer uses ConvLSTM as its core module, supplemented by dual ResNets before and after it, solving the gradient vanishing problem of ConvLSTM and improving the accuracy of traffic flow prediction. The shallow layer uses ChebyshevGCN and CNN for preliminary spatial-temporal feature extraction. Additionally, a spatiotemporal attention module is designed to assist in the training of the ASTR-CR model, enabling rapid convergence. This invention fully learns the spatiotemporal features of traffic flow, extracting both temporal and spatial features simultaneously, and fully considers the dynamic correlation between time and space, making the model's prediction results for traffic flow data more accurate. Attached Figure Description
[0065] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0066] Figure 1 A schematic diagram of a traffic flow prediction model provided in an embodiment of the present invention.
[0067] Figure 2 This is a schematic diagram of a traffic network provided for an embodiment of the present invention.
[0068] Figure 3 This is a schematic diagram of a spatiotemporal convolution module provided in an embodiment of the present invention.
[0069] Figure 4 A schematic diagram of an RCR network module provided in an embodiment of the present invention.
[0070] Figure 5(a) is a schematic diagram comparing the MAE prediction results of the PEMS04 dataset with μ1 as the horizontal axis and μ2 as the vertical axis of each cluster, provided by the embodiment of the present invention.
[0071] Figure 5(b) is a schematic diagram comparing the MAE prediction results of the PEMS04 dataset with μ2 as the horizontal axis and μ1 as the vertical axis of each cluster, provided by the embodiment of the present invention.
[0072] Figure 6(a) is a schematic diagram comparing the RMSE results predicted by the PEMS04 dataset with μ1 as the horizontal axis and μ2 as the vertical axis of each cluster, provided by the embodiment of the present invention.
[0073] Figure 6(b) is a schematic diagram comparing the RMSE results predicted by the PEMS04 dataset with μ2 as the horizontal axis and μ1 as the vertical axis of each cluster, according to an embodiment of the present invention.
[0074] Figure 7(a) is a schematic diagram comparing the MAPE prediction results of the PEMS04 dataset with μ1 as the horizontal axis and μ2 as the vertical axis of each cluster, provided by the embodiment of the present invention.
[0075] Figure 7(b) is a schematic diagram comparing the MAPE prediction results of the PEMS04 dataset with μ2 as the horizontal axis and μ1 as the vertical axis of each cluster, according to the embodiment of the present invention. Detailed Implementation
[0076] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0077] This invention discloses a spatiotemporal convolutional traffic flow prediction method and system based on an RCR structure, comprising: acquiring a training set of traffic flow data; constructing a traffic flow prediction model; inputting the training set into the traffic flow prediction model and preprocessing the training set to obtain preprocessed data; performing spatiotemporal convolution processing on the preprocessed data to initially extract spatial and temporal features of the data; using a ConvLSTM network as the core module and supplemented by a ResNet network to construct a spatiotemporal feature extraction layer of an RCR structure to obtain the dynamic correlation between spatial and temporal features; generating a prediction dataset after multiple iterations; comparing the prediction dataset with the true values to obtain the optimal traffic flow prediction model; and inputting traffic flow data for a first time period according to the optimal traffic flow prediction model to obtain the optimal prediction result for traffic flow data for a second time period; wherein the first time period is earlier than the second time period.
[0078] The embodiments of the present invention solve the problem of gradient vanishing in ConvLSTM networks, improve the accuracy of traffic flow prediction, and enable the model to achieve rapid convergence, resulting in more accurate predictions of traffic flow data.
[0079] In one specific embodiment of the present invention, a spatiotemporal convolutional traffic flow prediction method based on an RCR structure is disclosed, such as... Figure 1As shown, the process includes: acquiring a training set of traffic flow data; constructing a traffic flow prediction model; inputting the training set into the traffic flow prediction model and preprocessing the training set to obtain preprocessed data; performing spatiotemporal convolution processing on the preprocessed data to initially extract spatial and temporal features; using a ConvLSTM network as the core module and supplemented by a ResNet network to construct a spatiotemporal feature extraction layer with an RCR structure to obtain the dynamic correlation between spatial and temporal features; generating a prediction dataset after multiple iterations; comparing the prediction dataset with the true values to obtain the optimal traffic flow prediction model; and inputting traffic flow data for a first time period based on the optimal traffic flow prediction model to obtain the optimal prediction result for traffic flow data for a second time period; the first time period is earlier than the second time period.
[0080] In a specific embodiment of the present invention, the first time period and the second time period can be set to one hour, two hours or other time periods; for example, the first time period can be set to 5:00 a.m. to 6:00 a.m. Beijing time; the second time period can be set to 6:00 a.m. to 7:00 a.m. Beijing time; the existing traffic flow data from 5:00 a.m. to 6:00 a.m. Beijing time is input into the trained optimal traffic flow prediction model to predict the optimal prediction result of the traffic flow data from 6:00 a.m. to 7:00 a.m. Beijing time.
[0081] The traffic flow prediction model includes an input module, a spatiotemporal attention module, a spatiotemporal convolution module, an RCR network module, a processing module, and an output module connected in sequence.
[0082] Specifically, this also includes: constructing a traffic network map G based on traffic flow data.<V,E,A> ,like Figure 2 As shown; since the spatial relationship of upstream and downstream mutual influence of traffic flows can be approximated as a graph, this embodiment of the invention uses G =<V,E,A> Let V be the set of nodes in the graph, and |V| = N represent the total number of nodes. E represents the set of edges in the graph, that is, whether two nodes can be directly reached. A∈R N×N Let F represent the adjacency matrix of graph G. In the traffic network graph G, detectors that are irregularly distributed detect the measured value F at the same sampling frequency, that is, each node generates a feature vector of length F in each time slice.
[0083] Specifically, this embodiment of the invention uses a spatiotemporal attention module based on an attention mechanism, which includes a spatial dimension attention mechanism and a temporal dimension attention mechanism; initial weight allocation is performed on the training set based on the spatial and temporal dimension attention mechanisms; this enables the traffic flow prediction model to better capture dynamic spatiotemporal features and pay more attention to branches and nodes that play a greater role in the model. The method of this module can be defined by the following formula:
[0084]
[0085]
[0086]
[0087]
[0088] Equations (1) and (2) represent the spatial dimension attention mechanism, where It is the input of the r-th spatiotemporal module. C r-1 Let C0 be the number of input data channels at the r-th layer. When r = 1, C0 = F. r-1 This represents the time series length of the output data for the (r-1)th spatiotemporal module. When r = 1, T0 = T, where T is the time series length of the current data. V s b s ∈R N×N , W1, W2, and W3 are all learnable parameters. σ is the sigmoid activation function, S∈R. N×N This is the spatial attention matrix, where the matrix values represent the importance of different parts of the data. i,j S' represents the dependency strength between spatial node i and spatial node j; i,j ∈R N×N This represents the spatial node correlation weight matrix calculated using the softmax function.
[0089] Formulas (3) and (94) describe the attention mechanism in the time dimension. U1∈R N , U1, U2, and U3 are learnable parameters. Matrix E represents the temporal correlation between different inputs; E is the temporal attention matrix, which is a softmax-normalized matrix. i,j E' represents the dependency strength between time node i and time node j; i,j This represents the correlation weight matrix between time points calculated using the softmax function.
[0090] Specifically, the spatiotemporal convolution module uses convolution to initially extract the spatial and temporal features of the data as a shallow spatiotemporal feature extraction layer; for example... Figure 3 As shown, in this study of traffic flow prediction, the embodiment of the present invention treats the traffic network as a graph, and the road network graph is a topological graph. To address this characteristic of the road network graph and fully extract its spatial features, the embodiment of the present invention employs Chebyshev GCN, which implements topological graph convolution operations based on graph theory. In graph analysis, the properties of a graph are obtained by analyzing the Laplacian matrix and eigenvalues of the matrix. The Laplacian matrix of a graph is defined by L = DA, and normalizing this equation yields... Where A is the adjacency matrix of graph G, I N Let D be the identity matrix, and D ∈ R. N×N It is a diagonal matrix composed of the degrees of the nodes. U is the Laplacian eigenvalue decomposition L = UΛU T The obtained Fourier basis, where Λ=diag([λ0,…,λ N-1 ])∈R N×N Let be an eigenvalue diagonal matrix. Its n eigenvectors are linearly independent and mutually orthogonal. Using this as the basis for transformation, the signal x is projected onto this basis to obtain . Its inverse transformation is Therefore, the definition of graph convolution is obtained as follows:
[0091]
[0092] in This represents a graph convolution operation, where Θ is the convolution kernel. That is, graph convolution is performed on the signal x using Θ as the kernel. Since formula (5) has high computational complexity, Chebyshev polynomials are used to approximate it as shown in the following formula:
[0093]
[0094] Where θ m ∈R m It is a polynomial coefficient vector. These are the calculated Chebyshev polynomials. λ max Let T be the largest eigenvalue of the Laplacian matrix. M is the size of the convolution kernel, and m represents the m-th Chebyshev polynomial, which determines the maximum radius of the convolution. The m-th Chebyshev polynomial is recursively defined as T. m (x)=2xT m-1 (x)-T m-2(x). When m = 0, T0(x) = 1, and when m = 1, T1(x) = x. This problem can be solved by approximate expansion of Chebyshev polynomials, equivalent to using a convolution kernel g. θ Information about the neighbors of each node in the graph, from order 0 to (K-1)th, is extracted. To enable the model to adapt to dynamic node correlations, a... S'∈R N×N , ⊙ represents the Hadamard product, so formula (6) can be rearranged and transformed into:
[0095]
[0096] Based on formula (7), another convolution operation is performed to initially extract the features in the time dimension. Taking the r-th layer as an example, the formula becomes as follows after the convolution operation:
[0097]
[0098] Here, Ψ is the convolution kernel, which is a parameter that can be adjusted through learning. ReLU is the activation function. r represents the r-th time step.
[0099] Existing ASTGCN methods do not sufficiently extract temporal characteristics, and RNN networks suffer from vanishing and exploding gradients, limiting their ability to achieve better prediction results. Therefore, to address the vanishing gradient problem in RNN networks, this invention designs a ResNet-ConvLSTM-ResNet (RCR) residual structure composed of a bilateral ResNet module and a ConvLSTM module to strengthen the network's memory, thereby reducing the limitations imposed by vanishing gradients on network functionality. This structure is then used as a deep spatiotemporal feature extraction layer to further obtain the dynamic correlation between temporal and spatial features.
[0100] Specifically, for the RCR network module, a ConvLSTM network is used as the core module, supplemented by a ResNet network, to construct a spatiotemporal feature extraction layer of the RCR structure, obtaining the dynamic correlation between spatial and temporal features; and to capture deep spatial and temporal features of traffic flow data; such as... Figure 4 As shown, the main spatiotemporal extractor in this module is ConvLSTM. As a network structure that can take into account both temporal and spatial features, ConvLSTM performs quite satisfactorily in this module. However, it also suffers from the common problem of RNN series networks: gradient vanishing. Therefore, this embodiment of the invention designs a Resnet-ConvLSTM-Resnet (RCR) network structure to solve this problem.
[0101] ConvLSTM is a recurrent neural network used for spatiotemporal prediction. It applies convolutional structures to the transitions from input to state and from state to state, determining the future state of the current node by considering the past states of the input and neighboring nodes. ConvLSTM was specifically designed for prediction tasks, effectively addressing the limitation of LSTM networks in utilizing spatial information in data. It can simultaneously capture the dynamic correlations between time and space in the data, making it suitable for processing spatiotemporal data. The traffic flow prediction task of this invention perfectly aligns with this characteristic, as traffic flows possess both temporal information that changes over time and spatial information about the interaction between upstream and downstream roads within the entire graph space.
[0102] Specifically, the ConvLSTM network processes the data as follows:
[0103] i t =σ(W xi *x t +W hi *h t-1 +W ci ⊙c t-1 +b i (9)
[0104] f t =σ(W xf *x t +W hf *h t-1 +W cf ⊙c t-1 +b f (10)
[0105] c t =f t ⊙c t-1 +i t ⊙tanh(W xc *x t +W hc *h t-1 +b c (11)
[0106] o t =σ(W xo *x t +W ho *h t-1 +W co ⊙c t +b o (12)
[0107] h t =o t ⊙tanh(c t (13)
[0108] In the formula, * represents convolution, and ⊙ represents Hadamard product. t Indicates the input gate, f t Represents the forget gate, c t h represents long memory. t Represents short memory, o t Indicates the output gate; σ is the Sigmoid activation function; x t Input at time t; W *i and b i These are the weights and threshold of the input gate, respectively; W *f and b f These are the weights and threshold of the forget gate, respectively; W *c and b c These are the weights and thresholds of the state gate, respectively; W *o and b o These represent the weights and thresholds of the output gate, respectively. The * denotes the convolution operation, a significant change made by ConvLSTM compared to traditional LSTM. It replaces the input gate-state gate transition with convolution, and uses a feedforward neural network between state gates to improve the model's ability to extract temporal and spatial dynamic correlations from traffic flow data.
[0109] ResNet, short for Residual Neural Network, is a deep convolutional neural network proposed in 2015 by Kaiming He and others from Microsoft Research. The main feature of ResNet is the introduction of residual modules, which add a skip connection after each convolutional layer, allowing the input to be directly passed to the output, thus alleviating the vanishing gradient and degradation problems in deep networks.
[0110] ResNet possesses remarkable capabilities: it can construct very deep networks, such as ResNet-152 with 152 layers, without compromising training efficiency or prediction performance. It can effectively extract high-level semantic features from images, improving the accuracy of tasks such as image classification, object detection, and semantic segmentation. Furthermore, it allows for convenient model fine-tuning, enabling modifications to parameters or structure of pre-trained models to adapt to new datasets or tasks.
[0111] Of course, ResNet also has some drawbacks. For example, when the number of model layers is too high, such as when using ResNet-152, the network requires a large amount of computational resources and storage space because the number of model parameters increases significantly compared to when ResNet-152 is not used. This also leads to increased model complexity and the need to address overfitting, requiring more data. To address these drawbacks of ResNet, this embodiment of the invention chooses to reduce the number of ResNet layers, aiming to achieve better results with less resource consumption.
[0112] Specifically, the ResNet network processes the data as follows:
[0113] F(x)=F(x)+x (14)
[0114] In the formula, x represents the input data.
[0115] Specifically, the formula for the spatiotemporal feature extraction layer of the RCR structure is as follows:
[0116] F(x)=ConvLSTM(F(x)+μ1x)+μ2x (15)
[0117] Here, μ1 and μ2 are learnable and adjustable parameters. This invention also compares the model performance under various combinations of these two parameters. This invention uses manual modification of the values of μ1 and μ2, as well as adjustment through the reflection propagation mechanism of a neural network. The impact of changes in the values of μ1 and μ2 on the model performance is compared using specific values. After the adjustment of μ1 and μ2 is automatically handled by the neural network, the optimal prediction result is obtained through multiple model iterations.
[0118] Experimental setup
[0119] In this embodiment of the invention, the experiment was conducted on an NVIDIA A10 graphics card, and the model was built based on the PyTorch framework. The learning rate was set to 0.005, the total number of training epochs was set to 80, and the parameter m in Chebyshev polynomials could be set to 3. In the model, the kernel size of the temporal and spatial convolutional layers in the spatiotemporal convolution module could be set to 64. In the deep spatiotemporal feature extraction layer, μ1 and μ2 could be set to 0.1 and 0.2, respectively, or other values.
[0120] The mean absolute error (MAE), root mean square error (RMSE), and mean percentage error (MAPE) are used as evaluation indicators. The calculation formulas for the three evaluation indicators are shown in formulas (16) to (18).
[0121]
[0122]
[0123]
[0124] Where N is the total number of data points in the test set. and Y n These are the predicted results calculated by the model and the actual values at the corresponding times in the dataset, respectively.
[0125] Experiments were conducted on two publicly available real datasets, PEMS04 and PEMS08, and the information contained in the datasets is shown in Table 1.
[0126] Table 1
[0127]
[0128] Data was collected every 5 minutes for both the PEMS04 and PEMS08 datasets. The datasets were split in a 6:2:2 ratio to serve as the training set, test set, and validation set, respectively.
[0129] ablation experiment
[0130] The embodiments of the present invention conducted ablation experiments on the model to verify the effectiveness of the deep spatiotemporal feature extraction layer in the model and the effectiveness of each module in the deep spatiotemporal feature extraction layer.
[0131] The model was segmented and degenerated to obtain the following models: ASTR-C-R_Res1 (containing only Res1), ASTR-C-R_ConvLSTM (containing only ConvLSTM), ASTR-C-R_Res1-ConvLSTM (containing only Res1-ConvLSTM), ASTR-C-R_Res2-ConvLSTM (containing only Res2-ConvLSTM), and the complete model ASTR-CR (traffic flow prediction model). The model performance under various ablation conditions is compared in Table 2.
[0132] Table 2
[0133]
[0134]
[0135] Comparison of experimental results reveals that the performance of ASTR-CR is inferior to all ablation-treated models. This conclusion is even more evident on the PEMS04 dataset. With only the spatiotemporal convolution module, the model fails to converge with the same number of training iterations, resulting in abnormally high performance metrics. However, adding a ConvLSTM network as a deep spatiotemporal feature extractor significantly improves overall performance, demonstrating the rationale for incorporating the ConvLSTM module into the original model. With the addition of Res1 and Res2, the model performance is further enhanced. After all modules are in place, the ASTR-CR model achieves the best results. The results in the table above also demonstrate the effectiveness of the deep feature extraction module designed in this embodiment of the invention.
[0136] Comparative experiment
[0137] In the comparative experiments, the embodiments of the present invention selected the following methods as the baseline for comparing the model experimental results. The following methods involve existing parameter-based methods and deep learning-based methods, wherein the deep learning-based methods are classic methods that are widely recognized in the field or have achieved good results on the datasets in question.
[0138] HA: Historical Average. The historical average model predicts future traffic flow on the test set based on the historical average of inflows and outflows over a given time period in the training set data.
[0139] SVR: Support Vector Regression, uses linear support vector machines for regression tasks.
[0140] LSTM: Long Short-Term Memory Network. A special type of RNN network that can effectively process temporal data and solves the gradient vanishing and long-term memory problems to some extent through gating mechanisms.
[0141] DCRNN: A diffusing convolutional recurrent neural network that uses RandomWalk to capture spatial dependencies and a time-dependent encoder-decoder that uses time-sampling to capture temporal dependencies.
[0142] STGCN: Spatiotemporal Graph Convolutional Network. A spatiotemporal convolutional model based on spatial methods, using ChebNet to encode spatial information.
[0143] ASTGCN: Uses an attention mechanism to assist in learning spatiotemporal features. It defines the traffic flow prediction task against a road network map and processes the data across three time spans: the most recent hour, the most recent day, and the most recent week. However, to ensure fairness in the comparison, its multi-temporal feature model is not used in this experiment. STSGCN: Spatiotemporal Graph Convolutional Network. It captures information between different times and nodes synchronously by constructing a local spatiotemporal graph.
[0144] The results of the proposed method and other methods on the PEMS04 and PEMS08 datasets are shown in Table 3.
[0145] Table 3
[0146]
[0147] Results Analysis
[0148] In the model design, this embodiment of the invention sets different values for μ1 and μ2 to adjust the influence of the original data on the network prediction, avoiding an excessive proportion of the original data covering the importance of the data generated after network learning during training, and also ensuring that the original data can help the ResNet network solve the problems of gradient explosion and gradient vanishing in ConvLSTM. To explore the most suitable weight values for the ConvLSTM and ResNet residual structures, this embodiment of the invention records the influence of different Res1 and Res2 weights on the network prediction results during the process.
[0149] The results are compared in Figures 5(a), 5(b), 6(a), 6(b), 7(a), and 7(b). These figures represent the model's predictions on the PEMS04 dataset under different μ1 and μ2 settings. In this embodiment, MAE, RMSE, and MAPE under each weight are used to represent the results. Figure (a) shows the result with μ1 as the horizontal axis and μ2 as the vertical axis for each cluster; Figure (b) shows the result with μ2 as the horizontal axis and μ1 as the vertical axis for each cluster. The dashed lines in the figures represent the linear trend of the clusters as a whole relative to the horizontal axis of 0.1. As can be seen from the dashed lines, the overall trend of the (a) series of figures is greater than that of the (b) series, meaning that the change in μ1 has a more significant impact on the model's performance, and the model's performance deteriorates as μ1 increases. This conclusion is reflected in the MAE, RMSE, and MAPE of the experimental results.
[0150] To further explore whether the impact of changes in μ1 and μ2 on the model prediction results can be fully affirmed from a mathematical perspective, the embodiments of this invention conducted an analysis of variance on the experimental results, as shown in Table 4:
[0151] Table 4
[0152]
[0153] Regarding the impact of μ1 and μ2 on the model performance, this embodiment of the invention performed an analysis of variance on the obtained results. The intermediate values obtained during the analysis of variance are shown in Table 4. At a confidence level of 99%, the F-value of μ1 is approximately 0.878697, which is less than the F-value of μ2. 0.01(9, 81) = 2.6344, therefore, the effect of μ1 on the model performance is significant. Similarly, the F-value of μ2 is approximately 2.608094, which is less than F... 0.01 (9, 81) = 2.6344, indicating that μ2 has a significant impact on the model's performance. Therefore, after analyzing the experimental data of this embodiment from a mathematical perspective, it can be seen that the model's performance is significantly affected by the values of μ1 and μ2. When μ1 and μ2 are adjusted to appropriate values, the model can achieve better results. Furthermore, comparing the experimental results with Figures 5(a), 5(b), 6(a), 6(b), 7(a), and 7(b), it can be seen that the better-performing μ1 and μ2 should be within a smaller range of values. When the step size of μ1 and μ2 is 0.1, the best performance result of the current model is achieved when μ1 = 0.1 and μ2 = 0.2. When the adjustment of parameters μ1 and μ2 is delegated to the reflection propagation mechanism of the neural network, the experiment obtains the optimal results, as shown in Table 3.
[0154] The ASTR-CR method provided in this invention is a novel traffic flow prediction method designed to better acquire spatial-temporal features. Its spatial-temporal feature extraction module comprises two layers: a deep spatiotemporal feature extraction layer and a shallow spatiotemporal feature extraction layer. The deep spatiotemporal feature extraction layer uses ConvLSTM as its core module, supplemented by front and rear ResNet networks; the shallow spatiotemporal feature extraction layer uses Chebyshev GCN and CNN for preliminary spatial and temporal feature extraction. Additionally, a spatiotemporal attention module is designed to assist in the training of the ASTR-CR model.
[0155] This invention proposes an STblock with ConvLSTM as the main feature extractor, which extracts spatial features from data while simultaneously capturing temporal features, addressing the problem of insufficient attention to the dynamic correlation between time and space in existing methods. The RCR structure composed of bilateral ResNet modules solves the vanishing gradient problem of ConvLSTM, improving the accuracy of traffic flow prediction. This invention was tested on the PEMS04 and PEMS08 datasets, achieving better results than baseline methods. The impact of different ResNet weights in the RCR structure on model accuracy is also discussed. In intelligent transportation systems, this can sensitively and accurately predict changes in traffic conditions in the next moment, achieving more accurate traffic flow prediction; alleviating traffic pressure in cities and reducing the time citizens spend on their journeys.
[0156] This invention also provides a spatiotemporal convolutional traffic flow prediction system based on an RCR structure, comprising:
[0157] The data acquisition module is used to acquire the training set of traffic flow data;
[0158] The model building module is used to build a traffic flow prediction model, which includes an input module, a spatiotemporal attention module, a spatiotemporal convolution module, an RCR network module, a processing module, and an output module connected in sequence.
[0159] The input module is used to input the training set and the traffic flow data for the first time period;
[0160] The spatiotemporal attention module is used to preprocess the training set to obtain preprocessed data;
[0161] The spatiotemporal convolution module is used to perform spatiotemporal convolution processing on the preprocessed data to initially extract the spatial and temporal features of the data.
[0162] The RCR network module is used to obtain the dynamic correlation between spatial features and temporal features;
[0163] The processing module is used to generate a prediction dataset and compare the prediction dataset with the actual values to obtain the optimal traffic flow prediction model.
[0164] The output module is used to output the optimal prediction result of traffic flow data in the second time period based on the optimal traffic flow prediction model and the traffic flow data in the first time period; the first time period is earlier than the second time period.
[0165] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.
[0166] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A spatiotemporal convolutional traffic flow prediction method based on RCR structure, characterized in that, include: Obtain a training set of traffic flow data; Develop traffic flow prediction models; The training set is input into the traffic flow prediction model, and the training set is preprocessed to obtain preprocessed data. Spatiotemporal convolution is performed on the preprocessed data to initially extract the spatial and temporal features of the data. The ConvLSTM network is used as the core module. The ResNet-ConvLSTM-ResNet (RCR) residual structure, composed of bilateral ResNet modules and ConvLSTM modules, is used to enhance the network's memory, thereby reducing the limitation of gradient vanishing on the network's function. It is also used as a deep spatiotemporal feature extraction layer to further obtain the dynamic correlation between temporal and spatial features. After multiple iterations, a prediction dataset is generated. The prediction dataset is then compared with the actual values to obtain the optimal traffic flow prediction model. Based on the optimal traffic flow prediction model, input the traffic flow data for the first time period to obtain the optimal prediction result for the traffic flow data for the second time period; The first time period is earlier than the second time period; The formula for the spatiotemporal feature extraction layer of the RCR structure is expressed as follows: ; in, , For learnable and adjustable parameters, , The adjustment is handled automatically by the neural network to obtain the prediction result.
2. The spatiotemporal convolutional traffic flow prediction method based on RCR structure according to claim 1, characterized in that, Also includes: Construct a traffic network map G based on traffic flow data.<V,E,A> ; Where V is the set of nodes in the traffic network graph, |V|=N means there are N nodes in total; E represents the set of edges in the traffic network graph; Let G be the adjacency matrix; detectors irregularly distributed in the traffic network graph G detect the measurement value F at the same sampling frequency, and each node generates a feature vector of length F in each time slice.
3. The spatiotemporal convolutional traffic flow prediction method based on RCR structure according to claim 1, characterized in that, Preprocessing the training set includes: performing initial weight allocation on the training set based on spatial and temporal attention mechanisms; The spatial dimension attention mechanism is represented as follows: in, It is the input of the r-th spatiotemporal module; Let r be the number of channels for input data at layer r. When r=1, =F; The time series length of the output data of the (r-1)th spatiotemporal module; when r=1, =T, where T is the length of the time series of the current data; , , , , ; , and All of these are learnable parameters; It is the sigmoid activation function. For spatial attention matrix, This represents the dependency strength between spatial node i and spatial node j; This represents the spatial node correlation weight matrix calculated using the softmax function; The time-dimensional attention mechanism is represented as follows: ; ; in, , , , ; , and All of these are learnable parameters; E is the temporal attention matrix; This represents the dependency strength between time node i and time node j; This represents the correlation weight matrix between time points calculated using the softmax function.
4. The spatiotemporal convolutional traffic flow prediction method based on RCR structure according to claim 1, characterized in that, The preprocessed data is subjected to spatiotemporal convolution to initially extract its spatial and temporal features, including: based on graph theory, a convolution operation is performed on the traffic network map to obtain the definition of graph convolution as follows: ; in, Represents graph convolution operations. For convolution kernel, Let U be the diagonal matrix of eigenvalues, and U be the Laplace eigenvalue decomposition. The obtained Fourier base, Indicates the signal Performing a projection transformation on the basis, its inverse transformation is: ; The above equation is processed using Chebyshev polynomials, through convolution kernels. Extracting information about the neighbors of order 0 to (K-1)th centered on each node in the graph, and initially extracting the spatial features of the data, we obtain the following formula: ; in, It is a polynomial coefficient vector. The calculated Chebyshev polynomials, denoted as Hadamard product, M is the size of the convolution kernel, and m represents the m-th Chebyshev polynomial; After initially extracting the spatial features of the data, a convolution operation is performed again to initially extract the temporal features of the data. The formula after the convolution operation is as follows: ; in, is the convolution kernel for the convolution operation, ReLU is the activation function, and r represents the r-th time step.
5. The spatiotemporal convolutional traffic flow prediction method based on RCR structure according to claim 1, characterized in that, The ConvLSTM network processes the data as follows: ; In the formula This represents the convolution operation. It represents the Hadamah accumulation. Indicates the input gate. Represents the Gate of Oblivion Indicates long memory, Represents short memory, This represents the output gate; σ is the Sigmoid activation function. Input at time t; and These are the weights and thresholds of the input gate, respectively; and These are the weights and thresholds of the forget gate, respectively; and These are the weights and thresholds of the state gate, respectively; and These are the weights and thresholds of the output gate, respectively.
6. The spatiotemporal convolutional traffic flow prediction method based on RCR structure according to claim 1, characterized in that, The ResNet network processes data as follows: ; In the formula, x represents the input data.
7. The spatiotemporal convolutional traffic flow prediction method based on RCR structure according to claim 1, characterized in that, The mean absolute error (MAE), root mean square error (RMSE), and mean percentage error (MAPE) are used as evaluation metrics, as shown in the following formula: ; ; ; Where N is the total number of data points in the test dataset. and These are the predicted results calculated by the model and the actual values at the corresponding times in the dataset, respectively.
8. A spatiotemporal convolutional traffic flow prediction system based on an RCR structure, employing the spatiotemporal convolutional traffic flow prediction method based on an RCR structure as described in any one of claims 1-7, characterized in that, include: The data acquisition module is used to acquire the training set of traffic flow data; The model building module is used to build a traffic flow prediction model, which includes an input module, a spatiotemporal attention module, a spatiotemporal convolution module, an RCR network module, a processing module, and an output module connected in sequence. The input module is used to input the training set and the traffic flow data for the first time period; The spatiotemporal attention module is used to preprocess the training set to obtain preprocessed data; The spatiotemporal convolution module is used to perform spatiotemporal convolution processing on the preprocessed data to initially extract the spatial and temporal features of the data. The RCR network module is used to obtain the dynamic correlation between spatial features and temporal features; The processing module is used to generate a prediction dataset and compare the prediction dataset with the actual values to obtain the optimal traffic flow prediction model. The output module is used to output the optimal prediction result of traffic flow data in the second time period based on the optimal traffic flow prediction model and the traffic flow data in the first time period; the first time period is earlier than the second time period.