Space-time diagram neural network traffic flow prediction method and system combined with interactive learning

By combining a spatiotemporal graph neural network model with interactive learning, and integrating periodic, spatial, and adaptive information, interactive learning of temporal and spatial features is achieved, solving the problem of insufficient interactive learning of spatiotemporal features and improving the accuracy and robustness of traffic flow prediction.

CN121747341APending Publication Date: 2026-03-27TSINGHUA SHENZHEN INTERNATIONAL GRADUATE SCHOOL
View PDF 5 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-02-26
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing spatiotemporal graph neural networks are insufficient in learning the spatiotemporal feature interactions in traffic flow prediction, making it difficult to capture dynamic spatial dependencies and spatiotemporal heterogeneity, resulting in low accuracy in long-term predictions.

Method used

A spatiotemporal graph neural network model combining interactive learning is adopted. The model integrates periodic, spatial and adaptive information through a data embedding layer, uses a spatiotemporal interaction module to perform interactive learning of temporal and spatial features, and further enhances feature representation through a feature enhancement layer. This breaks down the separation barrier of spatiotemporal processing in traditional models and achieves deep interaction and collaborative learning.

Benefits of technology

It significantly improves the model's ability to represent the spatiotemporal dynamics of traffic flow, enhances the accuracy and robustness of long-term traffic flow prediction, and solves the problems of low accuracy in complex traffic scenarios and long-term prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121747341A_ABST
    Figure CN121747341A_ABST
Patent Text Reader

Abstract

The invention provides a space-time diagram neural network traffic flow prediction method and system combined with interactive learning, and the method comprises the steps: S1, obtaining original traffic feature data, and inputting the original traffic feature data into a trained space-time diagram neural network model; s2, performing embedding processing on the original traffic characteristic data through a data embedding layer to obtain a hidden high-dimensional space-time embedding representation fused with periodicity, spatiality and adaptive information; s3, performing space-time interaction processing on the high-dimensional space-time embedded representation through a space-time interaction module: performing space-time feature interaction learning between the time feature extraction process and the space feature extraction process, and outputting space-time feature representation with enhanced space-time interaction features; and S4, performing further feature enhancement processing on the spatial-temporal feature representation through a feature enhancement layer, and outputting a traffic flow prediction result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of traffic flow prediction, artificial intelligence, and other technologies, and in particular to a traffic flow prediction method and system that combines interactive learning with a spatiotemporal graph neural network. Background Technology

[0002] In recent years, intelligent transportation systems have developed rapidly. Dynamic traffic control and route guidance planning, through real-time traffic management, have become effective means of alleviating traffic congestion. In this system, accurate and real-time traffic flow forecasting plays a crucial role, profoundly impacting urban traffic planning, management, and control. High-precision traffic forecasting is vital support for transportation departments to make appropriate decisions. It not only provides scientific basis for traffic planners but also offers flexible and intelligent solutions, thereby improving road utilization efficiency, alleviating traffic congestion, reducing traffic accidents, ensuring traveler safety, reducing environmental pollution, and providing the public with optimal travel routes, ultimately enhancing the overall operational efficiency of the city.

[0003] However, traffic flow forecasting faces multiple challenges. As a multivariate time series data, traffic flow exhibits significant periodicity and trends, and its complex temporal correlations make long-term forecasting extremely difficult. Its evolution is constrained by both the static structure of the road network topology and follows complex dynamic spatiotemporal patterns; changes in traffic conditions in one area can affect the traffic conditions in its surrounding areas. Furthermore, traffic flow is spatiotemporally heterogeneous, exhibiting non-uniformity and dynamic variability in both time and space dimensions. That is, traffic patterns differ significantly at different times and locations, with no uniform pattern to follow, making this spatiotemporal heterogeneity difficult to capture. Simultaneously, due to the coupling disturbances of external factors such as sudden weather changes, holiday patterns, traffic accidents, and large-scale events, traffic flow displays highly nonlinear, dynamically non-stationary, and uncertain characteristics. These intertwined factors make accurate traffic flow forecasting an extremely challenging task.

[0004] With the continuous advancement of artificial intelligence technology, especially the development of deep learning methods, many deep learning-based methods are replacing traditional traffic prediction methods due to their powerful ability to build complex models and capture nonlinear relationships. However, recurrent neural networks and their variants are somewhat lacking in long-term forecasting capabilities, cannot perform parallel computation, struggle to meet real-time prediction requirements, and neglect spatial feature modeling. While convolutional neural networks can capture spatial features, they are mainly used to process Euclidean structured data and cannot effectively capture the spatial correlations of non-Euclidean traffic networks. With the rise of graph neural networks, more and more spatiotemporal graph neural network models incorporating spatiotemporal features are being used for traffic flow prediction.

