A Time-Varying Graph Neural Network-Based Traffic Flow Prediction Method Based on Dynamic Memory
By using a time-varying graphical neural network based on a dynamic memory bank, combined with multi-scale spatial propagation and spatiotemporal dynamic modeling, the problem of balancing local and global dependencies in traffic flow prediction is solved, enabling accurate characterization of complex traffic situations and efficient prediction of emergencies.
Patent Information
- Application Number
- CN202511695390.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-19
- Publication Date
- 2026-03-13
- Estimated Expiration
- 2045-11-19
AI Technical Summary
Existing traffic flow prediction methods struggle to balance local feature extraction with global dependency modeling, and lack dynamic adaptive capabilities under unforeseen circumstances, resulting in insufficient prediction accuracy and stability.
A time-varying graph neural network based on dynamic memory is adopted. By introducing a delay-aware multi-scale spatial propagation mechanism and two-dimensional spatiotemporal dynamic evolution modeling, combined with spatiotemporal embedding, dynamic graph structure, time-delay graph convolution module and hierarchical time-series perception module, the dynamic correlation of traffic network is captured, and the dynamic memory is used to enhance the reuse capability of historical patterns.
It significantly improves the accuracy and stability of traffic flow forecasting, can adapt to complex traffic dynamics, and enhances the accuracy of forecasting emergencies and the robustness of the system.
Smart Images

