A Traffic Flow Prediction Method Based on Multivariate Spatiotemporal Feature Extraction
The DSTF model addresses the shortcomings of existing traffic flow prediction models in terms of multi-scale time dependence and spatiotemporal correlation, achieving more accurate traffic flow prediction and improving the efficiency and accuracy of urban traffic management.
Patent Information
- Application Number
- CN202411985073.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-12-31
AI Technical Summary
Existing traffic flow prediction models struggle to effectively capture the multi-scale temporal dependence and spatiotemporal correlation of traffic flow, resulting in insufficient prediction accuracy. This is especially true when dealing with complex urban traffic networks, as they neglect the spatial correlation and multi-scale temporal characteristics of distant nodes.
A multivariate spatiotemporal feature extraction model (DSTF) is adopted. In the time dimension, a gated convolution improved Res2Net module is used to capture the temporal scale change pattern of traffic flow. In the spatial dimension, a spatial attention mechanism and Geom-GCN are used to capture the global and local spatial correlations between nodes. The dynamic interaction relationship across time slices is captured through a dynamic spatiotemporal synchronization aggregation module.
It improves the accuracy of traffic flow forecasting, enabling both short-term and long-term forecasts, effectively extracting local spatial dependence and global dynamic spatial dependence, and utilizing the dynamic interrelationships of traffic flow at different times and locations to improve urban traffic conditions.
Smart Images