[0005] However, existing spatiotemporal modeling methods typically employ a "serial or parallel" architecture of temporal and spatial modules. This involves first capturing temporal or spatial correlations using one independent module, then capturing another type of correlation using a different module, or using two modules to capture temporal and spatial correlations separately, followed by simple feature stitching and fusion. This approach not only struggles to deeply model spatiotemporal relationships across multiple scales and dimensions but also completely ignores the interactive learning of spatiotemporal features, resulting in a fragmented capture of spatiotemporal correlations. Secondly, it generally relies on prior geographic information or human experience to predefine adjacency matrices. This static and subjective definition method struggles to capture the implicit, dynamically evolving relationships between nodes, leading to a severe disconnect between the graph structure's representational capabilities and the complex coupling relationships of real traffic networks. Furthermore, it fails to adequately consider the impact of spatiotemporal heterogeneity, ignoring the inherent differences and local characteristics of traffic patterns in different regions and time periods. By assuming a uniform distribution of spatiotemporal patterns using a single model, it struggles to characterize the multi-scale, non-stationary dynamic characteristics of real traffic flows. Therefore, how to improve the ability to capture the spatiotemporal heterogeneity of traffic flow, conduct in-depth modeling of spatiotemporal correlations at multiple scales, and deeply explore hidden spatial correlations remains a key issue that needs to be addressed in the field of traffic flow prediction.

[0006] It should be noted that the information disclosed in the background section above is only for understanding the background of this application, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0007] To overcome the problems of insufficient spatiotemporal feature interaction learning, difficulty in capturing dynamic spatial dependencies and spatiotemporal heterogeneity in existing spatiotemporal graph neural networks for traffic flow prediction, which leads to low long-term prediction accuracy, this invention provides a spatiotemporal graph neural network traffic flow prediction method and approach that combines interaction learning.

[0008] In a first aspect, this invention provides a traffic flow prediction method combining a spatiotemporal graph neural network with interactive learning, comprising the following steps: S1. Obtain raw traffic feature data and input it into a trained spatiotemporal graph neural network model, wherein the spatiotemporal graph neural network model includes a data embedding layer, at least one spatiotemporal interaction module, a feature enhancement layer and an output layer connected in sequence. S2. Through the data embedding layer, the original traffic feature data is subjected to periodic, spatial and adaptive embedding processing to obtain a hidden high-dimensional spatiotemporal embedding representation that integrates periodic, spatial and adaptive information. S3. Through the at least one spatiotemporal interaction module, perform spatiotemporal interaction processing on the hidden high-dimensional spatiotemporal embedded representation: by performing interactive learning of spatiotemporal features between the processes of temporal feature extraction and spatial feature extraction, output a spatiotemporal feature representation that enhances the spatiotemporal interaction features. S4. Through the feature enhancement layer, further feature enhancement processing is performed on the spatiotemporal feature representation that has been enhanced with spatiotemporal interaction features, and traffic flow prediction results are output from the output layer based on the processed features.

[0009] A second aspect of the present invention provides a spatiotemporal graph neural network traffic flow prediction system incorporating interactive learning, comprising: a processor; a memory for storing a computer program; wherein, when the computer program is executed by the processor, it implements the method described in the first aspect.

[0010] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method described in the first aspect.

[0011] The beneficial effects of this invention include: The spatiotemporal graph neural network traffic flow prediction method combined with interactive learning provided by this invention, through the design of a model architecture including a data embedding layer, a spatiotemporal interaction module, and a feature enhancement layer, firstly utilizes the data embedding layer to fuse periodic, spatial, and adaptive information, providing the model with rich prior knowledge and high-dimensional feature representation; then, the core spatiotemporal interaction module performs temporal feature extraction and spatial feature extraction separately through sequence segmentation, and performs interactive learning of spatiotemporal features during the extraction process, so that the extraction process of temporal features can be influenced by the spatial context, and the construction of spatial relationships directly depends on the current temporal features, thereby breaking the barrier of spatiotemporal processing separation in traditional models, realizing deep interaction and collaborative learning of temporal and spatial features; this deep interaction mechanism can more precisely capture the complex, dynamically evolving spatiotemporal coupling relationships and heterogeneity in traffic flow, and is further enhanced by the feature enhancement layer, thereby significantly improving the model's ability to represent the spatiotemporal dynamic characteristics of traffic flow, so that the overall technical solution achieves the beneficial effect of improving the accuracy of long-term traffic flow prediction. This invention achieves good overall results in terms of prediction accuracy, computational complexity, and robustness, and solves the problems of low accuracy in traffic flow prediction in complex traffic scenarios and long-term prediction. Attached Figure Description

[0012] Figure 1 This is a flowchart illustrating the spatiotemporal graph neural network traffic flow prediction method combined with interactive learning in an example of the present invention. Figure 2 These are the structure diagrams of the spatiotemporal graph neural network model combining interactive learning and the spatiotemporal interaction module in this embodiment of the invention. Figure 3 This is a diagram of the gated timing graph convolution structure in an embodiment of the present invention; Figure 4 This is a diagram of the dynamic graph convolutional network structure in an embodiment of the present invention; Figure 5 This is the result of a comparative experiment between the present invention and other common models. Detailed Implementation