Figure CN121171043B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of traffic prediction technology, and in particular relates to a time-varying graph neural network traffic flow prediction method based on a dynamic memory bank. Background Technology
[0002] With the acceleration of global urbanization and the rapid growth of motor vehicle ownership, urban transportation systems are facing increasingly severe pressure, and traffic congestion is becoming more and more serious, greatly affecting travel efficiency, energy consumption, and the urban environment. Transportation, as a crucial cornerstone of national prosperity and development, is closely related to the stable operation of the economy and society. However, traditional measures such as vehicle restrictions and road expansion are no longer sufficient to fundamentally solve the traffic problem.
[0003] Against this backdrop, Intelligent Transportation Systems (ITS) have become a key means to improve traffic management efficiency and promote sustainable urban transportation development. By predicting changes in traffic flow, management departments can provide early warnings of potential traffic accidents or emergencies, reducing the impact of accidents on traffic and improving public safety. At the same time, traffic flow prediction also provides the foundation for the implementation of ITS, which can adjust traffic flow in real time and optimize measures such as traffic light control and traffic guidance, thereby improving the overall operational efficiency of the transportation system.
[0004] The development of traffic flow prediction methods can be broadly divided into two stages: traditional methods and deep learning. Traditional methods are mainly based on mathematical statistics and classical machine learning techniques, such as Kalman filtering, autoregressive moving average models, and locally weighted regression. These methods have played a role in short-term, single-point predictions, but due to their inherent linear assumptions and limited modeling capabilities, they struggle to capture the complex nonlinear spatiotemporal relationships in traffic data. With the continuous increase in data scale and complexity, deep learning models have gradually become the mainstream solution. Early convolutional neural networks and recurrent neural networks focused on extracting spatial and temporal features, respectively; subsequently, graph neural networks significantly improved the ability to characterize spatial dependencies by explicitly modeling the road network topology; and the Transformer model, with its unique self-attention mechanism, has shown significant advantages in handling long-range temporal dependencies. Although methods represented by deep learning have become the trend, these methods often struggle to balance local feature extraction and global dependency modeling when capturing complex spatiotemporal dependencies, resulting in insufficient representation of long-range spatiotemporal relationships or high computational costs.
[0005] Chinese invention patent application CN202411122085.0 discloses a traffic flow prediction method based on a multimodal dynamic memory graph convolutional network. This method fuses temporal features through a temporal feature extraction module and a bidirectional memory recurrent network module, and utilizes diffusion graph convolution, attention mechanisms, and typical traffic patterns to capture spatial correlations, generating a dynamic adjacency matrix to improve prediction accuracy and robustness. Its advantage lies in constructing a comprehensive traffic situation representation through multimodal feature fusion. However, this method fails to dynamically subdivide and maintain its memory by time step, limiting its ability to capture instantaneous pattern differences between adjacent time steps. Furthermore, its multimodal fusion mechanism employs a fixed weight allocation strategy, lacking dynamic adaptability for different traffic scenarios, and is prone to weakening the feature contributions of key modes in sudden situations or data distribution drift. Summary of the Invention
[0006] To address the aforementioned shortcomings in existing technologies, this invention introduces a multi-scale spatial propagation mechanism based on delayed perception and two-dimensional spatiotemporal dynamic evolution modeling. This effectively overcomes the deficiencies of traditional models in capturing dynamic spatiotemporal features and balancing long-term and short-term dependencies, thereby significantly improving prediction accuracy and the ability to model complex traffic dynamics.
[0007] To achieve the above objectives, this invention provides a time-varying graph neural network traffic flow prediction method based on a dynamic memory bank, comprising the following steps:
[0008] S1. Collect historical traffic flow data and obtain traffic flow sequences through preprocessing;
[0009] S2. The temporal pattern of the collaboratively encoded traffic flow sequence is spatially correlated with the road network. Through spatiotemporal embedding, refinement and fusion, and feature splicing, enhanced embedded features are generated.
[0010] S3. Construct an initial weighted adjacency matrix based on the road network topology, calculate the correlation of node features by combining enhanced embedding features, optimize the weight and connection of edges accordingly, and construct a dynamic graph structure.
[0011] S4. Input the dynamic graph structure and enhanced embedded features into the spatiotemporal flow decoupling extraction module, which includes a temporal branch and a spatial branch;
[0012] The spatial branch includes a sequentially connected time-delay graph convolutional module and a spatial Mamba module, which characterizes local and global spatial dependencies and obtains spatial features.
[0013] The time branch includes a hierarchical time-series awareness module and a time Mamba module connected in sequence, which capture short-term changes and long-term evolution patterns to obtain time features;
[0014] S5. Spatial and temporal features are fused through cross-attention to obtain spatiotemporal fusion features;
[0015] S6. Input the spatiotemporal fusion features into the dynamic memory bank, enhance the spatiotemporal fusion features based on the memory perception mechanism, and generate memory-enhanced features;
[0016] S7. Use GCRN as a decoder to integrate memory-enhanced features and generate the final prediction result.
[0017] Furthermore, S1 specifically refers to:
[0018] Historical traffic flow data is collected, cleaned, and normalized.
[0019] The preprocessed data is used to construct an initial spatiotemporal tensor. This initial spatiotemporal tensor is then divided using a sliding window of fixed length to generate traffic flow sequences. .
[0020] Furthermore, S2 specifically refers to:
[0021] S2.1. The traffic flow sequence X is mapped through a fully connected layer and transformed into features. ;
[0022] S2.2, Based on the time information of the input sequence, including time information and periodic information Initial temporal embeddings are generated through one-hot encoding and linear transformation. ;
[0023] S2.3. The initial temporal embedding is refined using an unbiased multilayer perceptron to capture multi-resolution temporal features, and then broadcast along the node dimension to obtain the temporal embedding. ;
[0024] S2.4. Based on the traffic network topology, calculate the normalized Laplacian matrix and perform eigenvalue decomposition, selecting the top... The eigenvectors corresponding to the smallest non-zero eigenvalues constitute the initial spatial embedding. ;
[0025] S2.5. The initial space is embedded and projected onto the dimension using an unbiased multilayer perceptron. And broadcast along the time dimension to obtain spatial embedding. ;
[0026] S2.6 Embedding Time With spatial embedding To perform fusion, a sine function is used to process the temporal embedding. The function processes spatial embeddings and adds the two to obtain a fused spatiotemporal embedding. ;
[0027] S2.7, Features spatiotemporal embedding Concatenate the data to generate enhanced embedded features. .
[0028] Furthermore, S3 specifically refers to:
[0029] S3.1 Based on the traffic network topology, the Gaussian kernel function is used to calculate the distance between nodes and construct the initial weighted adjacency matrix A;
[0030] S3.2 Calculate each pair of nodes The statistical distribution similarity of embedded features is enhanced within a historical time window to obtain their feature relevance score. ;
[0031] S3.3, Set a correlation threshold The initial adjacency matrix A containing elements below the threshold The edges are scored based on their relevance. Make adjustments to generate a temporary adjacency matrix. ;
[0032] S3.4 For each time step t, the temporary adjacency matrix is... The initial adjacency matrix A and the similarity matrix calculated from the enhanced embedding features at this time step are weighted and fused to obtain the dynamically adjusted adjacency matrix. ;
[0033] S3.5, Generate a dynamic graph structure for each time step. Where V is the set of nodes and E is the set of edges. Let be the dynamic adjacency matrix corresponding to time step t.
[0034] Furthermore, in the spatial branch, the time-delay graph convolution module first performs multi-scale graph convolution operations using graph wavelet transform, and combines a delay-aware mechanism to model the network information propagation delay, so as to capture the local and global spatial dependencies and output multi-scale spatial features. ;
[0035] The spatial Mamba module receives the multi-scale spatial features output by the delay map convolution module. The system models the long-range dependencies of spatial dimensions using a state-space model and leverages its selective mechanism to dynamically adjust the state transition process based on the input, ultimately outputting enhanced spatial features. ;
[0036] In the aforementioned time branch, the hierarchical time-series awareness module captures short-term time patterns at different time scales through multiple parallel causal convolutional layers with different dilation rates. It then fuses the outputs of each branch to extract multi-scale time features without introducing future information, outputting temporal context features. ;
[0037] The time Mamba module receives the time context features output by the hierarchical time-aware module. By selectively encoding the temporal dimension using a state-space model, fine-grained modeling of temporal dynamics and capture of evolutionary trends are achieved, ultimately outputting enhanced temporal features. .
[0038] Furthermore, in S5, spatial features are... With time characteristics By employing a cross-attention mechanism for bidirectional interactive fusion, spatiotemporal fusion features containing complex evolutionary patterns are generated. .
[0039] Furthermore, S6 specifically includes:
[0040] The spatiotemporal fusion features are input into a learnable dynamic memory. The spatiotemporal fusion features are retrieved through a memory perception mechanism, and relevant patterns are dynamically extracted from the memory bank and reconstructed into memory features.
[0041] The reconstructed memory features are adaptively fused with the original spatiotemporal fusion features to generate memory-enhanced features. .
[0042] Furthermore, S7 specifically includes:
[0043] Using GCRN as the decoder, a unified mapping and modeling of memory-enhanced features is performed. At each time step t, the memory-enhanced features at the current time step are... Compared to the previous hidden state The inputs are fed into the gated graph convolutional recurrent unit to synchronously update the spatiotemporal hidden state;
[0044] The decoder iterates along the time dimension, transforming the resulting sequence of hidden states linearly through a fully connected layer to map the future. Prediction results of steps .
[0045] Compared with the prior art, the present invention has the following beneficial effects:
[0046] 1. This invention addresses the shortcomings of traditional methods in representing spatiotemporal features. By using an innovative spatiotemporal embedding mechanism to collaboratively encode temporal patterns and spatial topological relationships, combined with the construction of a dynamic graph structure based on real-time node features, it achieves an accurate characterization of the dynamic correlation of traffic networks.
[0047] 2. This invention overcomes the limitations of existing models in multi-scale spatiotemporal dependency modeling. It adopts a time-delay graph convolution module to introduce a delay-aware mechanism to accurately characterize the traffic wave propagation effect. Combined with a hierarchical time-series awareness module and a two-dimensional Mamba model, it achieves refined spatiotemporal feature extraction from local to global.
[0048] 3. This invention enhances the adaptability and generalization ability of traffic prediction systems to complex traffic dynamics. It matches and reuses historical spatiotemporal patterns through a dynamic memory bank and uses a GCRN decoder to achieve accurate integration of memory-enhanced features and synchronous updates of spatiotemporal states, which significantly improves the prediction accuracy and stability of the model under sudden traffic events. Attached Figure Description
[0049] Figure 1 This is a flowchart illustrating the method.
[0050] Figure 2 This is a schematic diagram of the traffic flow prediction model.
[0051] Figure 3 A schematic diagram of the branch structure for spatial feature extraction.
[0052] Figure 4 This is a schematic diagram of the branch structure for time feature extraction.
[0053] Figure 5 This is a schematic diagram of the feature fusion module structure.
[0054] Figure 6 This is a schematic diagram of the decoder module structure.
[0055] Figure 7 This is a schematic diagram of the prediction results using this method. Detailed Implementation
[0056] The present invention will be further described below with reference to embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0057] like Figure 1 As shown, this invention provides a time-varying graph neural network-based traffic flow prediction method based on a dynamic memory bank, the implementation of which is as follows:
[0058] S1. Collect historical traffic flow data and obtain traffic flow sequences through preprocessing;
[0059] S2. The temporal pattern of the collaboratively encoded traffic flow sequence is spatially correlated with the road network. Through spatiotemporal embedding, refinement and fusion, and feature splicing, enhanced embedded features are generated.
[0060] S3. Construct an initial weighted adjacency matrix based on the road network topology, calculate the correlation of node features by combining enhanced embedding features, optimize the weight and connection of edges accordingly, and construct a dynamic graph structure.
[0061] S4. Input the dynamic graph structure and enhanced embedding features into the spatiotemporal flow decoupling extraction module. The spatiotemporal flow decoupling extraction consists of two parts: a time branch and a spatial branch.
[0062] The spatial branch includes a spatial feature extraction module, which is sequentially connected to the time delay graph convolution module and the spatial Mamba module to characterize local and global spatial dependencies and obtain spatial features.
[0063] The time branch includes a time feature extraction module, which is sequentially connected to the hierarchical time series awareness module and the time Mamba module to capture short-term changes and long-term evolution patterns and obtain time features.
[0064] S5. Spatial and temporal features are fused through cross-attention to obtain spatiotemporal fusion features;
[0065] S6. Input the spatiotemporal fusion features into the spatiotemporal node dynamic memory bank, strengthen the spatiotemporal fusion features based on the memory perception mechanism, and generate memory-enhanced features;
[0066] S7 and GCRN are used as decoders to integrate memory-enhanced features to generate the final prediction result.
[0067] like Figure 2 As shown, the present invention provides a time-varying graph neural network traffic flow prediction method based on dynamic memory bank, which includes a data embedding layer, a spatiotemporal coding layer, a memory enhancement layer, and a prediction output layer;
[0068] Data embedding layer: used to preprocess traffic flow data into traffic flow sequences and co-encode their temporal patterns and road network topology, forming enhanced embedding features through the fused spatiotemporal embeddings;
[0069] Spatiotemporal coding layer: used to achieve decoupled extraction of spatiotemporal flow. The spatial branch uses delay graph convolution and spatial Mamba to realize delay-aware spatial dependency modeling. The temporal branch uses a hierarchical temporal awareness module and temporal Mamba to capture multi-granular temporal features. The outputs of the two branches are fused through a cross-attention mechanism to generate spatiotemporal fusion features.
[0070] Memory enhancement layer: used for pattern matching and reconstruction of spatiotemporal fusion features based on dynamic memory bank, generating memory enhancement features by retrieving and reusing similar historical spatiotemporal patterns;
[0071] The prediction output layer uses GCRN as the core decoder and, through the collaborative decoding mechanism of GCN and LSTM, performs sequence decoding and mapping of memory-enhanced features to ultimately output the prediction results of future traffic flow.
[0072] Specifically, historical traffic flow data is collected and preprocessed to obtain a traffic flow sequence, including the following sub-steps:
[0073] S1.1 Obtain California highway sensor data as a dataset, perform data cleaning, and normalize the traffic flow data using the Z-score normalization method;
[0074] S1.2. Construct an initial spatiotemporal tensor from the preprocessed data, and continuously divide it using a sliding window of fixed length T. Use the data slice within each window as a training sample to generate traffic flow sequences. Where T is the historical time step, N is the number of nodes, and D is the feature dimension.
[0075] Specifically, the collaborative coding of temporal patterns and spatial correlations in traffic flow sequences forms enhanced embedding features, including the following sub-steps:
[0076] S2.1 Map the traffic flow sequence X into features through a fully connected layer. ,in For the hidden layer dimension;
[0077] S2.2 Based on the time information in the input sequence, including time information and periodic information Initial temporal embeddings are generated through one-hot encoding and linear transformation. The formula for its calculation is:
[0078] ;
[0079] in, The ReLU activation function is used. Represents learnable parameters;
[0080] S2.3, Initial time embedding is performed using an unbiased multilayer perceptron. The process involves refining the data to capture multi-resolution temporal features and broadcasting them along the node dimensions to obtain the temporal embedding. The formula for its calculation is:
[0081] ;
[0082] in, represent Activation function These are learnable parameters;
[0083] S2.4 Calculate the normalized Laplace matrix based on the traffic network topology. ,in Let D be the adjacency matrix, D be the degree matrix, and I be the identity matrix. Perform eigenvalue decomposition And select the eigenvector matrix Center front The eigenvectors corresponding to the smallest non-zero eigenvalues constitute the initial spatial embedding. ;
[0084] S2.5. Embed the initial space using an unbiased multilayer perceptron. Projected onto target dimension And broadcast along the time dimension to obtain spatial embedding. The formula for its calculation is:
[0085] ;
[0086] in, These are learnable parameters;
[0087] S2.6 Embedding Time With spatial embedding To achieve fusion, a sine function is used to process the time embedding. The function processes spatial embeddings and adds the two to obtain a fused spatiotemporal embedding. The formula for its calculation is:
[0088] ;
[0089] S2.7, Features spatiotemporal embedding Concatenate the data to generate enhanced embedded features. Its calculation formula is ,in, .
[0090] Specifically, based on the road network topology and real-time node characteristics, it is mapped to a dynamically evolving graph structure, including the following sub-steps:
[0091] S3.1 Based on the traffic network topology, construct an initial weighted adjacency matrix A, where for any two nodes i and j, if they are physically directly connected, then the adjacency matrix is determined based on spatial distance. Calculate connection weights using a Gaussian kernel function ,otherwise ;
[0092] S3.2 Calculate the feature relevance score of two nodes i and j within the historical time window based on node-based enhanced embedding features. The formula for its calculation is:
[0093] ;
[0094] in, This is a normalization parameter used to adjust the sensitivity of the relevant metric; its value is set to 0.5 to strike a balance between model sensitivity and noise robustness, and to ensure the stability of numerical calculations. It is the feature mean of node i within the historical window. It is the variance of the eigenvalues of node i within the historical window. The feature correlation score represents the correlation between nodes i and j. The higher the value, the more similar the traffic patterns of the two nodes.
[0095] S3.3, Set a correlation threshold Based on this threshold, and combining the initial adjacency matrix A and the relevance score matrix S, the graph structure is dynamically adjusted to generate a temporary adjacency matrix. :
[0096] ;
[0097] Where the threshold Used to determine the strength of node associations, guiding the dynamic addition and deletion of edges in the graph: higher than This indicates high feature similarity, requiring the addition of missing connections; below this level... This indicates that the two nodes are highly heterogeneous and the existing invalid connections need to be deleted; its value is set to 0.5, which serves as the natural midpoint of the similarity interval and can effectively distinguish between strongly correlated and weakly correlated nodes;
[0098] S3.4 To achieve the spatiotemporal adaptive capability of the adjacency matrix, for each time step t, the temporary adjacency matrix is... The initial adjacency matrix A and the similarity matrix calculated from the enhanced embedding features at this time step are weighted and fused to obtain the dynamically adjusted adjacency matrix. :
[0099] ;
[0100] Where, α, β, For learnable weight coefficients, satisfying The initial values are set to 0.4, 0.4, and 0.2 respectively. This configuration aims to balance static topology and dynamic feature information, while moderately suppressing transient noise, so as to achieve efficient fusion of multi-source information.
[0101] S3.5 Therefore, a dynamic graph structure is generated for each time step. Where V is the set of nodes and E is the set of edges. Let be the dynamic adjacency matrix corresponding to time step t.
[0102] Specifically, the spatiotemporal dual-stream decoupling extraction includes the following sub-steps:
[0103] S4.1. The dynamic graph structure and enhanced embedding features are input into the spatiotemporal flow decoupling extraction module. The spatiotemporal flow decoupling extraction consists of two parts: a temporal branch and a spatial branch. The spatial branch includes a sequentially connected time-delay graph convolution module and a spatial Mamba module, such as... Figure 3 As shown, multi-scale spatial features are extracted through graph wavelet transform and delay sensing mechanisms, and long-range spatial dependencies are captured using a state-space model; the temporal branch includes a sequentially connected time-series sensing module and a time Mamba module, as shown... Figure 4 As shown, multi-scale causal convolution is used to extract temporal context features, and a state-space model is used to achieve fine-grained modeling of temporal dynamics.
[0104] S4.2 In the spatial feature extraction branch, the time-delay graph convolution module uses graph wavelet transform to perform multi-scale convolution operations in the spatial domain. Specifically, this module embeds the input enhanced features. Each time step in Treating them as independent graph signals and applying graph wavelet transform independently to each feature channel, the graph signal of each channel is filtered in the spectral domain, thereby capturing the spatial dependencies from local to global.
[0105] Simultaneously, a delay-aware mechanism is introduced to model the distance or time cost of information propagation as a signal delay on a graph, with the specific formula as follows:
[0106] ;
[0107] in, This represents the time-delay graph convolution operation. It is a set of graphical wavelet kernel functions with different scale parameters s. It is a dynamic adjacency matrix. For a learnable delay-aware matrix, its elements Characterizes the propagation delay from node i to node j;
[0108] This convolution process ultimately outputs all time steps. Stacking yields multi-scale spatial features. ,in Output channel dimensions for spatial features;
[0109] S4.3, Spatial Mamba module receives multi-scale spatial features The module models long-range dependencies in the spatial dimension using a state-space model. For each time step t, the module treats the node sequence as an independent sequence and applies the state-space model along the spatial dimension. Its discrete state-space equation is as follows:
[0110] ;
[0111] The output equation is:
[0112] ;
[0113] in, The discrete state transition matrix, C and C are the input projection matrix and the state projection matrix, respectively. It is the input for time step t. It is a hidden state, where the outputs of all time steps are stacked along the time dimension to form spatial features. ;
[0114] S4.4 In the time feature extraction branch, the hierarchical time series perception module captures short-term change patterns at different time scales through multiple parallel causal convolutional layers with different dilation rates.
[0115] Define the set of expansion rates This set defines the sampling interval of the convolution kernel in the time dimension, corresponding to small, medium, and large time scales respectively:
[0116] The convolutional kernel continuously covers the time steps, capturing features at small time scales;
[0117] The convolutional kernels are spaced one time step apart, capturing features at medium time scales.
[0118] The convolutional kernels are spaced three time steps apart to capture features at larger time scales.
[0119] Each group of dilated causal convolutional branches processes and enhances the embedded features independently. The specific formula is as follows:
[0120] ;
[0121] in, This represents a causal convolution operation with an expansion rate of r. As a learnable convolutional kernel, this operation strictly follows causal constraints, ensuring that the output at time t depends only on the input at time t and previous times, avoiding interference from future information;
[0122] The outputs of each branch are concatenated along the feature dimension and fused through a linear transformation to obtain multi-scale time features:
[0123] ;
[0124] The final output is a temporal context feature based on historical information. ,in Output channel dimension for time features;
[0125] S4.5 The time Mamba module receives the time context features output by the hierarchical time-aware module. For each node n, the module treats the time series as an independent sequence and applies a state-space model along the time dimension. The state-space equation and output equation are the same as in S4.3. This module adaptively adjusts the state transition process through an input-dependent selective mechanism, achieving fine-grained modeling of temporal dynamics and capturing evolutionary trends, outputting temporal features. .
[0126] Specifically, the step of fusing spatial and temporal features through cross-attention to obtain spatiotemporal fusion features includes the following sub-steps:
[0127] S5.1, such as Figure 5 As shown, spatial features With time characteristics By using a cross-attention mechanism for bidirectional interactive fusion, spatial features are made aware of the temporal context, and temporal features are integrated into spatial structural information. This mechanism first maps temporal features and spatial features to a unified hidden dimension d, thereby performing cross-attention calculation.
[0128] For attention streams from space to time, temporal features are used as queries. At the same time, spatial features are used as keys Sum :
[0129] , , ;
[0130] Calculate the attention weights from temporal features to spatial features:
[0131] ;
[0132] By performing weighted aggregation on the spatial value vectors, we obtain a temporal feature representation enhanced with spatial context:
[0133] ;
[0134] Similarly, for attention flows from time to space, spatial features are used as the query. At the same time, using time features as keys Sum :
[0135] , ;
[0136] Calculate the attention weights from spatial features to temporal features:
[0137] ;
[0138] By weighted aggregation of the time value vectors, a spatial feature representation enhanced with temporal context is obtained:
[0139] ;
[0140] Finally, the attention outputs from both directions are fused with the original input through residual connections and then normalized at each layer to generate a spatiotemporal fusion feature that simultaneously contains complex spatiotemporal evolution laws. The calculation formula is:
[0141] ;
[0142] Where C is the feature dimension after fusion, which fully preserves the spatiotemporal structure of the input, and the features at each position incorporate cross-domain semantic information.
[0143] Specifically, the memory-aware mechanism based on a dynamic memory bank is used to enhance spatiotemporal fusion features and generate memory-enhanced features, including the following sub-steps:
[0144] S6.1 Input the spatiotemporal fusion features into a learnable dynamic memory. To learn the inherent spatiotemporal patterns of traffic sequences, the memory maintains a memory pattern matrix for each historical time step t. ,in Indicates the number of memory entries. The dimension representing the memory entry;
[0145] Based on current spatiotemporal fusion characteristics Generate query vector through linear transformation and residual characteristics :
[0146] ;
[0147] ;
[0148] For each time step t, perform the following operations:
[0149] The query matrix for the current time step is obtained by slicing the query vector Q. ;
[0150] From memory bank Obtain the memory pattern matrix corresponding to time step t. ;
[0151] Calculate the similarity between the query matrix and the memory pattern matrix: Obtain the similarity weight matrix by performing a dot product operation and applying softmax normalization. The calculation formula is as follows:
[0152] ;
[0153] The memory patterns are weighted and aggregated using similarity weights to obtain the memory features at time step t. The calculation formula is as follows:
[0154] ;
[0155] By stacking the memory enhancement features of all time steps, the overall memory features are obtained. ;
[0156] S6.2, Memory Features Projected onto spatiotemporally fused features via linear transformation The same feature space, subsequently through learnable gating weights. By controlling the intensity of memory injection, adaptive fusion of memory features and original features can be achieved:
[0157] ;
[0158] The enhanced feature representation is then further refined using a feedforward network, which consists of two linear transformations and a GELU activation function, and maintains the integrity of the original information through residual connections.
[0159] ;
[0160] The final output memory enhancement features It retains the complete information flow of the original spatiotemporal fusion features, and also incorporates representative spatiotemporal patterns retrieved from the memory bank.
[0161] Specifically, GCRN, as a decoder, integrates memory-enhanced features to generate the final prediction result, including the following sub-steps:
[0162] S7.1 Using GCRN as a decoder for memory-enhanced features Perform unified mapping and modeling, with a structure such as Figure 6 As shown, to further enhance the spatial feature representation capability, a gated augmented graph convolution operation is used to capture spatial dependencies in the traffic network. This operation is defined as follows:
[0163] ;
[0164] in, These are the kernel parameters for the K-order Chebyshev polynomial approximation. It is an activation function, and ⊙ represents element-wise multiplication. This module captures spatial dependencies through graph convolution and then performs feature selection through a gating mechanism, thereby dynamically enhancing important spatial patterns and suppressing noise.
[0165] At each time step t, the decoder adds the memory-enhanced features from the current time step. Compared to the previous hidden state As input, based on dynamically generated graph structures The above graph convolution operation is combined with GRU to construct GCRN for synchronous spatiotemporal state computation. This process is implemented through the following gating mechanism:
[0166] ;
[0167] in, This represents the gated augmented graph convolution operation, where z and r represent the update gate and reset gate of GCRN, respectively. In the candidate hidden state, These are the learnable parameters for the corresponding gating;
[0168] S7.2, The decoder, based on the input feature sequence Iterate gradually, updating the hidden state at each step. And based on the complete hidden state sequence A linear mapping is performed through the prediction layer to output the traffic flow prediction results for the next T′ time steps. .
[0169] In this embodiment, the experiment of the time-varying graph neural network traffic flow prediction method based on dynamic memory bank was completed under the Ubuntu 22.04 operating system, with Python 3.12 as the programming environment and PyTorch 2.3.0 as the deep learning framework. The model training was carried out on a hardware platform equipped with NVIDIA RTX GeForce 3090 GPU (24GB VRAM) for a total of 200 rounds.
[0170] The experimental data came from the PEMS08 dataset from the California Traffic Performance Measurement System (Caltrans), specifically containing records from 170 sensors during July and August 2016. To verify the effectiveness of the method, the model's predictions were compared with the actual values on the PEMS08 dataset. Figure 7 As shown, the predicted curve closely matches the actual value, indicating that this method can accurately capture spatiotemporal dynamic features.
[0171] For the PEMS08 dataset, the model performance was evaluated by predicting traffic flow over the next 15, 30, and 60 minutes. Root mean square error (RMSE), mean absolute error (MAE), and mean absolute percentage error (MAPE) were used as evaluation metrics to compare the prediction performance of different methods. Lower RMSE and MAE values indicate higher prediction accuracy; MAPE directly reflects the relative magnitude of the prediction error, and a lower value is also better. Specific comparative experimental results are shown in Table 1, with the best results indicated in bold and the second-best results underlined.
[0172] Table 1. Comparison of prediction performance of different methods in the next 15 minutes, 30 minutes, and 60 minutes.
[0173]
[0174] In summary, this invention addresses the shortcomings of existing traffic prediction methods, such as insufficient modeling of dynamic spatiotemporal dependencies and difficulty in adapting to real-time changes in traffic conditions. By introducing dynamic graph convolution and a hierarchical temporal perception module, it accurately characterizes dynamic associations and long-range dependencies. Furthermore, by combining a dynamic memory library, it enhances the ability to reuse historical experience, thereby significantly improving prediction accuracy and robustness in complex scenarios.
[0175] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
[0176] While the specific embodiments of the present invention have been described above, they are not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.
Claims
1. A dynamic memory bank based time-varying graph neural network traffic flow prediction method, characterized in that, The method comprises the following steps: S1, collecting historical traffic flow data to obtain traffic flow sequence after preprocessing; S2, cooperatively coding the time sequence mode of the traffic flow sequence and the spatial correlation of the road network, refining and fusing the time-space embedding, and generating enhanced embedding features; S3, constructing an initial weighted adjacency matrix based on the topology of the road network, calculating the correlation of node features combined with the enhanced embedding features, optimizing the weight and connection of edges, and constructing a dynamic graph structure; S4, inputting the dynamic graph structure and the enhanced embedding features into a space-time flow decoupling extraction module, which comprises a time branch and a space branch; The space branch comprises a time-delay graph convolution module and a spatial Mamba module connected in sequence, which depict local and global spatial dependence relationships to obtain spatial features; The time branch comprises a hierarchical time sequence perception module and a time Mamba module connected in sequence, which capture short-term changes and long-term evolution rules to obtain time features; In the spatial branch, the time delay graph convolution module firstly performs multi-scale graph convolution operation by using graph wavelet transform, and combines a delay perception mechanism to model network information propagation delay, so as to capture local and global spatial dependence relationship and output multi-scale spatial features wherein is a spatial feature output channel dimension The spatial Mamba module receives the multi-scale spatial features output by the delay graph convolution module , the long-range dependencies of the spatial dimension are modeled by a state space model, and a selective mechanism is used to dynamically adjust the state transition process according to the input, and finally output enhanced spatial features ; In the time branch, the hierarchical time-aware module captures short-term time patterns at different time scales through multiple parallel causal convolution layers with different expansion rates, and fuses the outputs of each branch to extract multi-scale time features without introducing future information, and outputs the time context features wherein is the time feature output channel dimension The time mamba module receives the time context features output by the hierarchical time-aware module , through the selective encoding in the time dimension by the state space model, the fine-grained modeling of the time dynamics and the evolution trend capturing are realized, and finally the enhanced time features are output ; S5, fusing the spatial features and the time features through cross-attention to obtain space-time fusion features; S6, inputting the space-time fusion features into a dynamic memory bank, strengthening the space-time fusion features based on a memory perception mechanism, and generating memory-enhanced features; S7, integrating the memory-enhanced features using GCRN as a decoder to generate the final prediction result.
2. The dynamic memory bank based time-varying graph neural network traffic flow prediction method of claim 1, wherein: The S1 is specifically: Collecting historical traffic flow data, cleaning the data, and normalizing the data; The preprocessed data is constructed as an initial space-time tensor, and the initial space-time tensor is divided using a fixed-length sliding window to generate a traffic flow sequence where T is a historical time step, N is the number of nodes, and D is the feature dimension.
3. The dynamic memory bank based time-varying graph neural network traffic flow prediction method of claim 2, wherein: The S2 is specifically: S2.1, map the traffic flow sequence X through a fully connected layer to transform into features wherein is the hidden layer dimension; S2.2, based on the time information of the input sequence, including time information and period information , generate initial time embedding through one-hot encoding and linear transformation ; S2.3, refining the initial temporal embeddings by an unbiased multi-layer perceptron to capture multi-resolution temporal features and broadcasting them along the node dimension, resulting in temporal embeddings ; S2.4, based on the traffic network topology, calculate the normalized Laplacian matrix and perform eigen decomposition, select the eigenvectors corresponding to the first ; S2.5, project the initial spatial embedding to dimensions by an unbiased multi-layer perceptron and broadcast along the time dimension, resulting in a spatial embedding ; S2.6, time embeddings with spatial embeddings fused, using a sine function to process the time embeddings, a function to process the spatial embeddings, and adding the two to get the fused spatio-temporal embedding ; S2.7, the features spatial-temporal embedding concatenating to generate enhanced embedding features wherein, .
4. The dynamic memory bank based time-varying graph neural network traffic flow prediction method of claim 3, wherein: The S3 is specifically: S3.1, based on the topology of the traffic road network, using a Gaussian kernel function to calculate the distance between nodes to construct an initial weighted adjacency matrix A; S3.2, compute the correlation score of each pair of nodes The statistical distribution similarity of spatio-temporal features within the historical time window, get the feature correlation score ; S3.3, set a relevance threshold , adjust the edges in the initial adjacency matrix A that are below the threshold according to their relevance scores to generate a temporary adjacency matrix ; S3.4, for each time step t, the temporary adjacency matrix , the initial adjacency matrix A and the similarity matrix calculated by the time step enhanced embedding features are weighted and fused to obtain the dynamically adjusted adjacency matrix ; S3.5, generate dynamic graph structure for each time step where V is the set of nodes, E is the set of edges, is the dynamic adjacency matrix corresponding to time step t.
5. The dynamic memory bank based time-varying graph neural network traffic flow prediction method of claim 4, wherein: In S5, the spatial features and the time features are fused by a cross-attention mechanism to generate spatio-temporal fusion features containing complex evolution rules where C is the dimension of the fused features.
6. The dynamic memory bank based time-varying graph neural network traffic flow prediction method of claim 5, wherein: The S6 is specifically: Inputting the spatio-temporal fusion features into a learnable dynamic memory bank wherein represents the number of memory entries, represents the dimension of memory entries; performing memory retrieval on the spatio-temporal fusion features through a memory perception mechanism, dynamically extracting relevant patterns from the memory bank and reconstructing into memory features; The reconstructed memory feature is adaptively fused with the original spatiotemporal fusion feature to generate a memory-enhanced feature .
7. The dynamic memory bank based time-varying graph neural network traffic flow prediction method of claim 6, wherein: The S7 is specifically: GCRN is used as a decoder to uniformly map and model the memory-augmented features, and at each time step t, the memory-augmented features of the current time are input into the gated graph convolution recurrent unit together with the hidden state of the previous time to synchronously update the spatio-temporal hidden state together with the hidden state of the previous time The decoder iteratively runs along the time dimension, and the finally generated hidden state sequence is linearly transformed by a fully connected layer to map the prediction results of the future steps .
Citation Information
Patent Citations
A traffic flow prediction method based on a multi-mode dynamic memory graph convolution network
CN119107798B
Mama-based traffic flow prediction method
CN119942813A