Traffic flow prediction method and device based on spatio-temporal attention graph neural network

CN117576894BActive Publication Date: 2026-09-08TSINGHUA UNIVERSITY +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311402973.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-26
Publication Date
2026-09-08
Estimated Expiration
2043-10-26

AI Technical Summary

Technical Problem

[0004]因此,目前的交通流量预测方法存在诸多缺陷,导致其难以有效精准地捕捉真实交通路况,亟需提供一种新的交通流量预测方法

Benefits of technology

[0047]This invention provides a traffic flow prediction method and apparatus based on a spatiotemporal attention graph neural network, comprising: acquiring a pre-constructed spatiotemporal attention graph neural network; wherein the spatiotemporal attention graph neural network includes a spatiotemporal feature learning layer, a pooling layer, and a prediction layer; utilizing a road network spatial topology map and the spatiotemporal feature learning layer, performing spatiotemporal dual-dimensional information fusion learning on fine-grained traffic flow data of each intersection in the road network within a preset time period to obtain fine-grained traffic flow features of each intersection in the target path within the preset time period; pooling the fine-grained traffic flow features according to the intersection connectivity of the target path and the pooling layer to obtain coarse-grained traffic flow features of the target path within the preset time period; and predicting the traffic flow of the target path within the target time period based on the prediction layer, the coarse-grained traffic flow features, and the coarse-grained traffic flow data of the target path within the preset time period. This invention pre-constructs a spatiotemporal attention graph neural network capable of capturing the spatiotemporal correlation patterns of traffic flow at different intersections and at different times in the main traffic flow path, and then, based on the spatiotemporal attention graph neural network, uses fine-grained intersection traffic flow to predict coarse-grained path traffic flow, achieving high prediction accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117576894B_ABST
    Figure CN117576894B_ABST
Patent Text Reader

Abstract

This invention provides a traffic flow prediction method and apparatus based on a spatiotemporal attention graph neural network. The spatiotemporal attention graph neural network includes a spatiotemporal feature learning layer, a pooling layer, and a prediction layer. Utilizing a road network spatial topology map and the spatiotemporal feature learning layer, it performs spatiotemporal dual-dimensional information fusion learning on fine-grained traffic flow data at each intersection in the road network within a preset time period, obtaining fine-grained traffic flow features at each intersection along the target path within the preset time period. Based on the intersection connectivity of the target path and the pooling layer, the fine-grained traffic flow features are pooled to obtain coarse-grained traffic flow features for the target path within the preset time period. Based on the prediction layer, the coarse-grained traffic flow features, and the coarse-grained traffic flow data of the target path within the preset time period, the traffic flow of the target path during the target time period is predicted. This invention utilizes fine-grained intersection traffic flow and a spatiotemporal attention graph neural network capable of capturing the spatiotemporal correlation patterns of traffic flow at different intersections and at different time periods to accurately predict coarse-grained path traffic.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Traffic flow prediction is a technology that senses and predicts traffic flow at intersections, lanes, and major traffic routes in advance. It provides important reference information and decision-making guidance for downstream tasks such as driving navigation prompts, route planning, and traffic restriction on road sections.

[0003] The current traffic flow prediction methods can be roughly divided into the following categories: (1) The method of constructing a data-driven statistical model to realize traffic flow prediction; (2) The method of extracting the spatial topology features of the road network using convolutional neural networks / recurrent neural networks and predicting traffic flow based on the spatial topology features of the road network; (3) The method of predicting traffic flow based on spatiotemporal graph neural networks. In method (1), although the statistical model is simple and has a small computational load, it is built on the basis of making certain statistical assumptions (such as the simplest linear regression assumption) on past traffic data and future traffic volume, which is equivalent to imposing a large prior constraint on the statistical model. Such prior constraints are not necessarily reasonable and it is difficult to capture complex spatiotemporal dynamics. In method (2), since convolutional neural networks and recurrent neural networks are both proposed for Euclidean structure data, convolutional neural networks are usually for images and recurrent neural networks are usually for sequence data. The spatial topology of the road network is a topological structure graph, so convolutional neural networks and recurrent neural networks cannot effectively learn the spatial topology features of the road network, thus affecting the effect of traffic flow prediction. In method (3), intersection traffic is generally predicted using intersection traffic, and it is assumed that there is no missing intersection traffic data. It does not take into account the lack of intersection traffic data and the problem of downstream task learning in actual applications.

[0004] Therefore, current traffic flow prediction methods have many shortcomings, making it difficult to effectively and accurately capture real traffic conditions. There is an urgent need to provide a new traffic flow prediction method. Summary of the Invention

[0005] To address the aforementioned problems, this invention provides a traffic flow prediction method and apparatus based on a spatiotemporal attention graph neural network. The method utilizes road network spatial topology, historical traffic flow at road network intersections, and historical traffic flow information of main traffic paths to construct a spatiotemporal attention graph neural network, thereby uncovering the temporal dependence of road network traffic and capturing its complex spatiotemporal characteristics. Based on this, the spatiotemporal attention graph neural network can be used to accurately predict the traffic flow of a specific main traffic path within a specific future time period.

[0006] In a first aspect, the present invention provides a traffic flow prediction method based on a spatiotemporal attention graph neural network, the method comprising:

[0007] Obtain a pre-constructed spatiotemporal attention graph neural network; wherein the spatiotemporal attention graph neural network includes a spatiotemporal feature learning layer, a pooling layer, and a prediction layer;