[0013] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some, not all, of the embodiments of the present application. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative effort should fall within the scope of protection of the present application.

[0014] In one specific embodiment, the present invention provides a traffic flow prediction method combining a spatiotemporal graph neural network with interactive learning, comprising the following steps: S1. Obtain raw traffic feature data and input it into a trained spatiotemporal graph neural network model, wherein the spatiotemporal graph neural network model includes a data embedding layer, at least one spatiotemporal interaction module, a feature enhancement layer and an output layer connected in sequence. S2. Through the data embedding layer, the original traffic feature data is subjected to periodic, spatial and adaptive embedding processing to obtain a hidden high-dimensional spatiotemporal embedding representation that integrates periodic, spatial and adaptive information. S3. Through the at least one spatiotemporal interaction module, perform spatiotemporal interaction processing on the hidden high-dimensional spatiotemporal embedded representation: by performing interactive learning of spatiotemporal features between the processes of temporal feature extraction and spatial feature extraction, output a spatiotemporal feature representation that enhances the spatiotemporal interaction features. S4. Through the feature enhancement layer, further feature enhancement processing is performed on the spatiotemporal feature representation that has been enhanced with spatiotemporal interaction features, and traffic flow prediction results are output from the output layer based on the processed features.

[0015] In some implementations, in step S1, the original traffic feature data is obtained by preprocessing historical traffic flow data; wherein the historical traffic flow data has the continuity of the data collection sequence and includes the following information: sensor number, timestamp of each data point, and flow rate; wherein the preprocessing includes: filtering sensor nodes according to a preset sensor spacing threshold; aggregating traffic flow data into a time window of a preset length and performing normalization processing; and segmenting the normalized data according to a preset historical observation sequence length T and a future prediction length T' to obtain the original traffic feature data.

[0016] More specifically, the historical traffic flow data is a publicly available dataset. The publicly available dataset is preprocessed as described above to obtain the dataset required for the experiment. The dataset is then divided into a training set, a validation set, and a test set in a ratio (e.g., 6:2:2).

[0017] In a preferred embodiment, the preset sensor spacing threshold is 3.5 miles; the preset time window is 5 minutes; the normalization process is z-score normalization; and the historical observation sequence length T and the future prediction length T' are both set to 12, representing the past hour and the future hour, respectively.

[0018] In some implementations, step S2 includes: S2.1. Convert the original traffic feature data into feature embeddings through a fully connected layer; S2.2. Based on the weekday index and daytime stamp index in the traffic time series, extract the corresponding weekday embedding and daytime stamp embedding from the learnable weekday embedding dictionary and daytime stamp embedding dictionary, and concatenate the weekday embedding and the daytime stamp embedding to obtain the periodic embedding of the traffic time series. S2.3. Based on the sensor number index in the traffic time series, extract the sensor number embedding from the learnable sensor number embedding dictionary; S2.4 Introduce learnable spatiotemporal adaptive embedding; S2.5. The feature embedding, the periodic embedding, the sensor number embedding, and the spatiotemporal adaptive embedding are concatenated and broadcast to obtain the hidden high-dimensional spatiotemporal embedding representation.

[0019] In some implementations, in step S3, the spatiotemporal interaction module includes a gated temporal graph convolutional network for extracting temporal correlations and a dynamic graph convolutional network with shared weights for extracting spatial correlations; step S3 includes: S3.1. The input sequence is divided into two subsequences based on the parity index interval; S3.2. Input the two sub-sequences into two different gated temporal convolutional networks respectively, and input the results after passing through the gated temporal convolutional networks into a dynamic graph convolutional network for spatiotemporal interactive learning. S3.3 Reorganize the subsequences obtained from spatiotemporal interaction learning according to their time positions to obtain a complete spatiotemporal representation; S3.4. The spatiotemporal representation obtained after recombination is added element-wise to the original unsegmented input sequence to achieve residual connection, thus obtaining the final spatiotemporal feature representation.

[0020] In some implementations, step S3.2 includes: The temporal convolution in the gated temporal graph convolution is a dilated causal convolution, which includes two temporal graph convolution sub-modules: the activation function of the first temporal graph convolution sub-module is the hyperbolic tangent function tanh, and the activation function of the second temporal graph convolution sub-module is the sigmoid function, and their output is used as the output gate; after the two sub-sequences are respectively input into the gated temporal graph convolution network, the result after passing through the second temporal graph convolution sub-module and the result after passing through the first temporal graph convolution sub-module are multiplied by Hadamard, and the output of the first temporal graph convolution sub-module is adjusted, thereby completing the extraction of temporally relevant features; The extracted temporal correlation features are input into the dynamic graph convolutional network to extract spatial correlation features: the dynamic graph convolutional network utilizes a trainable traffic pattern library and the input hidden representation to construct a dynamically evolving fused adjacency matrix over time, and then uses the dynamically fused adjacency matrix to perform a diffusing convolution operation to extract spatial correlation features; and Through the interactive operation of the two subsequences and the spatial correlation features, the interactive learning of temporal correlation features and spatial correlation features is achieved.

