A traffic flow prediction method and system based on a spatio-temporal graph neural network

By using a spatiotemporal graph neural network-based approach, and leveraging a bi-branch spatiotemporal graph neural network and the Mamba module to generate explicit and implicit spatiotemporal features, the complex nonlinearity and dynamic spatial dependence issues in traffic flow prediction are addressed, resulting in higher prediction accuracy and reduced computational costs.

CN121725624BActive Publication Date: 2026-07-21甘肃省科学院
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
甘肃省科学院
Filing Date
2025-12-22
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Existing traffic flow prediction methods struggle to effectively capture the complex nonlinear relationships and dynamic spatial dependencies in traffic flow data. Traditional models are limited by linear assumptions and feature engineering, while deep learning models suffer from gradient vanishing problems and insufficient long-term modeling capabilities.

Method used

A spatiotemporal graph neural network-based approach is adopted, which extracts latent spatiotemporal features through a dual-branch spatiotemporal graph neural network, generates explicit spatiotemporal features using a gated dynamic multi-graph convolution module, and combines it with a Mamba module to generate implicit spatiotemporal features, thereby realizing traffic flow prediction.

Benefits of technology

It improves the accuracy and efficiency of traffic flow prediction, reduces computational costs, and can efficiently capture the overall trend and local changes of traffic flow without relying on adjacency graphs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121725624B_ABST
    Figure CN121725624B_ABST
Patent Text Reader

Abstract

The application discloses a traffic flow prediction method and system based on a space-time graph neural network, and relates to the technical field of computers.The method comprises the following steps: preprocessing road network data; extracting potential space-time feature representation of the preprocessed road network data based on full connection layers and linear layers of a double-branch space-time graph neural network; determining a query matrix, a key matrix and a value matrix based on the potential space-time feature representation, calculating self-attention scores based on the query matrix and the key matrix, and generating time Transformer features in combination with the value matrix; generating explicit space-time features by using the time Transformer features based on a gated dynamic multi-graph convolution module; generating implicit space-time features by using the potential space-time feature representation based on a Mamba module; and performing traffic flow prediction based on the explicit space-time features and the implicit space-time features.The application realizes effective improvement of prediction performance and improves the accuracy of traffic flow prediction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a traffic flow prediction method and system based on spatiotemporal graph neural networks. Background Technology

[0002] Traffic flow prediction, as one of the core technologies of intelligent transportation systems, aims to predict future traffic patterns on roads through historical observation data. It plays a key role in optimizing traffic scheduling, alleviating road pressure, and reducing carbon emissions.

[0003] Traffic flow prediction typically employs traditional forecasting methods and deep learning approaches. Traditional methods rely primarily on time-series statistical models or shallow machine learning algorithms; however, these methods are limited by linear assumptions and feature engineering, making it difficult to capture the complex nonlinear relationships within traffic flow data. Deep learning methods, such as convolutional neural networks (CNNs) and recurrent neural networks (RNNs), are used to extract spatial features and temporal dependencies, respectively. However, CNNs struggle to model road network structures in non-Euclidean spaces, while RNNs are limited in their long-term modeling capabilities due to the vanishing gradient problem. In recent years, the development of graph neural networks (Graph Neural Networks) has provided new solutions for modeling the interaction between road network topology and dynamic traffic flow. However, most current Graph Neural Network models still rely on static, predefined adjacency matrices. These structures are typically built based on road topology or geographical distance, making it difficult to reflect the true traffic flow relationships between nodes. To address this, some research attempts have focused on generating adjacency matrices using node similarity, random walks, or data-driven methods to model potential spatial relationships. However, these static generation methods still cannot characterize the spatial dependency structure that changes over time, making it difficult for models to cope with the complex and ever-changing traffic dynamics in real-world scenarios. Summary of the Invention

[0004] The purpose of this invention is to overcome the shortcomings of the prior art. This invention provides a traffic flow prediction method and system based on spatiotemporal graph neural networks. The explicit spatiotemporal features and implicit spatiotemporal features are completely decoupled in terms of structure and information flow. They are integrated through a lightweight fusion mechanism for prediction, thereby improving the prediction accuracy.

[0005] To address the aforementioned technical problems, this invention provides a traffic flow prediction method based on a spatiotemporal graph neural network, the method comprising:

[0006] Acquire road network data and preprocess the road network data to obtain preprocessed road network data;

[0007] The latent spatiotemporal feature representation of preprocessed road network data is extracted using fully connected layers and linear layers of a bi-branch spatiotemporal graph neural network.

[0008] The query matrix, key matrix, and value matrix are determined based on the latent spatiotemporal feature representation, and a self-attention score is calculated based on the query matrix and key matrix. The temporal Transformer feature is generated based on the self-attention score and the value matrix.

[0009] The gated dynamic multi-graph convolution module utilizes the temporal Transformer features to generate explicit spatiotemporal features;

[0010] Based on the Mamba module, implicit spatiotemporal features are generated using the latent spatiotemporal feature representation, and traffic flow prediction is performed based on the explicit spatiotemporal features and implicit spatiotemporal features.

[0011] Optionally, the preprocessing of the road network data to obtain preprocessed road network data includes:

[0012] The road network data is cleaned to obtain cleaned road network data.

[0013] The road network data after data cleaning is timestamped to obtain preprocessed road network data.

[0014] Optionally, the extraction of latent spatiotemporal feature representations of the preprocessed road network data by the fully connected layer and linear layer based on the bi-branch spatiotemporal graph neural network includes:

[0015] High-dimensional embeddings of preprocessed road network data are extracted using a fully connected layer based on a dual-branch spatiotemporal graph neural network.

[0016] The first and second time embedding features of the preprocessed road network data are extracted by the linear layer of the bi-branch spatiotemporal graph neural network, and the first and second time embedding features are concatenated to obtain the periodic embedding.

[0017] The spatiotemporal adaptive embedding of the preprocessed road network data is extracted, and the high-dimensional embedding, periodic embedding and spatiotemporal adaptive embedding are concatenated to obtain the latent spatiotemporal feature representation.

[0018] Optionally, the step of determining the query matrix, key matrix, and value matrix based on the latent spatiotemporal feature representation, calculating a self-attention score based on the query matrix and key matrix, and generating temporal Transformer features based on the self-attention score combined with the value matrix includes:

[0019] Obtain the first, second, and third learnable parameters of the latent spatiotemporal feature representation;

[0020] A query matrix is ​​generated based on the latent spatiotemporal feature representation and the first learnable parameter; a key matrix is ​​generated based on the latent spatiotemporal feature representation and the second learnable parameter; and a value matrix is ​​generated based on the latent spatiotemporal feature representation and the third learnable parameter.

[0021] The self-attention score is calculated based on the query matrix and key matrix combined with the Softmax function;

[0022] The self-attention score is combined with the value matrix to generate the temporal Transformer features.

[0023] Optionally, the expression for the self-attention score is:

[0024] ,

[0025] in, For self-attention score, Here, Q is the Softmax function, K is the query matrix, K is the key matrix, and T is the transpose operation. The dimension of the key matrix;

[0026] The expression for the time Transformer feature is:

[0027] ,

[0028] in, For time-varying Transformer features, Let V be the self-attention score, V be the value matrix, and FFN be the feedforward neural network layer. This is the layer normalization function.

[0029] Optionally, the gated dynamic multi-graph convolution module utilizes the temporal Transformer features to generate explicit spatiotemporal features, including:

[0030] The attention weight matrix is ​​generated using a learnable matrix based on a gated dynamic multi-graph convolution module. The expression of the attention weight matrix is ​​as follows:

[0031] ,

[0032] in, Here is the attention weight matrix. The Softmax function is used, and ReLU is used as the activation function. Let T be a learnable matrix, and T be the transpose operation;

[0033] A spatial correlation weight matrix is ​​constructed based on the temporal Transformer features. The expression for the spatial correlation weight matrix is ​​as follows:

[0034] ,

[0035] in, This is the spatial correlation weight matrix. For time-varying Transformer features, Let T be the dimension of the key matrix, and T be the transpose operation.

[0036] Explicit spatiotemporal features are generated based on the attention weight matrix and spatial correlation weight matrix combined with gated linear units.

[0037] Optionally, the expression for the explicit spatiotemporal feature is:

[0038] ,

[0039]

[0040] in, For explicit spatiotemporal characteristics, GLU is a gated linear unit. For a symmetric normalized adjacency matrix, This is the spatial correlation weight matrix. For time-varying Transformer features, and These are the weighting coefficients. Here, is the attention weight matrix, and FFN is the feedforward neural network layer. This is the layer normalization function.

[0041] Optionally, the step of generating implicit spatiotemporal features using the latent spatiotemporal feature representation based on the Mamba module, and performing traffic flow prediction based on the explicit and implicit spatiotemporal features, includes:

[0042] The latent spatiotemporal feature representation is reshaped based on the Mamba module to obtain the reshaped latent spatiotemporal feature representation.

[0043] Based on the Mamba module, implicit spatiotemporal features are generated using the reshaped latent spatiotemporal feature representation. The expression for the implicit spatiotemporal features is as follows:

[0044] ,

[0045] in, For implicit spatiotemporal features, Reshape is the matrix dimension reconstruction function, and Mamba is the Mamba module. To represent the latent spatiotemporal features after reshaping, FFN is a feedforward neural network layer. For layer normalization function;

[0046] The target fusion feature is generated based on the explicit spatiotemporal features and implicit spatiotemporal features combined with the latent spatiotemporal feature representation. The expression of the target fusion feature is as follows:

[0047] ,

[0048] in, To achieve the goal of feature fusion, As explicit spatiotemporal features, Z represents the implicit spatiotemporal features;

[0049] Traffic flow prediction is performed based on the target fusion features to obtain traffic flow prediction results.

[0050] Optionally, the expression for the traffic flow prediction result is:

[0051] ,

[0052] in, For traffic flow prediction results, FC stands for fully connected layer and MLP stands for multilayer perceptron. Features are fused to target specific features.

[0053] In addition, the present invention also provides a traffic flow prediction system based on a spatiotemporal graph neural network, the system comprising:

[0054] Data preprocessing module: used to acquire road network data and preprocess the road network data to obtain preprocessed road network data;

[0055] Feature representation extraction module: used to extract latent spatiotemporal feature representations of preprocessed road network data based on the fully connected layers and linear layers of a bi-branch spatiotemporal graph neural network;

[0056] Temporal feature generation module: used to determine the query matrix, key matrix and value matrix based on the latent spatiotemporal feature representation, calculate the self-attention score based on the query matrix and key matrix, and generate temporal Transformer features based on the self-attention score and the value matrix;

[0057] The feature extraction module is used to generate explicit spatiotemporal features based on the temporal Transformer features from the gated dynamic multi-graph convolution module.

[0058] Traffic flow prediction module: used to generate implicit spatiotemporal features based on the latent spatiotemporal feature representation using the Mamba module, and to predict traffic flow based on the explicit spatiotemporal features and implicit spatiotemporal features.

[0059] In this embodiment of the invention, latent spatiotemporal feature representations of preprocessed road network data are extracted using fully connected layers and linear layers of a bi-branch spatiotemporal graph neural network. Query matrices, key matrices, and value matrices are determined based on these latent spatiotemporal feature representations to calculate self-attention scores. Temporal Transformer features are generated based on these self-attention scores combined with the value matrix. Explicit spatiotemporal features are generated using a gated dynamic multi-graph convolution module, which captures local temporal variations and spatial structure evolution. Implicit spatiotemporal features are generated using a Mamba module based on the latent spatiotemporal feature representations, enabling efficient capture of overall trends without relying on adjacency graphs. Traffic flow prediction is performed based on both explicit and implicit spatiotemporal features, effectively improving prediction performance and increasing the accuracy of traffic flow prediction. Attached Figure Description

[0060] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0061] Figure 1 This is a flowchart illustrating the traffic flow prediction method based on a spatiotemporal graph neural network in an embodiment of the present invention.

[0062] Figure 2 This is a flowchart illustrating a traffic flow prediction method based on a spatiotemporal graph neural network according to another embodiment of the present invention.

[0063] Figure 3 This is a schematic diagram of the structural composition of a traffic flow prediction system based on a spatiotemporal graph neural network in an embodiment of the present invention. Detailed Implementation

[0064] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0065] Example 1

[0066] Please see Figure 1 , Figure 1 This is a flowchart illustrating the traffic flow prediction method based on a spatiotemporal graph neural network according to an embodiment of the present invention. The method includes:

[0067] S11: Acquire road network data and preprocess the road network data to obtain preprocessed road network data;

[0068] In the specific implementation of this invention, road network data is acquired, and the road network data is cleaned to obtain cleaned road network data. The cleaned road network data is then timestamped to obtain preprocessed road network data. This data preprocessing provides more reliable data support for subsequent traffic flow prediction.

[0069] S12: Extracting latent spatiotemporal feature representations of preprocessed road network data based on fully connected layers and linear layers of a bi-branch spatiotemporal graph neural network;

[0070] In the specific implementation of this invention, a high-dimensional embedding of the preprocessed road network data is extracted based on a fully connected layer of a bi-branch spatiotemporal graph neural network; a first temporal embedding feature and a second temporal embedding feature of the preprocessed road network data are extracted based on a linear layer of the bi-branch spatiotemporal graph neural network, and the first temporal embedding feature and the second temporal embedding feature are concatenated to obtain a periodic embedding; a spatiotemporal adaptive embedding of the preprocessed road network data is extracted, and the high-dimensional embedding, the periodic embedding and the spatiotemporal adaptive embedding are concatenated to obtain a latent spatiotemporal feature representation, which can obtain richer feature information.

[0071] S13: Determine the query matrix, key matrix, and value matrix based on the latent spatiotemporal feature representation, calculate the self-attention score based on the query matrix and key matrix, and generate temporal Transformer features based on the self-attention score and the value matrix;

[0072] In the specific implementation of this invention, a first learnable parameter, a second learnable parameter, and a third learnable parameter of the latent spatiotemporal feature representation are obtained; a query matrix is ​​generated based on the latent spatiotemporal feature representation and the first learnable parameter; a key matrix is ​​generated based on the latent spatiotemporal feature representation and the second learnable parameter; a value matrix is ​​generated based on the latent spatiotemporal feature representation and the third learnable parameter; a self-attention score is calculated based on the query matrix and the key matrix using the Softmax function; and a temporal Transformer feature is generated based on the self-attention score and the value matrix, which can adaptively focus on key information and ignore irrelevant information.

[0073] S14: Based on the gated dynamic multi-graph convolution module, explicit spatiotemporal features are generated using the temporal Transformer features;

[0074] In the specific implementation of this invention, an attention weight matrix is ​​generated using a learnable matrix based on a gated dynamic multi-graph convolution module; a spatial correlation weight matrix is ​​constructed based on the temporal Transformer features; and explicit spatiotemporal features are generated by combining the attention weight matrix and the spatial correlation weight matrix with gated linear units. This can simultaneously handle geospatial dependence and potential spatiotemporal dynamic relationships, thereby more comprehensively modeling the spatiotemporal features of traffic flow.