[0008] By utilizing the road network spatial topology diagram and the spatiotemporal feature learning layer, information fusion learning is performed on the spatial and temporal dimensions of the fine-grained traffic data of each intersection in the road network within a preset time period to obtain the fine-grained traffic features of each intersection in the target path within a preset time period.

[0009] Based on the intersection connectivity of the target path and the pooling layer, the fine-grained flow characteristics are pooled to obtain the coarse-grained flow characteristics of the target path within a preset time period.

[0010] Based on the prediction layer, the coarse-grained traffic characteristics, and the coarse-grained traffic data of the target path within a preset time period, the traffic of the target path during the target time period is predicted.

[0011] The preset time period is a long period of time preceding the target time period.

[0012] According to the traffic flow prediction method based on spatiotemporal attention graph neural network provided by the present invention, the spatiotemporal feature learning layer includes a graph neural network layer and an attention temporal encoder;

[0013] The method utilizes the road network spatial topology map and the spatiotemporal feature learning layer to perform spatial and temporal information fusion learning on the fine-grained traffic data of each intersection in the road network within a preset time period, thereby obtaining the fine-grained traffic features of each intersection in the target path within the preset time period, including:

[0014] Based on the fine-grained traffic data of each intersection in the road network within a preset time period, an intersection traffic matrix is ​​generated for each fine-grained time slice of the road network within the preset time period.

[0015] In the graph neural network layer, based on the road network spatial topology diagram, spatial dimension information fusion learning is performed on the intersection traffic matrix under each fine-grained time slice of the road network in the preset time period to obtain the traffic characteristics of each intersection in the target path under each fine-grained time slice of the preset time period.

[0016] Based on the traffic characteristics of each intersection in the target path under all fine-grained time slices in the preset time period, a time series sequence of traffic characteristics corresponding to each intersection in the target path is generated.

[0017] In the attention-based temporal encoder, the temporal sequence of traffic features corresponding to each intersection in the target path is fused and learned in the time dimension to obtain the fine-grained traffic features of each intersection in the target path within a preset time period.

[0018] According to the traffic flow prediction method based on spatiotemporal attention graph neural network provided by the present invention, the process of generating the road network spatial topology map includes:

[0019] The first topology graph is generated by using intersections in the road network as nodes and the connections between intersections in the road network as edges.

[0020] The first topology graph is labeled with node features and edge weights to obtain the road network spatial topology graph.

[0021] The node features include: the latitude and longitude coordinates of the intersection corresponding to the node and the intersection ID;

[0022] The weight A of the edge connecting node i and node j in the first topological graph ij The expression is:

[0023]

[0024] Where α is the first hyperparameter, c i Let c be the latitude and longitude coordinates of node i. j Let be the latitude and longitude coordinates of node j.

[0025] According to the traffic flow prediction method based on spatiotemporal attention graph neural network provided by the present invention, the graph neural network layer is a K-layer GCN network;

[0026] In the graph neural network layer, based on the road network spatial topology graph, spatial dimension information fusion learning is performed on the intersection traffic matrix of the road network under any fine-grained time slice to obtain the traffic characteristics of each intersection in the target path under any fine-grained time slice, including:

[0027] The intersection traffic matrix and the spatial topology diagram of the road network under any fine-grained time slice are input into the first layer of the GCN network, so that the GCN network learns the node features in each layer according to its own transfer function as the mean of its own features and the features of its neighboring nodes, and finally obtains the intersection traffic matrix output by the last layer of the GCN network.

[0028] Based on the intersection traffic matrix output by the last layer of the GCN network, the traffic characteristics of each intersection in the target path under any fine-grained time slice are determined.

[0029] According to the traffic flow prediction method based on spatiotemporal attention graph neural network provided by the present invention, the attention temporal encoder adopts a Transformer network;

[0030] In the attention-based temporal encoder, the temporal sequence of traffic features corresponding to any intersection in the target path is fused and learned in the time dimension to obtain fine-grained traffic features of any intersection in the target path within a preset time period, including:

[0031] The attention-based temporal encoder is controlled to perform time-dimensional information fusion learning on the traffic feature temporal sequence corresponding to any intersection according to the multi-head self-attention mechanism, so as to obtain the fine-grained traffic features of any intersection within a preset time period.

[0032] According to the traffic flow prediction method based on spatiotemporal attention graph neural network provided by the present invention, the pooling layer includes a path pooling layer and a time pooling layer; the step of pooling the fine-grained traffic flow features according to the intersection connectivity of the target path and the pooling layer to obtain the coarse-grained traffic flow features of the target path within a preset time period includes:

[0033] In the path pooling layer, the fine-grained traffic features are path pooled according to the intersection connection of the target path to generate the fine-grained traffic features of the target path within a preset time period.

[0034] In the time pooling layer, the fine-grained flow characteristics of the target path within a preset time period are averaged to obtain the coarse-grained flow characteristics of the target path within the preset time period.

[0035] According to the traffic flow prediction method based on spatiotemporal attention graph neural network provided by the present invention, the step of predicting the traffic flow of the target path during a target time period based on the prediction layer, the coarse-grained traffic flow features, and coarse-grained traffic flow data of the target path within a preset time period includes:

[0036] The first feature is obtained by feature encoding of the coarse-grained traffic data of the target path within a preset time period;

[0037] By combining the coarse-grained flow characteristic and the first characteristic, a second characteristic is obtained;

[0038] The second feature is input into the prediction layer so that the prediction layer predicts the traffic flow of the target path during the target time period based on the second feature.