[0021] In some implementations, the dynamic graph convolutional network constructs a dynamically evolving, time-dependent fusion adjacency matrix, including: The time-related features are non-linearly mapped using a fully connected layer to obtain a vector without a time dimension. The time-free vector is used as a query, and spatial similarity is calculated with the traffic pattern library and itself to generate two dynamic adjacency matrices. The two dynamic adjacency matrices are first concatenated along their last dimension, and then the last dimension is weighted and summed through a fully connected layer to generate the dynamic fused adjacency matrix.

[0022] In some implementations, in step S4, the feature enhancement layer includes serially connected... L A time-based Transformer layer and serial connections L A series of serially connected spatial Transformer layers, wherein the temporal Transformer layer computes self-attention in the time dimension, and the spatial Transformer layer computes self-attention in the node dimension; the output layer is a multilayer perceptron; step S4 includes: The temporal feature enhancement is performed on the spatiotemporal feature representation that enhances the spatiotemporal interaction features using a temporal Transformer layer; Spatial feature enhancement is performed on the temporally enhanced representation using a spatial Transformer layer; The spatially enhanced representation is input into a multilayer perceptron to obtain the final traffic flow prediction result.

[0023] In some implementations, the spatiotemporal graph neural network model is trained using the mean absolute error (MAE) as a loss function.

[0024] A specific embodiment of the present invention also includes a spatiotemporal graph neural network traffic flow prediction system combining interactive learning, comprising: a processor; a memory for storing a computer program; wherein the computer program, when executed by the processor, implements the method described herein.

[0025] The present invention further includes a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described thereon.

[0026] The present invention will be further illustrated below through specific embodiments.

[0027] In the following embodiments, the main symbols are explained in the table below:

[0028]

[0029]

[0030] The spatiotemporal graph neural network traffic flow prediction method combined with interactive learning in this embodiment includes: S1: The dataset used in the experiment is obtained by preprocessing the public datasets (PEMS04, PEMS07, PEMS08) and dividing the datasets into training set, validation set and test set according to the proportion.

[0031] In this embodiment, the data collection area for the public dataset is an urban highway network scenario. The collected data includes the following information: sensor number, timestamp of each data point, and traffic flow, ensuring the continuity of the data collection sequence. During preprocessing, a minimum sensor spacing of 3.5 miles is set for filtering. Subsequently, the traffic flow data is aggregated into time windows with 5-minute intervals and z-score normalization is applied. Then, the input features are obtained by segmenting the data according to the observation sequence length T and the prediction window length T' (in this example, T=T'=12, i.e., using data from the past hour to predict the traffic flow for the next hour). and output features The dataset required for the experiment is obtained, where T represents the length of the observation sequence, N represents the number of nodes, and D represents the feature dimension of the nodes. Finally, the dataset is divided into training set, validation set, and test set in a 6:2:2 ratio.

[0032] The obtained raw traffic feature data is input into the trained spatiotemporal graph neural network model, such as... Figure 2The diagram shows the structure of the spatiotemporal graph neural network model combining interactive learning and the spatiotemporal interaction module in this embodiment of the invention. The model starts with the original input, passes through a data embedding layer, then undergoes feature concatenation and recombination after spatiotemporal interactive learning, followed by spatiotemporal feature enhancement through multiple Transformer layers. To prevent gradient vanishing and model degradation caused by increased network depth, residual connections are added. Finally, the model passes through a multilayer perceptron to obtain the final output. In this embodiment, MAE is selected as the loss function.

[0033] S2: Through the data embedding layer, the original traffic feature data is periodically, spatially, and adaptively embedded to obtain a richer spatiotemporal feature representation (i.e., a hidden high-dimensional spatiotemporal embedding representation that integrates periodic, spatial, and adaptive information).

