Transfer perception-based time-space diagram attention network traffic flow prediction method and system

By introducing transmission perception and time and space diagrams in the traffic flow prediction model, combined with map attention models and door control networks, the limitations of existing models when processing complex road networks and timing change characteristics, increasing traffic flow, and increasing traffic flow. Prediction accuracy and explanatory.

CN119360607AActive Publication Date: 2025-01-24SHENZHEN ZHENWEI ZHIXING TECHNOLOGY CO LTD

Patent Information

Application Number
CN202411413696.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-11
Publication Date
2025-01-24
Estimated Expiration
2044-10-11

AI Technical Summary

Technical Problem

The existing traffic flow prediction model has limitations in dealing with complex road network structures and time-varying characteristics, especially ignoring the transitiveness of nodes and the time-varying nature of spatial characteristics, resulting in insufficient prediction accuracy and interpretability.

Method used

Put forward the time and space diagram of the time and space map attention network traffic flow prediction method, through the Tagat-LSTM model combined with diagram, the transmission probability matrix, and the distance attenuation matrix, capture the space-time characteristics of the traffic network, and dynamically integrate different times through the door control network dynamic integration at different times The space characteristics of the step.

Benefits of technology

It improves the accuracy and interpretability of traffic flow forecasting, can more accurately capture the time and space dependencies of traffic flow, and enhance the modeling ability and characteristic extraction ability of complex transportation models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119360607A_ABST
    Figure CN119360607A_ABST
Patent Text Reader

Abstract

The invention discloses a time-space diagram attention network traffic flow prediction method and system based on transmission perception, and relates to the technical field of traffic flow prediction, and the method comprises the steps: building a diagram structure set corresponding to a to-be-predicted region according to the spatial connection relation of an actual road network; acquiring traffic flow data of the to-be-predicted area in a first preset time length, and training a preset TAGAT-LSTM model by using the traffic flow data of the to-be-predicted area based on the graph structure set to obtain a target model which corresponds to the TAGAT-LSTM model and is trained; acquiring a historical traffic flow of the to-be-predicted region in a preset time length, and inputting the historical traffic flow into the target model for processing to obtain a predicted traffic flow of the to-be-predicted region in a future preset time length; through combination of three core modules in the TAGAT-LSTM model, the model can capture richer space-time dependency relationships, and the precision of traffic flow prediction is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of traffic flow prediction, and more specifically, to a method and system for traffic flow prediction based on a spatiotemporal graph attention network based on transfer perception. Background Art

[0002] Intelligent transportation system (ITS) plays an important role in urban road traffic management, and traffic flow prediction is a key component of ITS. Accurate and efficient road traffic flow prediction can predict future road traffic flow based on past traffic flow status, thereby improving urban traffic mobility, reducing congestion, and improving the operating efficiency and safety of urban transportation systems.

[0003] With the acceleration of urbanization and the rapid growth of private car ownership, traffic congestion has gradually become the norm. Traffic congestion not only reduces the efficiency of urban operation, but also brings a series of environmental problems, such as energy consumption, exhaust pollution, noise pollution, etc. These problems seriously restrict the healthy and harmonious development of cities and have become a common problem in many cities. Therefore, the development of effective traffic flow prediction methods is of great significance for optimizing traffic management, improving travel experience, and achieving sustainable urban development.

[0004] At present, the most widely used traffic flow prediction methods are those based on deep learning; existing prediction models, especially graph convolutional neural networks (GCN) and graph attention networks (GAT), perform well in capturing the spatial characteristics of traffic flow. However, these models still have limitations when dealing with complex road network structures and time-varying characteristics. For example, traditional GCN assumes that all nodes are equally important, while GAT assigns different weights by introducing an attention mechanism. Although it improves prediction accuracy, its interpretability is poor and it ignores the transitivity of nodes, that is, the ability of nodes to transmit their own traffic characteristics. In addition, most existing models design spatial feature extraction and temporal feature extraction as independent modules, ignoring the time-varying nature of spatial features and failing to fully consider the spatiotemporal continuity of traffic flow.

[0005] In view of this, this application is hereby made. Summary of the invention

[0006] The purpose of the present invention is to provide a method and system for traffic flow prediction based on spatiotemporal graph attention network based on transfer perception to solve the problems existing in the above-mentioned background technology.

[0007] The above technical objectives of the present invention are achieved through the following technical solutions:

[0008] In the first aspect, the present application provides a method for traffic flow prediction based on a spatiotemporal graph attention network based on transfer perception, comprising the following specific steps:

[0009] Obtain the actual road network of the area to be predicted, and establish a graph structure set corresponding to the area to be predicted based on the spatial connection relationship of the actual road network, wherein the graph structure set represents the road nodes in the area to be predicted and the connection relationship between each road node;

[0010] Obtain the traffic flow data of the area to be predicted within the first preset time length, and based on the graph structure set, use the traffic flow data of the area to be predicted to train the preset TAGAT-LSTM model to obtain a target model that corresponds to and is trained with the TAGAT-LSTM model. The target model is obtained in the following way:

[0011] The traffic flow data is preprocessed by using the input module in the TAGAT-LSTM model, and the preprocessed traffic flow data is input into the spatial feature extraction module in the TAGAT-LSTM model for processing to obtain a first feature sequence of spatial features of each road node aggregating adjacent nodes within a first preset time length. The preprocessing includes smoothing and standardization.