[0039] Secondly, the present invention provides a traffic flow prediction device based on a spatiotemporal attention graph neural network, the device comprising:

[0040] An acquisition module is used to acquire a pre-constructed spatiotemporal attention graph neural network; wherein the spatiotemporal attention graph neural network includes a spatiotemporal feature learning layer, a pooling layer, and a prediction layer;

[0041] The spatiotemporal feature learning module is used to perform spatial and temporal information fusion learning on the fine-grained traffic data of each intersection in the road network within a preset time period using the road network spatial topology diagram and the spatiotemporal feature learning layer, so as to obtain the fine-grained traffic features of each intersection in the target path within the preset time period.

[0042] The pooling module is used to perform pooling processing on the fine-grained traffic features based on the intersection connection of the target path and the pooling layer to obtain the coarse-grained traffic features of the target path within a preset time period.

[0043] The prediction module is used to predict the traffic of the target path in the target time period based on the prediction layer, the coarse-grained traffic characteristics, and the coarse-grained traffic data of the target path in the preset time period.

[0044] The preset time period is a long period of time preceding the target time period.

[0045] Thirdly, the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the traffic flow prediction method based on a spatiotemporal attention graph neural network as described in the first aspect.

[0046] Fourthly, the present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the traffic flow prediction method based on a spatiotemporal attention graph neural network as described in the first aspect.

[0047] This invention provides a traffic flow prediction method and apparatus based on a spatiotemporal attention graph neural network, comprising: acquiring a pre-constructed spatiotemporal attention graph neural network; wherein the spatiotemporal attention graph neural network includes a spatiotemporal feature learning layer, a pooling layer, and a prediction layer; utilizing a road network spatial topology map and the spatiotemporal feature learning layer, performing spatiotemporal dual-dimensional information fusion learning on fine-grained traffic flow data of each intersection in the road network within a preset time period to obtain fine-grained traffic flow features of each intersection in the target path within the preset time period; pooling the fine-grained traffic flow features according to the intersection connectivity of the target path and the pooling layer to obtain coarse-grained traffic flow features of the target path within the preset time period; and predicting the traffic flow of the target path within the target time period based on the prediction layer, the coarse-grained traffic flow features, and the coarse-grained traffic flow data of the target path within the preset time period. This invention pre-constructs a spatiotemporal attention graph neural network capable of capturing the spatiotemporal correlation patterns of traffic flow at different intersections and at different times in the main traffic flow path, and then, based on the spatiotemporal attention graph neural network, uses fine-grained intersection traffic flow to predict coarse-grained path traffic flow, achieving high prediction accuracy. Attached Figure Description

[0048] To more clearly illustrate the technical solutions in this 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 some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0049] Figure 1 This is a flowchart illustrating the traffic flow prediction method based on spatiotemporal attention graph neural network provided by the present invention.

[0050] Figure 2 This is a schematic diagram of the framework of the spatiotemporal attention graph neural network provided by the present invention;

[0051] Figure 3 This is a road network spatial topology diagram provided by the present invention;

[0052] Figure 4 This is a schematic diagram of the traffic flow prediction device based on spatiotemporal attention graph neural network provided by the present invention;

[0053] Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention.

[0054] Figure label:

[0055] 510: Processor; 520: Communication interface; 530: Memory; 540: Communication bus. Detailed Implementation

[0056] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0057] The following is combined Figures 1-5 The present invention describes a traffic flow prediction method and apparatus based on a spatiotemporal attention graph neural network.

[0058] In a first aspect, the present invention provides a traffic flow prediction method based on a spatiotemporal attention graph neural network, such as... Figure 1 As shown, the method includes:

[0059] S11: Obtain a pre-constructed spatiotemporal attention graph neural network; wherein the spatiotemporal attention graph neural network includes a spatiotemporal feature learning layer, a pooling layer, and a prediction layer;

[0060] S12: Using the road network spatial topology diagram and the spatiotemporal feature learning layer, perform spatial and temporal information fusion learning on the fine-grained traffic data of each intersection in the road network within a preset time period to obtain the fine-grained traffic features of each intersection in the target path within a preset time period.

[0061] Here, the preset time period is a long period of time before the target time period. For example, if the target time period is time period t, the preset time period is a long period of time consisting of M time periods before time period t.

[0062] Fine-grained traffic data within a preset time period consists of the traffic volume under each fine-grained time slice within that period. Similarly, coarse-grained traffic data within a preset time period consists of the traffic volume under each coarse-grained time slice within that period. Here, fine-grained and coarse-grained time slices are relative concepts. For example, if the preset time period is 2 hours, the fine-grained time slice is 5 minutes, and the coarse-grained time slice is 30 minutes, then there will be 24 fine-grained traffic data points within 2 hours (one every 5 minutes), and 4 coarse-grained traffic data points within 2 hours (one every 30 minutes).

[0063] S13: Based on the intersection connection of the target path and the pooling layer, perform pooling processing on the fine-grained flow characteristics to obtain the coarse-grained flow characteristics of the target path within a preset time period.

[0064] The path is formed by connecting several intersections in the road network. This invention mainly studies the traffic flow prediction problem of the main traffic flow path in the road network. Therefore, the target path is a path in the main traffic flow path.

[0065] S14: Based on the prediction layer, the coarse-grained traffic characteristics, and the coarse-grained traffic data of the target path within a preset time period, predict the traffic of the target path during the target time period.