[0075] S15: Based on the Mamba module, implicit spatiotemporal features are generated using the latent spatiotemporal feature representation, and traffic flow is predicted based on the explicit spatiotemporal features and implicit spatiotemporal features.

[0076] In the specific implementation of this invention, the latent spatiotemporal feature representation is reshaped using the Mamba module to obtain a reshaped latent spatiotemporal feature representation; implicit spatiotemporal features are generated using the reshaped latent spatiotemporal feature representation based on the Mamba module, which can efficiently capture complex dependencies in sequence data; target fusion features are generated by combining the explicit spatiotemporal features and implicit spatiotemporal features with the latent spatiotemporal feature representation; traffic flow prediction is performed based on the target fusion features. Prediction after feature fusion not only improves the accuracy of traffic flow prediction but also significantly reduces computational costs.

[0077] In this embodiment of the invention, latent spatiotemporal feature representations of preprocessed road network data are extracted using fully connected layers and linear layers of a bi-branch spatiotemporal graph neural network. Query matrices, key matrices, and value matrices are determined based on these latent spatiotemporal feature representations to calculate self-attention scores. Temporal Transformer features are generated based on these self-attention scores combined with the value matrix. Explicit spatiotemporal features are generated using a gated dynamic multi-graph convolution module, which captures local temporal variations and spatial structure evolution. Implicit spatiotemporal features are generated using a Mamba module based on the latent spatiotemporal feature representations, enabling efficient capture of overall trends without relying on adjacency graphs. Traffic flow prediction is performed based on both explicit and implicit spatiotemporal features, effectively improving prediction performance and increasing the accuracy of traffic flow prediction.

[0078] Example 2

[0079] Please see Figure 2 , Figure 2 This is a flowchart illustrating a traffic flow prediction method based on a spatiotemporal graph neural network according to another embodiment of the present invention. The method includes:

[0080] S201: Acquire road network data and preprocess the road network data to obtain preprocessed road network data;

[0081] In a specific implementation of the present invention, the step of preprocessing the road network data to obtain preprocessed road network data includes: performing data cleaning on the road network data to obtain cleaned road network data; and performing timestamp annotation on the cleaned road network data to obtain preprocessed road network data.

[0082] Specifically, road network data is acquired, which includes traffic flow data for each time slice of the road. The road network data can be represented as a graph. The road network data is then cleaned, including removing garbled characters and abnormal characters, to obtain cleaned road network data.

[0083] After cleaning and processing, the road network data is timestamped. Traffic flow data shows similar time patterns during weekdays, holidays, morning rush hours, and evening rush hours. To capture this information, the road network data needs to be pre-processed with the timestamp of the current day and the day of the week. For example, if the road network data is at 12:00 on the current day and the day is the 3rd of the week, then the timestamps of 12:00 and the 3rd day are used to annotate the road network data to obtain pre-processed road network data. This data preprocessing provides more reliable data support for subsequent traffic flow prediction.

[0084] S202: Extracting latent spatiotemporal feature representations of preprocessed road network data based on fully connected layers and linear layers of a bi-branch spatiotemporal graph neural network;

[0085] In the specific implementation of this invention, the extraction of latent spatiotemporal feature representations of preprocessed road network data based on the fully connected layer and linear layer of the bi-branch spatiotemporal graph neural network includes: extracting high-dimensional embeddings of preprocessed road network data based on the fully connected layer of the bi-branch spatiotemporal graph neural network; extracting first and second temporal embedding features of preprocessed road network data based on the linear layer of the bi-branch spatiotemporal graph neural network, and concatenating the first and second temporal embedding features to obtain periodic embeddings; extracting spatiotemporally adaptive embeddings of preprocessed road network data, and concatenating the high-dimensional embeddings, periodic embeddings, and spatiotemporally adaptive embeddings to obtain latent spatiotemporal feature representations.

[0086] Specifically, the high-dimensional embedding of the preprocessed road network data is extracted based on the fully connected layer of the bi-branch spatiotemporal graph neural network. That is, the preprocessed road network data is input into the fully connected layer of the bi-branch spatiotemporal graph neural network to obtain its high-dimensional embedding.

[0087] The linear layer of the bi-branch spatiotemporal graph neural network extracts the first and second time embedding features of the preprocessed road network data. The first time embedding feature is the embedding feature of the timestamp of the data on the current day, and the second time embedding feature is the embedding feature of which day of the week the data is on. The first and second time embedding features are concatenated to obtain the periodic embedding.

[0088] Spatiotemporal adaptive embeddings are extracted from the preprocessed road network data. These embeddings aim to capture more complex spatiotemporal relationships. The high-dimensional embeddings, periodic embeddings, and spatiotemporal adaptive embeddings are then concatenated to obtain a latent spatiotemporal feature representation. This latent spatiotemporal feature representation captures the feature information of spatiotemporal relationships, and its expression is as follows:

[0089] ,

[0090] Where Z represents the latent spatiotemporal features. For high-dimensional embedding, For periodic embedding, It is a spatiotemporally adaptive embedding.

[0091] S203: Obtain the first, second, and third learnable parameters of the latent spatiotemporal feature representation;