[0012] The gated network module in the TAGAT-LSTM model is used to process the first feature sequence of each road node to obtain the second feature sequence of each road node aggregating the spatial features of adjacent time steps;

[0013] The second feature sequence is processed by using the time feature extraction module in the TAGAT-LSTM model to obtain the time feature of the second feature sequence, and a preliminary prediction value within a second preset time length is generated by using the fully connected layer in the TAGAT-LSTM model, where the second preset time length corresponds to the first preset time length;

[0014] Performing denormalization processing on the preliminary prediction values, and calculating the loss function of the TAGAT-LSTM model based on the denormalized preliminary prediction values, until the loss function meets a preset training end condition, and determining the TAGAT-LSTM model that meets the training end condition as the target model;

[0015] The historical traffic flow of the area to be predicted in a preset time length is obtained, and the historical traffic flow is input into the target model for processing to obtain the predicted traffic flow of the area to be predicted in the future preset time length.

[0016] The beneficial effects of the present invention are as follows: in this solution, the spatial feature extraction module is used to capture spatial dependencies, the gated network module performs preliminary temporal aggregation on the extracted spatial features, and weightedly fuses the spatial features of adjacent time steps to obtain a richer spatial feature representation. The temporal feature extraction module is responsible for further capturing temporal dependencies. Through the combination of the three modules, the model can capture richer spatiotemporal dependencies and improve the accuracy of traffic flow prediction.

[0017] In this scheme, the gating network module serves as a transition layer between spatial feature extraction and temporal feature extraction, enabling the model to dynamically fuse spatial features at different time steps and capture the time-varying nature of spatial features, thereby more accurately capturing the temporal dependence of traffic flow and enhancing the model's ability to model complex traffic patterns. Furthermore, through the gating network, the model can better learn the temporal continuity and changing laws of spatial features of traffic flow, thereby improving the model's feature extraction capability and thus improving the model's prediction accuracy.

[0018] Based on the above technical solution, the present invention can also be improved as follows.

[0019] Furthermore, the above-mentioned spatial feature extraction module includes a graph attention model, a transfer probability matrix and a distance attenuation matrix.

[0020] The beneficial effect of adopting the above further scheme is: using the transfer probability matrix to represent the ability of road nodes to transmit traffic characteristics at the current time step, and calculating the distance decay matrix based on the distance between road nodes to replace the traditional adjacency matrix, enriching the spatial expression ability of the model, thereby improving GAT's extraction of spatial characteristics of traffic flow.

[0021] Furthermore, the above traffic flow data includes the flow, average speed and occupancy rate of each road node, and the spatial characteristics include congestion coefficient, transmission probability factor, distance attenuation factor and weight coefficient, among which:

[0022] The congestion coefficient is as follows:

[0023]

[0024] In the formula, represents the congestion coefficient of road node i at the tth time step, v i,max represents the maximum speed of road node i in the entire time series, represents the average speed of road node i at time step t, q i,max represents the maximum flow rate of road node i in the entire time series, represents the flow of road node i at time step t, k i,max represents the maximum occupancy rate of road node i in the entire time series, Represents the occupancy rate of road node i at time step t.

[0025] Furthermore, the above transmission probability factor is specifically:

[0026]

[0027] In the formula, p ij represents the transmission probability factor from road node j to road node i, represents the transfer coefficient of road node i, represents the transfer coefficient of road node j, c i represents the congestion coefficient of road node i, c j Represents the congestion coefficient of road node j, where congestion coefficient = 1-transmission coefficient.

[0028] Furthermore, the above distance attenuation factor is specifically:

[0029]

[0030] Where, distance ij represents the distance between node i and node j, σ is the standard deviation of the Gaussian kernel function, which is calculated from the statistical information of the data, and d ij That is, the distance attenuation factor between node i and node j. The greater the distance, the smaller the attenuation factor, which means the influence between the nodes is weaker.

[0031] Furthermore, the above weight coefficient is specifically:

[0032]

[0033] In the formula, p ij is the transmission probability factor between road nodes i and j, d ij is the distance attenuation factor between road nodes i and j, That is, the weight coefficient of the improved road nodes i and j, is the new feature of the lth layer after node i is transformed, is the new feature of the lth layer after node j is transformed, a T represents a trainable attention vector, || represents the concatenation operation of the feature vector, and LeakyReLU represents the activation function.

[0034] Furthermore, the spatial features of the above-mentioned aggregation of adjacent time steps are specifically:

[0035] Among them G t =σ(W g ·X t +b g ), X t =[Ht-1 ,H t ];

[0036] In the formula, H t-1 is the vector of spatial features at time step t-1, H t is the vector of spatial features at time step t, X t is the vector of spatial features after splicing, w g is the weight matrix, b g is the bias vector, σ is the sigmoid function, G t is the gating signal, which is used to adaptively adjust the contribution of different time steps. The new vector after aggregating the spatial features of the previous time step for the t time step.

[0037] Furthermore, the above de-normalization process is specifically as follows:

[0038] y=y′·σ+μ;

[0039] Where y′ is the initial prediction value of the fully connected layer output, σ is the standard deviation obtained during standardization, μ is the mean obtained during standardization, and y represents the initial prediction value after denormalization.

[0040] Furthermore, the above loss function is specifically:

[0041]