[0066] It should be noted that in practical applications, S11 to S14 are performed in a spatiotemporal attention graph neural network. That is, you only need to input the road network spatial topology map, the fine-grained traffic data of each intersection in the road network within a preset time period, the intersection connection status of the target path, and the coarse-grained traffic data of the target path within a preset time period into the spatiotemporal attention graph neural network to obtain the traffic of the target path in the target time period predicted by the spatiotemporal attention graph neural network.

[0067] Furthermore, the training and application of spatiotemporal attention graph neural networks are not significantly different; the training phase includes:

[0068] Construct a training set for a spatiotemporal attention graph neural network. Each sample in the training set is for traffic prediction of a specific main traffic flow path in a specific time period. It includes: a road network spatial topology map, fine-grained traffic data of each intersection in the road network in a specific preset time period, intersection connection of a specific main traffic flow, and coarse-grained traffic data of a specific main traffic flow path in a specific preset time period.

[0069] Each sample is fed into the spatiotemporal attention graph neural network to obtain the traffic prediction result for each sample;

[0070] The loss function is calculated based on the deviation between the traffic prediction results and the actual results of all samples, and the parameters of the spatiotemporal attention graph neural network are updated using the loss function.

[0071] Repeat the above steps until the model converges.

[0072] Furthermore, in reality, traffic flow data may contain errors or omissions. Therefore, the fine-grained traffic flow data of each intersection in the road network within a preset time period and the coarse-grained traffic flow data of the target path within a preset time period in S12 and S14 of this invention are the results after preprocessing.

[0073] Preprocessing specifically includes: In terms of data correction, based on the visualization of traffic flow at intersections / target paths, identifying data gaps and anomalies at intersections / target paths within a preset time period, and then using a weighted information smoothing method to complete or correct the data, effectively solving the problem of inaccurate traffic data.

[0074] Traffic flow data at intersections / target paths with unstable temporal variations is manually segmented into different phases. Then, the data from each phase is normalized separately, and finally, the normalized results from different phases are concatenated. Here, the normalization method involves subtracting the mean first and then dividing by the variance to improve the stability of temporal variations and effectively solve the problem of uneven traffic flow across different phases.

[0075] This invention provides a traffic flow prediction method based on a spatiotemporal attention graph neural network. It pre-constructs a spatiotemporal attention graph neural network that can capture the spatiotemporal correlation patterns of traffic flow at different intersections and at different times in the main traffic flow path. Then, based on the spatiotemporal attention graph neural network, it uses fine-grained intersection traffic flow to predict coarse-grained path traffic flow, resulting in high prediction accuracy.

[0076] Figure 2 This is a schematic diagram of the framework of a spatiotemporal attention graph neural network, such as... Figure 2 As shown, the spatiotemporal feature learning layer includes a graph neural network layer and an attention temporal encoder; S12 includes:

[0077] S12.1: Based on the fine-grained traffic data of each intersection in the road network within a preset time period, generate the intersection traffic matrix for each fine-grained time slice of the road network within the preset time period;

[0078] The intersection traffic flow matrix of the road network in the f-th fine-grained time slice of the preset time period is represented by X. f To represent, X f ={x f,1 ,x f,2 …x f,n …x f,N}, x f,n Let f be the traffic flow of the nth intersection in the road network under the fth fine-grained time slice of the preset time period, where f∈(1~F) and n∈(1~N), F is the number of fine-grained time slices included in the preset time period, and N is the total number of intersections in the road network.

[0079] S12.2: In the graph neural network layer, based on the road network spatial topology diagram, spatial dimension information fusion learning is performed on the intersection traffic matrix under each fine-grained time slice of the road network in the preset time period to obtain the traffic characteristics of each intersection in the target path under each fine-grained time slice of the preset time period.

[0080] That is, the road network spatial topology diagram and X f Input into the graph neural network layer, so that the graph neural network layer can perform X based on the road network spatial topology graph. f Perform spatial dimension information fusion learning (multi-layer graph convolution operation) to obtain

[0081] in, in, This represents the traffic flow characteristics of the nth intersection in the road network during the fth fine-grained time slice within a preset time period.

[0082] S12.3: Based on the traffic flow characteristics of each intersection in the target path under all fine-grained time slices in the preset time period, generate the traffic flow characteristic time series sequence corresponding to each intersection in the target path;

[0083] In fact, the time series sequence of traffic flow characteristics corresponding to each intersection in the road network can be obtained through S12. The time series sequence of traffic flow characteristics corresponding to the nth intersection in the road network is used... To indicate, However, in order to predict the traffic flow of the target path during the target time period, this step only retains the time series sequence of traffic flow characteristics corresponding to each intersection in the target path.

[0084] S12.4: In the attention temporal encoder, the time dimension information fusion learning is performed on the traffic feature time sequence corresponding to each intersection in the target path to obtain the fine-grained traffic features of each intersection in the target path within a preset time period.

[0085] Assuming the first in the road network If the nth intersection is an intersection in the target path, then the nth intersection in the road network... Traffic flow characteristics time series corresponding to each intersection Will The input is entered into the attention temporal encoder so that the attention temporal encoder can input the information into the attention temporal encoder. By performing information fusion learning along the time dimension, the first... Fine-grained traffic flow characteristics of each intersection within a preset time period It is a high-dimensional hidden layer feature.

[0086] It can be seen that the spatiotemporal feature learning layer mainly mines the spatiotemporal correlation patterns of traffic flow at different intersections and at different times through spatial information propagation and temporal information propagation.