[0092] In the specific implementation of this invention, the first learnable parameter, the second learnable parameter, and the third learnable parameter of the potential spatiotemporal feature representation can be obtained through a database.

[0093] S204: Generate a query matrix based on the latent spatiotemporal feature representation and the first learnable parameter, generate a key matrix based on the latent spatiotemporal feature representation and the second learnable parameter, and generate a value matrix based on the latent spatiotemporal feature representation and the third learnable parameter;

[0094] In a specific implementation of this invention, a query matrix is ​​generated based on the latent spatiotemporal feature representation and the first learnable parameter; a key matrix is ​​generated based on the latent spatiotemporal feature representation and the second learnable parameter; and a value matrix is ​​generated based on the latent spatiotemporal feature representation and the third learnable parameter. The expressions for the query matrix, key matrix, and value matrix are as follows:

[0095] ,

[0096] ,

[0097] ,

[0098] Where Q is the query matrix and Z is the latent spatiotemporal feature representation. These are learnable parameters, K is the key matrix, and V is the value matrix.

[0099] S205: Calculate the self-attention score based on the query matrix and key matrix combined with the Softmax function;

[0100] In a specific implementation of this invention, the self-attention score is calculated based on the query matrix and the key matrix combined with the Softmax function. The expression for the self-attention score is as follows:

[0101] ,

[0102] in, For self-attention score, Here, Q is the Softmax function, K is the query matrix, K is the key matrix, and T is the transpose operation. is the dimension of the key matrix.

[0103] S206: Generate temporal Transformer features based on the self-attention score and the value matrix;

[0104] In a specific implementation of this invention, a temporal Transformer feature is generated based on the self-attention score and the value matrix. The expression for the temporal Transformer feature is as follows:

[0105] ,

[0106] in, For time-varying Transformer features, Let V be the self-attention score, V be the value matrix, and FFN be the feedforward neural network layer. This is the layer normalization function. The generation of temporal Transformer features aims to enable the model to dynamically focus on the parts of the input data most relevant to the current task when processing information, rather than treating all input information equally. This allows the model to adaptively focus on key information and ignore irrelevant information, thereby improving its ability to model complex patterns and long-term dependencies in the data.

[0107] S207: Based on the gated dynamic multi-graph convolution module, explicit spatiotemporal features are generated using the temporal Transformer features;

[0108] In a specific implementation of this invention, the gated dynamic multi-graph convolution module generates explicit spatiotemporal features using the temporal Transformer features, including: the gated dynamic multi-graph convolution module generates an attention weight matrix using a learnable matrix, the expression of which is:

[0109] ,

[0110] in, Here is the attention weight matrix. The Softmax function is used, and ReLU is used as the activation function. Let T be a learnable matrix, and T be the transpose operation;

[0111] A spatial correlation weight matrix is ​​constructed based on the temporal Transformer features. The expression for the spatial correlation weight matrix is ​​as follows:

[0112] ,

[0113] in, This is the spatial correlation weight matrix. For time-varying Transformer features, Let T be the dimension of the key matrix, and T be the transpose operation.

[0114] Explicit spatiotemporal features are generated based on the attention weight matrix and spatial correlation weight matrix combined with gated linear units.

[0115] Furthermore, the expression for the explicit spatiotemporal features is:

[0116] ,

[0117]

[0118] in, For explicit spatiotemporal characteristics, GLU is a gated linear unit. For a symmetric normalized adjacency matrix, This is the spatial correlation weight matrix. For time-varying Transformer features, and These are the weighting coefficients. Here, is the attention weight matrix, and FFN is the feedforward neural network layer. This is the layer normalization function.

[0119] Specifically, the gated dynamic multi-graph convolution module utilizes a learnable matrix to generate an attention weight matrix, the expression of which is:

[0120] ,

[0121] in, Here is the attention weight matrix. The Softmax function is used, and ReLU is used as the activation function. Let T be the learnable matrix and T be the transpose operation. Graph convolution is a technique that performs convolution operations on graph-structured data, aiming to extract node features using the topological information of the graph. The core idea of ​​graph convolution is that the features of each node depend not only on its own features but also on the features of its neighboring nodes. By performing convolution operations on the graph, the features of a node can be aggregated with the features of its neighbors, thereby capturing the local structural features of the graph.

[0122] A spatial correlation weight matrix is ​​constructed based on the temporal Transformer features. The expression for the spatial correlation weight matrix is ​​as follows:

[0123] ,

[0124] in, This is the spatial correlation weight matrix. For time-varying Transformer features, Let T be the dimension of the key matrix, and T be the transpose operation.

[0125] Explicit spatiotemporal features are generated based on the attention weight matrix and spatial correlation weight matrix combined with gated linear units. The expression for the explicit spatiotemporal features is as follows:

[0126] ,

[0127]