[0034] In this embodiment, the data embedding layer includes a fully connected layer that implements the embedding function, and step S2 specifically includes the following steps: S2.1: Transfer the original traffic feature data It is converted into feature embedding through a fully connected layer. , The embedded dimension not only preserves the intrinsic information in the original data, but also expands the feature dimension; S2.2: Based on the weekday index and daytime timestamp index in the traffic time series, extract the corresponding weekday embeddings and daytime timestamp embeddings from the learnable weekday embedding dictionary and daytime timestamp embedding dictionary, and concatenate the weekday embeddings and daytime timestamp embeddings to obtain the periodic embedding of the traffic time series; specifically, in this step, a learnable adaptive time periodic embedding is introduced to integrate prior periodic knowledge into the data features: first, the learnable weekday embedding dictionary is represented as... The timestamps within a day are embedded into a dictionary and represented as follows: ,in Indicates the number of days in a week. This refers to the number of timestamps per day (the data in this invention uses a daily sampling interval of 5 minutes); subsequently... , As traffic time series respectively The data includes intraday and intraday timestamp data, which are used as indexes to extract the corresponding intraday embeddings from the embedding dictionary. and intraday timestamp embedding Finally, these are concatenated to obtain the periodic embedding of the traffic time series. ; S2.3: Based on the sensor ID index in the traffic time series, extract the sensor ID embedding from the learnable sensor ID embedding dictionary; specifically, in this step, an adaptive spatial embedding is introduced to integrate prior spatial knowledge into the data features: first, the learnable sensor ID embedding dictionary is represented as... ,in This represents the number of sensors in the dataset, which is also equal to the number of sensor nodes. .Will As a traffic time series The sensor ID data is used as a spatial index to extract the corresponding sensor ID embedding representation from the spatial embedding dictionary. .

[0035] S2.4: A spatiotemporal adaptive embedding was designed. , It is a learnable parameter matrix that captures additional spatiotemporal relationships in a unified way, thus taking into account that traffic flow is also affected by external factors such as weather and special events, as well as spatiotemporal heterogeneity; the spatiotemporal adaptive embedding Ea is a learnable parameter matrix that is updated during backpropagation.

[0036] S2.5: The feature embedding, the periodic embedding, the sensor number embedding, and the spatiotemporal adaptive embedding are concatenated and broadcast to obtain the hidden high-dimensional spatiotemporal embedding representation. .

[0037] S3: Through the spatiotemporal interaction module, the spatiotemporal characteristics of traffic flow (including temporal and spatial correlations) are modeled at multiple scales. Each spatiotemporal interaction module models the temporal correlation of traffic flow through temporal convolution and the spatial correlation of traffic flow through dynamic graph convolution. An interactive learning strategy is employed to achieve spatiotemporal feature interaction, thereby enhancing spatiotemporal feature learning. Specifically, such as... Figure 2 As shown, in this embodiment, the spatiotemporal interaction module includes four gated temporal convolutional network (G-TCN) networks for extracting temporal correlations and one dynamic graph convolutional network (DGCN) with shared weights for extracting spatial correlations. The specific operation steps of the spatiotemporal interaction module include the following: S3.1: After splitting the input sequence based on the parity index interval, two subsequences are obtained: the even subsequence. odd subsequence ; S3.2: Subsequence , The inputs are respectively fed into two different G-TCNs (referred to as G-TCNs in the formula). 1、 The results of G-TCN2 are input into DGCN and activated by the tanh function. The result is then multiplied by the subsequence to obtain the subsequence with spatial information enhancement. , Then , The inputs are then fed into two different G-TCNs (referred to as G-TCNs in the formula). 3、 The result of G-TCN4 is input into DGCN and activated by the tanh function, and the result is the same as... , Then add and fuse the elements one by one to obtain , This completes the spatiotemporal interactive learning process; the process of this spatiotemporal interaction is defined as follows:

[0038]

[0039]

[0040]

[0041] in The four distinct tanh values ​​represent the Hadamard product, tanh represents the hyperbolic tangent activation function, and tanh represents the four distinct tanh values. They have the same structure but different initial values, and each updates independently during the learning process.

[0042] S3.3: Reorganize the subsequences obtained from spatiotemporal interactive learning according to their time positions to obtain a complete spatiotemporal representation.

[0043] S3.4: By adding the recombined spatiotemporal representation to the original unsegmented input sequence element by element to achieve residual connection, the final spatiotemporal feature representation is obtained.

[0044] According to this embodiment, as Figure 3 In the gated temporal graph convolutional structure diagram shown, the temporal convolution in G-TCN is dilated causal convolution. Specifically, each G-TCN consists of two temporal graph convolutional sub-modules (TCN-a and TCN-b). The activation function of TCN-a is the hyperbolic tangent function tanh, and the activation function of TCN-b is the sigmoid (σ) function, whose output is between 0 and 1. As the output gate, the result of TCN-b and the result of TCN-a are multiplied by Hadamard to adjust the output of TCN-a, suppress noise, highlight key features, and thus complete the screening of time-related features.