[0087] Furthermore, the road network spatial topology diagram is a topology diagram with intersections in the road network as nodes, the connection relationships between intersections in the road network as edges, and node features and edge weights labeled.

[0088] The node features include, but are not limited to: the latitude and longitude coordinates of the intersection corresponding to the node and the intersection ID;

[0089] The weight A of the edge connecting node i and node j in the first topological graph ij The expression is:

[0090]

[0091] Where α is the first hyperparameter, c i Let c be the latitude and longitude coordinates of node i. j Let j be the latitude and longitude coordinates of node j. This is the symbol for the 2-norm.

[0092] Here, the value of α can be set based on experience, or it can be input as an unknown into the graph neural network layer for optimization.

[0093] Figure 3 This is an example of the corresponding road network spatial topology diagram. The node feature annotations and edge weights in this diagram are not shown.

[0094] Furthermore, the graph neural network layer is a K-layer GCN network; S12.2 includes:

[0095] S12.2.1: Input the intersection traffic matrix of the road network under any fine-grained time slice and the spatial topology diagram of the road network into the first layer of the GCN network, so that the GCN network learns the node features in each layer according to its own transfer function as the mean of its own features and the features of its neighboring nodes, and finally obtains the intersection traffic matrix output by the last layer of the GCN network.

[0096] Here, the GCN network transfer function is:

[0097]

[0098]

[0099]

[0100] Where θ is a hyperparameter, and A is the adjacency matrix of the road network spatial topology graph. ij Let I be the element in the i-th row and j-th column of A, representing the weight of the edge connecting node i and node j in the road network spatial topology graph. I is the identity matrix. yes The degree matrix, W (1) The input intersection traffic matrix (e.g., X) f ), W (l) H is the weight matrix learned in the l-th layer of the GCN network. (l) It is a flow matrix (such as X) f The input features of the l-th layer in the GCN network, H (l+1) It is a flow matrix (such as X) f The input features of the (l+1)th layer in the GCN network. (K*) It is a flow matrix (such as X) fThe learning results of the Kth layer in the GCN network (e.g.) ).

[0101] S12.2.2: Based on the intersection traffic matrix output by the last layer of the GCN network, determine the traffic characteristics of each intersection in the target path under any fine-grained time slice.

[0102] The spatial information propagation of this invention is mainly based on graph convolutional networks, which perform spatial dimensional information fusion on traffic flow information at different intersections. That is, the traffic flow information of each intersection is updated using the traffic flow information of spatially adjacent intersections. The graph convolutional network can be regarded as a spatial feature extractor, which mainly learns the spatial dependence of traffic flow at different intersections at the same time.

[0103] Furthermore, the attention-based temporal encoder employs a Transformer network; S12.4 includes:

[0104] The attention-based temporal encoder is controlled to perform time-dimensional information fusion learning on the traffic feature temporal sequence corresponding to any intersection according to the multi-head self-attention mechanism, so as to obtain the fine-grained traffic features of any intersection within a preset time period.

[0105] Here, the purpose of this invention is to extract feature encodings from graph time series, so only the encoder in the transformer's encoding-decoder is used. The multi-head attention mechanism adopts the classic form in transformer, which will not be elaborated here.

[0106] The time information propagation of this invention is mainly based on Transformer. It integrates traffic flow information at different times at the same intersection according to the multi-head attention mechanism to achieve information fusion in the time dimension. It mainly learns the time dependence of traffic flow at the same intersection at different time periods.

[0107] Specifically, S13 includes:

[0108] S13.1: In the path pooling layer, the fine-grained traffic features are path pooled according to the intersection connection of the target path to generate the fine-grained traffic features of the target path within a preset time period.

[0109] The purpose of this invention is not to predict the traffic flow at intersections, but to predict the traffic flow of a target path. Therefore, based on the intersection connectivity of the target path, the fine-grained traffic flow characteristics of all intersections associated with the target path within a preset time period are added and pooled to obtain the fine-grained traffic flow characteristics of the target path within the preset time period.

[0110] S13.2: In the time pooling layer, the fine-grained flow characteristics of the target path within a preset time period are averaged to obtain the coarse-grained flow characteristics of the target path within the preset time period.

[0111] Since path pooling yields fine-grained traffic features of the target path within a preset time period, while the final target path to be predicted has coarse-grained traffic features within the preset time period, it is necessary to convert the fine-grained traffic features to coarse-grained traffic features. For example, the fine-grained traffic features are at the 5-minute level, while the coarse-grained traffic features are at the 1-hour level. In the time dimension, it is still necessary to perform average pooling on multiple features at the 5-minute level to obtain features at the 1-hour level.

[0112] Specifically, S14 includes:

[0113] S14.1: Perform feature encoding on the coarse-grained traffic data of the target path within a preset time period to obtain the first feature;

[0114] S14.2: Combine the coarse-grained flow characteristic and the first characteristic to obtain the second characteristic;

[0115] S14.3: Input the second feature into the prediction layer so that the prediction layer predicts the traffic flow of the target path during the target time period based on the second feature.

[0116] The predictor uses a simple fully connected neural network. The second feature, which is a combination of the coarse-grained traffic feature and the first feature, is a high-dimensional feature of the coarse-grained traffic data of the target path within a preset time period. Inputting this feature into the predictor to predict the traffic of the target path within the target time period can greatly improve the prediction accuracy.