[0042] Where N is the total number of road nodes, q t+p,i is the actual traffic flow of road node i at time step t+p, is the initial predicted value of node i after denormalization at time t.

[0043] In a second aspect, the present application provides a spatiotemporal graph attention network traffic flow prediction system based on transfer perception, which is applied to any of the spatiotemporal graph attention network traffic flow prediction methods based on transfer perception in the first aspect, including:

[0044] The first module is used to obtain the actual road network of the area to be predicted, and establish a graph structure set corresponding to the area to be predicted based on the spatial connection relationship of the actual road network. The graph structure set represents the road nodes in the area to be predicted and the connection relationship between each road node;

[0045] The second module is used to obtain the traffic flow data of the area to be predicted within the first preset time length, and based on the graph structure set, the preset TAGAT-LSTM model is trained using the traffic flow data of the area to be predicted to obtain a target model corresponding to the TAGAT-LSTM model and trained. The second module includes:

[0046] The first submodule is used to preprocess the traffic flow data using the input module in the TAGAT-LSTM model, and input the preprocessed traffic flow data into the spatial feature extraction module in the TAGAT-LSTM model for processing, so as to obtain a first feature sequence of spatial features of each road node aggregating adjacent nodes within a first preset time length, and the preprocessing includes smoothing processing and standardization processing;

[0047] The second submodule is used to process the first feature sequence of each road node using the gated network module in the TAGAT-LSTM model to obtain a second feature sequence of spatial features of each road node aggregating adjacent time steps;

[0048] The third submodule is used to process the second feature sequence using the time feature extraction module in the TAGAT-LSTM model to obtain the time feature of the second feature sequence, and generate a preliminary prediction value within a second preset time length through the fully connected layer in the TAGAT-LSTM model, where the second preset time length corresponds to the first preset time length;

[0049] The fourth submodule is used to perform a denormalization process on the preliminary prediction value, and calculate the loss function of the TAGAT-LSTM model based on the denormalized preliminary prediction value, until the loss function meets a preset training end condition, and determine the TAGAT-LSTM model that meets the training end condition as the target model;

[0050] The third module is used to obtain the historical traffic flow of the area to be predicted within a preset time length, and input the historical traffic flow into the target model for processing to obtain the predicted traffic flow of the area to be predicted within the future preset time length.

[0051] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any one of the methods in the first aspect when executing the computer program.

[0052] In a fourth aspect, the present application provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions enable a computer to execute any one of the methods in the first aspect.

[0053] Compared with the prior art, the present invention has at least the following beneficial effects:

[0054] In this application, the spatial feature extraction module is used to capture spatial dependencies, the gated network module performs preliminary temporal aggregation on the extracted spatial features, and weightedly fuses the spatial features of adjacent time steps to obtain a richer spatial feature representation. The temporal feature extraction module is responsible for further capturing temporal dependencies. The combination of the three modules enables the model to capture richer spatiotemporal dependencies and improve the accuracy of traffic flow prediction.

[0055] In this application, the gated network module serves as a transition layer between spatial feature extraction and temporal feature extraction, enabling the model to dynamically fuse spatial features at different time steps and capture the time-varying nature of spatial features, thereby more accurately capturing the temporal dependence of traffic flow and enhancing the model's ability to model complex traffic patterns; and through the gated network, the model can better learn the temporal continuity and changing patterns of spatial features of traffic flow, thereby improving the model's feature extraction capability and thus improving the model's prediction accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] The drawings described herein are used to provide a further understanding of the embodiments of the present invention, constitute a part of this application, and do not constitute a limitation of the embodiments of the present invention. In the drawings:

[0057] Figure 1 A method flow chart of a prediction method in an embodiment of the present invention;

[0058] Figure 2 It is a basic framework diagram of the TAGAT-LSTM model in an embodiment of the present invention;

[0059] Figure 3 This is a GAT layer model framework diagram in an embodiment of the present invention;

[0060] Figure 4 A schematic diagram of node transmission probability in an embodiment of the present invention;

[0061] Figure 5 Schematic diagram of a TA-GAT module in an embodiment of the present invention;

[0062] Figure 6 Schematic diagram of a gated network module in an embodiment of the present invention. DETAILED DESCRIPTION

[0063] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0064] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0065] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0066] In the description of the embodiments of the present invention, "plurality" means at least 2.

[0067] Embodiment 1: This embodiment provides a method for predicting traffic flow based on a spatiotemporal graph attention network based on transfer perception, such as Figure 1 As shown, the specific steps include:

[0068] S1, obtaining the actual road network of the area to be predicted, and establishing a graph structure set corresponding to the area to be predicted based on the spatial connection relationship of the actual road network. The graph structure set represents the road nodes in the area to be predicted and the connection relationship between each road node.

[0069] Among them, since traffic flow has unique spatiotemporal characteristics, it is not only affected by the historical traffic flow of the road section itself, but also has spatial interactions with its surrounding adjacent sections. Therefore, it is necessary to consider both time and space dimensions when predicting. Specifically, the spatial connection relationship of the actual road network represents the graph structure of the road network as G = (V, E, A), where V = {v1, v2, …, v N} represents the set of all road nodes in the road network; N is the number of road nodes, E is the set of edges. If two nodes are connected in space, then there is an edge in G connecting the two nodes; A∈R N×N is the adjacency matrix of the graph, and the element a in A is ij Then it means that node v i and v j The spatial connection status of is represented by 0 and 1 as follows:

[0070]

[0071] Furthermore, the temporal features of all nodes in G = (V, E, A) are represented by X∈R N×T×C Indicated by, where T represents the time series length of the node, C represents the number of feature types of the node. In this embodiment, C is taken as {flow rate, average speed, occupancy rate}, then the traffic flow prediction problem can be described by the following formula:

[0072] (X t+1 ,Xt+2 ,…,X t+P )=F{(X t-T+1 ,X t-T+2 ,…,X t ); G}.

[0074] Where t is the time step, T is the length of the historical traffic sequence, and P is the length of the predicted traffic sequence. t-T+1 ,X t-T+2 ,…,X t ) and graph structure G, and predict the traffic status (X) in the next P time steps through the prediction model F. t+1 ,X t+2 ,…,X t+P ).

[0075] S2, obtaining traffic flow data of the area to be predicted within a first preset time length, and based on the graph structure set, training a preset TAGAT-LSTM model using the traffic flow data of the area to be predicted to obtain a target model corresponding to and trained with the TAGAT-LSTM model.

[0076] Traffic flow prediction is a spatiotemporal data prediction problem. The difficulty lies in the accurate modeling and feature extraction of the time and space of the traffic network. To this end, a spatiotemporal graph attention network model TAGAT-LSTM based on transfer perception is designed. Its basic framework is as follows Figure 2 As shown in the figure, it mainly consists of five modules: ① data input module (Inputs), ② spatial feature extraction module (TA-GAT), ③ gating network module (Gating Network), ④ temporal feature extraction module (LSTM), and ⑤ training and output module (Outputs). The data input module obtains the input of the model by smoothing and standardizing the original input data; the spatial feature extraction module TA-GAT consists of a graph attention model (GAT), a transfer coefficient matrix, and a distance decay matrix, which is responsible for modeling and extracting the spatial features of the traffic network; the gating network module consists of several gating networks, which is responsible for the preliminary temporal aggregation of the extracted spatial features; the temporal feature extraction module consists of an LSTM network, which is responsible for extracting the temporal features of the historical traffic sequence; the training and output module maps the obtained spatiotemporal features to the prediction results through a fully connected layer, and then restores the results to the original scale of the data through denormalization, and finally outputs the final prediction results through the loss function training model.

[0077] Specifically, the target model can be obtained by:

[0078] S21, using the input module in the TAGAT-LSTM model to preprocess the traffic flow data, and input the preprocessed traffic flow data into the spatial feature extraction module in the TAGAT-LSTM model for processing, to obtain a first feature sequence of spatial features of each road node aggregating adjacent nodes within a first preset time length, the preprocessing includes smoothing processing and normalization processing.

[0079] Preprocessing includes smoothing and standardization. Since there are many noises in the original traffic data, these noises may come from sensor errors or abnormal events (such as traffic accidents, road construction, etc.), which will seriously affect the training and prediction performance of the prediction model. Therefore, smoothing the original data is an important step in data preprocessing, which helps to reduce short-term fluctuations, reduce the risk of model overfitting, and improve model performance. This paper uses a sliding average filter to smooth the data and reduce noise. For a given time series data x t , the calculation process of the sliding average filter is shown as follows:

[0080] Where W is the size of the sliding window, x t-i is the original data at time ti, is the data after noise removal.

[0081] Optionally, time series models are affected by the statistical properties of the data (such as mean and standard deviation), which reduces the prediction accuracy. Therefore, standardization is also an important part of data preprocessing. Z-score standardization converts the data into a standard normal distribution with a mean of 0 and a standard deviation of 1, eliminating the dimensional differences between different features, which helps to accelerate the convergence of the gradient descent algorithm and improve model performance. For a given input data The calculation of Z-score standardization is as follows:

[0082] Where μ is the input data The mean of , σ is its standard deviation, is the input data of feature f, is the standardized output data.

[0083] Optionally, the above-mentioned spatial feature extraction module includes a graph attention model, a transfer probability matrix and a distance attenuation matrix.

[0084] Among them, due to the complex time-varying spatial characteristics of real-world traffic flow, the spatial relationship and importance between road nodes and their neighboring nodes will change over time. GAT introduces an attention mechanism to assign adaptive weights to each edge and dynamically adjusts the relationship between nodes, so that the model can better capture the time-varying spatial relationship in the traffic network. At the same time, the multi-head attention mechanism is introduced to enable the model to jointly learn attention coefficients from multiple representation subspaces to obtain a richer spatial representation. Its structure is as follows: Figure 3 shown.

[0085] Specifically, when extracting spatial features from the input data at each time step, GAT first defines a feature transformation matrix W∈R F×F′ Perform a linear transformation on the input features of each node and map the input features to a new feature space, as shown in the following formula: In the formula, h i is the input feature of node i, W is the learnable feature transformation matrix, is the new feature of the lth layer after transformation.

[0086] Furthermore, the weight between two nodes is calculated through an attention mechanism, as shown in the formula: In the formula, a is a trainable attention vector, || represents the concatenation operation of the feature vector, LeakyReLU is the activation function, and the attention coefficient e is calculated by concatenating the features of node i and node j. ij Node j is a neighbor node of node i. Since node i may have more than one neighbor node, it needs to be normalized as shown in the following formula:

[0087]