[0045] According to this embodiment, as Figure 4 This diagram illustrates the structure of a dynamic graph convolutional network (DGCN) in an embodiment of the present invention. In DGCN, a trainable traffic pattern library is first defined. (Using random initialization between 0 and 1), this traffic pattern library is able to adaptively learn, update, and store the unique traffic patterns of each node due to spatial heterogeneity during training. The graph generator utilizes the traffic pattern library. and hidden representation of input to DGCN ( This indicates the timing length at this point, for example, in the first-layer STI module. =T / 2, in the second-level STI module =T / 4), constructing a dynamic fusion adjacency matrix that evolves over time. Subsequently, the diffusion graph convolution utilizes dynamically fused adjacency matrices. Diffusion convolution is performed to extract spatial correlations. Specifically, in the graph generator, hidden representations are used. It is obtained by capturing temporal correlations through G-TCN. First, a fully connected layer is used to perform a non-linear mapping to obtain a vector without a time dimension. Next, it means This will be used as a query to calculate spatial similarity with both the traffic pattern database and itself. This process generates two dynamic adjacency matrices. and The two dynamic adjacency matrices are calculated as follows:

[0046]

[0047] Then and First, the data is concatenated along the last dimension. Then, the last dimension is weighted and summed through a fully connected layer (the input of a fully connected layer is 2-dimensional, and the output is 1-dimensional) to construct a dynamically evolving adjacency matrix that changes over time. Then, the spread graph convolution of the input subsequence at each time step utilizes dynamically fused adjacency matrices. This enables weight sharing. Diffusion convolution operations are used to dynamically extract spatial correlations.

[0048] S4: The spatiotemporal sequence obtained after processing by the spatiotemporal interaction module is further enhanced by multiple Transformer layers, and then passed to the multilayer perceptron to obtain the final output, realizing multi-step and accurate prediction of traffic flow.

[0049] Specifically, in this embodiment, the spatiotemporal sequence obtained after processing by the spatiotemporal interaction module is further enhanced in terms of spatiotemporal features through multiple Transformer layers, among which... A time Transformer layer and A spatial Transformer layer, Each Transformer layer is connected serially, and its results are then input into... A series of serially connected spatial Transformer layers. Each Transformer layer contains two layers of self-attention computation, which enhance the temporal and spatial feature representations of the data through an attention mechanism. The enhanced spatiotemporal feature representations are then passed to a multilayer perceptron, thereby achieving multi-step and accurate prediction of traffic flow. Given a hidden spatiotemporal representation as... This invention obtains the query matrix, key matrix, and value matrix through a time transformer layer, and the calculation methods are as follows: .in These are learnable parameters. Then through...

[0050] The self-attention score is calculated, and the output of the time transformer is finally obtained. Similarly, the spatial transformer layer performs a similar operation to obtain the spatial attention score matrix. The output of the space transformer is then obtained as follows. Temporal attention is calculated in the time dimension, while spatial attention is calculated in the node dimension. This yields the temporal relevance of each node and the node relevance of each time step, capturing temporal and spatial relevance with fine granularity.

[0051] S5: Determine the hyperparameters in the model through validation experiments (hyperparameters include learning rate, batch size, convolution kernel size, data embedding dimension, number of network layers, etc.), and provide a set of quantitative analysis and comparison methods using indicators such as mean absolute error (MAE), root mean square error (RMSE), and mean absolute percentage error (MAPE) to evaluate the model from the perspectives of prediction accuracy, generalization ability, and robustness.

[0052] Specifically, in this embodiment, Adam is selected as the optimizer, and MAE is used as the loss function during training, with random initialization. This includes the process of selecting hyperparameters such as learning rate, batch size, convolutional kernel size, data embedding dimension, and number of network layers, as well as the model evaluation and assessment methods, which include the following steps: A1: Select an appropriate training Epoch size (the model converges after approximately 80 Epochs, so in this example, 100 Epochs are selected), and determine the number of network layers in the three modules of G-TCN, DGCN, and Transformer in the prediction model based on the results on the validation set. A2: Select an appropriate training epoch size (the model converges after approximately 80 epochs, so in this example, 100 epochs are selected), use a grid search strategy, and determine the learning rate (0.0001 to 0.01), batch size (16 to 64), kernel size (1 to 5), data embedding dimension (16 to 48), number of network layers (1 to 8), and other hyperparameters to find the optimal combination of hyperparameters; A3: Using standard metrics commonly used in traffic flow prediction, such as mean absolute error (MAE), root mean square error (RMSE), and mean absolute percentage error (MAPE), the model's prediction accuracy, generalization ability, and robustness are evaluated and verified on the test set.

[0053] Assumption Represents the true value. Indicates the predicted value. Let the set of indices represent the observed samples. Then, the evaluation indicators are defined as follows:

[0054]

[0055]

[0056] The smaller the value of the evaluation index, the more accurate the model's prediction.

[0057] In this embodiment, step S5, A3, is based on the optimal hyperparameter combination and common models (such as DCRNN, STGCN, GWNet, STID, D...). 2 The comparative experimental results of STGCN, DGCRN, and STAEformer are as follows: Figure 5 As shown, its metric is the average of predicting the next 1 to 12 steps (i.e., the average of predicting the next 5 minutes to 1 hour). It can be seen that on the three public datasets PEMS04, PEMS07, and PEMS08, the method of this invention (in...) Figure 5The method (referred to as "Ours") achieved the best results in MAE, and the best or second-best results in RMSE and MAPE. This shows that the method outperforms other common models in multi-step prediction and prediction accuracy, and achieves good overall results.