[0117] In summary, this invention takes into account the richer characteristics of fine-grained intersection traffic flow. Therefore, based on the spatiotemporal attention graph neural network, it uses fine-grained intersection traffic flow to predict coarse-grained path traffic flow, thereby improving prediction accuracy.

[0118] This invention predicts traffic flow on any path at any given time. Furthermore, it can also predict traffic flow at different intersections at any given time. Intuitively, these two tasks are related. If the model can simultaneously predict these two different traffic flow rates during training, it provides more supervisory signals, reduces the risk of overfitting, and improves prediction performance. Previous models directly predicted path traffic flow values, and the future traffic flow values ​​at intersections can also be used as labels for supervised learning. For example, after path pooling, an MLP can be embedded to predict future intersection traffic flow values, thus achieving a multi-task learning problem. Multi-task learning allows multiple tasks to mutually reinforce each other, thereby increasing the model's accuracy and generalization performance.

[0119] Secondly, the traffic flow prediction device based on spatiotemporal attention graph neural network provided by the present invention will be described. The traffic flow prediction device based on spatiotemporal attention graph neural network described below and the traffic flow prediction method based on spatiotemporal attention graph neural network described above can be referred to in correspondence with each other. Figure 4 A schematic diagram of a traffic flow prediction device based on a spatiotemporal attention graph neural network is shown, such as... Figure 4 As shown, the device includes:

[0120] The acquisition module 21 is used to acquire a pre-constructed spatiotemporal attention graph neural network; wherein the spatiotemporal attention graph neural network includes a spatiotemporal feature learning layer, a pooling layer and a prediction layer;

[0121] The spatiotemporal feature learning module 22 is used to perform spatial and temporal fusion learning on the fine-grained traffic data of each intersection in the road network within a preset time period using the road network spatial topology diagram and the spatiotemporal feature learning layer, so as to obtain the fine-grained traffic features of each intersection in the target path within a preset time period.

[0122] Pooling module 23 is used to perform pooling processing on the fine-grained flow characteristics based on the intersection connection of the target path and the pooling layer to obtain the coarse-grained flow characteristics of the target path within a preset time period.

[0123] Prediction module 24 is used to predict the traffic of the target path in the target time period based on the prediction layer, the coarse-grained traffic characteristics and the coarse-grained traffic data of the target path in the preset time period.

[0124] The preset time period is a long period of time preceding the target time period.

[0125] This invention provides a traffic flow prediction device based on a spatiotemporal attention graph neural network. It pre-constructs a spatiotemporal attention graph neural network that can capture the spatiotemporal correlation patterns of traffic flow at different intersections and at different times in the main traffic flow path. Then, based on the spatiotemporal attention graph neural network, it uses fine-grained intersection traffic flow to predict coarse-grained path traffic flow, resulting in high prediction accuracy.

[0126] Based on the above embodiments, as an optional embodiment, the spatiotemporal feature learning layer includes a graph neural network layer and an attention temporal encoder; the spatiotemporal feature learning module includes:

[0127] The first generation unit is used to generate an intersection traffic matrix for each fine-grained time slice of the road network within a preset time period, based on the fine-grained traffic data of each intersection in the road network within a preset time period.

[0128] The spatial dimension information fusion unit is used in the graph neural network layer to perform spatial dimension information fusion learning on the intersection traffic matrix of the road network under each fine-grained time slice in the preset time period based on the road network spatial topology diagram, so as to obtain the traffic characteristics of each intersection in the target path under each fine-grained time slice in the preset time period.

[0129] The second generation unit is used to generate a time series sequence of traffic characteristics for each intersection in the target path based on the traffic characteristics of each intersection in the target path under all fine-grained time slices in the preset time period.

[0130] The time-dimensional information fusion unit is used in the attention-based temporal encoder to perform time-dimensional information fusion learning on the time-series sequence of traffic features corresponding to each intersection in the target path, so as to obtain fine-grained traffic features of each intersection in the target path within a preset time period.

[0131] Based on the above embodiments, as an optional embodiment, the process of generating the road network spatial topology map includes:

[0132] The first topology graph is generated by using intersections in the road network as nodes and the connections between intersections in the road network as edges.

[0133] The first topology graph is labeled with node features and edge weights to obtain the road network spatial topology graph.

[0134] The node features include, but are not limited to: the latitude and longitude coordinates and intersection ID of the intersection corresponding to the node;

[0135] The weight A of the edge connecting node i and node j in the first topological graph ij The expression is:

[0136]

[0137] Where α is the first hyperparameter, c i Let c be the latitude and longitude coordinates of node i. j Let be the latitude and longitude coordinates of node j.

[0138] Based on the above embodiments, as an optional embodiment, the graph neural network layer is a K-layer GCN network;

[0139] The spatial dimension information fusion unit includes:

[0140] The graph convolutional computation unit is used to input the intersection traffic matrix and the spatial topology diagram of the road network under any fine-grained time slice into the first layer of the GCN network, so that the GCN network learns the node features in each layer according to its own transfer function as the mean of its own features and the features of its neighboring nodes, and finally obtains the intersection traffic matrix output by the last layer of the GCN network.

[0141] A sub-unit is determined to determine the traffic characteristics of each intersection in the target path under any fine-grained time slice, based on the intersection traffic matrix output by the last layer of the GCN network.

[0142] Based on the above embodiments, as an optional embodiment, the attention-based temporal encoder employs a Transformer network;

[0143] The time-dimensional information fusion unit is used for:

[0144] The attention-based temporal encoder is controlled to perform time-dimensional information fusion learning on the traffic feature temporal sequence corresponding to any intersection according to the multi-head self-attention mechanism, so as to obtain the fine-grained traffic features of any intersection within a preset time period.

[0145] Based on the above embodiments, as an optional embodiment, the pooling layer includes a path pooling layer and a time pooling layer;

[0146] The pooling module includes:

[0147] The path pooling unit is used in the path pooling layer to perform path pooling on the fine-grained traffic features according to the intersection connection of the target path, so as to generate the fine-grained traffic features of the target path within a preset time period.

[0148] It is a time pooling unit, used in the time pooling layer to perform average pooling on the fine-grained flow characteristics of the target path within a preset time period to obtain the coarse-grained flow characteristics of the target path within the preset time period.

[0149] Based on the above embodiments, as an optional embodiment, the prediction module based on the prediction layer includes:

[0150] The encoding unit is used to encode the coarse-grained traffic data of the target path within a preset time period to obtain the first feature;

[0151] A feature splicing unit is used to splice the coarse-grained flow feature and the first feature to obtain the second feature;

[0152] A prediction unit is used to input the second feature into the prediction layer so that the prediction layer predicts the traffic flow of the target path during the target time period based on the second feature.

[0153] Thirdly, Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute a traffic flow prediction method based on a spatiotemporal attention graph neural network. The method includes: acquiring a pre-constructed spatiotemporal attention graph neural network; wherein the spatiotemporal attention graph neural network includes a spatiotemporal feature learning layer, a pooling layer, and a prediction layer; using a road network spatial topology map and the spatiotemporal feature learning layer, performing spatial and temporal fusion learning on fine-grained traffic flow data of each intersection in the road network within a preset time period to obtain fine-grained traffic flow features of each intersection in the target path within the preset time period; performing pooling processing on the fine-grained traffic flow features according to the intersection connectivity of the target path and the pooling layer to obtain coarse-grained traffic flow features of the target path within the preset time period; and predicting the traffic flow of the target path in a target time period based on the prediction layer, the coarse-grained traffic flow features, and the coarse-grained traffic flow data of the target path within the preset time period; wherein the preset time period is a long period preceding the target time period.

[0154] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0155] Fourthly, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the traffic flow prediction method based on the spatiotemporal attention graph neural network provided by the above methods. The method includes: acquiring a pre-constructed spatiotemporal attention graph neural network; wherein the spatiotemporal attention graph neural network includes a spatiotemporal feature learning layer, a pooling layer, and a prediction layer; using a road network spatial topology map and the spatiotemporal feature learning layer, performing spatial and temporal fusion learning on fine-grained traffic data of each intersection in the road network within a preset time period to obtain fine-grained traffic features of each intersection in the target path within the preset time period; performing pooling processing on the fine-grained traffic features according to the intersection connection status of the target path and the pooling layer to obtain coarse-grained traffic features of the target path within the preset time period; and predicting the traffic flow of the target path in a target time period based on the prediction layer, the coarse-grained traffic features, and the coarse-grained traffic data of the target path within the preset time period; wherein the preset time period is a long period preceding the target time period.

[0156] Fifthly, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the traffic flow prediction method based on a spatiotemporal attention graph neural network provided by the above methods. The method includes: acquiring a pre-constructed spatiotemporal attention graph neural network; wherein the spatiotemporal attention graph neural network includes a spatiotemporal feature learning layer, a pooling layer, and a prediction layer; using a road network spatial topology map and the spatiotemporal feature learning layer, performing spatial and temporal fusion learning on fine-grained traffic flow data of each intersection in the road network within a preset time period to obtain fine-grained traffic flow features of each intersection in the target path within the preset time period; performing pooling processing on the fine-grained traffic flow features according to the intersection connectivity of the target path and the pooling layer to obtain coarse-grained traffic flow features of the target path within the preset time period; and predicting the traffic flow of the target path in a target time period based on the prediction layer, the coarse-grained traffic flow features, and the coarse-grained traffic flow data of the target path within the preset time period; wherein the preset time period is a long period preceding the target time period.

[0157] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0158] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0159] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A traffic flow prediction method based on a spatiotemporal attention graph neural network, characterized in that, The method includes: Obtain a pre-constructed spatiotemporal attention graph neural network; wherein the spatiotemporal attention graph neural network includes a spatiotemporal feature learning layer, a pooling layer, and a prediction layer; By utilizing the road network spatial topology diagram and the spatiotemporal feature learning layer, information fusion learning is performed on the spatial and temporal dimensions of the fine-grained traffic data of each intersection in the road network within a preset time period to obtain the fine-grained traffic features of each intersection in the target path within a preset time period. Based on the intersection connectivity of the target path and the pooling layer, the fine-grained flow characteristics are pooled to obtain the coarse-grained flow characteristics of the target path within a preset time period. Based on the prediction layer, the coarse-grained traffic characteristics, and the coarse-grained traffic data of the target path within a preset time period, the traffic of the target path during the target time period is predicted. The preset time period is a long period of time preceding the target time period; The spatiotemporal feature learning layer includes a graph neural network layer and an attention-based temporal encoder; The method utilizes the road network spatial topology map and the spatiotemporal feature learning layer to perform spatial and temporal information fusion learning on the fine-grained traffic data of each intersection in the road network within a preset time period, thereby obtaining the fine-grained traffic features of each intersection in the target path within the preset time period, including: Based on the fine-grained traffic data of each intersection in the road network within a preset time period, an intersection traffic matrix is ​​generated for each fine-grained time slice of the road network within the preset time period. In the graph neural network layer, based on the road network spatial topology diagram, spatial dimension information fusion learning is performed on the intersection traffic matrix under each fine-grained time slice of the road network in the preset time period to obtain the traffic characteristics of each intersection in the target path under each fine-grained time slice of the preset time period. Based on the traffic characteristics of each intersection in the target path under all fine-grained time slices in the preset time period, a time series sequence of traffic characteristics corresponding to each intersection in the target path is generated. In the attention-based temporal encoder, the temporal sequence of traffic features corresponding to each intersection in the target path is fused and learned in the time dimension to obtain the fine-grained traffic features of each intersection in the target path within a preset time period.

