Urban traffic flow prediction method and system based on time sequence deep learning
By introducing a spatiotemporal attention mechanism and an adaptive graph generation mechanism in traffic flow prediction, the spatiotemporal graph convolution network is improved, and the problems of insufficient dynamic spatial relationship capture and insufficient fusion of spatiotemporal features in the existing technology are solved, thereby achieving high-precision traffic flow prediction.
Patent Information
- Application Number
- CN202510637975.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-19
- Publication Date
- 2025-06-17
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing traffic flow prediction method based on spatiotemporal graph convolutional network (STGCN) is difficult to capture the insufficient fusion of dynamic spatial relationships and spatial characteristics, resulting in insufficient prediction accuracy.
The improved spatiotemporal graph convolution network is adopted, which combines the spatiotemporal attention mechanism and the adaptive graph generation mechanism, and dynamically adjusts the spatiotemporal weights and road network topology, and builds static and dynamic adjacency matrices to improve the accuracy of traffic flow prediction.
It realizes high-precision traffic flow prediction in a dynamic road network environment, dynamically adjusts the importance of space-time and space dependence intensity, and enhances the model's modeling ability of complex traffic scenarios.
Smart Images

Figure CN120162555A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent transportation, and more specifically, to an urban traffic flow prediction method and system based on temporal deep learning. Background Art
[0002] With the improvement of the urbanization rate, people's living standards have become better and better, and the ownership of cars has also been continuously increasing. In daily work and life, car travel has gradually become the first choice for people, which has led to traffic congestion during the commuting peak hours, seriously affecting the travel efficiency and quality. Therefore, road traffic problems have attracted more and more attention from all sectors of society. With the development of informatization and intelligence, intelligent transportation systems have become a new means to solve road traffic problems, and the accuracy of traffic flow directly affects the effectiveness of intelligent transportation systems.
[0003] In the prior art, the traffic flow prediction method based on the spatio-temporal graph convolutional network (STGCN) mainly relies on static road network topology to model spatio-temporal dependence relationships, but there are the following defects in the prior art:
[0004] The static adjacency matrix cannot capture dynamic spatial relationships (such as road network changes caused by temporary construction and emergencies); the spatio-temporal feature fusion is insufficient, and the traditional method has fixed attention allocation for the time and space dimensions and is difficult to dynamically adjust the importance of different time periods and different road sections.
[0005] Therefore, how to improve the accuracy of traffic flow prediction is an urgent problem to be solved by those skilled in the art. Summary of the Invention
[0006] In view of this, the present invention provides an urban traffic flow prediction method and system based on temporal deep learning, which is an urban traffic flow prediction method and system combining the spatio-temporal graph convolutional network (STGCN), the spatio-temporal attention mechanism and the adaptive graph generation mechanism, and is applicable to short-term traffic flow prediction and optimization in a dynamic road network environment.
[0007] In order to achieve the above object, the present invention adopts the following technical solutions:
[0008] An urban traffic flow prediction method based on temporal deep learning, comprising the following steps:
[0009] Step 1: Collect traffic flow data and road network topology, and perform preprocessing;
[0010] Step 2: Construct a static adjacency matrix and a dynamic adjacency matrix according to the preprocessed traffic flow data and road network topology;
[0011] Step 3: Calculate spatio-temporal attention weights according to the preprocessed traffic flow data by using the spatio-temporal attention mechanism;
[0012] Step 4: According to the static adjacency matrix, dynamic adjacency matrix, and spatio-temporal attention weights, an improved spatio-temporal graph convolutional network is used to predict and output future traffic flow.
[0013] Preferably, the preprocessing method in Step 1 includes denoising, outlier removal, data filling, and data augmentation, etc.
[0014] Preferably, constructing the static adjacency matrix according to traffic flow data and road network topology in Step 2 includes the following steps:
[0015] Step 211: Calculate the distance between nodes according to the road network topology, and construct a distance weight matrix through a preset distance threshold Gaussian kernel. Construct a static distance adjacency matrix according to the distance weight matrix , the distance weight matrix is expressed as:
[0016] ;
[0017] Among them, represents the weight of the edge between node and node ; represents the distance between node and node ; represents the standard deviation; q represents the distance threshold;
[0018] Step 212: Calculate the Pearson correlation coefficient between nodes according to traffic flow data , and construct a static similarity adjacency matrix according to the Pearson correlation coefficient ; The Pearson correlation coefficient between nodes is expressed as:
[0019] ;
[0020] Among them, and respectively represent the observed values of node X and node Y at the i-th time step; and are the average values of the observed values of node X and node Y respectively;
[0021] Step 213: Stack the static distance adjacency matrix and the static similarity adjacency matrix, and obtain the static adjacency matrix after max-pooling operation , expressed as:
[0022] ;
[0023] Among them, MaxPool represents the max-pooling operation; Stack represents the Stack stacking.
[0024] Preferably, a dynamic adjacency matrix is constructed based on traffic flow data , expressed as:
[0025] ;
[0026] where E1 and E2 respectively represent two nodes with learnable parameters randomly initialized in the traffic flow data , represents the set of real numbers, N represents the number of nodes, C represents the feature dimension; T represents transpose; ReLU represents the rectified linear activation function; Softmax represents the normalization activation function. The spatial dependence weight between the embedded source node and the target node is derived by multiplying the two nodes; the ReLU activation function eliminates the weak connections between the spatial dependencies; the Softmax activation function normalizes the data.
[0027] Preferably, the spatio-temporal attention weight includes a temporal attention weight and a spatial attention weight , expressed as:
[0028] ;
[0029] ;
[0030] where represents the learnable temporal weight matrix; represents the feature at time step t; represents the feature at time step ; [ ] represents the concatenation operation; represents the spatial attention weight of the d-th feature; a represents the attention vector; T represents transpose; represents the d-th feature of node i, represents the d-th feature of node j; W represents the learnable spatial weight matrix; Softmax represents the normalization activation function; LeakyReLU represents the leaky rectified linear activation function.
[0031] Preferably, the improved spatio-temporal graph convolutional network includes an input layer, a diffusion convolutional layer, a gated temporal convolutional layer, and a fully connected layer connected in sequence; the input layer adjusts the traffic flow data, the static adjacency matrix, and the dynamic adjacency matrix according to the spatio-temporal attention weight; the diffusion convolutional layer captures the spatial propagation law between nodes in the road network topology, performs spatial dimension modeling, and obtains spatial features; the gated temporal convolutional layer captures the long-term dependence relationship of the traffic flow data in the time dimension, performs time dimension modeling, and obtains time features; the fully connected layer performs feature integration and prediction mapping on the spatial features and the time features, and outputs the future traffic flow.
[0032] Preferably, the input layer obtains the original temporal feature H after preprocessing the traffic flow data according to the temporal attention weight raw to perform adjustment in the time dimension, and dynamically adjusts the propagation weights between nodes in the static adjacency matrix and the dynamic adjacency matrix according to the spatial attention weight;
[0033] Multiply the temporal attention weight by the original temporal feature H obtained after preprocessing the traffic flow data raw to obtain the temporally weighted feature H time-attn ; It is expressed as:
[0034] ;
[0035] Combine the spatial attention weight with the static adjacency matrix and the dynamic adjacency matrix to generate the dynamically adjusted spatial propagation weight; It is expressed as:
[0036] ;
[0037] where represents the spatial propagation weight between node i and node j.
[0038] Preferably, the diffusion convolutional layer uses diffusion convolution to perform K-hop diffusion on the spatial propagation weight to obtain the spatial feature of each node , It is expressed as:
[0039] ;
[0040] where represents the k-th power of the spatial propagation weight; represents the convolutional kernel parameter of the k-th hop.
[0041] Preferably, the gated temporal convolutional layer sequentially performs causal convolution and gated temporal convolution on the temporal feature of each node to obtain the temporal feature , It is expressed as:
[0042] ;
[0043] where GLU represents gated temporal convolution; Conv1D represents causal convolution.
[0044] Preferably, the mean square error and the dynamic adjacency matrix regularization term are used to construct the loss function to train and optimize the improved spatio-temporal graph convolutional network, and step 4 uses the trained improved spatio-temporal graph convolutional network for prediction; The loss function is expressed as:
[0045] ;
[0046] where MSE represents the mean square error; Y represents the actual traffic flow; represents the predicted future traffic flow; represents the regularization coefficient, ; represents the regularization calculation.
[0047] Preferably, in step 2, based on the real-time traffic flow data, an adaptive graph generation network (GAT variant) can also be used to dynamically adjust the adjacency weights of the static adjacency matrix to obtain a dynamic adjacency matrix.
[0048] Preferably, after improving the fully connected layer of the spatio-temporal graph convolutional network, a random Dropout layer is introduced, and the Bayesian deep learning framework is realized through Monte Carlo Dropout; the randomness of Dropout is retained during the training stage of the improved spatio-temporal graph convolutional network, and during the testing stage, through multiple forward propagation samplings, the mean and variance of multiple groups of prediction results are respectively used as the final prediction value and the uncertainty measure, and the formula is expressed as:
[0049]
[0050] where, T represents the number of samplings; represents the final prediction value; is the prediction result of the t-th forward inference; is the prediction variance.
[0051] Preferably, after improving the fully connected layer of the spatio-temporal graph convolutional network, an interpretability module is added, and based on the SHAP value, the contribution degrees of each time feature and space feature to the predicted future traffic flow are quantified to obtain an interpretability heat map; the interpretability module includes the following steps:
[0052] Step 41: Sample the time features and space features input to the fully connected layer to generate a feature perturbation data set;
[0053] Step 42: Use the SHAP kernel function to calculate the marginal contribution of each feature in the feature perturbation data set in the prediction to generate feature importance weights;
[0054] Step 43: Map the feature importance weights to the spatio-temporal dimension and output the interpretability heat map.
[0055] A city traffic flow prediction system based on temporal deep learning includes a preprocessing module, an adaptive graph generation module, a spatio-temporal attention module, and a spatio-temporal graph convolutional prediction module;
[0056] The preprocessing module collects traffic flow data and road network topologies and performs preprocessing;
[0057] The adaptive graph generation module constructs a static adjacency matrix and a dynamic adjacency matrix according to the preprocessed traffic flow data and road network topologies;
[0058] The spatio-temporal attention module calculates spatio-temporal attention weights using the spatio-temporal attention mechanism based on the preprocessed traffic flow data;
[0059] The spatio-temporal graph convolution prediction module predicts the future traffic flow output using an improved spatio-temporal graph convolutional network based on the static adjacency matrix, dynamic adjacency matrix, and spatio-temporal attention weights.
[0060] As can be seen from the above technical solutions, compared with the prior art, the present invention discloses a method and system for predicting urban traffic flow based on temporal deep learning, which adopts a spatio-temporal graph convolutional network integrating the spatio-temporal attention mechanism and the adaptive graph generation mechanism. By dynamically adjusting the spatio-temporal weights and road network topology, high-precision traffic flow prediction is achieved. Among them, the spatio-temporal attention mechanism is used to improve the input feature preprocessing of the spatio-temporal graph convolutional network (improved STGCN). The temporal attention weights can dynamically adjust the importance of different time steps, and the spatial attention weights can dynamically adjust the spatial dependence strength between nodes (road segments), dynamically screening key spatio-temporal information, highlighting key information, suppressing noise, and enhancing the network model's ability to model important time periods and key regions; an adaptive dynamic connection matrix is generated, and the spatial correlation is modeled by combining the static graph structure and the adaptive dynamic graph structure, enabling the network to capture the hidden spatial dependence relationships between different nodes at different times while considering the inherent structure of the road; the improved spatio-temporal graph convolutional network combines the static and dynamic adjacency matrices, uses diffusion convolution and gated temporal convolution to model spatio-temporal dependence, and the spatio-temporal attention mechanism directly serves the improved spatio-temporal graph convolutional network. By dynamically adjusting the spatio-temporal weights of the input features, the model's ability to model complex traffic scenarios is improved, the attention mechanism and dynamic graph generation are deeply integrated, breaking through the limitations of traditional static models and solving the problem of poor adaptability of static models to dynamic scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained according to the provided drawings without creative efforts.
[0062] Figure 1 It is a schematic flowchart of a method for predicting urban traffic flow based on temporal deep learning provided by the present invention;
[0063] Figure 2 It is a schematic structural diagram of a system for predicting urban traffic flow based on temporal deep learning provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0064] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0065] An embodiment of the present invention discloses a method for predicting urban traffic flow based on temporal and spatial deep learning, as Figure 1 shown, which includes the following steps:
[0066] S1: Collect traffic flow data and road network topology, and perform preprocessing;
[0067] S2: Construct a static adjacency matrix and a dynamic adjacency matrix according to the preprocessed traffic flow data and road network topology;
[0068] S3: Calculate the spatio-temporal attention weights using the spatio-temporal attention mechanism according to the preprocessed traffic flow data;
[0069] S4: Predict the future traffic flow output using an improved spatio-temporal graph convolutional network according to the static adjacency matrix, dynamic adjacency matrix and spatio-temporal attention weights.
[0070] Furthermore, the traffic flow data includes the number of vehicle passages, average vehicle speed, road capacity utilization rate, congestion index, vehicle type distribution, sampling interval, etc. Sampling interval: Collect real-time data at a fixed time granularity; Number of vehicle passages: The number of vehicles passing through the monitoring node per unit time; Average speed: The average driving speed of vehicles on the road section covered by the monitoring node; Congestion index: A coefficient calculated based on the ratio of road section capacity to actual traffic flow, ranging from 0 to 1, where 0 indicates smooth traffic and 1 indicates severe congestion; Road capacity utilization rate: The ratio of the current traffic flow to the maximum capacity of the road section; Vehicle type distribution: The proportion of different vehicle types.
[0071] Furthermore, the preprocessing methods include denoising, outlier removal, data filling, and data augmentation, etc. Sliding average, wavelet transform, and low-pass filter can be selected for denoising; Statistical methods and clustering methods can be selected for outlier removal; Linear interpolation, neighboring node interpolation, and LSTM model interpolation can be selected for data filling; Window sliding and road section masking can be selected for data augmentation.
[0072] Furthermore, the preprocessing method further includes multi-index normalization, spatio-temporal alignment, and feature fusion; multi-index normalization: perform Min-Max normalization or Z-Score standardization on heterogeneous indices (such as traffic flow and speed) respectively to eliminate the dimension difference; spatio-temporal alignment: ensure that the data timestamps of different sensors correspond one-to-one with the spatial nodes, and fill in the missing values through spatio-temporal interpolation; feature fusion: splice the multi-index data along the feature dimension to form a three-dimensional tensor for input.
[0073] Furthermore, in S2, constructing a static adjacency matrix according to the traffic flow data and the road network topology includes the following steps:
[0074] S211: Calculate the distances between nodes according to the road network topology, and construct a distance weight matrix through a preset distance threshold Gaussian kernel, and construct a static distance adjacency matrix according to the distance weight matrix , and the distance weight matrix is expressed as:
[0075] ;
[0076] Among them, represents the weight of the edge between node and node ; represents the distance between node and node ; represents the standard deviation; q represents the distance threshold;
[0077] S212: Calculate the Pearson correlation coefficient between nodes according to the traffic flow data , and construct a static similarity adjacency matrix according to the Pearson correlation coefficient ; the Pearson correlation coefficient between nodes is expressed as:
[0078] ;
[0079] Among them, and respectively represent the observed values of node X and node Y at the i-th time step; and are respectively the average values of the observed values of node X and node Y;
[0080] S213: Stack the static distance adjacency matrix and the static similarity adjacency matrix, and obtain the static adjacency matrix after performing a max pooling operation , which is expressed as:
[0081] ;
[0082] Among them, MaxPool represents the max pooling operation; Stack represents the Stack stacking.
[0083] Furthermore, a dynamic adjacency matrix is constructed based on traffic flow data , which is expressed as:
[0084] ;
[0085] Among them, E1 and E2 respectively represent two randomly initialized nodes with learnable parameters in the traffic flow data , represents the set of real numbers, N represents the number of nodes, C represents the feature dimension; ReLU represents the rectified linear activation function; Softmax represents the normalization activation function. The spatial dependence weight between the embedded source node and the target node is derived by multiplying the two nodes; the ReLU activation function eliminates the weak connections between the spatial dependencies; the Softmax activation function normalizes the data. By randomly initializing two nodes with learnable parameters, the embedding dictionary realizes an adaptive adjacency matrix and performs stochastic gradient descent learning, so that the adjacency matrix does not require any prior knowledge and can generate hidden spatial dependence relationships based on the training data.
[0086] Furthermore, the spatio-temporal attention weight includes the temporal attention weight and the spatial attention weight , which is expressed as:
[0087] ;
[0088] ;
[0089] Among them, represents the learnable temporal weight matrix; represents the feature at time step t; represents the time step of the feature; [ ] represents the concatenation operation; represents the spatial attention weight of the d-th feature; a represents the attention vector; T represents the transpose; represents the d-th feature of node i, represents the d-th feature of node j; W represents the learnable spatial weight matrix; Softmax represents the normalization activation function; LeakyReLU represents the leaky rectified linear activation function.
[0090] Furthermore, the improved spatio-temporal graph convolutional network includes an input layer, a diffusion convolutional layer, a gated temporal convolutional layer, and a fully connected layer connected in sequence; the input layer adjusts traffic flow data, a static adjacency matrix, and a dynamic adjacency matrix according to spatio-temporal attention weights; the diffusion convolutional layer captures the spatial propagation law between nodes in the road network topology, performs spatial dimension modeling, and obtains spatial features; the gated temporal convolutional layer captures the long-term dependence relationship of traffic flow data in the time dimension, and at the same time filters out irrelevant information through a gating mechanism, enhances the model's attention to important time features, performs time dimension modeling, and obtains time features; the fully connected layer performs feature integration and prediction mapping on spatial features and time features, and outputs future traffic flow.
[0091] Furthermore, the input layer adjusts the original temporal features H obtained after preprocessing the traffic flow data according to the time attention weight raw in the time dimension, and dynamically adjusts the propagation weights between nodes in the static adjacency matrix and the dynamic adjacency matrix according to the spatial attention weight;
[0092] Multiply the time attention weight by the original temporal features H obtained after preprocessing the traffic flow data raw to obtain the time-weighted features H time-attn ; It is expressed as:
[0093] ;
[0094] Combine the spatial attention weight with the static adjacency matrix and the dynamic adjacency matrix to generate the dynamically adjusted spatial propagation weight; It is expressed as:
[0095] ;
[0096] Among them, represents the spatial propagation weight between node i and node j.
[0097] Furthermore, the diffusion convolutional layer uses diffusion convolution (multi-hop propagation) to perform K-hop diffusion (K-hop) on the spatial propagation weight to obtain the spatial features of each node , It is expressed as:
[0098] ;
[0099] Among them, represents the k-th power of the spatial propagation weight; represents the convolutional kernel parameter of the k-th hop; K represents the number of diffusion hops.
[0100] Furthermore, the gated temporal convolutional layer performs causal convolution and gated temporal convolution on the temporal features of each node in sequence to obtain the time features , It is expressed as:
[0101] ;
[0102] Among them, GLU represents gated temporal convolution; Conv1D represents causal convolution. A gating mechanism is introduced to filter redundant information.
[0103] Furthermore, the mean square error and the dynamic adjacency matrix regularization term are used to construct the loss function, and the improved spatio-temporal graph convolutional network is trained and optimized. S4 uses the trained improved spatio-temporal graph convolutional network for prediction; the loss function is expressed as:
[0104] ;
[0105] Among them, MSE represents the mean square error; Y represents the actual traffic flow; represents the predicted future traffic flow; represents the regularization coefficient, ; represents the regularization calculation.
[0106] Furthermore, a random Dropout layer is added after the fully connected layer of the improved spatio-temporal graph convolutional network. During training, the Dropout probability is set to p = 0.2 and kept active to learn the uncertainty; during testing, through T = 50 random Dropout forward propagations, multiple sets of prediction results are generated, and the mean and variance are calculated. The mean and variance of the multiple sets of prediction results are used as the final prediction value and the uncertainty measure respectively, expressed as:
[0107]
[0108] Y
[0109] Among them, T represents the number of sampling times; represents the final prediction value; is the prediction result of the t-th forward inference; is the prediction variance; Y represents the future traffic flow; k represents the confidence level coefficient, and the default value is 2 (95% confidence interval).
[0110] Furthermore, an interpretability module is added after the fully connected layer of the improved spatio-temporal graph convolutional network to quantify the contribution degree of each time feature and space feature to the prediction result based on the SHAP value; the interpretability module specifically includes the following steps:
[0111] Step 41: Sample the time features and space features input to the fully connected layer to generate a feature perturbation data set;
[0112] Step 42: Use the SHAP kernel function to calculate the marginal contribution of each feature in the feature perturbation data set to the prediction, and generate the feature importance weights;
[0113] Step 43: Map the feature importance weights to the spatio-temporal dimension and output the interpretable heatmaps at the node level, time level, and metric level.
[0114] Furthermore, based on the real-time traffic flow data in S2, an adaptive graph generation network (a variant of GAT) can also be used to dynamically adjust the adjacency weights of the static adjacency matrix to obtain a dynamic adjacency matrix.
[0115] In a specific embodiment, a method for predicting urban traffic flow based on temporal deep learning includes the following steps:
[0116] S1: Collect traffic flow data and road network topology data; the traffic flow data is the 5-minute granularity flow data (vehicles / minute) collected by 500 geomagnetic sensors within the Fifth Ring Road of a certain city; the road network topology data is the road segment connection relationship extracted from OpenStreetMap (nodes = sensor locations, edges = road segment connections);
[0117] S2: Preprocess the collected data;
[0118] Apply a moving average filter (window size = 3, i.e., 15 minutes) to the flow data to smooth short-term fluctuations and achieve denoising;
[0119] Use Z-Score detection (threshold = 3.5) to remove data points that exceed the data;
[0120] Adopt spatio-temporal bidirectional interpolation to fill in the missing values. Use linear interpolation to fill in 1-2 consecutive missing time dimension flow values in the traffic flow data, and fill in the missing road segment flow values according to the inverse distance weighted average of the flow values of the nearest 3 adjacent road segments in the same time period;
[0121] Normalize the processed data to the [0, 1] interval using Min-Max normalization;
[0122] S3: Construct a static adjacency matrix based on the Pearson correlation coefficient of the traffic flow data and the road network topology distance in the road network topology data; use an adaptive graph generation network (AGGN), with the input being the traffic flow data to generate a dynamic adjacency matrix, and update the dynamic adjacency matrix every 10 minutes according to the latest flow data;
[0123] S4: Calculate the time attention weights and space attention weights based on the traffic flow data;
[0124] S5: The input layer of the improved spatio-temporal graph convolutional network receives the normalized traffic flow data, static adjacency matrix, and dynamic adjacency matrix, and generates weighted features and spatial propagation weights according to the temporal attention weights and spatial attention weights; the diffusion convolutional layer performs diffusion convolution on the weighted features according to the spatial propagation weights to obtain spatial features; the gated temporal convolutional layer performs causal convolution and gated temporal convolution on the spatial features to obtain time; the fully connected layer predicts the future traffic flow according to the spatial features and temporal features.
[0125] In a specific embodiment, meteorological data and traffic event data are also collected. The meteorological data includes weather conditions, rainfall, visibility, etc., and the traffic event data includes accidents, construction, etc. The meteorological data and traffic event data are used as external features. Based on the above method for predicting urban traffic flow based on temporal deep learning, the external features are aligned with the temporal features and spatial features output by the improved spatio-temporal graph convolutional network in terms of timestamps and mapped to spatial nodes. The fusion weights of the external features with the temporal features and spatial features are dynamically adjusted through a learnable gating mechanism. Feature fusion is performed on the external features, temporal features, and spatial features according to the fusion weights, and the future traffic flow is predicted based on the fused features.
[0126] On the other hand, in a specific embodiment, a system for predicting urban traffic flow based on temporal deep learning, as Figure 2 shown, includes a preprocessing module, an adaptive graph generation module, a spatio-temporal attention module, and a spatio-temporal graph convolutional prediction module;
[0127] The preprocessing module collects traffic flow data and road network topologies and performs preprocessing;
[0128] The adaptive graph generation module constructs a static adjacency matrix and a dynamic adjacency matrix according to the preprocessed traffic flow data and road network topologies;
[0129] The spatio-temporal attention module calculates spatio-temporal attention weights according to the preprocessed traffic flow data using a spatio-temporal attention mechanism;
[0130] The spatio-temporal graph convolutional prediction module predicts and outputs the future traffic flow using the improved spatio-temporal graph convolutional network according to the static adjacency matrix, dynamic adjacency matrix, and spatio-temporal attention weights.
[0131] Furthermore, a random Dropout layer is introduced after the fully connected layer of the improved spatio-temporal graph convolutional network to implement a Bayesian deep learning framework through Monte Carlo Dropout; the randomness of Dropout is retained during the training stage of the improved spatio-temporal graph convolutional network, and during the testing stage, multiple forward propagation samplings are performed, and the mean and variance of multiple groups of prediction results are used as the final prediction value and uncertainty measure respectively.
[0132] Furthermore, the improved spatio-temporal graph convolutional network includes a multi-modal feature fusion layer. The preprocessing module also collects external features and preprocesses them. The multi-modal feature fusion layer dynamically adjusts the fusion weights of the external features with the temporal features and spatial features through a learnable gating mechanism, performs feature fusion on the external features, temporal features, and spatial features according to the fusion weights, and predicts future traffic flow based on the fused features.
[0133] Furthermore, the spatio-temporal graph convolutional prediction module further includes an interpretability module, which quantifies the contribution degrees of each temporal feature, spatial feature, and external feature to the predicted future traffic flow based on SHAP values, and obtains an interpretability heat map.
[0134] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the various embodiments, reference can be made to each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description in the method section.
[0135] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be obvious to those skilled in the art. The general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but will be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for predicting urban traffic flow based on time series deep learning, characterized in that: The following steps are involved: Step 1: Collect traffic flow data and road network topology and perform preprocessing; Step 2: Construct static adjacency matrix and dynamic adjacency matrix based on preprocessed traffic flow data and road network topology; Step 3: Calculate the spatiotemporal attention weights using the spatiotemporal attention mechanism based on the preprocessed traffic flow data; Step 4: Based on the static adjacency matrix, dynamic adjacency matrix and spatiotemporal attention weights, an improved spatiotemporal graph convolutional network is used to predict and output future traffic flow.
2. According to claim 1, a method for predicting urban traffic flow based on time series deep learning is characterized in that: The preprocessing methods in step 1 include denoising, outlier removal, data filling and data enhancement.
3. According to claim 1, a method for predicting urban traffic flow based on time series deep learning is characterized in that: In step 2, a static adjacency matrix is constructed based on traffic flow data and road network topology, including the following steps: Step 211: Calculate the distance between nodes according to the road network topology, and construct a distance weight matrix by using a preset distance threshold Gaussian kernel, and construct a static distance adjacency matrix according to the distance weight matrix , the distance weight matrix is expressed as: ; in, Representation Node With Node The weight of the edge between them; Representation Node With Node The distance between represents the standard deviation; q represents the distance threshold; Step 212: Calculate the Pearson correlation coefficient between nodes based on traffic flow data , construct a static similarity adjacency matrix based on the Pearson correlation coefficient ; The Pearson correlation coefficient between nodes is expressed as: ; in, and Respectively represent the observation values of node X and node Y at the i-th time step; and are the average values of the observations of node X and node Y respectively; Step 213: Stack the static distance adjacency matrix and the static similarity adjacency matrix, and obtain the static adjacency matrix through the maximum pooling operation. , expressed as: ; Among them, MaxPool represents the maximum pooling operation; Stack represents Stack stacking.
4. According to claim 3, a method for predicting urban traffic flow based on time series deep learning is characterized in that: Constructing a dynamic adjacency matrix based on traffic flow data , expressed as: ; Among them, E1 and E2 represent two nodes with learnable parameters randomly initialized in traffic flow data; T represents transpose; ReLU represents the rectified linear activation function; Softmax represents the normalized activation function.
5. The urban traffic flow prediction method based on time series deep learning according to claim 4 is characterized in that: The spatiotemporal attention weights include the temporal attention weights and spatial attention weights , expressed as: ; ; in, represents the learnable temporal weight matrix; represents the features of time step t; Represents the time step Features; [ ] indicates splicing operation; represents the spatial attention weight of the d-th feature; a represents the attention vector; T represents transposition; represents the d-th feature of node i, represents the d-th feature of node j; W represents the learnable spatial weight matrix; Softmax represents the normalized activation function; LeakyReLU represents the leaky linear activation function.
6. The urban traffic flow prediction method based on time series deep learning according to claim 5 is characterized in that: The improved spatiotemporal graph convolutional network includes an input layer, a diffusion convolutional layer, a gated temporal convolutional layer and a fully connected layer connected in sequence; the input layer adjusts the traffic flow data, the static adjacency matrix and the dynamic adjacency matrix according to the spatiotemporal attention weights; the diffusion convolutional layer captures the spatial propagation law between nodes in the road network topology, performs spatial dimension modeling, and obtains spatial features; The gated temporal convolution layer captures the long-term dependency of traffic flow data in the time dimension, performs time dimension modeling, and obtains time features; The fully connected layer integrates and predicts the spatial and temporal features and outputs the future traffic flow.
7. The urban traffic flow prediction method based on time series deep learning according to claim 6 is characterized in that: The input layer obtains the original time series features H after preprocessing the traffic flow data according to the time attention weight. raw Adjust the time dimension and dynamically adjust the propagation weights between nodes in the static adjacency matrix and the dynamic adjacency matrix according to the spatial attention weight; The temporal attention weight is combined with the original time series feature H obtained after preprocessing the traffic flow data. raw Multiply them together to get the time-weighted feature H time-attn ; expressed as: ; The spatial attention weights are combined with the static adjacency matrix and the dynamic adjacency matrix to generate dynamically adjusted spatial propagation weights; expressed as: ; in, represents the spatial propagation weight between node i and node j.
8. The urban traffic flow prediction method based on time series deep learning according to claim 7 is characterized in that: The diffusion convolution layer uses diffusion convolution to perform K-hop diffusion on the spatial propagation weights to obtain the spatial features of each node. , expressed as: ; in, represents the kth power of the spatial propagation weight; Represents the convolution kernel parameters of the k-th hop.
9. The urban traffic flow prediction method based on time series deep learning according to claim 8 is characterized in that: The gated temporal convolution layer performs causal convolution and gated temporal convolution on the temporal features of each node in turn to obtain the temporal features. , expressed as: ; Among them, GLU represents gated temporal convolution; Conv1D represents causal convolution.
10. An urban traffic flow prediction system based on time series deep learning, characterized in that: A method for predicting urban traffic flow based on time series deep learning as described in any one of claims 1 to 9, comprising a preprocessing module, an adaptive graph generation module, a spatiotemporal attention module and a spatiotemporal graph convolution prediction module; The preprocessing module collects traffic flow data and road network topology and performs preprocessing; Adaptive graph generation module, which constructs static and dynamic adjacency matrices based on preprocessed traffic flow data and road network topology; The spatiotemporal attention module uses the spatiotemporal attention mechanism to calculate the spatiotemporal attention weights based on the preprocessed traffic flow data; The spatiotemporal graph convolution prediction module uses an improved spatiotemporal graph convolution network to predict and output future traffic flow based on the static adjacency matrix, dynamic adjacency matrix and spatiotemporal attention weights.
Citation Information
Patent Citations
Traffic flow prediction method and device based on dynamic space-time diagram convolution circulation network, and storage medium
CN114220271A
Adaptive learning traffic flow prediction method under dynamic traffic condition
CN116721538A
Urban traffic prediction method and device based on space-time mixed graph convolution
CN117218846A
Traffic flow prediction method based on interactive dynamic graph convolution and probability sparse attention
CN117290707A
Traffic flow prediction method based on adaptive partial attention diffusion map convolutional neural network
CN117456730A
Cited By
Green wave control method based on traffic flow prediction driving
CN121459605A
Low-altitude traffic flow prediction and dispersion method based on space-time diagram network
CN121459642A
A low-altitude traffic flow prediction and diversion method based on a space-time diagram network
CN121459642B
Highway traffic flow prediction method based on STGCN-Transform hybrid model
CN121661828A
A Highway Traffic Flow Prediction Method Based on STGCN-Transformer Hybrid Model
CN121661828B