[0058] As can be seen from the above specific embodiments, the present invention has the following advantages: By fusing periodic, spatial, and adaptive information through the data embedding layer, the model is provided with rich prior knowledge and high-dimensional feature representations, laying the foundation for subsequent deep modeling. Furthermore, through the spatiotemporal interaction module, employing odd-even segmentation and interactive learning strategies, and utilizing gated temporal convolutional networks and dynamic graph convolutional networks, multiple interactive operations are performed during the extraction of temporal and spatial correlations. This breaks the limitations of the fragmented spatiotemporal features in traditional serial or parallel architectures, achieving deep fusion and synergistic enhancement of temporal and spatial features. This deep interactive learning enables the model to capture the complex and dynamically evolving spatiotemporal dependencies in traffic flow more precisely and uniformly. Finally, the temporal and spatial Transformers in the feature enhancement layer further strengthen features in their respective dimensions, thereby synergistically achieving the top-level beneficial effect of improving the accuracy of long-term traffic flow prediction.

[0059] By using a dynamic graph convolutional network to dynamically generate a fused adjacency matrix based on the input data, the model avoids dependence on a predefined static adjacency matrix and can adaptively capture the dynamic spatial relationships between nodes as traffic patterns change, thus enhancing the model's adaptability and robustness to different traffic scenarios.

[0060] By introducing various learnable embeddings (periodicity, sensor numbering, spatiotemporal adaptation), the model is able to explicitly encode and utilize spatiotemporal heterogeneity information, thereby more accurately characterizing the unique traffic patterns in different regions and at different times, and improving prediction accuracy.

[0061] By employing gating mechanisms and residual connections in gated temporal convolutional networks, the vanishing gradient and model degradation problems are effectively controlled, improving the stability of model training and the expressive power of deep networks. Dynamic graph convolutional networks, by dynamically generating fused adjacency matrices, break free from the dependence on predefined static graphs and adaptively capture the implicit spatial relationships between nodes that change with traffic conditions, thereby enhancing the model's spatial representation capabilities.

[0062] By using the temporal and spatial Transformer layers in the feature enhancement layer, the expressive power of spatiotemporal features is further enhanced, enabling the model to model traffic flow from multiple scales and dimensions, ultimately achieving more accurate and robust traffic flow prediction results.

[0063] Using mean absolute error as the loss function for training is consistent with commonly used evaluation metrics, which helps align the model optimization direction with the final evaluation goal.

[0064] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A traffic flow prediction method combining spatiotemporal graph neural networks with interactive learning, characterized in that, Includes the following steps: S1. Obtain raw traffic feature data and input it into a trained spatiotemporal graph neural network model, wherein the spatiotemporal graph neural network model includes a data embedding layer, at least one spatiotemporal interaction module, a feature enhancement layer and an output layer connected in sequence. S2. Through the data embedding layer, the original traffic feature data is subjected to periodic, spatial and adaptive embedding processing to obtain a hidden high-dimensional spatiotemporal embedding representation that integrates periodic, spatial and adaptive information. S3. Through the at least one spatiotemporal interaction module, perform spatiotemporal interaction processing on the hidden high-dimensional spatiotemporal embedded representation: by performing interactive learning of spatiotemporal features between the processes of temporal feature extraction and spatial feature extraction, output a spatiotemporal feature representation that enhances the spatiotemporal interaction features. S4. Through the feature enhancement layer, further feature enhancement processing is performed on the spatiotemporal feature representation that has been enhanced with spatiotemporal interaction features, and traffic flow prediction results are output from the output layer based on the processed features.

2. The traffic flow prediction method combining spatiotemporal graph neural networks with interactive learning as described in claim 1, characterized in that, In step S1, the original traffic characteristic data is obtained by preprocessing historical traffic flow data; The historical traffic flow data has a continuous data collection sequence and includes the following information: sensor number, timestamp of each data point, and traffic flow. The preprocessing includes: filtering sensor nodes according to a preset sensor spacing threshold; aggregating traffic flow data into a time window of a preset length and performing normalization processing; and segmenting the normalized data according to a preset historical observation sequence length T and a future prediction length T' to obtain the original traffic feature data.

3. The spatiotemporal graph neural network traffic flow prediction method combining interactive learning as described in claim 1 or 2, characterized in that, Step S2 includes: S2.

1. Convert the original traffic feature data into feature embeddings through a fully connected layer; S2.

2. Based on the weekday index and daytime stamp index in the traffic time series, extract the corresponding weekday embedding and daytime stamp embedding from the learnable weekday embedding dictionary and daytime stamp embedding dictionary, and concatenate the weekday embedding and the daytime stamp embedding to obtain the periodic embedding of the traffic time series. S2.