[0128] in, For explicit spatiotemporal characteristics, GLU is a gated linear unit. For a symmetric normalized adjacency matrix, This is the spatial correlation weight matrix. For time-varying Transformer features, and These are the weighting coefficients. Here, is the attention weight matrix, and FFN is the feedforward neural network layer. This is the layer normalization function. The gated dynamic multi-graph convolution module of the bi-branch spatiotemporal graph neural network can simultaneously handle geospatial dependencies and potential spatiotemporal dynamic relationships, thus more comprehensively modeling the spatiotemporal characteristics of traffic flow. The explicit-local modeling path, through the temporal Transformer and dynamic graph convolution module, enables explicit spatiotemporal features to clearly characterize short-term disturbances and adjacency structure changes.

[0129] S208: Based on the Mamba module, implicit spatiotemporal features are generated using the latent spatiotemporal feature representation, and traffic flow is predicted based on the explicit spatiotemporal features and implicit spatiotemporal features.

[0130] In a specific implementation of this invention, the step of generating implicit spatiotemporal features based on the latent spatiotemporal feature representation using the Mamba module, and performing traffic flow prediction based on the explicit and implicit spatiotemporal features, includes: reshaping the latent spatiotemporal feature representation using the Mamba module to obtain a reshaped latent spatiotemporal feature representation; and generating implicit spatiotemporal features using the reshaped latent spatiotemporal feature representation using the Mamba module. The expression for the implicit spatiotemporal features is:

[0131] ,

[0132] in, For implicit spatiotemporal features, Reshape is the matrix dimension reconstruction function, and Mamba is the Mamba module. To represent the latent spatiotemporal features after reshaping, FFN is a feedforward neural network layer. For layer normalization function;

[0133] The target fusion feature is generated based on the explicit spatiotemporal features and implicit spatiotemporal features combined with the latent spatiotemporal feature representation. The expression of the target fusion feature is as follows:

[0134] ,

[0135] in, To achieve the goal of feature fusion, As explicit spatiotemporal features, Z represents the implicit spatiotemporal features;

[0136] Traffic flow prediction is performed based on the target fusion features to obtain traffic flow prediction results.

[0137] Furthermore, the expression for the traffic flow prediction result is as follows:

[0138] ,

[0139] in, For traffic flow prediction results, FC stands for fully connected layer and MLP stands for multilayer perceptron. Features are fused to target specific features.

[0140] Specifically, the latent spatiotemporal feature representation is reshaped based on the Mamba module to obtain the reshaped latent spatiotemporal feature representation. The obtained latent feature representation is then... Remodeling T represents the time slice, and N represents the node. Using timestamps, the Mamba module of the dual-branch spatiotemporal graph neural network is a model architecture based on an improved state-space model, designed to efficiently capture complex dependencies in sequence data. Its core components include a selective state-space model, a hardware-aware algorithm, and a simplified SSM architecture, enabling it to maintain modeling capabilities comparable to the Transformer while possessing near-linear scalability, suitable for complex and long sequence data. The core mechanism of the Mamba module is based on the selective state-space model, whose parameters can be dynamically adjusted according to the input data, thereby achieving selective processing of information. This allows the Mamba module to efficiently compress contextual information and dynamically adjust the propagation and forgetting of information along the sequence length dimension. Specifically, the Mamba module updates sequence information by discretizing the state-space equations and uses a selective mechanism to focus on key information and ignore irrelevant content, employing a selective scanning algorithm to efficiently process sequence data and supporting efficient parallel computing.

[0141] Based on the Mamba module, implicit spatiotemporal features are generated using the reshaped latent spatiotemporal feature representation. The expression for the implicit spatiotemporal features is as follows:

[0142] ,

[0143] in, For implicit spatiotemporal features, Reshape is the matrix dimension reconstruction function, and Mamba is the Mamba module. To represent the latent spatiotemporal features after reshaping, FFN is a feedforward neural network layer. This is the layer normalization function. The implicit-global modeling path, based on the Mamba module, focuses on modeling long-term time dependencies, efficiently capturing overall trends without relying on adjacency graphs.

[0144] The target fusion feature is generated based on the explicit spatiotemporal features and implicit spatiotemporal features combined with the latent spatiotemporal feature representation. The expression of the target fusion feature is as follows:

[0145] ,

[0146] in, To achieve the goal of feature fusion, As explicit spatiotemporal features, Z represents the implicit spatiotemporal features.

[0147] Traffic flow prediction is performed based on the target fusion features to obtain traffic flow prediction results, the expression of which is:

[0148] ,

[0149] in, For traffic flow prediction results, FC stands for fully connected layer and MLP stands for multilayer perceptron. The target is to fuse features. Explicit and implicit spatiotemporal features are completely decoupled in terms of structure and information flow. They are integrated through a lightweight fusion mechanism for prediction, which not only improves prediction accuracy but also significantly reduces computational cost and training difficulty.

[0150] Meanwhile, the training time, inference time, and memory usage of the dual-branch spatiotemporal graph neural network are better than other models, as shown in the table below:

[0151]