2. The traffic flow prediction method based on spatiotemporal attention graph neural network according to claim 1, characterized in that, The process of generating the road network spatial topology diagram includes: The first topology graph is generated by using intersections in the road network as nodes and the connections between intersections in the road network as edges. The first topology graph is labeled with node features and edge weights to obtain the road network spatial topology graph. The node features include, but are not limited to: the latitude and longitude coordinates and intersection ID of the intersection corresponding to the node; Nodes in the first topology graph and nodes Weight of the edges connecting them The expression is: , in, As the first hyperparameter, For nodes latitude and longitude coordinates For nodes Latitude and longitude coordinates.

3. The traffic flow prediction method based on spatiotemporal attention graph neural network according to claim 1, characterized in that, The graph neural network layer is a K-layer GCN network; In the graph neural network layer, based on the road network spatial topology graph, spatial dimension information fusion learning is performed on the intersection traffic matrix of the road network under any fine-grained time slice to obtain the traffic characteristics of each intersection in the target path under any fine-grained time slice, including: The intersection traffic matrix and the spatial topology diagram of the road network under any fine-grained time slice are input into the first layer of the GCN network, so that the GCN network learns the node features in each layer according to its own transfer function as the mean of its own features and the features of its neighboring nodes, and finally obtains the intersection traffic matrix output by the last layer of the GCN network. Based on the intersection traffic matrix output by the last layer of the GCN network, the traffic characteristics of each intersection in the target path under any fine-grained time slice are determined.

4. The traffic flow prediction method based on spatiotemporal attention graph neural network according to claim 1, characterized in that, The attention-based temporal encoder employs a Transformer network. In the attention-based temporal encoder, the temporal sequence of traffic features corresponding to any intersection in the target path is fused and learned in the time dimension to obtain fine-grained traffic features of any intersection in the target path within a preset time period, including: The attention-based temporal encoder is controlled to perform time-dimensional information fusion learning on the traffic feature temporal sequence corresponding to any intersection according to the multi-head self-attention mechanism, so as to obtain the fine-grained traffic features of any intersection within a preset time period.

5. The traffic flow prediction method based on spatiotemporal attention graph neural network according to claim 1, characterized in that, The pooling layer includes a path pooling layer and a time pooling layer; the step of pooling the fine-grained traffic features based on the intersection connectivity of the target path and the pooling layer to obtain the coarse-grained traffic features of the target path within a preset time period includes: In the path pooling layer, the fine-grained traffic features are path pooled according to the intersection connection of the target path to generate the fine-grained traffic features of the target path within a preset time period. In the time pooling layer, the fine-grained flow characteristics of the target path within a preset time period are averaged to obtain the coarse-grained flow characteristics of the target path within the preset time period.

6. The traffic flow prediction method based on spatiotemporal attention graph neural network according to claim 1, characterized in that, The step of predicting the traffic flow of the target path during the target time period based on the prediction layer, the coarse-grained traffic characteristics, and the coarse-grained traffic data of the target path within a preset time period includes: The first feature is obtained by feature encoding of the coarse-grained traffic data of the target path within a preset time period; By combining the coarse-grained flow characteristic and the first characteristic, a second characteristic is obtained; The second feature is input into the prediction layer so that the prediction layer predicts the traffic flow of the target path during the target time period based on the second feature.

7. A traffic flow prediction device based on a spatiotemporal attention graph neural network, characterized in that, The apparatus performs the traffic flow prediction method based on a spatiotemporal attention map neural network as described in any one of claims 1 to 6; the apparatus comprises: An acquisition module is used to acquire a pre-constructed spatiotemporal attention graph neural network; wherein the spatiotemporal attention graph neural network includes a spatiotemporal feature learning layer, a pooling layer, and a prediction layer; The spatiotemporal feature learning module is used to perform spatial and temporal information fusion learning on the fine-grained traffic data of each intersection in the road network within a preset time period using the road network spatial topology diagram and the spatiotemporal feature learning layer, so as to obtain the fine-grained traffic features of each intersection in the target path within the preset time period. The pooling module is used to perform pooling processing on the fine-grained traffic features based on the intersection connection of the target path and the pooling layer to obtain the coarse-grained traffic features of the target path within a preset time period. The prediction module is used to predict the traffic of the target path in the target time period based on the prediction layer, the coarse-grained traffic characteristics, and the coarse-grained traffic data of the target path in the preset time period. The preset time period is a long period of time preceding the target time period.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the traffic flow prediction method based on spatiotemporal attention graph neural network as described in any one of claims 1 to 6.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the traffic flow prediction method based on spatiotemporal attention graph neural network as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Long-time-sequence traffic flow prediction method based on graph convolution-Informer model

    CN113487061A

  • Traffic prediction method based on multi-scale space-time fusion graph network

    CN115240425A