3. Based on the sensor number index in the traffic time series, extract the sensor number embedding from the learnable sensor number embedding dictionary; S2.4 Introduce learnable spatiotemporal adaptive embedding; S2.

5. The feature embedding, the periodic embedding, the sensor number embedding, and the spatiotemporal adaptive embedding are concatenated and broadcast to obtain the hidden high-dimensional spatiotemporal embedding representation.

4. The traffic flow prediction method combining spatiotemporal graph neural networks with interactive learning as described in claim 1, characterized in that, In step S3, the spatiotemporal interaction module includes a gated temporal graph convolutional network for extracting temporal correlations and a dynamic graph convolutional network with shared weights for extracting spatial correlations; step S3 includes: S3.

1. The input sequence is divided into two subsequences based on the parity index interval; S3.

2. Input the two sub-sequences into two different gated temporal convolutional networks respectively, and input the results after passing through the gated temporal convolutional networks into a dynamic graph convolutional network for spatiotemporal interactive learning. S3.3 Reorganize the subsequences obtained from spatiotemporal interaction learning according to their time positions to obtain a complete spatiotemporal representation; S3.

4. The spatiotemporal representation obtained after recombination is added element-wise to the original unsegmented input sequence to achieve residual connection, thus obtaining the final spatiotemporal feature representation.

5. The traffic flow prediction method using a spatiotemporal graph neural network combined with interactive learning as described in claim 4, characterized in that, Step S3.2 includes: The temporal convolution in the gated temporal graph convolution is a dilated causal convolution, which includes two temporal graph convolution sub-modules: the activation function of the first temporal graph convolution sub-module is the hyperbolic tangent function tanh, and the activation function of the second temporal graph convolution sub-module is the sigmoid function, and their output is used as the output gate; after the two sub-sequences are respectively input into the gated temporal graph convolution network, the result after passing through the second temporal graph convolution sub-module and the result after passing through the first temporal graph convolution sub-module are multiplied by Hadamard, and the output of the first temporal graph convolution sub-module is adjusted, thereby completing the extraction of temporally relevant features; The extracted temporal correlation features are input into the dynamic graph convolutional network to extract spatial correlation features: the dynamic graph convolutional network utilizes a trainable traffic pattern library and the input hidden representation to construct a dynamically evolving fused adjacency matrix over time, and then uses the dynamically fused adjacency matrix to perform a diffusing convolution operation to extract spatial correlation features; and Through the interactive operation of the two subsequences and the spatial correlation features, the interactive learning of temporal correlation features and spatial correlation features is achieved.

6. The traffic flow prediction method using a spatiotemporal graph neural network combined with interactive learning as described in claim 5, characterized in that, The dynamic graph convolutional network constructs a dynamically evolving, time-dependent fused adjacency matrix, including: The time-related features are non-linearly mapped using a fully connected layer to obtain a vector without a time dimension. The time-free vector is used as a query, and spatial similarity is calculated with the traffic pattern library and itself to generate two dynamic adjacency matrices. The two dynamic adjacency matrices are first concatenated along their last dimension, and then the last dimension is weighted and summed through a fully connected layer to generate the dynamic fused adjacency matrix.

7. The traffic flow prediction method combining spatiotemporal graph neural networks with interactive learning as described in claim 1, characterized in that, In step S4, the feature enhancement layer includes serially connected... L A time-based Transformer layer and serial connections L A series of serially connected spatial Transformer layers, wherein the temporal Transformer layer computes self-attention in the time dimension, the spatial Transformer layer computes self-attention in the node dimension, and the output layer is a multilayer perceptron; Step S4 includes: The temporal feature enhancement is performed on the spatiotemporal feature representation that enhances the spatiotemporal interaction features using a temporal Transformer layer; Spatial feature enhancement is performed on the temporally enhanced representation using a spatial Transformer layer; The spatiotemporally enhanced representation is input into a multilayer perceptron to obtain the final traffic flow prediction result.

8. The traffic flow prediction method using a spatiotemporal graph neural network combined with interactive learning as described in claim 1, characterized in that, The spatiotemporal graph neural network model is trained using the mean absolute error (MAE) as the loss function.

9. A traffic flow prediction system combining spatiotemporal graph neural networks with interactive learning, characterized in that, include: processor; Memory, used to store computer programs; When the computer program is executed by the processor, it implements the method as described in any one of claims 1 to 8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Traffic flow prediction method based on interactive dynamic graph convolution and probability sparse attention

    CN117290707A

  • Traffic flow prediction method and system based on time-space synchronization dynamic graph attention network

    CN117671952A

  • Traffic flow prediction method and system, storage medium, computer equipment and terminal

    CN118411825A

  • Traffic flow prediction method based on time-space synchronization embedded graph Transform model

    CN120071622A

  • Time-varying graph neural network traffic flow prediction method based on dynamic memory bank

    CN121171043A