[0088] In the formula, is the set of neighbor nodes of node i, and the attention weight α is obtained by performing softmax normalization on the attention coefficient ij .

[0089] Furthermore, the attention weights are used to perform weighted summation on the features of neighboring nodes to obtain the output features of node i, as shown below:

[0090] In the formula, σ is the activation function, is the neighbor node feature, α ij is the attention weight of node j for node i, and the weighted sum of all neighbor node features is used to obtain the new feature representation of node i.

[0091] In this embodiment, in order to enhance the performance of the model and the ability to capture more feature information and relationships, a multi-head attention mechanism is adopted, such as Figure 2 As shown in , multi-head attention calculation is performed on the input features, and the output features of all attention heads are spliced ​​together to obtain the final output features, as shown in the following formula:

[0092]

[0093] Where K is the number of attention heads, l is the current layer. If the current layer is an intermediate layer, the output features of all attention heads are concatenated using formula (1). In the final output layer, the concatenated features are averaged using formula (2) to generate the final output features.

[0094] Optionally, the traffic flow data includes the flow rate, average speed and occupancy rate of each road node, and the spatial characteristics include congestion coefficient, transmission probability factor, distance attenuation factor and weight coefficient, where:

[0095] The congestion coefficient is as follows:

[0096]

[0097] In the formula, represents the congestion coefficient of road node i at the tth time step, v i,max represents the maximum speed of road node i in the entire time series, represents the average speed of road node i at time step t, q i,max represents the maximum flow rate of road node i in the entire time series, represents the flow of road node i at time step t, k i,max represents the maximum occupancy rate of road node i in the entire time series, Represents the occupancy rate of road node i at time step t.

[0098] Among them, GAT is used to extract the spatial characteristics of the traffic network. Its principle is to calculate the importance of the neighbor nodes to the central node at each time step based on the feature similarity between the nodes, so as to achieve the effect of aggregating the spatial characteristics of the neighbor nodes. However, in the actual traffic network, the spatial interaction between nodes not only depends on the similarity and connection relationship of their traffic characteristics, but also the traffic status of the node at the current time step is also crucial. This is related to the ability of the neighbor node's features to be transmitted to the target node and the target node's ability to receive the neighbor node's features. Therefore, this method takes into account the traffic status of each node at the current time step. In this embodiment, the congestion coefficient is used to describe the current status of the node.

[0099] Optionally, the above transmission probability factor is specifically:

[0100]

[0101] In the formula, pij represents the transmission probability factor from road node j to road node i, represents the transfer coefficient of road node i, represents the transfer coefficient of road node j, c i represents the congestion coefficient of road node i, c j Represents the congestion coefficient of road node j, where congestion coefficient = 1-transmission coefficient.

[0102] Among them, after obtaining the current congestion coefficient of the node, the transfer coefficient of the node is further calculated. The transfer coefficient represents the ability of the node to output and receive features. By introducing the transfer coefficient matrix of the node, the model can more accurately reflect and extract the real spatial characteristics in the traffic network. The calculation is shown in the following formula: In the formula, is the transfer coefficient of node i at time step t, is the congestion coefficient of node i at time step t.

[0103] Specifically, Figure 4 As shown in the figure, after obtaining the transmission coefficient of a single node, the transmission probability of the neighboring node transmitting its own characteristics to the target node is further calculated. Taking into account the influence of the node on itself, that is, the self-connectivity of the node, the congestion probability is used to represent the probability that the node maintains its own characteristics unchanged, and then the transmission probability matrix P is constructed. The transmission probability of each position in the transmission probability matrix is ​​the calculation formula of the above transmission probability factor.

[0104] Among them, the transmission probability matrix of road nodes in the traffic network has been obtained above, which represents the probability of transmitting their own features and maintaining unchanged features between nodes. However, in reality, the factors affecting the node transmission ability are very complex, and distance is the most direct and influential factor. As the spatial distance between nodes increases, the mutual influence between nodes will inevitably weaken, and the probability of neighbor nodes transmitting features to the target node will also decrease. Therefore, in this embodiment, the distance factor is introduced when extracting the spatial features of the traffic road network; the distance attenuation factor is used to represent the influence of distance on the spatial features extracted by the model, and the distance attenuation factor is calculated by the Gaussian kernel function. The specific value is:

[0105]

[0106] Where, distance ij represents the distance between node i and node j, σ is the standard deviation of the Gaussian kernel function, which is calculated from the statistical information of the data, and d ij That is, the distance attenuation factor between node i and node j. The greater the distance, the smaller the attenuation factor, which means the influence between the nodes is weaker.

[0107] Among them, the adjacency matrix of the GAT model only uses 0 and 1 to represent the connectivity of the node, which is used to help the model identify the set of neighbor nodes of the node. However, it is difficult to reflect the complex spatial structure of the transportation network, which greatly limits its expression ability. Therefore, the adjacency matrix is ​​replaced by the distance decay matrix, and the connectivity of the node is expressed by the distance decay factor, so that the distance decay matrix with richer spatial features is obtained, as shown below:

[0108]

[0109] The diagonal of the matrix is ​​set to 1, indicating the self-connectivity of the nodes.

[0110] Specifically, the transfer probability matrix and the distance attenuation matrix are integrated with the GAT module, wherein the transfer probability factor and the distance attenuation factor are added to the calculation process of the neighbor node weight coefficient to obtain a new neighbor node weight calculation formula; the above weight coefficient is specifically:

[0111]

[0112] In the formula, p ij is the transmission probability factor between road nodes i and j, d ij is the distance attenuation factor between road nodes i and j, That is, the weight coefficient of the improved road nodes i and j, is the new feature of the lth layer after node i is transformed, is the new feature of the lth layer after node j is transformed, a T represents a trainable attention vector, || represents the concatenation operation of feature vectors, and LeakyReLU represents the activation function. Figure 5 The figure shows the fused TA-GAT module, where D is the distance attenuation matrix module and P is the transmission probability matrix module. is the element-wise product of tensors, is the element-by-element sum of the tensor. The input of the module is the preprocessed traffic sequence data and adjacency matrix, and the output is a new feature sequence after aggregating the spatial features of neighbor nodes.

[0113] S22, using the gated network module in the TAGAT-LSTM model to process the first feature sequence of each road node, to obtain a second feature sequence of spatial features of each road node aggregating adjacent time steps.

[0114] Among them, the spatial features of the road node are not only affected by its neighbor nodes in the current time step, but also by the previous time step. Therefore, a gating network is inserted after TA-GAT to fuse the spatial features of the previous time step and the current time step, such as Figure 6As shown in the figure, the feature sequence processed by TA-GAT is input into the gating network, which can weightedly fuse the spatial features of the previous time step and the spatial features of the current time step to form a new spatial feature representation of the current time step. By introducing the gating network, the expressive power of the model can be improved, so that the model can better understand the dynamic changes of traffic flow and improve the accuracy of prediction. At the same time, a preliminary time aggregation is made for the feature sequence of the data, which is helpful for the next step of extracting time features.

[0115] Optionally, the spatial features of the above-mentioned aggregation of adjacent time steps are specifically:

[0116] Among them G t =σ(W g ·X t +b g ), X t =[H t-1 ,H t ];

[0117] In the formula, H t-1 is the vector of spatial features at time step t-1, H t is the vector of spatial features at time step t, X t is the vector of spatial features after splicing, w g is the weight matrix, b g is the bias vector, σ is the sigmoid function, G t is the gating signal, which is used to adaptively adjust the contribution of different time steps. The new vector after aggregating the spatial features of the previous time step for the t time step.

[0118] S23, using the time feature extraction module in the TAGAT-LSTM model to process the second feature sequence to obtain the time features of the second feature sequence, and generating a preliminary prediction value within a second preset time length through the fully connected layer in the TAGAT-LSTM model, where the second preset time length corresponds to the first preset time length.

[0119] Among them, traffic data has obvious time dependence. RNN is usually used to learn time dependence and time series prediction, but it has gradient explosion and gradient vanishing problems. LSTM solves this problem by introducing a set of gated units and unit states that control information flow. In this embodiment, LSTM network is selected to extract time features. The node spatial feature sequence processed by TA-GAT and gated network is input into LSTM. Given data x t , whose input feature is represented by H∈R T×N×F′ , where F′ is the feature dimension of TA-GAT output, then the unit output state c tand the hidden layer output h t It can be calculated by the following formula:

[0120] i t =σ(W ii x t +b ii +W hi h t-1 +b hi ), f t =σ(W if x t +b if +W hf h t-1 +b hf );

[0121] g t =tanh(W ig x t +b ig +W hg h t-1 +b hg ), o t =σ(W io x t +b io +W ho h t-1 +b ho );

[0122] c t =f t *c t-1 +i t *g t ,h t =o t *tanh(c t );

[0123] In the above formula, i t 、f t , o t They are input, forget and output gates, g t is the memory cell state, W ii , W if , W ig , W io , W hi , W hf , W hg Is the connection x t ,h t-1 The weight matrix to the three gates and the input unit, b ii , b if , b ig , b io , b hi , bhf , hg, b ho is the corresponding bias, σ represents the sigmoid function, tanh represents the hyperbolic tangent function, and * represents element-wise multiplication.

[0124] Specifically, the hidden state of LSTM is finally input into the fully connected layer, which is responsible for mapping the hidden state to the target output space and generating a preliminary prediction value of the traffic flow.

[0125] S24, performing denormalization processing on the preliminary prediction values, and calculating the loss function of the TAGAT-LSTM model based on the denormalized preliminary prediction values, until the loss function meets a preset training end condition, and determining the TAGAT-LSTM model that meets the training end condition as the target model.

[0126] Optionally, the predicted value obtained by the fully connected layer is a standardized value, and it is necessary to perform de-standardization to reintegrate the non-stationary elements back into the data set and restore it to its original scale; the de-standardization process is as follows:

[0127] y=y′·σ+μ;

[0128] Where y′ is the initial prediction value of the fully connected layer output, σ is the standard deviation obtained during standardization, μ is the mean obtained during standardization, and y represents the initial prediction value after denormalization.

[0129] Optionally, the TAGAT-LSTM model can be optimized using mean square error (MSE) as a loss function. The above loss function is specifically:

[0130]

[0131] Where N is the total number of road nodes, q t+p,i is the actual traffic flow of road node i at time step t+p, is the initial predicted value of node i after denormalization at time t.

[0132] Among them, the adjustable parameters of the model are continuously optimized by minimizing the loss function to improve the performance of the prediction model. When the loss function value reaches the set threshold, the best set of parameters is selected, and the predicted value calculated under this parameter is used as the output of the traffic flow prediction model.