Figure CN119863929B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical fields of information technology, graph convolutional neural networks, residual networks and attention mechanisms, and specifically relates to a traffic flow prediction method based on multivariate spatiotemporal feature extraction. Background Technology
[0002] Traffic flow forecasting is a crucial basis for Intelligent Transportation Systems (ITS) to manage traffic problems and a significant driving force for achieving efficient and green urban transportation. With the increasing prominence of urban traffic issues, the importance of traffic flow forecasting has significantly increased. The task of traffic flow forecasting is to analyze historical traffic flow data, road network structure data, and other relevant information to predict traffic flow in future time periods. By accurately predicting future traffic flow conditions, ITS and traffic management departments can monitor future urban traffic conditions, thereby optimizing traffic signal control, helping travelers choose reasonable travel routes, and reducing traffic accidents.
[0003] Current research on traffic flow forecasting is becoming increasingly in-depth. Existing studies mainly include traffic flow state analysis based on specific observation points on road segments and traffic flow state analysis based on urban areas or grid divisions. The latter typically includes both inflow and outflow traffic. See the accompanying diagrams for illustrations of both methods. Figure 7 (a) and Figure 7 (b) Prediction models are mainly divided into three categories: mathematical statistics models, traditional machine learning models, and deep neural networks.
[0004] Traffic flow prediction models based on mathematical statistics are simple in principle, but they often rely on linear assumptions and struggle to fully consider the complex spatial characteristics of traffic flow, resulting in poor prediction accuracy. Traditional machine learning models, such as the K-Nearest Neighbors (KNN) algorithm, can learn the interaction relationships of traffic flow at different spatial nodes, but they cannot model the complex dynamic spatiotemporal characteristics of traffic flow. Recently, deep learning technology has become a powerful tool in the field of traffic flow prediction. Convolutional Neural Networks (CNNs) can effectively handle grid data. Early researchers processed road networks as grid topologies and then used CNNs to simulate the spatial interactions of traffic flow, and utilized Recurrent Neural Networks (RNNs) and their variants to mine the temporal feature correlations of traffic flow. However, due to the complexity of traffic networks, simplifying them to grid data may lead to the loss of spatial information, especially when the grid division is unreasonable. In addition, RNNs perform well in capturing short-term temporal dependencies in sequence data, but suffer from problems such as gradient vanishing and gradient exploding, and high training time overhead when handling long-term temporal dependencies. Graph structures can naturally represent complex traffic networks. By introducing graph structures, Graph Convolutional Neural Networks (GCNs) can capture the interactions between nodes in the road network using the adjacency relationships between nodes in the graph.
[0005] Existing studies have largely extracted the spatiotemporal features of traffic flow by integrating temporal models such as GCN, RNN, and attention mechanisms. However, GCN-based models lose structural information about neighboring nodes, and these models are typically based on road network adjacency matrix design graph structures, neglecting the correlations between nodes that are geographically distant but have similar traffic flow patterns. (See attached manual.) Figure 8 As shown in (a) and (b), nodes A and F are two sensor nodes that are far apart in the road network, but they exhibit similar traffic flow patterns. Furthermore, extracting the global dynamic spatial correlations of network nodes is crucial. Due to the intricate nature of the traffic network, changes in one node not only affect neighboring nodes but may also ripple through distant nodes, and the dependencies between nodes may dynamically change due to temporal patterns and emergency situations.
[0006] Furthermore, in terms of the time dimension, existing models mainly focus on modeling time dependencies at a fixed time scale, lacking sufficient multi-scale modeling and making it difficult to learn the rich temporal patterns of traffic flow data. Traffic flow data has multi-scale characteristics, and traffic flow patterns differ at different time scales. (See the attached manual.) Figure 8 As shown in (c), at fine-grained time scale 1, the traffic flow curves of nodes B and C are in a stable state. At fine-grained time scale 2, the traffic flow curves of nodes B and C gradually rise from a stable state, indicating the early morning peak. At coarse-grained time scale 3, the traffic flow curves of nodes B and C are in the morning peak period, fully reflecting the changes in traffic flow during the morning peak, with traffic flow gradually rising from a stable state to reach the morning peak and then declining. Fine-grained time scales mainly focus on short-term fluctuations in traffic flow, while increasing the time scale can capture medium- and long-term trends in traffic flow. However, current technical solutions struggle to effectively utilize this information and these characteristics. Summary of the Invention
[0007] Therefore, addressing the shortcomings and deficiencies of existing technologies and identifying areas for improvement, this invention proposes a traffic flow prediction method based on multivariate spatiotemporal feature extraction. It presents a Multivariate Spatiotemporal Feature Extraction (DSTF) model for traffic flow prediction, capable of effectively predicting future road traffic flow states. First, in the temporal dimension, DSTF uses a gated convolution-modified Res2Net module to capture traffic flow patterns over time. Second, in the spatial dimension, this invention adopts both global and local perspectives, employing spatial attention mechanisms and a dual-view Geom-GCN to comprehensively capture global spatial correlations, geographical neighborhood spatial correlations, and semantic similarity spatial correlations between nodes in the urban road network. Third, in the temporal-spatial interaction dimension, this invention uses spatiotemporal attention to construct a dynamic spatiotemporal synchronous aggregation module to capture dynamic interaction relationships between nodes or regions across time slices. By accurately predicting future road traffic flow states, road transport efficiency can be improved, and urban traffic conditions can be better addressed.
[0008] The specific technical solution adopted by this invention to solve its technical problem is as follows:
[0009] A traffic flow prediction method based on multivariate spatiotemporal feature extraction is proposed. In the temporal dimension, a gated convolution-modified Res2Net module is used to capture traffic flow patterns over time. In the spatial dimension, from both global and local perspectives, a spatial attention mechanism and a dual-view Geom-GCN are employed to capture global spatial correlations, geographic neighborhood spatial correlations, and semantic similarity spatial correlations between nodes in the urban road network. In the temporal-spatial interaction dimension, a dynamic spatiotemporal synchronization aggregation module constructed using spatiotemporal attention is used to capture dynamic interaction relationships between nodes or regions across time slices to predict future road traffic flow.
[0010] Furthermore, the multivariate spatiotemporal feature extraction model includes: a data embedding layer, L stacked spatiotemporal feature extraction layers, and an output layer; the data embedding layer is used to integrate traffic flow with temporal and spatial information to embed traffic flow data; the spatiotemporal feature extraction layers are used to extract and fuse features, including a local-global spatial feature extraction module for capturing spatial features, a gated convolution improved Res2Net module for extracting multi-scale temporal features, a dynamic spatiotemporal synchronization aggregation module for modeling spatiotemporal cross-correlation, and a spatiotemporal feature fusion module that concatenates the extracted spatiotemporal features and fuses them through two linear layers and a ReLU activation function; the output layer is used to predict future traffic flow.
[0011] Furthermore, the data embedding layer incorporates information including time location encoding, time periodicity, and geospatial adjacency to embed and represent traffic flow data.
[0012] Furthermore, after the data embedding layer, the tensor X... emb ∈R N×T×d Perform segmentation, dividing into feature subsets X1∈R N×T×d1 and X2∈R N×T×d2 d1+d2=d, so that the feature subset X1∈R N×T×d1 The input local-global feature extraction module captures local and global spatial features in traffic flow data; the feature subset X2∈R N×T×d2 An improved Res2Net module with input-gated convolution extracts temporal features at different scales.
[0013] Furthermore, the local-global feature extraction module includes a local spatial feature extraction module and a dynamic global spatial feature extraction module. The local spatial feature extraction module is used to model the local spatial correlation of traffic flow using Geom-GCN from a dual perspective: based on the sensor adjacency matrix corresponding to road network connectivity and traffic data similarity, a geospatial graph structure and a semantic spatial graph structure are constructed; potential spatial neighborhoods are constructed using Struc2vec and Node2vec embedding algorithms, and graph aggregation is performed using Geom-GCN; the dynamic global spatial feature extraction module uses a spatial self-attention mechanism to dynamically assign weights to spatial information at different locations to capture global dynamic spatial correlation.
[0014] Furthermore, in the local spatial feature extraction module:
[0015] Geographic Neighborhood Spatial Graph Structure G G Sensor adjacency matrix construction;
[0016] Semantic similarity space graph structure G S Given any two time series X = (x1, x2, x3, ..., x...) m ) and Y = (y1, y2, x3, ..., y n Given sequences of lengths m and n, the FastDTW algorithm is used to calculate the similarity between any two traffic flow sequences from different sensor nodes, thus obtaining the similarity between the two sensor nodes. Based on the FastDTW calculation results, the top_k (v) sensor nodes with the highest similarity to each node are identified. i Thus, the adjacency matrix A is established. S ∈R N×N ;
[0017] The graph structure based on geographic neighborhood uses the Struc2Vec algorithm as the node embedding algorithm, while the graph structure based on semantic similarity uses the Node2vec algorithm as the node embedding algorithm.
[0018] The dynamic global spatial feature extraction module employs a multi-head self-attention mechanism to capture global dynamic spatial correlations.
[0019] The output layer consists of two 1×1 convolutional layers, which take the results obtained from the spatiotemporal feature extraction layer through the skip connection layer as input and convert them into the final prediction output.
[0020] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of a traffic flow prediction method based on multivariate spatiotemporal feature extraction as described above.
[0021] A non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a traffic flow prediction method based on multivariate spatiotemporal feature extraction as described above.
[0022] Compared with the prior art, the present invention and its preferred embodiments have at least the following advantages:
[0023] The DSTF model effectively addresses issues such as the dynamic nature of traffic flow data, multi-scale time dependence, and insufficient consideration of spatiotemporal correlation. It can effectively extract various spatiotemporal features, enabling more accurate traffic flow prediction in complex traffic scenarios.
[0024] In the time dimension, DSTF successfully extracts multi-scale temporal features of traffic flow, enabling both short-term and long-term predictions. In the spatial dimension, DSTF effectively extracts both local spatial dependencies and global dynamic spatial dependencies.
[0025] In terms of time-space correlation, by introducing a dynamic spatiotemporal synchronization aggregation module, DSTF can effectively utilize the dynamic interrelationships of traffic flows at different times and locations. Attached Figure Description
[0026] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments:
[0027] Figure 1 This is a comparison chart of the prediction performance of different models in embodiments of the present invention. The left chart shows the visualization of the PEMS04 dataset, and the right chart shows the visualization of the PEMS08 dataset.
[0028] Figure 2 This is a performance comparison chart of different models in this invention for short-term and medium-to-long-term predictions on the PEMS04 dataset.
[0029] Figure 3 This is a performance comparison chart of different models in this invention for short-term and medium-to-long-term predictions on the PEMS08 dataset.
[0030] Figure 4 The figure shows the ablation experiment results performed on the PEMS04 dataset according to an embodiment of the present invention.
[0031] Figure 5 This is a comparison of the prediction performance of the DSTF model and the PDFormer model on the PEMS04 dataset, as shown in the embodiments of the present invention. (a) shows the traffic flow at sparse nodes, and (b) shows the traffic flow at dense nodes. The black curve represents the actual traffic flow value. The light blue and dark blue curves represent the prediction values obtained by the PDFormer model for the 5-minute and 60-minute prediction tasks, respectively. The red and purple curves show the prediction values obtained by the DSTF model for the 5-minute and 60-minute prediction tasks, respectively.
[0032] Figure 6 This is a comparison chart of predicted traffic flow values and actual traffic flow values according to an embodiment of the present invention. The black curve represents the actual traffic flow value, and the purple curve represents the predicted value.
[0033] Figure 7 These are schematic diagrams of two existing methods for representing traffic flow, where (a) is a traffic flow diagram at a specified observation point on a road segment, and (b) is a traffic flow diagram based on region or grid division. In Figure (a), the arrows represent vehicle flow directions detected by specific sensors. In Figure (b), the entire region is divided into multiple grids, and inflow and outflow traffic flows are calculated for each grid cell.
[0034] Figure 8 This diagram illustrates traffic flow characteristics, where (a) is a distribution map of node locations, (b) are traffic flow curves for nodes A and F, and (c) are traffic flow patterns for nodes B and C. (b) demonstrates the long-distance spatial similarity of traffic flow, while (c) illustrates the multi-scale characteristics of traffic flow.
[0035] Figure 9 This is a structural diagram of the DSTF model in an embodiment of the present invention.
[0036] Figure 10 This is a visualization of traffic flow on the PEMS03 dataset in an embodiment of the present invention, where: (a) daily cycle, (b) weekly cycle. Figure (a) shows traffic data from selected sensor nodes for two consecutive days within the same week. Figure (b) shows data from two consecutive Thursdays. The legend uses a color gradient from dark gray to light gray, then to light green, and finally to dark green to represent traffic flow, with values increasing from 0 to peak value.
[0037] Figure 11 This is a flowchart illustrating the processing of the Geom-GCN model from a dual-view perspective, as described in an embodiment of the present invention.
[0038] Figure 12 This is a structural diagram of the GRes2Net module according to an embodiment of the present invention. The left figure shows an overall schematic diagram of GRes2Net, and the right figure depicts the structure of gated convolution (GConv). Detailed Implementation
[0039] To make the features and advantages of this patent more apparent and understandable, specific embodiments are provided below for detailed explanation:
[0040] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of this application. Unless otherwise specified, all technical and scientific terms used in this specification have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.
[0041] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0042] To facilitate a detailed explanation of this invention, we will first provide a unified explanation of the relevant basic concepts.
[0043] Definition 1 (Directed Graph G of Traffic Network): Given a traffic network containing N sensor nodes, the traffic network can be modeled as a directed graph G = (V, E, A), where V = {v1, v2, ..., v...} n} represents a sensor node on the road network, E represents the set of edges between nodes, and A∈R N×N Let be the weighted adjacency matrix of graph G. Assume... F represents the traffic status (such as traffic flow, speed, etc.) of each sensor node at time t, where F is the observed feature dimension.
[0044] Definition 2 (Traffic Flow Prediction Problem f) In this embodiment, the traffic flow X of each sensor node over the past T steps is taken. (t-T+1):t ={X t-T+1 ,X t-T+2 ,....,X t} is used as the research object, and a model f is built based on it to predict the traffic flow X of these nodes in the next T' steps. (t+1):(t+T’) ={X (t+1) ,X(t+2) ,....,X (t+T’)}:
[0045]
[0046] The structure of the multivariate spatiotemporal feature extraction model (DSTF) for traffic flow prediction proposed in this embodiment of the invention is as follows: Figure 9 As shown, the system includes a data embedding layer for input, L stacked spatiotemporal feature extraction layers, and an output layer. The data embedding layer embeds traffic flow data, temporal and spatial features to form more comprehensive spatiotemporal features. Each spatiotemporal feature extraction layer includes a Local-Global Spatial Feature Extraction Module (LGSFEM), a gated convolution-improved Res2Net module (GRes2Net), a Dynamic Spatiotemporal Synchronous Aggregation Module (DSTSAM), and a spatiotemporal feature fusion module. The Local-Global Spatial Feature Extraction Module is mainly divided into two parts: the first part uses Geom-GCN to capture local spatial dependencies from a dual-view perspective, and the second part extracts spatial features from a global perspective. GRes2Net is used to extract temporal features at different scales. DSTSAM simultaneously extracts dynamic spatiotemporal dependencies. The extracted spatiotemporal features are fused by the feature fusion module, followed by a feedforward fully connected layer. Finally, skip connections and fully connected layers transform the data into the final dimension required for the output.
[0047] (1) Data embedding layer
[0048] The following describes the detailed process of the data embedding layer. In this embodiment, the data embedding layer introduces information such as time location encoding, time periodicity, and road network structure, effectively enhancing the model's ability to extract complex spatiotemporal dependencies. Specifically, the input traffic flow X... input First, it is transformed into a fixed-dimensional representation X through a fully connected layer. f ∈R N×d Where d represents the data embedding dimension. Secondly, in the time dimension, time embedding encoding is performed by combining time-location encoding with the daily and weekly periodicity of traffic flow. Finally, in the spatial dimension, spatial graph Laplace embedding is used for road network spatial structure embedding encoding.
[0049] Traffic flow data exhibits a typical time-series pattern. As time progresses and vehicles move through space, traffic flow on various roads changes continuously at different times. Therefore, there is a positional relationship between traffic flow measurements at different time steps. To address this characteristic, this invention first encodes a time-location value X. t ∈R T×d X included in the input data input After that, such as Figure 10As shown in (a), traffic flow heatmaps for 10 sensor nodes on Thursdays and Fridays are displayed using the PEMS03 dataset. Figure 10 (b) presents traffic flow heatmaps from 10 sensor nodes over two consecutive Thursdays. These graphs clearly show that traffic flow exhibits both daily and weekly periodicity.
[0050] Therefore, to further improve the prediction accuracy of the DSTF model, this invention introduces daily and weekly periodic embeddings. Following established convention, each day is divided into 1440 time slots based on minutes, and each week is divided into 7 days. These time slots are then converted into a high-dimensional representation to obtain the periodic embedding X. p ∈R T×d .
[0051] Given the constraints of the transportation network, traffic flow within each road segment is influenced not only by its immediate surroundings but also by adjacent road segments within the network. Therefore, incorporating the geospatial adjacency relationships of each road segment is essential. This embodiment utilizes graph Laplacian eigenvectors to represent the structural information of the road network. Specifically, firstly, the Laplacian eigenvectors of the normalized adjacency matrix are obtained using Equation 2. Subsequently, these eigenvectors are processed through a linear operation layer to generate a spatial embedding X. s ∈R N×d Specifically, this is represented by the following steps:
[0052] Step 1: Input traffic flow X input Transformed into a fixed-dimensional representation X through a fully connected layer. f ∈R N×d ;
[0053] Step 2: Construct the time location code X t ∈R T×d :
[0054]
[0055] Where t is the position in the time series, i is the length of the series, and d is the dimension of the series.
[0056] Step 3: Divide each day into 1440 time periods in minutes and each week into 7 days in days, and convert them into a high-dimensional representation to obtain the periodic embedding code X. p ∈R T×d ;
[0057] Step 4: Represent the structural information of the road network using graph Laplacian eigenvectors. Obtain the Laplacian eigenvectors of the normalized adjacency matrix using formula (3);
[0058] Δ = ID -1 / 2 AD-1 / 2 =U T ΛU(3)
[0059] Where A is the adjacency matrix, D is the degree matrix, I is the identity matrix, U is the eigenvector matrix, and Λ is the eigenvalue.
[0060] Step 5: Generate a spatial embedding encoding X from these feature vectors through a linear operation layer. s ∈R N×d .
[0061] Step 6: Based on the temporal embedding coding and spatial embedding coding described above, perform a simple summation to obtain the output X of the data embedding layer. emb ∈R N×d :
[0062] X emb =X f +X t +X p +X s (4)
[0063] At this point, the data embedding layer of this invention is basically complete.
[0064] (2) Spatiotemporal feature extraction layer (spatiotemporal encoder layer)
[0065] The following describes the detailed process of the spatiotemporal feature extraction layer. The spatiotemporal feature extraction layer mainly consists of four parts: a local-global spatial feature extraction module, a multi-scale feature extraction GRes2Net module, a dynamic spatiotemporal synchronous aggregation module, and a spatiotemporal feature fusion module. This encoder layer can extract various spatiotemporal features from traffic flow data, thereby more comprehensively capturing the evolution patterns of traffic flow. To improve the model's expressive power, inspired by the multi-head attention mechanism, in the subsequent parts of the model, this embodiment uses tensor X... emb ∈R N×T×d Perform segmentation, dividing into feature subsets and Where d1 + d2 = d. The feature subsets are input into different feature extraction modules, allowing each feature subset to learn different feature representations.
[0066] The following sections describe the detailed processes of the local-global spatial feature extraction module, the multi-scale feature extraction GRes2Net module, and the dynamic spatiotemporal synchronization aggregation module.
[0067] Local-Global Spatial Feature Extraction Module:
[0068] The local-global feature extraction module consists of two parts: a local spatial feature extraction module and a dynamic global spatial feature extraction module. The local spatial feature extraction module uses Geom-GCN to model the local spatial correlation of traffic flow from a dual-view perspective. The specific process is as follows: Figure 11 As shown, 1 / 1, 1 / 2, and 1 / 4 represent the sequence length being reduced to 1 / 1, 1 / 2, and 1 / 4 of the original sequence length, respectively. Based on road network connectivity and traffic data similarity, two perspectives are constructed: geospatial graph structure and semantic spatial graph structure. Subsequently, latent spatial neighborhoods are constructed using the Struc2vec and Node2vec embedding algorithms, and finally, Geom-GCN is used for graph aggregation. The dynamic global spatial feature extraction module dynamically assigns weights to spatial information at different locations using a spatial self-attention mechanism to capture global dynamic spatial correlations.
[0069] The following sections describe the detailed processes of the local spatial feature extraction module and the dynamic global spatial feature extraction module:
[0070] Local Spatial Feature Extraction Module: As a key component of graph convolutional neural networks (GCNs), the construction method of the graph structure is crucial to the model's prediction results. Previous GCN-based models typically constructed the graph structure based on the road network adjacency matrix. However, in real-world scenarios, relying solely on this method to capture the spatial dependencies of traffic flow is insufficient. This is because even if two nodes are geographically far apart, they may still possess similar attributes if they perform similar traffic functions or roles. For example, two distant and unconnected commercial or residential areas may exhibit similar traffic patterns. Therefore, this embodiment constructs a geographical neighborhood G based on both the sensor geographical adjacency matrix and temporal similarity. G G and semantic similarity S Two spatial structure diagrams are used to extract a more comprehensive spatial dependency.
[0071] To capture local spatial dependencies in traffic networks, graph convolutional neural networks (GNNs) are widely used to model traffic flow propagation patterns within these networks. However, traditional GNNs have limitations when processing graph data; they fail to preserve the structural information of neighboring nodes and struggle to capture long-distance spatial dependencies. Geom-GCN improves upon the aggregation function in GNNs using a geometric aggregation scheme. By leveraging geometric relationships defined in the latent space and a designed two-layer aggregator, it preserves the structural information between nodes. Furthermore, by introducing a suitable node embedding algorithm, Geom-GCN can capture long-distance spatial dependencies.
[0072] Node embedding algorithms aim to map each node in a graph to a vector in a low-dimensional continuous space. Traditional adjacency matrices based on geographical neighborhood ignore the strong spatial correlation between nodes that are far apart but have similar spatial structures in a transportation network. The Struc2Vec algorithm uses the distance between the order sequences of two nodes as a metric, enabling it to embed nodes with similar local spatial structures into locations closer together in the latent space. Finally, a two-level aggregation is used to replace the aggregation scheme in the graph convolutional neural network, allowing the structural information of nodes to be utilized during the updating of the hidden features. The two-level aggregation includes two aggregation functions: a low-level aggregation function and a high-level aggregation function. The low-level aggregation function aggregates the information of nodes that are in the same neighborhood and have the same geometric relationship as the node, and treats them as virtual nodes. Then, high-level aggregation is performed, which aggregates the features of the virtual nodes generated in the previous step to obtain the final hidden features of the node, specifically represented by the following steps:
[0073] Step 1: Construct the geographic neighborhood G G Spatial Structure Diagram: The geographic neighborhood spatial structure diagram is constructed based on the real-world sensor adjacency matrix, and its adjacency matrix A G ∈R N×N The expression is as follows:
[0074]
[0075] Step 2: Construct semantic similarity G S Spatial structure diagram: Given any two time series X = (x1, x2, x3, ..., x... m ) and Y = (y1, y2, x3, ..., y n Given sequences of length m and n, the FastDTW algorithm is used to calculate the similarity between any two traffic flow sequences from different sensor nodes, thus obtaining the similarity between the two sensor nodes. Based on the FastDTW calculation results, the top_k (v) sensor nodes with the highest similarity to each node are identified. i Based on this, an adjacency matrix A is constructed. S ∈R N ×N :
[0076]
[0077] Step 3: For the graph structure built based on geographical neighborhood, the Struc2Vec algorithm is used as the node embedding algorithm. For the graph structure built based on semantic similarity, the Node2vec algorithm is used as the node embedding algorithm.
[0078] Step 4: Constructing the structural neighborhood: Based on the latent space generated by the node embedding algorithm in Step 3, given any two nodes u∈V and v∈V, this invention first determines the ordered positions of nodes u and v in the latent space. Define a relation operator τ that represents the geometric relationship between two nodes. Then, define a parameter ρ to find nodes z∈V in the latent space whose distance from each node u is less than ρ, thereby constructing the neighborhood N of the nodes in the latent space. s (u). Finally, combine the neighborhood N in the original graph. g (u), construct the structural neighborhood N(u) = {N g (u),N s (u),τ}.
[0079] Step 5: Use two-level aggregation to obtain the final hidden features of the nodes.
[0080]
[0081] in, It is the hidden feature of node u in the (l-1)th layer. It is a virtual node feature representation, obtained by aggregating the features of nodes that are in the same neighborhood i as node v and have a geometric relationship r with node v. o(·) and q(·) are the low-level aggregation function and the high-level aggregation function, respectively. The input of q(·) includes two parts: virtual node features. And the index (i,r), σ is a non-linear activation function, W l These are learnable matrix parameters.
[0082] Step 6: Given input features Based on the geographical neighborhood spatial graph structure G G and semantic similarity space graph structure G S Local spatial correlations were captured using Geom-GCN, and the results were obtained. and Furthermore, by employing a gated fusion mechanism, and simultaneously considering both geographical adjacency and semantic similarity spatial dependencies, the final local spatial feature X is obtained. LS :
[0083] z = sigmoid((X G W G +b G )+(X S W S +b S (10)
[0084] X LS =z⊙X G +(1-z)⊙X S (11)
[0085] in, For the characteristics after fusion, W G W S Given two learnable parameter matrices, b G and b S ⊙ represents the weight bias, and ⊙ represents the Hadamard product.
[0086] At this point, the local spatial feature extraction work of this invention is basically completed.
[0087] Dynamic Global Spatial Feature Extraction Module: Traffic networks are complex, with traffic flows between different road segments influencing each other. Some road segments may exhibit strong correlations in their traffic flows, while others show relatively weaker correlations. Furthermore, different time slices of each road segment exhibit varying correlations. To better model the spatial correlations of traffic flows, this invention employs a multi-head self-attention mechanism to capture these global dynamic spatial correlations, specifically represented by the following steps:
[0088] Step 1: At time t, given the input data First, the three matrices needed to calculate multi-head self-attention are obtained through linear transformation:
[0089]
[0090] in, These are three learnable parameter matrices.
[0091] Step 2: Subsequently, the correlation between individual sensor nodes in each attention head is calculated using the scaled dot product attention mechanism:
[0092]
[0093] in, Indicates sensor node v at time t i With node v j The similarity between them. Due to the sensor node v at time t+1 i The traffic flow is correlated with the traffic flow of all sensor nodes at time t. Therefore:
[0094] Step 3: Use the softmax function to normalize the above similarity vectors and calculate the node v. i Similarity scores are calculated between each sensor node. Finally, these similarity scores are used to evaluate the values. Weighting is applied.
[0095]
[0096] in, It is a learnable parameter matrix. This represents the output of the h-th attention head module at time t. It is the output of the multi-head self-attention module at time t.
[0097] At this point, the global spatial feature extraction work of this invention is basically completed.
[0098] GRes2Net module for multi-scale feature extraction
[0099] Traffic flow exhibits different patterns of change at different time scales. This embodiment uses the Res2Net architecture to overcome the problem of insufficient multi-scale temporal feature extraction in existing prediction models. Unlike the standard Res2Net, this embodiment uses gated convolutions instead of standard convolutions to learn richer feature representations. Figure 12 The framework structure of GRes2Net is shown, specifically in the following steps:
[0100] Step 1: First, input features After a 1×1 convolution.
[0101] Step 2: Segment the input features along the channel dimension, dividing them evenly into k feature mapping subsets. Where i∈{1,2,...,k}.
[0102] Step 3: Map each feature subset After performing a gated convolution and upsampling operation, the next feature mapping subset is obtained. The results are summed, and the process proceeds to the next gated convolution. The process is as follows:
[0103]
[0104] Where Г1 and Г2 are convolution kernels of size 1×S1 and 1×S2, respectively; ★ denotes the convolution operation; and g and σ are the tanh and sigmoid activation functions, respectively. Feature map subset X (2,i) Each gated convolution operation results in a larger receptive field; therefore, the GRes2Net module can progressively extract multi-scale temporal features.
[0105] Step 4: Finally, in order to fully integrate multi-scale temporal information, the output y of all feature mapping subsets is processed. i The concatenation operation is performed, followed by a residual convolutional layer and a ReLU activation function to obtain the final output:
[0106]
[0107] in This indicates a splicing operation.
[0108] Step 5: Obtain the output of GRes2Net Then, in order to reduce the number of parameters, the division was performed. For feature subset and Where c1 + c2 = d2.
[0109] At this point, the multi-scale feature extraction work of this invention is basically completed.
[0110] Dynamic spatiotemporal synchronization aggregation module
[0111] In the foregoing sections, this invention has designed feature extraction modules for both the temporal and spatial correlations of traffic flow. However, traffic flow data is typical spatiotemporal data, and its temporal variation patterns and spatial distribution patterns are interrelated and mutually influential. Extracting temporal and spatial features separately may overlook this correlation. Therefore, this embodiment designs a dynamic spatiotemporal synchronous aggregation module based on an attention mechanism, aiming to simultaneously extract the temporal and spatial features of traffic flow to achieve more accurate traffic flow prediction.
[0112] In the time dimension, traffic flow in the current time slice is influenced by traffic flow in historical time slices and also affects traffic flow in future time slices. Therefore, traffic flows in different time slices are correlated, and this correlation is dynamic. This embodiment uses a self-attention mechanism to capture this long-term, dynamic temporal correlation. Furthermore, since multi-head attention mechanisms allow the model to focus on different features in different subspaces, a multi-head self-attention mechanism is used, specifically represented by the following steps:
[0113] Step 1: Given the traffic flow data of sensor node n at time slice T First, calculate the two inputs for multi-head attention:
[0114]
[0115] Among them, X GR1 A subset of features output by the GRes2Net module. These are the three learnable parameter matrices for the h-th attention head.
[0116] Step 2: Obtain the dynamic temporal adjacency matrix:
[0117]
[0118] Step 3: Similarly, given the input data The dynamic space adjacency matrix is calculated using the following formula:
[0119]
[0120] Step 4: Given the input data In addition to the two dynamic adjacency matrices mentioned above, a temporal adjacency matrix is added to the standard graph convolutional neural network to further achieve synchronous spatiotemporal feature extraction:
[0121] X DST =A s X2A t W1+b3(22)
[0122] X2 = X GR W2+b4(23)
[0123] Where W1, W2 and b3, b4 are the learnable weights and bias parameters, respectively.
[0124] At this point, the dynamic spatiotemporal synchronization aggregation of the present invention is basically completed.
[0125] Spatiotemporal feature fusion module
[0126] Based on the output of the above modules, this invention concatenates the extracted spatiotemporal features and fuses them through two linear layers and a ReLU activation function to learn richer features.
[0127]
[0128] Where W3, W4 and b5, b6 are the learnable weights and bias parameters, respectively. These are the outputs of the GRes2Net module, the local-global spatial feature extraction module, and the dynamic spatiotemporal aggregation module, respectively. Based on the extracted spatiotemporal features, the output of the spatiotemporal layer is obtained through a residual connection layer and a feedforward neural network layer.
[0129] At this point, the spatiotemporal feature fusion work of this invention is basically completed.
[0130] (3) Output layer
[0131] This embodiment of the invention uses skip connection layers, enabling information to be passed between different layers. Finally, two 1×1 convolutional layers are used to convert it into the final output of the model.
[0132] This concludes the complete introduction to the DSTF model.
[0133] Furthermore, the present invention uses three metrics—mean absolute error (MAE), root mean square error (RMSE), and mean absolute percentage error (MAPE)—to evaluate the model's performance. The specific calculation formulas are as follows:
[0134]
[0135] Where N is the sample data size, y i and These are the actual value and the predicted value, respectively. MAE (Modular Error Analysis) can intuitively reflect the average difference between the predicted and actual values. MAPE (Modular Error Correction) further compares the error between the predicted and actual values with the actual values, providing better interpretation. Compared to MAE and MAPE, RMSE (Root Mean Square Error) calculates the root mean square error between the predicted and actual values, making it more sensitive to predictions that deviate significantly from the actual values.
[0136] The following specific test examples will further illustrate and demonstrate the solutions of the embodiments of the present invention:
[0137] Experimental Dataset
[0138] The PEMS03, PEMS04, PEMS07, and PEMS08 datasets originate from the California Department of Transportation Performance Measurement System (PeMS), collected using sensors deployed on California highways. Data is aggregated every 5 minutes, and missing values are imputed using linear interpolation. The Hangzhou Metro (HZMETRO) dataset is a passenger flow dataset based on the metro system, derived from transaction records of 80 operating stations, representing approximately 2.35 million passenger trips per day. This dataset provides inflow and outflow data for each station every 15 minutes. More detailed information about these datasets is presented in Table 1.
[0139] Dataset processing
[0140] Consistent with the baseline method, the highway dataset and the Hangzhou Metro (HZMETRO) dataset were divided into training, validation, and test sets in ratios of 6:2:2 and 7:1:2, respectively. Z-Score normalization was applied to all datasets to standardize each feature.
[0141]
[0142] For all datasets, this embodiment employs a multi-step prediction method. The input data contains a sequence of traffic flow data for the past hour (12 time steps), and the output data represents the traffic flow for the next hour (12 time steps). For the Hangzhou Metro (HZMETRO) dataset, data from the past 6 time steps is used to predict traffic flow for the next 6 time steps.
[0143] Table 1: Dataset Description
[0144] Dataset node side Sampling time Time step Time interval Missing rate PEMS03 358 547 09 / 01 / 2018-11 / 30 / 2018 26208 5min 0.672% PEMS04 307 340 01 / 01 / 2018-02 / 28 / 2018 16992 5min 3.182% PEMS07 883 866 05 / 01 / 2017-08 / 31 / 2017 28224 5min 0.452% PEMS08 170 295 07 / 01 / 2016-08 / 31 / 2016 17856 5min 0.672% HZMETRO 80 240 01 / 01 / 2019-01 / 25 / 2019 - 15min -
[0145] Baseline contrast experiment
[0146] To evaluate the effectiveness of the proposed DSTF, it was compared with the following eight baselines:
[0147] •LSVR: Linear Support Vector Regression uses SVM for traffic flow prediction, modeling only the temporal correlation of traffic flows.
[0148] • FNN: Feed-forward Neural Network, which uses a standard fully connected neural network for traffic flow prediction.
[0149] •FC-LSTM: Fully-Connected LSTM, as a variant of RNN, LSTM has advantages in capturing the long-term temporal dependencies of traffic flow due to its ability to alleviate the gradient vanishing and gradient exploding problems.
[0150] STGCN: Spatial-temporal graph convolution network, which combines temporal convolution with spatial graph convolution to capture the temporal and spatial dependencies of traffic flow.
[0151] ·GWN: Graph WaveNet, which uses temporally gated convolution and spatial graph diffusion convolution to capture temporal and spatial dependencies respectively, and designs an adaptive adjacency matrix to learn the hidden graph structure.
[0152] ·ASTGCN(r): Attention-based spatial-temporal graph convolutional network. It designs temporal attention mechanism and spatial attention mechanism to capture dynamic temporal and spatial dependencies respectively, and uses spatiotemporal convolution to capture static spatiotemporal dependencies, considering only the dependencies of adjacent time periods.
[0153] •STSGCN: Spatial-temporal synchronous graph convolutional network, which captures the spatiotemporal dependencies of traffic flow by constructing multiple local spatiotemporal graphs.
[0154] STG-NCDE: Graph Neural Controlled Differential Equations for TrafficForecasting, designed temporal neural control differential equations and spatial neural control differential equations to extract temporal and spatial features, respectively.
[0155] PDFormer: A Propagation Delay-Aware Dynamic Long-Range Transformer for Traffic Flow Prediction, employing temporal and spatial self-attention mechanisms to capture spatiotemporal correlations. Specifically, the spatial self-attention mechanism incorporates two graph masking matrices to highlight long-range and short-range spatial dependencies, and further includes a traffic delay-aware feature transformation module to capture spatial information propagation delays caused by traffic accidents and other factors.
[0156] Table 2 shows the average prediction results of different models for traffic flow in the next hour (12 time steps) on four datasets. Results highlighted in bold represent the best performance, while results marked as the second best are also highlighted accordingly. Figure 1 A direct comparison of the DSTF model's predictive capabilities with major benchmark models on the PEMS04 and PEMS08 datasets was conducted. The results of this invention demonstrate that the proposed model exhibits superior overall performance compared to other models across all four datasets.
[0157] As shown in Table 2, the performance of LSVR, FNN, and FC-LSTM models is relatively poor compared to other models. These three models mainly focus on temporal dependencies, ignoring the inherent spatial dependencies in road networks. STGCN addresses spatial dependencies by combining graph convolutional neural networks with one-dimensional temporal convolutions; however, traditional convolutional neural networks primarily focus on local information, which may lead to suboptimal performance in scenarios relying on long-term temporal patterns. GWN uses dilated causal convolutions to expand the receptive field, thereby enhancing its ability to capture long-term temporal features. However, in the spatial dimension, the adaptive adjacency matrix designed to learn the hidden graph structure is static and cannot capture complex dynamic features. STSGCN introduces a new perspective by simultaneously extracting local spatiotemporal correlations through the design of local spatiotemporal graphs. However, the construction of these graphs depends on fixed-size time windows, limiting their ability to model global traffic flow dependencies.
[0158] ASTGCN(r) incorporates an attention mechanism to capture correlations in traffic flow dynamics. However, its effectiveness is affected because the model fails to consider diurnal and weekly periodic characteristics. STG-NCDE introduces neural control differential equations to capture spatiotemporal dependencies, achieving excellent results. PDFormer introduces two graph mask matrix spatial self-attention mechanisms to model spatial dependencies and also incorporates a novel propagation delay sensing module, demonstrating outstanding modeling performance.
[0159] In contrast, the DSTF model effectively handles the complex spatiotemporal dependencies of traffic flow and achieves higher prediction accuracy. Specifically, GRes2Net progressively expands the receptive field in the temporal dimension through stepwise connections, thereby capturing multi-scale temporal features. LSGSFEM combines local dual-viewpoints with a global spatial perspective, capturing both local node interaction features and the dynamic interactions between global nodes. Furthermore, by incorporating temporal and spatial dynamic matrices into the graph aggregation process, DSTSAM can capture the dynamic interactions of nodes in both temporal and spatial dimensions.
[0160] Tables 3 and 4 Figure 2 and Figure 3 This paper presents the average prediction results of the DSTF model and other benchmark models on two datasets for time intervals of 5, 15, 30, and 45 minutes. The best results are presented in bold, and the second-best results are marked with an underline. The results show that the DSTF model performs best in both short-term and medium-to-long-term predictions. This can be attributed to the DSTF model's ability to extract multiple spatiotemporal features. Specifically, the multi-scale temporal feature extraction module utilizes a convolutional neural network to consider local temporal features, while the temporal adjacency matrix calculated through a temporal self-attention mechanism captures long-term temporal dependencies. Furthermore, the local feature extraction module comprehensively considers short-distance spatial dependencies, while the global spatial self-attention module effectively extracts global spatial dependencies. Moreover, it can be observed that the prediction performance of each model decreases to varying degrees as the prediction time increases. This phenomenon may be attributed to the complex and dynamic nature of traffic systems, which are influenced by numerous factors, including weather conditions and sudden emergencies. Traffic flow within the road network may change significantly over time, posing a greater challenge to accurate model prediction.
[0161] Table 2: Prediction results of different models on four datasets. The best value is highlighted in bold. The second-best results are marked with an underline.
[0162]
[0163]
[0164] Table 3: Prediction performance of the DSTF model on the PEMS04 dataset. Best results are highlighted in bold, and second-best results are underlined.
[0165]
[0166] Table 4: Prediction performance of the DSTF model on the PEMS08 dataset. Best results are highlighted in bold, and second-best results are underlined.
[0167]
[0168]
[0169] Generalization ability
[0170] To evaluate the robustness of the DSTF model under different conditions, it was tested on the Hangzhou Metro (HZMETRO) dataset. Unlike the PEMS series datasets, the Hangzhou Metro (HZMETRO) dataset presents distinctly different geographical features and traffic patterns. For comparison, three competitive benchmark models were selected, as detailed in Table 5. The results show that the DSTF model consistently outperforms these benchmark models across all three evaluation metrics, highlighting its effectiveness and robustness.
[0171] Table 5: Prediction results of different models on the Hangzhou Metro (HZMETRO) dataset. The best value is highlighted in bold, and the second best value is marked with an underline.
[0172]
[0173] ablation experiment
[0174] To further verify the effectiveness of each component of the model, the following six model variants were designed and ablation experiments were conducted on the PEMS04 dataset:
[0175] The w / o GR2N variant removes the GRes2Net module that captures multi-scale temporal dependencies;
[0176] The w / o SPA variant removes the attention module that captures dynamic global dependencies;
[0177] • w / o SG-GCN removes the temporal similarity of Geom-GCN, which captures static local features;
[0178] • w / o GG-GCN removes the adjacency Geom-GCN that captures static local features;
[0179] The dynamic spatiotemporal synchronization aggregation module has been removed from DSTSA.
[0180] • w / o GConv replaces the gated convolutions in the GRes2Net module with ordinary convolutions.
[0181] Table 6 and Figure 4The results show that the DSTF model outperforms its variants, validating the effectiveness of each component. The GG-GCN and SG-GCN variants exhibit the most significant performance degradation, indicating that relying solely on geographic or semantic spatial perspectives is insufficient to fully consider traffic flow and interactions influenced by real-world road network structures. Furthermore, the performance of the w / o SPA variant highlights the critical importance of capturing dynamic spatial dependencies between nodes that evolve over time. The results of the w / o GR2N variant underscore the necessity of extracting multi-scale temporal features for effective time-series learning. Similarly, the performance of the w / o GConv variant emphasizes the superior ability of gated convolutions to comprehensively extract temporal features. This superiority stems from the gating mechanism's ability to regulate information flow within convolutional layers, ensuring that only crucial information essential for prediction is retained after each convolutional operation. Finally, the w / o DSTSA variant underscores the important role of capturing dynamic spatiotemporal cross-correlation in traffic flow prediction.
[0182] To investigate the impact of various attention mechanisms on the model, a series of comparative experiments were conducted using the PEMS04 dataset. The relevant results can be viewed in Table 7. The definitions of each module are as follows:
[0183] • w / oATT: Removes the temporal attention mechanism from DSTSAM.
[0184] • w / o STT: Remove spatial attention mechanism from DSTSAM.
[0185] • w / o ATT-STT: Removes both temporal and spatial attention mechanisms from DSTSAM, which is essentially removing DSTSAM completely.
[0186] • w / o SPA: Remove the global spatial attention mechanism from LGSFEM.
[0187] • w / o STT-SPA: Simultaneously remove the spatial attention mechanism in DSTSAM and the global spatial attention mechanism in LGSFEM.
[0188] • w / o ATT-SPA: Simultaneously removes the temporal attention mechanism in DSTSAM and the global spatial attention mechanism in LGSFEM.
[0189] • w / oATT-STT-SPA: Removes the global spatial attention mechanism from local LGSEM, and removes the temporal and spatial attention mechanisms from DSTSAM.
[0190] The results show that the global spatial attention mechanism in LGSFEM plays a crucial role in model performance, indicating that relying solely on local spatial correlations is insufficient to capture the broader spatial relationships between nodes within the road network. Furthermore, removing either the temporal or spatial attention mechanism from DSTSAM leads to a significant performance degradation, highlighting the importance of extracting spatiotemporal cross-correlation. This necessity stems from the inherent spatiotemporal dependencies in traffic flow, as vehicles traverse the road network over time.
[0191] Table 6: Ablation studies on the PEMS04 dataset; best values are highlighted in bold.
[0192]
[0193]
[0194] Table 7: Performance comparison of attention mechanisms on the PEMS04 dataset. The best value is highlighted in bold.
[0195]
[0196] Analysis and Visualization
[0197] To visually demonstrate the model's performance, traffic flow prediction results for sensor nodes on the PEMS04 dataset were visualized. Specifically, a day was randomly selected from the PEMS04 dataset, and for 5-minute and 60-minute prediction tasks, the actual traffic flow values were plotted alongside the predictions from the DSTF and PDFormer models. This visualization includes two randomly selected sensor nodes: one with relatively sparse traffic and the other with relatively dense traffic, such as... Figure 5 As shown. From Figure 5 It can be observed that both the PDFormer model and the DSTF model can effectively predict the dynamic changes in future traffic flow. However, the overall trend indicates that the DSTF model provides more accurate predictions, suggesting that incorporating multiple spatiotemporal characteristics can improve the accuracy of traffic flow prediction.
[0198] In addition, it is worth noting that traffic flow steadily increased between 4 a.m. and 6 a.m., and peaked around 6 a.m. Figure 5 The red box in (a) highlights that, when making long-term predictions, the DSTF model handles the long-term dynamic changes in traffic flow better than the PDFormer model. This is likely because the DSTF model covers a longer timeframe, during which traffic conditions undergo more complex changes. By considering various spatiotemporal correlations, the DSTF model can capture these complex features more comprehensively, thereby improving prediction accuracy.
[0199] Figure 6 This displays actual traffic flow over seven consecutive days and the predicted values given by the DSTF model for a 60-minute prediction task. From... Figure 6 As can be clearly seen, the DSTF model can generally predict dynamic changes in traffic flow. However, within the area marked by the blue circle, the DSTF model struggles to accurately capture these changes. This discrepancy is likely caused by external factors, such as social activities, unexpected events, or weather conditions, which can cause sudden fluctuations in traffic conditions. The data input into the DSTF model is merely historical surrounding traffic flow data along with corresponding daily and weekly time stamps, making it difficult for the DSTF model to capture sudden changes in traffic flow patterns.
[0200] Based on the same inventive concept, this invention also provides a computer device, comprising: one or more processors, and a memory for storing one or more computer programs; the programs include program instructions, and the processor executes the program instructions stored in the memory. The processor may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. It is the computing and control core of the terminal, used to implement one or more instructions, specifically for loading and executing one or more instructions stored in a computer storage medium to implement the above-described method.
[0201] It should be further explained that, based on the same inventive concept, the present invention also provides a computer storage medium storing a computer program, which, when executed by a processor, performs the above-described method. This storage medium can be any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In the present invention, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0202] In the description of this specification, references to terms such as "an embodiment," "example," "specific example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this disclosure. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0203] The foregoing has shown and described the basic principles, main features, and advantages of this disclosure. Those skilled in the art should understand that this disclosure is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of this disclosure. Various changes and modifications can be made to this disclosure without departing from its spirit and scope, and all such changes and modifications fall within the scope of this disclosure as claimed.
[0204] This patent is not limited to the above-described preferred embodiment. Anyone can derive other forms of traffic flow prediction methods based on multivariate spatiotemporal feature extraction under the guidance of this patent. All equivalent changes and modifications made within the scope of this patent application shall fall within the scope of this patent.
Claims
1. A traffic flow prediction method based on multivariate spatiotemporal feature extraction, characterized in that: A multivariate spatiotemporal feature extraction model is adopted. In the time dimension, a gated convolution improved Res2Net module is used to capture the traffic flow change pattern over time. In the spatial dimension, from the global and local perspectives, spatial attention mechanism and dual-view Geom-GCN are used to capture the global spatial correlation, geographical neighborhood spatial correlation and semantic similarity spatial correlation between nodes in the urban road network. In the time-space interaction dimension, a dynamic spatiotemporal synchronization aggregation module built using spatiotemporal attention captures the dynamic interaction relationships between nodes or regions across time slices to predict future road traffic flow. The multivariate spatiotemporal feature extraction model includes: a data embedding layer, L stacked spatiotemporal feature extraction layers, and an output layer. The data embedding layer integrates traffic flow with temporal and spatial information to embed traffic flow data. The spatiotemporal feature extraction layers extract and fuse features, including a local-global spatial feature extraction module for capturing spatial features, a gated convolution-improved Res2Net module for extracting multi-scale temporal features, a dynamic spatiotemporal synchronous aggregation module for modeling spatiotemporal cross-correlation, and a spatiotemporal feature fusion module that concatenates the extracted spatiotemporal features and fuses them through two linear layers and a ReLU activation function. The output layer is used to predict future traffic flow. The local-global spatial feature extraction module includes a local spatial feature extraction module and a dynamic global spatial feature extraction module. The local spatial feature extraction module is used to model the local spatial correlation of traffic flow using Geom-GCN from a dual perspective: based on the sensor adjacency matrix corresponding to road network connectivity and traffic data similarity, a geospatial graph structure and a semantic spatial graph structure are constructed; latent spatial neighborhoods are constructed using Struc2vec and Node2vec embedding algorithms, and graph aggregation is performed using Geom-GCN; the dynamic global spatial feature extraction module uses a spatial self-attention mechanism to dynamically assign weights to spatial information at different locations to capture global dynamic spatial correlation. In the local spatial feature extraction module: Geographic Neighborhood Spatial Graph Structure G G Based on the sensor adjacency matrix, adjacency matrix A is constructed. G ∈R N×N The expression is as follows: Where v represents a sensor node on the road network, E represents the set of edges between nodes, and A∈R N×N It models the transportation network as a weighted adjacency matrix of a directed graph; Semantic similarity space graph structure G S Given any two time series X = (x1, x2, x3, ..., x...) m ) and Y = (y1, y2, y3, ..., y n Given sequences of lengths m and n, the FastDTW algorithm is used to calculate the similarity between any two traffic flow sequences from different sensor nodes, thus obtaining the similarity between the two sensor nodes. Based on the FastDTW calculation results, the top_k (v) sensor nodes with the highest similarity to each node are identified. i Thus, the adjacency matrix A is established. S ∈R N×N : The graph structure based on geographic neighborhood uses the Struc2Vec algorithm as the node embedding algorithm, while the graph structure based on semantic similarity uses the Node2vec algorithm as the node embedding algorithm. Given input features Based on the geographical neighborhood spatial graph structure G G and semantic similarity space graph structure G S Local spatial correlations were captured using Geom-GCN, and the results were obtained. and By employing a gated fusion mechanism that simultaneously considers both geographical adjacency and semantic similarity spatial dependencies, local spatial features X are obtained. LS : z=sigmoid((X G W G +b G )+(X S W S +b S )) X LS =z⊙X G +(1-z)⊙X S in, For the characteristics after fusion, W G W S Given two learnable parameter matrices, b G and b S ⊙ represents the weight bias, and ⊙ represents the Hadamard product. The dynamic global spatial feature extraction module uses a multi-head self-attention mechanism to capture global dynamic spatial correlations, specifically represented by the following steps: At time t, given the input data First, the three matrices needed to calculate multi-head self-attention are obtained through linear transformation: in, These are three learnable parameter matrices; The correlation between individual sensor nodes in each attention head is calculated using a scaled dot product attention mechanism: in, Indicates sensor node v at time t i With node v j Similarity vectors between them; The similarity vector is normalized using the softmax function to calculate node v. i Similarity scores between individual sensor nodes; use similarity scores to evaluate values. Weighting; in, It is a learnable parameter matrix. This represents the output of the h-th attention head module at time t. It is the output of the multi-head self-attention module at time t.
2. The traffic flow prediction method based on multivariate spatiotemporal feature extraction according to claim 1, characterized in that: The data embedding layer incorporates information including time location encoding, time periodicity, and geospatial adjacency to embed and represent traffic flow data. The processing includes: Input traffic flow X input Transformed into a fixed-dimensional representation X through a fully connected layer. f ∈R N×d Where N is the number of sensor nodes in the traffic network, and d is the embedding dimension of the data; Constructing time location code X t ∈R T×d : Where t represents the position of time in the time series, and i is the length of the series; After dividing the time period, it is converted into a high-dimensional representation to form a periodic embedding X. p ∈R T×d Where T is the historical step size of each sensor node; The structural information of the road network is represented using the graph Laplacian eigenvector, using the formula: Δ = ID -1 / 2 AD -1 / 2 =U T ΛU yields the Laplacian eigenvectors of the normalized adjacency matrix; where A is the adjacency matrix, D is the degree matrix, I is the identity matrix, U is the eigenvector matrix, and Λ is the eigenvalue; then, the obtained eigenvectors are processed through a linear operation layer to generate a spatial embedding code X. s ∈R N×d ; The output X of the data embedding layer is obtained by summing the temporal and spatial embedding codes. emb ∈R N×T×d : X emb =X f +X t +X p +X s 。 3. The traffic flow prediction method based on multivariate spatiotemporal feature extraction according to claim 2, characterized in that: After the data embedding layer, tensor X emb ∈R N×T×d Perform segmentation, dividing into feature subsets and d1+d2=d, the feature subset The input local-global spatial feature extraction module captures local and global spatial features in traffic flow data; and the feature subsets are then processed. An improved Res2Net module with input-gated convolution extracts temporal features at different scales.
4. The traffic flow prediction method based on multivariate spatiotemporal feature extraction according to claim 1, characterized in that: In the gated convolution improved Res2Net module: Input features After a 1×1 convolution; The input features are then segmented along the channel dimension, uniformly divided into k feature mapping subsets. Where i∈{1,2,...,k}; Map each feature subset After performing one gated convolution and upsampling operation, it is mapped to the next feature subset. The two sides are added together, and then proceed to the next gated convolution; the process is as follows: Where Г1 and Г2 are convolution kernels of size 1×S1 and 1×S2, respectively; ★ represents the convolution operation; and g and σ are the tanh and sigmoid activation functions, respectively. The output y of all feature mapping subsets i The concatenation operation is performed, followed by a residual convolutional layer and a ReLU activation function to obtain the final output: in Indicates a splicing operation; Division For feature subset and Where c1 + c2 = d2.
5. The traffic flow prediction method based on multivariate spatiotemporal feature extraction according to claim 4, characterized in that: The dynamic spatiotemporal synchronization aggregation module uses a multi-head self-attention mechanism, specifically represented by the following steps: Given traffic flow data of sensor node n at time slot T First, calculate the two inputs for multi-head attention: in, These are the three learnable parameter matrices of the h-th attention head; Obtain the dynamic temporal adjacency matrix: Given input data The dynamic space adjacency matrix is calculated using the following formula: Given input data In addition to dynamic temporal adjacency matrices and dynamic spatial adjacency matrices, a temporal adjacency matrix is added to the graph convolutional neural network to achieve synchronous spatiotemporal feature extraction. X DST =A s X2A t W1+b3 X2=X GR W2+b4 Where W1, W2 and b3, b4 are the learnable weights and bias parameters, respectively; The expression for the spatiotemporal feature fusion module is: Where W3, W4 and b5, b6 are the learnable weights and bias parameters, respectively. The outputs are respectively the gated convolution improved Res2Net module, the local-global spatial feature extraction module, and the dynamic spatiotemporal aggregation module; based on the extracted spatiotemporal features, the output of the spatiotemporal layer is obtained through the residual connection layer and the feedforward neural network layer; The output layer consists of two 1×1 convolutional layers, which take the result obtained from the spatiotemporal feature extraction layer through the skip connection layer as input and convert it into the final prediction output.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of a traffic flow prediction method based on multivariate spatiotemporal feature extraction as described in any one of claims 1-5.
7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of a traffic flow prediction method based on multivariate spatiotemporal feature extraction as described in any one of claims 1-5.
Citation Information
Patent Citations
Traffic prediction method and device based on dynamic space-time diagram convolution attention model
CN113487088A
Traffic flow prediction method based on multimode dynamic memory graph convolutional network
CN119107798A