A traffic flow prediction method and device based on spatiotemporal sequence deep learning
By constructing a traffic flow prediction model based on spatiotemporal sequence deep learning, and utilizing adaptive graph convolution and self-attention mechanisms, the accuracy and robustness issues of existing models in spatiotemporal data prediction are solved, achieving more efficient traffic flow prediction and decision support.
Patent Information
- Application Number
- CN202311070477.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-24
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2043-08-24
AI Technical Summary
Existing traffic flow prediction models suffer from low prediction accuracy, weak robustness, and poor adaptability due to the uncertainty of future time in spatiotemporal data, low model generalization ability, and insufficient characterization of the learning directions in the time and spatial dimensions.
A traffic flow prediction method based on spatiotemporal sequence deep learning is adopted. By constructing convolutional network layers, temporal convolutional network layers, spaceblock layers, and Layer Norm layers, combined with adaptive graph convolutional networks and self-attention mechanisms, a traffic flow prediction model is built. The model is then iteratively updated using the training dataset to predict the temporal values at future times.
It improves the accuracy and robustness of traffic flow forecasting, effectively captures the intrinsic relationship between time and space dimensions, enhances the predictive ability of the model, adapts to changes in different time periods, and assists traffic management personnel in making decisions.
Smart Images

Figure CN117116045B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a traffic flow prediction method and apparatus based on spatiotemporal sequence deep learning, belonging to the field of deep learning prediction technology for spatiotemporal sequences. Background Technology
[0002] In recent decades, with the acceleration of globalization and economic development, an increasing number of vehicles have entered the road, placing enormous pressure on traffic system management and demanding higher standards for safety, efficiency, and convenience. The continuous application of affordable traffic sensor technology and the decline in the price of computer component storage technology have enabled the collection of explosive traffic flow data, driving the continuous development of intelligent transportation systems and smart cities. Simultaneously, the emergence of intelligent transportation systems can better address issues such as traffic congestion, route planning, road health checks, and the management of public safety emergencies, improving the utilization rate of transportation resources and enhancing the planning and construction of smart cities, as well as improving the quality of life and travel for urban residents. Therefore, long-term spatiotemporal prediction of traffic flow in specific periods is of great significance.
[0003] From the perspective of the history of artificial intelligence, as we move from traditional machine learning methods to deep learning, the spatiotemporal prediction of traffic flow has also been continuously improved in this way.
[0004] Initially, statistical and neural network-based correlation models were first applied to traffic flow prediction. References "Real-time road traffic prediction with spatio-temporal correlations" (W. Min and L. Wynter, Transp. Res. Part C Emerg. Technol., vol. 19, no. 4, pp. 606–616, Aug. 2011.) and "New Bayesian combination method for short-term traffic flow forecasting" (J. Wang, W. Deng, and Y. Guo, Transp. Res. Part C Emerg. Technol., vol. 43, pp. 79–94, Jun. 2014) used statistical models such as the Regression Integrated Moving Average (ARIMA) and Bayesian networks to model spatially related dependencies from a probabilistic perspective. However, these models have highly linear properties, hindering the effective simulation of the highly nonlinear internal structure of traffic flow, and their internal structure requires significant computational resources and memory.
[0005] Compared to traditional machine learning methods, deep learning can better uncover deeper information and improve the overall nonlinearity of the model. The reference "Learning traffic as images: A deep convolutional neural network for large-scale transportation network speed pre-diction" (X.Ma et al., Sensors, vol.17, no.4, p.818, Apr.2017.) uses CNN (Convolutional Neural Network) to extract spatial features from traffic networks converted into regular grids. Due to its powerful feature extraction capabilities, it can effectively uncover spatial relationships. However, the inherent grid conversion leads to the loss of inherent topological information in irregular traffic networks. The reference “Diffusion-convolutional neural networks” (J. Atwood and D. Towsley, in Adv. Neural Inf. Process. Syst. 29, Barcelona, Spain, Dec. 2016, pp. 1993–2001.) uses graph convolutional networks (GCNs) to extend classic convolutional networks to the graph and frequency domains. Starting from the perspective of graph signals, it further extends deep learning to the non-Euclidean domain, enabling more effective reading of spatial information. The reference "Graph wavenet for deep spatial-temporal graph modeling" (Z. Wu, S. Pan, G. Long, J. Jiang, and C. Zhang, in Proc. 28th Int. Joint Conf. Artif. Intell., Macao, China, Aug. 2019, pp. 1907–1913.) proposes a Graph WaveNet model that utilizes graph convolutional networks and TCNs (temporal convolutional networks) to perform learnable embeddings on each node, improving the accuracy of traffic prediction based on hidden spatial patterns. However, once trained, their spatial dependencies remain fixed.
[0006] The reference "Long short-term memory neural network for traffic speedprediction using remote microwave sensor data" (X.Ma, Z.Tao, Y.Wang, H.Yu, and Y.Wang, Transp. Res. Part C Emerg. Technol., vol. 54, pp. 187–197, May 2015.) points out that traditional RNN networks are limited in modeling time dependencies. The reference "Long short-term memory" (S. Hochreiter and J. Schmidhuber, Neural Comput., vol. 9, no. 8, pp. 1735–1780, Nov. 1997) proposes LSTM to improve the shortcomings of RNNs, facilitating the formation of long-term memory units across multiple time points; however, it still suffers from time-consuming training processes and limited long-term scalability. The reference "Attention is all you need" (A. Vaswani et al., in Adv. Neural Inf. Process. Syst. 30, Long Beach, CA, USA, Dec. 2017, pp. 5998–6008.) employs an attention mechanism architecture to achieve efficient sequence learning. Within a single layer, long-term time-varying dependencies can be adaptively captured from input sequences of varying lengths.
[0007] In summary, existing prediction models suffer from low generalization ability and insufficient characterization of the learning directions of both time and space dimensions due to the uncertainty of future time in spatiotemporal data. In practical applications, they have drawbacks such as low prediction accuracy, weak robustness, and poor adaptability. Summary of the Invention
[0008] In order to overcome the shortcomings of the existing technology, the present invention aims to provide a traffic flow prediction method and device based on spatiotemporal sequence deep learning.
[0009] The technical solution provided by this invention to solve the above-mentioned technical problems is: a traffic flow prediction method based on spatiotemporal sequence deep learning, comprising:
[0010] Obtain historical data on road shape and traffic flow.
[0011] Historical traffic flow data is preprocessed according to the relevant time association order, and further organized into tensors in batch form to construct a multivariate spatiotemporal sequence dataset of historical traffic flow data.
[0012] The multivariate spatiotemporal sequence dataset is divided into a training dataset, a validation dataset, and a test dataset, and the data in these datasets are standardized according to each attribute of the samples.
[0013] A traffic flow prediction model is constructed. The traffic flow prediction model includes a convolutional network layer, a temporal convolutional network layer, a space block layer, a Layer Norm layer, a temporal convolutional network layer, a Layer Norm layer, and two convolutional layers. The temporal convolutional network layer consists of a temporal embedding layer, a temporal MLP layer, a dilated convolutional layer, and a GRN layer. The space block layer consists of three parts: the first part is an adaptive graph convolutional network layer based on Chebyshev's formula; the second part is a multi-head attention layer based on a self-attention mechanism; and the third part is a GRN layer that filters information.
[0014] The traffic flow prediction model was trained using the training dataset;
[0015] The system collects traffic flow data at the current moment and inputs it into a trained traffic flow prediction model to predict time series values for future moments.
[0016] A further technical solution is that the historical traffic flow data is obtained through traffic station sensors.
[0017] A further technical solution is that the preprocessing includes error correction for outliers and missing values.
[0018] A further technical solution is that the standardization method involves calculating the mean μ and variance σ for each sample attribute, and then using the Z-score formula to obtain a new dataset x'.
[0019] A further technical solution is that the training steps of the traffic flow prediction model include:
[0020] The training dataset is used as input to the traffic flow prediction model for prediction.
[0021] The traffic flow prediction model is iteratively updated and trained using a loss function called Loss until the training conditions are terminated, generating a trained traffic flow prediction model that can be used to predict future time series values.
[0022] A further technical solution involves using the training dataset as input to the traffic flow prediction model for prediction, including:
[0023] S1. Input the training dataset into a convolutional network layer with a kernel of 1×1 and the number of channels of embed_size to enrich the semantics of the input tensor;
[0024] S2. Input the data into the temporal convolutional network layer to obtain the time-related hidden state;
[0025] S21. The unique time information is added to the input data through the time embedding layer to enhance the time information;
[0026] S22. Expand the time dimension using the temporal MLP layer to facilitate subsequent diffusing convolution operations, and then input the result into the diffusing convolution layer.
[0027] S23. Input the obtained results into the GRN layer to filter out useless information;
[0028] S24. Repeat steps S22-S23, and perform a convolution on the output of each step S22 and accumulate the results.
[0029] S25. Add the results of step S24 and step S22 and pass them through a LayerNorm layer to obtain the overall output of the temporal convolutional network layer;
[0030] S3. Input the data into a constructed spaceblock layer;
[0031] S31. After standardizing the adjacency matrix, input it together with the input data into the adaptive graph convolutional network layer;
[0032] S32. Input a GRN network layer;
[0033] S33. Input the multi-head attention layer based on the self-attention mechanism and add the result and output of step S32 into a LayerNorm layer and a Dropout layer respectively;
[0034] S34. Input it into another GRN network layer again, and add the result and output of step S31 into a LayerNorm layer and a Dropout layer respectively;
[0035] S4. Repeat step S2 multiple times, and repeatedly activate it with the ReLU function;
[0036] S5. Add the results of step S3 and step S2 and input them into a LayerNorm layer;
[0037] S6. Input the data again into a temporal convolutional network layer, and add the result and output of step S1 to a LayerNorm layer;
[0038] S7. Repeat steps S2-S6, and repeatedly activate with the ReLU function;
[0039] S8. The obtained data results are fed into two convolutional layers to achieve dimensionality reduction and reduce the number of sample attributes. A further technical solution is that the adjacency matrix standardization formula is:
[0040] D ii =∑ i A ij for i=1,...,N
[0041]
[0042]
[0043] In the formula: A represents the initial adjacency matrix, D represents the diagonal matrix; I N λ represents an identity matrix of length N; MAX This represents the largest eigenvalue in matrix A.
[0044] A further technical solution is that the design of the two convolutional layers is as follows:
[0045]
[0046] Its internal convolution is a 1×1 convolution kernel that treats the time dimension as a convolution of the number of channels to obtain the required output time window dimension;
[0047] The outer convolution is also a 1×1 convolution kernel that treats the attribute dimension as the number of channels, used to reconstruct and predict future values.
[0048] An electronic device includes at least one processor and a memory communicatively connected to the at least one processor; the memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to perform the aforementioned traffic flow prediction method based on spatiotemporal sequence deep learning.
[0049] A traffic flow decision-making device based on traffic flow collection and deep learning, comprising:
[0050] The traffic flow sensing and collection module is used to collect relevant information for traffic flow prediction. It utilizes low-cost storage technology and efficient collection devices to collect factors such as vehicle congestion flow, road shape, or average vehicle speed.
[0051] The information flow processing module is used to preprocess, predict, and fuse traffic-related flow information such as average vehicle speed, as well as road shape and driving route information.
[0052] Traffic flow prediction model, used to predict time series values of future traffic flow based on a spatiotemporal sequence deep learning-based traffic flow prediction method;
[0053] The decision execution module makes various decisions, such as traffic restriction or road maintenance, based on the processed information and relevant forecasts.
[0054] The present invention has the following beneficial effects:
[0055] I. This invention takes various traffic flows, road shapes, and driving routes as inputs, and can obtain the necessary information on the traffic of the entire city, making decisions that take into account the important low-end traffic control of ground traffic. This enables the decision to efficiently plan travel routes while ensuring traffic safety intervals and making full use of traffic road resources.
[0056] Second, we proposed the Temporal Convolutional Network (TCNx), which utilizes the diffusing convolution module to improve the perception range of time series spans within a limited number of layers. By utilizing the GRN (Gated Residual Network) within it, we can perceive the inherent connections of time information with fewer iterations, reduce the learning of erroneous information, improve the distinction between different time periods, and effectively filter and learn effective information.
[0057] Third, an adaptive graph convolution learning approach is proposed. This approach, building upon the original graph convolution, perceives information beyond the original adjacency matrix and learns a different adjacency matrix representation. Through layer stacking, it can deeply uncover the intrinsic connections related to spatial dimensions, improving the model's predictive ability and facilitating long-term time series forecasting. It extracts useful spatial information based on the topological graph.
[0058] Fourth, we propose the spaceblock block layer network, which can more effectively discover effective information on top of adaptive graph convolutional learning, improve the underfitting of the overall model, strengthen the overall training intensity of the model, and improve the effective learning of feature dimensions, especially spatial dimensions, by using the self-attention mechanism, discover the correlation between data, aggregate new learning expressions that were not originally in the data, and enhance the overall expression and application capabilities of the model.
[0059] V. Experiments show that this invention can predict effective changes in traffic flow in practical traffic flow prediction applications, and can assist traffic flow managers in providing reference and safety risk assessment for the current traffic flow situation. Attached Figure Description
[0060] Figure 1 This is a flowchart illustrating the overall invention method;
[0061] Figure 2 This is the model design architecture diagram of this method;
[0062] Figure 3This is an explanatory diagram of the TCNx module in the model;
[0063] Figure 4 This is a diagram explaining the principle of the GRN module;
[0064] Figure 5 This is a diagram illustrating the multi-head attention mechanism. Detailed Implementation
[0065] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. 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.
[0066] The present invention provides a traffic flow prediction method based on spatiotemporal sequence deep learning, comprising:
[0067] Step S1: Obtain traffic data collected by sensors at traffic stations to obtain the shape of the road to be predicted;
[0068] Step S2: Preprocess the historical traffic flow data according to the relevant time association order, and further organize it into tensor form in batch form to construct a multivariate spatiotemporal sequence dataset of traffic flow data;
[0069] The collected data is imputed for outliers and missing values. Each data point is used to predict the output for the next hour based on the historical records for the past hour. The batch size is set to 50 to represent the tensor.
[0070] Step S3: Divide the multivariate spatiotemporal sequence dataset into a training dataset, a validation dataset, and a test dataset, and standardize the data in each dataset according to each attribute of the sample.
[0071] The dataset x is divided into training, validation, and test sets in a 7:2:1 ratio. Standardization is achieved by calculating the mean μ and variance σ for each sample attribute, and then using the Z-score formula to obtain the new dataset x'.
[0072]
[0073] The training set is input into the traffic flow prediction model to make predictions and obtain predicted values through the following steps;
[0074] Step S4: Input this multivariate spatiotemporal sequence dataset into a convolutional network layer with a kernel of 1×1 and the number of channels of embed_size to enrich the semantics of the input tensor;
[0075] Step S5: Input the data into TCNx (Temporal Convolutional Network Layer) to obtain the hidden states related to time. The TCNx layer consists of a temporal embedding layer, a temporal MLP layer, a dilated convolutional layer, and a GRN layer;
[0076] Step S51: The unique time information is added to the input data through embedding to enhance the time information;
[0077] For the Embedding layer, it is to take a t∈R T The vector constructed from {0,1,…,T-1} is input into the Embedding network layer to obtain a t'∈R T×C A tensor, where C represents the number of attributes or channels, is finally broadcast to obtain t”∈R B ×N×T×C B represents the number of batches, and N represents the number of nodes in the adjacency matrix;
[0078] Step S52: Expand the time dimension using the temporal MLP layer to facilitate subsequent diffusing convolution operations, and then input the result into the diffusing convolution layer;
[0079] The formula for the first-order spread convolution F in the above step is as follows on a 1-D sequence:
[0080]
[0081] In this formula: X∈R T This represents the input data; f∈R k Let f(t) represent a convolution kernel; f(t) represent the kernel parameters at time t; X(i) represent the value of X at position i; d represents the diffusion factor of the spread convolution; k represents the overall size of the convolution kernel.
[0082] The overall formula for diffuse causal convolution is:
[0083] h=tanh(Θ1*X+b)⊙σ(Θ2*X+c)
[0084] In this formula: tanh represents the tanh activation function; σ represents the sigmoid activation function; Θ1, Θ2, b, and c all represent the parameters that the model needs to learn; Θ*X represents the diffusion convolution operation performed on the 4-D sequence; ⊙ represents the Hadamard product;
[0085] Step S53: Input the obtained result h into the GRN (Gated Residual Network) layer to filter out useless information;
[0086] The overall formula for the GRN network representation mentioned in the steps is as follows:
[0087] GRN(a)=Dropout(LayerNorm(a+GLU(η1)))
[0088] η1=W1η2+b1
[0089] η2=ELU(W2a+b2)
[0090] GLU(γ)=σ(W3γ+b3)⊙(W4γ+b4)
[0091] In this formula: a and γ represent the inputs of their respective networks; W1, W2, W3, W4, b1, b2, b3, and b4 represent the parameters that the network model needs to learn; ⊙ represents the Hadamard product; and ELU represents the ELU activation function.
[0092] Step S54: Repeat steps S52 to S53, and perform a 1×1 convolution on the output of each S52 and accumulate the results.
[0093] Step S55: Add the results of step S54 and step S52 together and pass them through a LayerNorm layer to obtain the overall output of the TCNx layer;
[0094] Step S6: Input the data into a constructed spaceblock layer, which mainly consists of three parts: the first part is an adaptive graph convolutional network layer based on Chebyshev's formula, the second part is a multi-head attention layer based on self-attention mechanism, and the third part is a GRN layer for filtering information.
[0095] Step S61: After standardizing the adjacency matrix, input it together with the input data into the adaptive graph convolutional network layer;
[0096] The standardization formula for the adjacency matrix is as follows:
[0097] D ii =∑ i A ij for i=1,...,N
[0098]
[0099]
[0100] In the above formula: A represents the initial adjacency matrix, D represents the diagonal matrix; I N λ represents an identity matrix of length N; MAX This represents the largest eigenvalue in matrix A;
[0101] The formula for an adaptive graph convolutional network layer is as follows:
[0102] The Chebyshev polynomial is:
[0103] T0(x)=1
[0104] T1(x)=x
[0105] T n (x)=2xT n-1 -T n-2
[0106] The formula for graph convolution is:
[0107]
[0108] In the formula: Θ i This represents the parameters to be learned;
[0109] The adaptive nature is reflected in the input graph convolutional network. A matrix is not just... We also need to add an adaptive adjacency matrix that needs to be learned, as shown in the following formula:
[0110]
[0111] Where: E1, E2∈R N×C C represents the size of the parameter that needs to be learned;
[0112] Step S62: Input a GRN network layer;
[0113] Step S63: Input the multi-head attention layer based on the self-attention mechanism and add the result and output of S62 into a LayerNorm layer and a Dropout layer respectively;
[0114] The multi-head self-attention mechanism layer formula for step S63 is expressed as follows:
[0115] The formula for the attention mechanism is:
[0116]
[0117] In this formula: Q, K, V represent different tensors, d k This indicates the size of the attribute dimension of K;
[0118] MlutiHead(Q,K,V)=Concat(head1,…,head h W o
[0119] where head i =Attention(QW i Q ,KW iK VW i V )
[0120] In the above formula: and Both represent the parameters that need to be learned. Concat means concatenating the vectors. Self-attention means that at the input, K = Q = V = X.
[0121] Step S64: Input the data into another GRN network layer, and add the result and output of S61 together and then input them into a LayerNorm layer and a Dropout layer.
[0122] Step S7: Repeat step S6 multiple times, and repeatedly activate with the ReLU function;
[0123] Step S8: Add the results of step S6 and step S5 together and input them into a LayerNorm layer;
[0124] Step S9: Input the data into a TCNx layer again, and add the results and output items of S3 to a LayerNorm layer;
[0125] Step S10: Repeat steps S5 to S9, and repeatedly activate with the ReLU function;
[0126] Step S11: Feed the obtained data results into two well-designed convolutional layers to achieve dimensionality reduction and reduce sample attributes;
[0127] The two convolutional layer designs are as follows:
[0128]
[0129] The internal convolution is a 1×1 convolution kernel that treats the time dimension as a convolution of the number of channels to obtain the required output time window dimension.
[0130] The outer convolution is also a 1×1 convolution kernel, which treats the attribute dimension as the number of channels and is used to reconstruct and predict future values.
[0131] Step S12: Set the relevant loss function Loss and iteratively update and train the prediction model until the training conditions are terminated, generating a trained prediction model that can be used to predict future time series values.
[0132] The loss function is set to MSE, and the formula is as follows:
[0133]
[0134] Where: n represents the number of samples, Y represents the predicted value.i Represents the actual value;
[0135] Step S13: Collect traffic flow data at the current moment, input the collected traffic flow data at the current moment into the trained traffic flow prediction model, and predict the time series value at future moments.
[0136] In step S12, the evaluation metric for the validation set is set to MSE and the Adam optimizer is used for training, with a learning rate of 1e-3 and a weight decay of 1e-3.
[0137] Simulation Experiment
[0138] To verify the effectiveness of a traffic flow prediction method based on spatiotemporal sequence deep learning, multivariate spatiotemporal sequence prediction experiments were conducted using real datasets. The experimental environment employed Python and the PyTorch deep learning framework. Furthermore, this method will be compared with methods such as HA, ARIMA, LSVR, FNN, FC-LSTM, DCRNN, STGCN, GraphWaveNet, and STTN. A brief description of these methods is as follows:
[0139] HA (Historical Average) models traffic flow as a seasonal process and uses a weighted average of the previous few seasons as a forecast. It is a classic method for time series forecasting.
[0140] ARIMA: Autoregressive Integrated Moving Average Model with Kalman Filtering, is a classic method for time series forecasting in the field of traditional machine learning and is widely used in time series forecasting.
[0141] LSVR: Linear Support Vector Machine Regression, a traditional machine learning task that uses linear support vector machines for regression tasks. It had wide applications during the period when support vector machines were popular.
[0142] FNN: A feedforward neural network with two hidden layers and L2 regularization.
[0143] FC-LSTM: A recurrent neural network with fully connected LSTM hidden units (FC-LSTM).
[0144] DCRNN: DCRNN employs bidirectional random walks and spatial dependencies between the encoder and decoder, and uses a scheduling algorithm.
[0145] Graph WaveNet: Graph WaveNet incorporates an adaptive adjacency matrix into graph convolutions and employs a dilated diffusion convolution structure to extract effective information.
[0146] STTN: STTN is based on module design in two directions: time model learning and spatial model learning. Specifically, it adopts attention mechanism as the main architecture to extract the effective value of long-term learning.
[0147] RMSE, RAE, and MAPE are used as analytical indicators of model error to evaluate the predictive performance of various methods. The formulas for calculating the error indicators are shown below:
[0148] Relative square root error:
[0149]
[0150] Where: n represents the number of samples, Y represents the predicted value. i Represents the actual value;
[0151] Relative absolute error:
[0152]
[0153] Where: n represents the number of samples, Y represents the predicted value. i Represents the actual value;
[0154] Mean absolute percentage error:
[0155]
[0156] Where: n represents the number of samples, Y represents the predicted value. i Represents the actual value;
[0157] Example 1
[0158] The experimental data came from the PeMSD7(M) traffic dataset of 228 sensor stations on the California Highway System during weekdays from May to June 2012. This dataset, sampled at a 5-minute frequency, includes traffic speed as a feature. Data for the next hour was predicted using historical 1-hour windows. Data from the 15th, 30th, and 45th minutes were compared. RMSE, RAE, and MAPE were used as evaluation metrics. The experimental results are shown in Table 1.
[0159] Table 1
[0160]
[0161]
[0162] An electronic device includes at least one processor and a memory communicatively connected to the at least one processor; the memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to perform the aforementioned traffic flow prediction method based on spatiotemporal sequence deep learning.
[0163] A traffic flow decision-making device based on traffic flow collection and deep learning, comprising:
[0164] The traffic flow sensing and collection module is used to collect relevant information for traffic flow prediction. It utilizes low-cost storage technology and efficient collection devices to collect factors such as vehicle congestion flow, road shape, or average vehicle speed.
[0165] The information flow processing module is used to preprocess, predict, and fuse traffic-related flow information such as average vehicle speed, as well as road shape and driving route information.
[0166] Traffic flow prediction model, used to predict time series values of future traffic flow based on a spatiotemporal sequence deep learning-based traffic flow prediction method;
[0167] The decision execution module makes various decisions, such as traffic restriction or road maintenance, based on the processed information and relevant forecasts.
[0168] The above description is not intended to limit the present invention in any way. Although the present invention has been disclosed through the above embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some changes or modifications to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the present invention shall still fall within the scope of the present invention.
Claims
1. A traffic flow prediction method based on spatiotemporal sequence deep learning, characterized in that, include: Obtain historical data on road shape and traffic flow. Historical traffic flow data is preprocessed according to the relevant time association order, and further organized into tensors in batch form to construct a multivariate spatiotemporal sequence dataset of historical traffic flow data. The multivariate spatiotemporal sequence dataset is divided into a training dataset, a validation dataset, and a test dataset, and the data in these datasets are standardized according to each attribute of the samples. A traffic flow prediction model is constructed. The traffic flow prediction model includes a convolutional network layer, a temporal convolutional network layer, a space block layer, a Layer Norm layer, a temporal convolutional network layer, a Layer Norm layer, and two convolutional layers. The temporal convolutional network layer consists of a temporal embedding layer, a temporal MLP layer, a dilated convolutional layer, and a GRN layer. The space block layer consists of three parts: the first part is an adaptive graph convolutional network layer based on Chebyshev's formula; the second part is a multi-head attention layer based on a self-attention mechanism; and the third part is a GRN layer that filters information. The traffic flow prediction model was trained using the training dataset; The training steps of the traffic flow prediction model are as follows: The training dataset is used as input to the traffic flow prediction model for prediction. The traffic flow prediction model is iteratively updated and trained by setting a loss function Loss until the training conditions are terminated, generating a trained traffic flow prediction model that can be used to predict time series values for future moments. Using the training dataset as input, and feeding it into the traffic flow prediction model for prediction includes: S1. Input the training dataset into a convolutional network layer with a kernel of 1×1 and the number of channels of embed_size to enrich the semantics of the input tensor; S2. Input the data into the temporal convolutional network layer to obtain the time-related hidden state; S21. The unique time information is added to the input data through the time embedding layer to enhance the time information; S22. Expand the time dimension using the temporal MLP layer to facilitate subsequent diffusing convolution operations, and then input the result into the diffusing convolution layer. S23. Input the obtained results into the GRN layer to filter out useless information; S24. Repeat steps S22-S23, and perform a convolution on the output of each step S22 and accumulate the results. S25. Add the results of step S24 and step S22 and pass them through a LayerNorm layer to obtain the overall output of the temporal convolutional network layer; S3. Input the data into a constructed spaceblock layer; S31. After standardizing the adjacency matrix, input it together with the input data into the adaptive graph convolutional network layer; S32. Input a GRN network layer; S33. Input the multi-head attention layer based on the self-attention mechanism and add the result and output of step S32 into a LayerNorm layer and a Dropout layer respectively; S34. Input it into another GRN network layer again, and add the result and output of step S31 into a LayerNorm layer and a Dropout layer respectively; S4. Repeat step S2 multiple times, and repeatedly activate it with the ReLU function; S5. Add the results of step S3 and step S2 and input them into a LayerNorm layer; S6. Input the data again into a temporal convolutional network layer, and add the result and output of step S1 to a LayerNorm layer; S7. Repeat steps S2-S6, and repeatedly activate with the ReLU function; S8. The obtained data results are fed into two convolutional layers to achieve dimensionality reduction and reduce the number of sample attributes; The system collects traffic flow data at the current moment and inputs it into a trained traffic flow prediction model to predict time series values for future moments.
2. The traffic flow prediction method based on spatiotemporal sequence deep learning according to claim 1, characterized in that, The historical traffic flow data is obtained through sensors at traffic stations.
3. The traffic flow prediction method based on spatiotemporal sequence deep learning according to claim 1, characterized in that, The preprocessing includes error correction for outliers and missing values.
4. The traffic flow prediction method based on spatiotemporal sequence deep learning according to claim 1, characterized in that, The standardization method involves calculating the mean for each sample attribute. and variance The new dataset is obtained by calculating according to the Z-score formula. .
5. The traffic flow prediction method based on spatiotemporal sequence deep learning according to claim 1, characterized in that, The normalization formula for the adjacency matrix is: In the formula: A This represents the initial adjacency matrix. D Represents a diagonal matrix; Represents an identity matrix of length N; express A The largest eigenvalue in the matrix.
6. The traffic flow prediction method based on spatiotemporal sequence deep learning according to claim 1, characterized in that, The design scheme for the two convolutional layers is as follows: Its internal convolution is a 1×1 convolution kernel that treats the time dimension as a convolution of the number of channels to obtain the required output time window dimension; The outer convolution is also a 1×1 convolution kernel that treats the attribute dimension as the number of channels, used to reconstruct and predict future values.
7. An electronic device, characterized in that, The device includes at least one processor and a memory communicatively connected to the at least one processor; the memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to perform a traffic flow prediction method based on spatiotemporal sequence deep learning as described in any one of claims 1 to 6.
8. A traffic processing flow decision-making device based on traffic flow collection and deep learning, characterized in that, include: Traffic flow sensing and collection module is used to collect relevant information for traffic flow prediction. It uses low-cost storage technology and efficient collection devices to collect data on vehicle congestion flow, road shape, or average vehicle speed. The information flow processing module is used to preprocess and predict and fuse information on average vehicle speed, road shape, and driving route. Traffic flow prediction model, used to predict time series values of future moments based on a traffic flow prediction method based on spatiotemporal sequence deep learning as described in any one of claims 1-6; The decision execution module makes decisions on traffic control or road maintenance based on the processed information and relevant forecasts.
Citation Information
Patent Citations
Vehicle flow prediction method combining attention mechanism and dynamic space-time convolution model
CN114299728A
Traffic sequence prediction method based on multivariate time series data analysis
CN115713155A