[0133] S3, obtaining the historical traffic flow of the area to be predicted within a preset time length, and inputting the historical traffic flow into the target model for processing to obtain the predicted traffic flow of the area to be predicted within the future preset time length.

[0134] Embodiment 2: The embodiment of the present application provides a spatiotemporal graph attention network traffic flow prediction system based on transfer perception, which is applied to any of the spatiotemporal graph attention network traffic flow prediction methods based on transfer perception in Embodiment 1, including:

[0135] The first module is used to obtain the actual road network of the area to be predicted, and establish a graph structure set corresponding to the area to be predicted based on the spatial connection relationship of the actual road network. The graph structure set represents the road nodes in the area to be predicted and the connection relationship between each road node.

[0136] The second module is used to obtain the traffic flow data of the area to be predicted within the first preset time length, and based on the graph structure set, the preset TAGAT-LSTM model is trained using the traffic flow data of the area to be predicted to obtain a target model corresponding to the TAGAT-LSTM model and trained. The second module includes:

[0137] The first submodule is used to preprocess the traffic flow data using the input module in the TAGAT-LSTM model, and input the preprocessed traffic flow data into the spatial feature extraction module in the TAGAT-LSTM model for processing, so as to obtain a first feature sequence of spatial features of each road node aggregating adjacent nodes within a first preset time length, and the preprocessing includes smoothing and standardization.

[0138] The second submodule is used to process the first feature sequence of each road node using the gated network module in the TAGAT-LSTM model to obtain a second feature sequence of each road node aggregating spatial features of adjacent time steps.

[0139] The third submodule is used to process the second feature sequence using the time feature extraction module in the TAGAT-LSTM model to obtain the time features of the second feature sequence, and generate a preliminary prediction value within a second preset time length through the fully connected layer in the TAGAT-LSTM model, and the second preset time length corresponds to the first preset time length.

[0140] The fourth submodule is used to perform denormalization processing on the preliminary prediction values, and calculate the loss function of the TAGAT-LSTM model based on the denormalized preliminary prediction values, until the loss function meets the preset training end condition, and the TAGAT-LSTM model that meets the training end condition is determined as the target model.

[0141] The third module is used to obtain the historical traffic flow of the area to be predicted within a preset time length, and input the historical traffic flow into the target model for processing to obtain the predicted traffic flow of the area to be predicted within the future preset time length.

[0142] Embodiment 3: The embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, any one of the methods in Embodiment 1 is implemented.

[0143] Embodiment 4: The embodiment of the present application provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions enable a computer to execute any method in Embodiment 1.

[0144] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A traffic flow prediction method based on spatiotemporal graph attention network based on transfer perception, characterized by: The specific steps include: Acquire the actual road network of the area to be predicted, and establish a graph structure set corresponding to the area to be predicted based on the spatial connection relationship of the actual road network, wherein the graph structure set represents the road nodes in the area to be predicted and the connection relationship between each road node; Obtain traffic flow data of the area to be predicted within a first preset time length, and based on the graph structure set, train a preset TAGAT-LSTM model using the traffic flow data of the area to be predicted to obtain a target model corresponding to and trained with the TAGAT-LSTM model, wherein the target model is obtained in the following manner: The traffic flow data is preprocessed by using the input module in the TAGAT-LSTM model, and the preprocessed traffic flow data is input into the spatial feature extraction module in the TAGAT-LSTM model for processing to obtain a first feature sequence of spatial features of each road node aggregating adjacent nodes within a first preset time length, wherein the preprocessing includes smoothing processing and standardization processing; The first feature sequence of each road node is processed by using the gated network module in the TAGAT-LSTM model to obtain a second feature sequence of each road node aggregating spatial features of adjacent time steps; Processing the second feature sequence using a time feature extraction module in a TAGAT-LSTM model to obtain a time feature of the second feature sequence, and generating a preliminary prediction value within a second preset time length through a fully connected layer in the TAGAT-LSTM model, where the second preset time length corresponds to the first preset time length; Performing a denormalization process on the preliminary prediction value, and calculating a loss function of the TAGAT-LSTM model based on the denormalized preliminary prediction value, until the loss function satisfies a preset training end condition, and determining the TAGAT-LSTM model that satisfies the training end condition as a target model; The historical traffic flow of the area to be predicted in a preset time length is obtained, and the historical traffic flow is input into the target model for processing to obtain the predicted traffic flow of the area to be predicted in the future preset time length.

2. The method for predicting traffic flow based on spatiotemporal graph attention network based on transfer perception according to claim 1 is characterized in that: The spatial feature extraction module includes a graph attention model, a transfer probability matrix and a distance attenuation matrix.

3. The method for predicting traffic flow based on spatiotemporal graph attention network based on transfer perception according to claim 1 is characterized in that: The traffic flow data includes the flow, average speed and occupancy rate of each road node, and the spatial characteristics include congestion coefficient, transmission probability factor, distance attenuation factor and weight coefficient, where: The congestion coefficient is specifically: In the formula, represents the congestion coefficient of road node i at the tth time step, v i,max represents the maximum speed of road node i in the entire time series, represents the average speed of road node i at time step t, q i,max represents the maximum flow rate of road node i in the entire time series, represents the flow of road node i at time step t, k i,max represents the maximum occupancy rate of road node i in the entire time series, Represents the occupancy rate of road node i at time step t.