[0152] In this embodiment of the invention, latent spatiotemporal feature representations of preprocessed road network data are extracted using fully connected layers and linear layers of a bi-branch spatiotemporal graph neural network. Query matrices, key matrices, and value matrices are determined based on these latent spatiotemporal feature representations to calculate self-attention scores. Temporal Transformer features are generated based on these self-attention scores combined with the value matrix. Explicit spatiotemporal features are generated using a gated dynamic multi-graph convolution module, which captures local temporal variations and spatial structure evolution. Implicit spatiotemporal features are generated using a Mamba module based on the latent spatiotemporal feature representations, enabling efficient capture of overall trends without relying on adjacency graphs. Traffic flow prediction is performed based on both explicit and implicit spatiotemporal features, effectively improving prediction performance and increasing the accuracy of traffic flow prediction.

[0153] Example 3

[0154] Please see Figure 3 , Figure 3 This is a schematic diagram of the structural composition of a traffic flow prediction system based on a spatiotemporal graph neural network according to an embodiment of the present invention. The system includes:

[0155] Data preprocessing module 31: used to acquire road network data and preprocess the road network data to obtain preprocessed road network data;

[0156] Feature representation extraction module 32: used to extract latent spatiotemporal feature representations of preprocessed road network data based on the fully connected layer and linear layer of the bi-branch spatiotemporal graph neural network;

[0157] Temporal feature generation module 33: used to determine the query matrix, key matrix and value matrix based on the latent spatiotemporal feature representation, calculate the self-attention score based on the query matrix and key matrix, and generate temporal Transformer features based on the self-attention score and the value matrix;

[0158] Display feature extraction module 34: used to generate explicit spatiotemporal features based on the time Transformer features using the gated dynamic multi-graph convolution module;

[0159] Traffic flow prediction module 35: used to generate implicit spatiotemporal features based on the latent spatiotemporal feature representation using the Mamba module, and to predict traffic flow based on the explicit spatiotemporal features and implicit spatiotemporal features.

[0160] In the specific implementation of this invention, the specific implementation methods of the system items can be referred to the implementation methods of the above-mentioned method items, and will not be repeated here.

[0161] In this embodiment of the invention, latent spatiotemporal feature representations of preprocessed road network data are extracted using fully connected layers and linear layers of a bi-branch spatiotemporal graph neural network. Query matrices, key matrices, and value matrices are determined based on these latent spatiotemporal feature representations to calculate self-attention scores. Temporal Transformer features are generated based on these self-attention scores combined with the value matrix. Explicit spatiotemporal features are generated using a gated dynamic multi-graph convolution module, which captures local temporal variations and spatial structure evolution. Implicit spatiotemporal features are generated using a Mamba module based on the latent spatiotemporal feature representations, enabling efficient capture of overall trends without relying on adjacency graphs. Traffic flow prediction is performed based on both explicit and implicit spatiotemporal features, effectively improving prediction performance and increasing the accuracy of traffic flow prediction.

[0162] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc.

[0163] Furthermore, the above provides a detailed description of a traffic flow prediction method and system based on a spatiotemporal graph neural network provided by the embodiments of the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A traffic flow prediction method based on a spatiotemporal graph neural network, characterized in that, The method includes: Acquire road network data and preprocess the road network data to obtain preprocessed road network data; The latent spatiotemporal feature representation of preprocessed road network data is extracted using fully connected layers and linear layers of a bi-branch spatiotemporal graph neural network. The query matrix, key matrix, and value matrix are determined based on the latent spatiotemporal feature representation, and a self-attention score is calculated based on the query matrix and key matrix. The temporal Transformer feature is generated based on the self-attention score and the value matrix. The gated dynamic multi-graph convolution module utilizes the temporal Transformer features to generate explicit spatiotemporal features; Based on the Mamba module, implicit spatiotemporal features are generated using the latent spatiotemporal feature representation, and traffic flow prediction is performed based on the explicit spatiotemporal features and implicit spatiotemporal features. The expression for the self-attention score is as follows: , in, For self-attention score, Here, Q is the Softmax function, K is the query matrix, K is the key matrix, and T is the transpose operation. The dimension of the key matrix; The expression for the time Transformer feature is: , in, For time-varying Transformer features, Let V be the self-attention score, V be the value matrix, and FFN be the feedforward neural network layer. For layer normalization function; The expression for the explicit spatiotemporal feature is: , in, For explicit spatiotemporal characteristics, GLU is a gated linear unit. For a symmetric normalized adjacency matrix, This is the spatial correlation weight matrix. For time-varying Transformer features, and These are the weighting coefficients. Here, is the attention weight matrix, and FFN is the feedforward neural network layer. This is the layer normalization function.

2. The traffic flow prediction method based on spatiotemporal graph neural network according to claim 1, characterized in that, The step of preprocessing the road network data to obtain preprocessed road network data includes: The road network data is cleaned to obtain cleaned road network data. The road network data after data cleaning is timestamped to obtain preprocessed road network data.

3. The traffic flow prediction method based on spatiotemporal graph neural network according to claim 1, characterized in that, The extraction of latent spatiotemporal feature representations from preprocessed road network data using fully connected layers and linear layers based on a dual-branch spatiotemporal graph neural network includes: High-dimensional embeddings of preprocessed road network data are extracted using a fully connected layer based on a dual-branch spatiotemporal graph neural network. The first and second time embedding features of the preprocessed road network data are extracted by the linear layer of the bi-branch spatiotemporal graph neural network, and the first and second time embedding features are concatenated to obtain the periodic embedding. The spatiotemporal adaptive embedding of the preprocessed road network data is extracted, and the high-dimensional embedding, periodic embedding and spatiotemporal adaptive embedding are concatenated to obtain the latent spatiotemporal feature representation.

4. The traffic flow prediction method based on spatiotemporal graph neural network according to claim 1, characterized in that, The process of determining the query matrix, key matrix, and value matrix based on the latent spatiotemporal feature representation, calculating a self-attention score based on the query matrix and key matrix, and generating temporal Transformer features based on the self-attention score and the value matrix includes: Obtain the first, second, and third learnable parameters of the latent spatiotemporal feature representation; A query matrix is ​​generated based on the latent spatiotemporal feature representation and the first learnable parameter; a key matrix is ​​generated based on the latent spatiotemporal feature representation and the second learnable parameter; and a value matrix is ​​generated based on the latent spatiotemporal feature representation and the third learnable parameter. The self-attention score is calculated based on the query matrix and key matrix combined with the Softmax function; The self-attention score is combined with the value matrix to generate the temporal Transformer features.

5. The traffic flow prediction method based on spatiotemporal graph neural network according to claim 1, characterized in that, The gated dynamic multi-graph convolution module utilizes the temporal Transformer features to generate explicit spatiotemporal features, including: The attention weight matrix is ​​generated using a learnable matrix based on a gated dynamic multi-graph convolution module. The expression of the attention weight matrix is ​​as follows: , in, Here is the attention weight matrix. The Softmax function is used, and ReLU is used as the activation function. Let T be a learnable matrix, and T be the transpose operation; A spatial correlation weight matrix is ​​constructed based on the temporal Transformer features. The expression for the spatial correlation weight matrix is ​​as follows: , in, This is the spatial correlation weight matrix. For time-varying Transformer features, Let T be the dimension of the key matrix, and T be the transpose operation. Explicit spatiotemporal features are generated based on the attention weight matrix and spatial correlation weight matrix combined with gated linear units.

6. The traffic flow prediction method based on spatiotemporal graph neural network according to claim 1, characterized in that, The method of generating implicit spatiotemporal features using the latent spatiotemporal feature representation based on the Mamba module, and performing traffic flow prediction based on the explicit and implicit spatiotemporal features, includes: The latent spatiotemporal feature representation is reshaped based on the Mamba module to obtain the reshaped latent spatiotemporal feature representation. Based on the Mamba module, implicit spatiotemporal features are generated using the reshaped latent spatiotemporal feature representation. The expression for the implicit spatiotemporal features is as follows: , in, For implicit spatiotemporal features, Reshape is the matrix dimension reconstruction function, and Mamba is the Mamba module. To represent the latent spatiotemporal features after reshaping, FFN is a feedforward neural network layer. For layer normalization function; The target fusion feature is generated based on the explicit spatiotemporal features and implicit spatiotemporal features combined with the latent spatiotemporal feature representation. The expression of the target fusion feature is as follows: , in, To achieve the goal of feature fusion, As explicit spatiotemporal features, Z represents the implicit spatiotemporal features; Traffic flow prediction is performed based on the target fusion features to obtain traffic flow prediction results.

7. The traffic flow prediction method based on spatiotemporal graph neural network according to claim 6, characterized in that, The expression for the traffic flow prediction result is: , in, For traffic flow prediction results, FC stands for fully connected layer and MLP stands for multilayer perceptron. Features are fused to target specific features.

8. A traffic flow prediction system based on a spatiotemporal graph neural network, characterized in that, The system includes: Data preprocessing module: used to acquire road network data and preprocess the road network data to obtain preprocessed road network data; Feature representation extraction module: used to extract latent spatiotemporal feature representations of preprocessed road network data based on the fully connected layers and linear layers of a bi-branch spatiotemporal graph neural network; Temporal feature generation module: used to determine the query matrix, key matrix and value matrix based on the latent spatiotemporal feature representation, calculate the self-attention score based on the query matrix and key matrix, and generate temporal Transformer features based on the self-attention score and the value matrix; The feature extraction module is used to generate explicit spatiotemporal features based on the temporal Transformer features from the gated dynamic multi-graph convolution module. Traffic flow prediction module: used to generate implicit spatiotemporal features based on the latent spatiotemporal feature representation using the Mamba module, and to predict traffic flow based on the explicit spatiotemporal features and implicit spatiotemporal features; The expression for the self-attention score is as follows: , in, For self-attention score, Here, Q is the Softmax function, K is the query matrix, K is the key matrix, and T is the transpose operation. The dimension of the key matrix; The expression for the time Transformer feature is: , in, For time-varying Transformer features, Let V be the self-attention score, V be the value matrix, and FFN be the feedforward neural network layer. For layer normalization function; The expression for the explicit spatiotemporal feature is: , in, For explicit spatiotemporal characteristics, GLU is a gated linear unit. For a symmetric normalized adjacency matrix, This is the spatial correlation weight matrix. For time-varying Transformer features, and These are the weighting coefficients. Here, is the attention weight matrix, and FFN is the feedforward neural network layer. This is the layer normalization function.