4. The method for predicting traffic flow based on spatiotemporal graph attention network based on transfer perception according to claim 3 is characterized in that: The transmission probability factor is specifically: In the formula, p ij represents the transmission probability factor from road node j to road node i, l i represents the transfer coefficient of road node i, l j represents the transfer coefficient of road node j, c i represents the congestion coefficient of road node i, c j Represents the congestion coefficient of road node j, where congestion coefficient = 1-transmission coefficient.

5. The method for predicting traffic flow based on spatiotemporal graph attention network based on transfer perception according to claim 3 is characterized in that: The distance attenuation factor is specifically: Where, distance ij represents the distance between node i and node j, σ is the standard deviation of the Gaussian kernel function, which is calculated from the statistical information of the data, and d ij That is, the distance attenuation factor between node i and node j. The greater the distance, the smaller the attenuation factor, which means the influence between the nodes is weaker.

6. The method for predicting traffic flow based on spatiotemporal graph attention network based on transfer perception according to claim 3 is characterized in that: The weight coefficient is specifically: Where: p ij is the transmission probability factor between road nodes i and j, d ij is the distance attenuation factor between road nodes i and j, That is, the weight coefficient of the improved road nodes i and j, is the new feature of the lth layer after node i is transformed, is the new feature of the lth layer after node j is transformed, a T represents a trainable attention vector, || represents the concatenation operation of the feature vector, and LeakyReLU represents the activation function.

7. The method for predicting traffic flow based on spatiotemporal graph attention network based on transfer perception according to claim 1 is characterized in that: The spatial features of the aggregation of adjacent time steps are specifically: among them G t =σ(W g ·X t +b g ),X t =[H t-1 ,H t ]; In the formula, H t-1 is the vector of spatial features at time step t-1, H t is the vector of spatial features at time step t, X t is the vector of spatial features after splicing, w g is the weight matrix, b g is the bias vector, σ is the sigmoid function, G t is the gating signal, which is used to adaptively adjust the contribution of different time steps. The new vector after aggregating the spatial features of the previous time step for the t time step.

8. The method for traffic flow prediction based on spatiotemporal graph attention network based on transfer perception according to claim 1 is characterized in that: The de-normalization process is specifically as follows: y=y′·σ+μ; Where y′ is the initial prediction value of the fully connected layer output, σ is the standard deviation obtained during standardization, μ is the mean obtained during standardization, and y represents the initial prediction value after denormalization.

9. The method for traffic flow prediction based on spatiotemporal graph attention network based on transfer perception according to claim 1 is characterized in that: The loss function is specifically: Where N is the total number of road nodes, q t+p,i is the actual traffic flow of road node i at time step t+p, is the initial predicted value of node i after denormalization at time t.

10. A spatiotemporal graph attention network traffic flow prediction system based on transfer perception, applied to the spatiotemporal graph attention network traffic flow prediction method based on transfer perception according to any one of claims 1 to 9, characterized in that: include: The first module is used to obtain the actual road network of the area to be predicted, and establish a graph structure set corresponding to the area to be predicted based on the spatial connection relationship of the actual road network, wherein the graph structure set represents the road nodes in the area to be predicted and the connection relationship between each road node; The second module is used to obtain the traffic flow data of the area to be predicted within the first preset time length, and based on the graph structure set, train the preset TAGAT-LSTM model using the traffic flow data of the area to be predicted to obtain a target model corresponding to the TAGAT-LSTM model and trained. The second module includes: The first submodule is used to pre-process the traffic flow data using the input module in the TAGAT-LSTM model, and input the pre-processed traffic flow data into the spatial feature extraction module in the TAGAT-LSTM model for processing, so as to obtain a first feature sequence of spatial features of each road node aggregating adjacent nodes within a first preset time length, wherein the pre-processing includes smoothing processing and standardization processing; The second submodule is used to process the first feature sequence of each road node using the gated network module in the TAGAT-LSTM model to obtain a second feature sequence of spatial features of each road node aggregating adjacent time steps; A third submodule is used to process the second feature sequence using the time feature extraction module in the TAGAT-LSTM model to obtain the time features of the second feature sequence, and generate a preliminary prediction value within a second preset time length through a fully connected layer in the TAGAT-LSTM model, where the second preset time length corresponds to the first preset time length; The fourth submodule is used to perform a denormalization process on the preliminary prediction value, and calculate the loss function of the TAGAT-LSTM model based on the denormalized preliminary prediction value, until the loss function meets a preset training end condition, and determine the TAGAT-LSTM model that meets the training end condition as the target model; The third module is used to obtain the historical traffic flow of the area to be predicted within a preset time length, and input the historical traffic flow into the target model for processing to obtain the predicted traffic flow of the area to be predicted within the future preset time length.

Citation Information

Patent Citations

  • Traffic flow prediction method based on Transform space-time diagram convolutional network

    CN114330671A

  • Traffic flow prediction method based on graph discrete attention network, medium and equipment

    CN114582128A

  • system for measurement and control, control method of edge computing terminal unit, and computer program

    KR102294851B1

  • Traffic prediction

    US20240054321A1

  • Method and system for predicting spatio-temporal perception information based on graph neural network

    US20240054339A1

Cited By

  • Dynamic traffic bottleneck identification method based on space-time diagram attention network

    CN120690022A