A traffic flow prediction method based on multivariate traffic flow spatiotemporal data information

By combining a diffusion graph convolutional network and a GRU gated unit with a multi-head attention mechanism, the problem of insufficient accuracy of existing traffic flow prediction methods in complex urban road networks is solved, and more accurate traffic flow prediction is achieved.

CN117496699BActive Publication Date: 2024-09-10SHAANXI XINGANG LOGISTICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311425642.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-30
Publication Date
2024-09-10
Estimated Expiration
2043-10-30

AI Technical Summary

Technical Problem

Existing traffic flow prediction methods struggle to effectively utilize road segment information and model road network relationships when dealing with complex urban road networks, and they also neglect the spatial correlation of traffic flow, resulting in low prediction accuracy.

Method used

A diffusion graph convolutional network module is used in conjunction with GRU gating units and multi-head attention mechanism. Traffic flow data is processed by constructing an adjacency matrix, dynamically weighting and sparsifying it, and then prediction is made by combining the geographical information and temporal characteristics of traffic nodes.

Benefits of technology

It improves the accuracy of traffic flow prediction, reduces the impact of traffic flow fluctuations on prediction results, and achieves more effective information fusion and time feature extraction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117496699B
    Figure CN117496699B
Patent Text Reader

Abstract

The present invention belongs to the technical field of traffic flow prediction, and specifically relates to a traffic flow prediction method for multivariate traffic flow spatiotemporal data information, comprising obtaining input data, performing weighted summation on the input data based on an attention mechanism to obtain a dynamically weighted input data matrix, and using an out-degree matrix and an in-degree matrix to respectively mask the input data to obtain a corresponding dynamic weight matrix; constructing an adaptive matrix and performing sparse processing on the matrix; constructing a diffusion graph convolutional network module based on the dynamic weight matrix and the adaptive matrix, constructing a GRU gating unit based on the diffusion graph convolutional network module, and inputting the input data into the gating unit to obtain a state vector; using a multi-head attention mechanism to process the acquired hidden state information, and inputting the output of the multi-head attention into a neural network layer for prediction; the present invention improves the accuracy of traffic flow prediction, and at the same time reduces the influence of traffic flow fluctuations on the prediction results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of traffic flow prediction, and in particular relates to a traffic flow prediction method oriented to multivariate traffic flow spatiotemporal data information. Background Art

[0002] Traffic flow prediction is of great significance for many practical applications, including traffic management, urban computing, public safety, etc. Especially in recent years, with the further progress of urbanization, the per capita car ownership of residents has also increased, so the problem of traffic flow prediction has received more and more attention from experts and scholars. Traffic flow prediction is an important process for analyzing urban road traffic conditions. It uses historical data from sensors to predict traffic flow information. Its prediction indicators mainly include: traffic flow per unit time, speed and occupancy rate of vehicles in road networks or detection nodes per unit time, and prediction of road traffic trends. Its goal is to make all vehicles on the road reasonably arranged. The essence of traffic flow prediction is multivariate time series prediction. However, compared with other multivariate time series prediction tasks (such as power prediction and stock market prediction), traffic flow prediction is more difficult. On the one hand, the number of urban road nodes is large and the structure is complex; on the other hand, when predicting on busy urban roads, due to the strong mutual influence between road nodes, the volatility of road traffic flow, and the uncertainty of emergencies, we need to pay attention to a lot of information when performing traffic flow prediction tasks, which further aggravates the difficulty of traffic flow prediction.

[0003] How to effectively utilize the past information of the road section itself and how to more effectively model the road network relationship are the keys to traffic flow prediction. Previous traffic flow prediction research is usually divided into two categories, namely knowledge-driven and data-driven. In transportation and operations research, knowledge-driven methods usually attempt to model the traffic network through queuing theory to simulate the driving behavior of vehicle drivers in traffic. However, this method cannot reflect the complexity of real traffic flow, so the accuracy is not satisfactory.

[0004] As the amount of traffic data continues to increase, data-driven machine learning methods have entered the public eye. Initially, some machine learning methods, including autoregressive integrated moving average (ARIMA) and Kalman filtering, attempted to model traffic flow prediction as a simple time series prediction problem in order to predict future traffic flow. However, these methods all rely heavily on the assumption of stationary correlation, which is contrary to the actual traffic flow situation. More importantly, like knowledge-driven methods, these methods ignore the spatial correlation of traffic flow itself, which is precisely the key to traffic flow prediction. Summary of the invention

[0005] In view of the shortcomings of the prior art, the present invention proposes a traffic flow prediction method for multi-dimensional traffic flow spatiotemporal data information, such as Figure 1 , specifically including the following steps:

[0006] S1. Obtain the original data of traffic flow and interpolate and standardize the missing data to obtain the pre-processed data;

[0007] S2, segmenting the traffic flow preprocessed data according to the timestamp, and dividing the input data into multiple segments;

[0008] S3, constructing an adjacency matrix according to the geographic information of the traffic speed sensor, and obtaining an out-degree matrix and an in-degree matrix according to the adjacency matrix;

[0009] S4. Based on the attention mechanism, each segment of input data is dynamically weighted and summed to obtain a dynamically weighted input data matrix;

[0010] S5, using the out-degree matrix and the in-degree matrix to perform mask operations on the dynamically weighted input data matrix, respectively, to obtain dynamic weight matrices for generating the out-degree matrix and the in-degree matrix;

[0011] S6, constructing an adaptive matrix, using the Pearson correlation coefficient between the two sensor data to construct a mask matrix, and using the mask matrix to sparse the adaptive matrix;

[0012] S7, constructing a diffusion graph convolutional network module based on the sparse adaptive matrix, generating the out-degree matrix, and the dynamic weight matrix of the in-degree matrix;

[0013] S8. Construct a GRU gating unit based on the diffusion graph convolutional network module to extract hidden information from the real-time collected input data and obtain a hidden state vector;

[0014] S9, using the multi-head attention mechanism to process the acquired hidden state information, and input the output of the multi-head attention into the neural network layer;

[0015] S10, the neural network layer outputs the predicted speed value of each sensor node at the next moment according to the input data.

[0016] Furthermore, the raw data of traffic flow is obtained and the missing data is interpolated and standardized to obtain the preprocessed data including:

[0017] Get the data of each node in the traffic sensor and arrange them in chronological order;

[0018] For the missing data, the mean value method is used for interpolation, that is, the mean value of the sum of the data at the moment before the missing data and the data at the moment after the missing data is used as a substitute for the missing data;

[0019] After completing the data interpolation, the data is normalized so that all data values ​​are scaled to between [-1, 1]. The process of normalizing the data includes:

[0020]

[0021] Among them, x is the value of the original data, mean(x) is the average value of all x, σ represents the standard deviation of the data, and x ′ This is the normalized scaled data.

[0022] Furthermore, the process of segmenting the traffic flow preprocessed data according to the timestamp includes:

[0023] When constructing the training data set, the real data corresponding to the data to be predicted in the historical data, the data of the previous hour, the data of the same period of the previous day, and the data of the same period of the previous week are used as input to predict the data of the time period to be tested, and the difference between the predicted value and the real data is used to update the prediction network parameters;

[0024] When making predictions in real time, the data of the previous hour of the time period to be predicted, the data of the same time period of the previous day, and the data of the same time period of the previous week are directly used as input to obtain the predicted value.

[0025] Furthermore, an adjacency matrix is ​​constructed according to the geographic information of the traffic speed sensor, and the traffic outflow matrix and inflow matrix are obtained according to the adjacency matrix, which specifically includes:

[0026] Generate an adjacency matrix according to the geographical location of the sensor. That is, if there are N sensors, an N×N adjacency matrix is ​​generated. The element in the i-th row and j-th column of the matrix indicates whether the i-th sensor is upstream of the j-th sensor. If so, the value of the corresponding element in the matrix is ​​1, otherwise it is 0.

[0027] Use the current adjacency matrix as the out-degree matrix;

[0028] Transpose the out-degree matrix to obtain the in-degree matrix.

[0029] Furthermore, the process of obtaining a dynamic weight matrix for generating an out-degree matrix and an in-degree matrix includes:

[0030] A out =SoftMax(G out ⊙Attention)

[0031] A in =SoftMax(G in ⊙Attention)

[0032] Among them, A outis the dynamic weight matrix of the out-degree matrix; G out is the out-degree matrix; ⊙ represents the calculation of the Hadamard product, that is, the product of the corresponding elements of the matrix; Attention is the dynamically weighted historical data matrix; A in is the dynamic weight matrix of the in-degree matrix; G in is the in-degree matrix.

[0033] Furthermore, the acquisition of the dynamically weighted historical data matrix includes:

[0034]

[0035] Q i =X i *W i_Q

[0036] K i =X i *W i_K

[0037]

[0038] Among them, Attention is the dynamically weighted historical data matrix; X i represents the i-th segment of data obtained after segmentation according to the timestamp; W i Represents the i-th historical data X i The weight matrix of Attention i Represents the i-th historical data X i The attention value of Q i Represents the i-th historical data X in the attention mechanism i The query value matrix, W i_Q Q i The corresponding query value weight matrix; K i Represents the i-th historical data X in the attention mechanism i The key value matrix, W i_K K i The corresponding key value weight matrix; d k Q i or K i The length of the vector.

[0039] Furthermore, constructing an adaptive matrix based on the dynamic weight matrix of the out-degree matrix and the in-degree matrix includes:

[0040]

[0041] Among them, A adp is the adaptive matrix; E 1 、E 2 are two trainable embedding vectors.

[0042] Furthermore, the Pearson correlation coefficient between the data of two sensors is used to construct a mask matrix, and the mask matrix is ​​used to sparse the adaptive matrix, that is, the Pearson correlation coefficient of the data between each sensor is calculated. If the Pearson correlation coefficient is greater than the set threshold, the value of the position corresponding to the two sensors in the mask matrix is ​​1, otherwise it is 0, and the mask matrix is ​​used to sparse the adaptive matrix.

[0043] Furthermore, the process of inputting the sparse adaptive matrix, the dynamic weight matrix of the generated out-degree matrix and the in-degree matrix into the GRU gating unit to extract hidden information includes:

[0044] r t =σ(θ r [h t-1 ,x t ])

[0045] z t =σ(θ z [h t-1 ,x t ])

[0046]

[0047]

[0048] Among them, r t represents the data obtained by resetting the gate at time t; z t Indicates the data obtained in the update gate at time t; represents the candidate hidden state; h t-1 represents the hidden state at time t-1; x t represents the input at the tth time, that is, the traffic flow data collected by the node at the tth time; θ r [h t-1 ,x t ] means to change x t 、h t-1 After splicing, the diffusion graph convolutional network module θ is reset in the gate r The data obtained; θ z [h t-1 ,x t ] means to change x t 、h t-1 After splicing, the diffusion graph convolutional network module θ is updated in the gate z The data obtained; θ h [r t *h t-1 ,x t ] means to change x t 、r t *h t-1After splicing, it passes through the diffusion graph convolutional network module θ in the candidate layer h The obtained data; if the input data is X, the diffusion graph convolutional network module processes the data including:

[0049]

[0050] Where Z represents the output of a diffusion graph convolutional network module; M represents the number of diffusion times; The dynamic weight matrix A represents the in-degree matrix in m to the power of The dynamic weight matrix A represents the degree matrix out m to the power of is the adaptive matrix after sparseness mth power; W k1 , W k2 , W k3 is the trainable weight matrix in the diffusion graph convolutional network module.

[0051] Furthermore, the multi-head attention mechanism is used to process the acquired hidden state information, including:

[0052] MHAttention(H t )=Concat(MHAttention(H v ),TE)

[0053] MHAttention(H v )=Concat(head 1 ,head 2 ,...head n )W O

[0054]

[0055]

[0056] TE={TE 1 ,…,TE i ,…}

[0057] Among them, MHAttention(H t ) represents the output of the multi-head attention mechanism at time t; Concat(·) represents the concatenation operation; W O is the trainable parameter of multi-head attention; head i represents the output of the i-th head, n is the total number of heads in the multi-head attention, H represents the hidden state vector, and W i Q represents the trainable weight matrix of the i-th head query vector, W iK W represents the trainable weight matrix of the i-th head key vector; i V represents the trainable weight matrix of the i-th head value vector; d represents the length of the hidden state vector; T is the length of the input data.

[0058] The present invention obtains the historical speed data in the traffic flow sensor node and performs vectorized encoding on it. At the same time, the geographic information of the traffic flow node is converted into a matrix vector, and the information interaction between the upstream and downstream nodes is dynamically regulated by using a gating mechanism, and the geographic information between the traffic nodes is fused at the same time; on the other hand, the implicit information between the traffic nodes is obtained by generating an adaptive matrix and sparsely ... BRIEF DESCRIPTION OF THE DRAWINGS

[0059] Figure 1 A flow chart of a traffic flow prediction method for multi-dimensional traffic flow spatiotemporal data information of the present invention;

[0060] Figure 2 It is a schematic diagram of the structure of the gate control unit in the present invention;

[0061] Figure 3 Schematic diagram of the upstream and downstream gating mechanism in the present invention;

[0062] Figure 4 The present invention is a schematic diagram of the architecture of a traffic flow prediction method for multi-dimensional traffic flow spatiotemporal data information. DETAILED DESCRIPTION

[0063] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. 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.

[0064] The present invention proposes a traffic flow prediction method for multi-dimensional traffic flow spatiotemporal data information, such as Figure 1 , specifically including the following steps:

[0065] S1. Obtain the original data of traffic flow and interpolate and standardize the missing data to obtain the pre-processed data;

[0066] S2, segmenting the traffic flow preprocessed data according to timestamps to obtain multiple segments of historical data;

[0067] S3, constructing an adjacency matrix according to the geographic information of the traffic speed sensor, and obtaining an out-degree matrix and an in-degree matrix according to the adjacency matrix;

[0068] S4. Based on the attention mechanism, each piece of historical data is dynamically weighted and summed to obtain a dynamically weighted historical data matrix;

[0069] S5, using the out-degree matrix and the in-degree matrix to perform mask operations on the dynamically weighted historical data matrix, respectively, to obtain dynamic weight matrices for generating the out-degree matrix and the in-degree matrix;

[0070] S6, constructing an adaptive matrix, using the Pearson correlation coefficient between the two sensor data to construct a mask matrix, and using the mask matrix to sparse the adaptive matrix;

[0071] S7, constructing a diffusion graph convolutional network module based on the sparse adaptive matrix, generating the out-degree matrix, and the dynamic weight matrix of the in-degree matrix;

[0072] S8. Construct a GRU gating unit based on the diffusion graph convolutional network module to extract hidden information from the real-time collected input data and obtain a hidden state vector;

[0073] S9, using the multi-head attention mechanism to process the acquired hidden state information, and input the output of the multi-head attention into the neural network layer;

[0074] S10, the neural network layer outputs the predicted speed value of each sensor node at the next moment according to the input data.

[0075] like Figure 4 In this embodiment, after the input data is passed through the gating unit to obtain the hidden state information, prediction is performed based on the transformer layer. The following specifically describes the implementation of a traffic flow prediction method for multivariate traffic flow spatiotemporal data information.

[0076] In this embodiment, obtaining the original data of the traffic flow and interpolating and standardizing the missing data to obtain the pre-processed data specifically includes the following steps:

[0077] Get the data of each node in the traffic sensor and arrange them in chronological order;

[0078] For the missing data, the mean value method is used for interpolation, that is, the mean value of the sum of the data at the moment before and the data at the moment after the missing data is used as a substitute;

[0079] After completing the data interpolation, the data is normalized so that all data values ​​are scaled to between [-1, 1]. The normalization formula is:

[0080]

[0081] Among them, x is the value of the original data, mean(x) is the average value of all x, σ represents the standard deviation of the data, and x ′ This is the normalized scaled data.

[0082] In this embodiment, the traffic flow preprocessed data is segmented according to the timestamp, so that each training set has multiple segments of historical data. Technical personnel in this field can segment the historical data according to actual needs and select corresponding data therefrom. For the convenience of description, in this embodiment, the data of one hour before the time period to be predicted, the data of the same time period one day before the time period to be predicted, and the data of the same time period one week before the time period to be predicted will be used. When implementing the prediction, for example, if it is necessary to predict the traffic flow data 5 minutes later, the data collected at the current time can be used as real-time data, and combined with the data of the same time period one day before the time period to be predicted and the data of the same time period one week before the time period to be predicted as the input of the prediction model.

[0083] For the preprocessed data, the sliding window method is used to divide the historical data and the predicted data according to the timestamp label it has. In this embodiment, a complete input data is represented as:

[0084] X history =(X w1 , …, X wT ;X d1 , …, X dT ;X h1 , …, X hT )

[0085] Y pred =(Y T+1 , …, Y T+T′ )

[0086] Among them, X history Indicates the data needed to predict traffic flow; X w1 , …, X wT Represents the data of the current time window; X d1 , …, X dT Represents the data of a time window in the same period of the day before the forecast period; X h1, …, X hT represents the data of a time window in the same period of the week before the forecast period, T is the time step of a window; Y pred is the predicted traffic flow data; Y T+1 , …, Y T+T′ Represents the predicted value of each time step when the prediction time step is T′.

[0087] According to the geographic information of the traffic speed sensors in the real world, an N×N matrix is ​​generated, where N is the total number of traffic speed sensors. If two traffic speed sensors are adjacent in the real world and sensor i is upstream of sensor j, the value of [i, j] in the matrix is ​​set to 1, otherwise it is set to 0, so as to generate the out-degree matrix G of the traffic flow. out , denoted by G out =(V, E), where V = {V 1 , …, V N} is the total number of N traffic sensor nodes, E is the set of edges connecting these nodes, and also indicates the direction of traffic flow.

[0088] Similarly, generate another N×N matrix, copy the data in the out-degree matrix to the newly generated N×N matrix, and transpose the matrix to obtain the in-degree matrix, expressed as G in =(V, E).

[0089] Afterwards, the attention mechanism is used on the historical data to obtain the dynamic weights between different sensor nodes in each time period. That is, each data segment with a length of T is given an attention weight through the attention mechanism, and the weight is used to dynamically weight each data segment, including:

[0090]

[0091] Q i =X i *W i_Q

[0092] K i =X i *W i_K

[0093]

[0094] Among them, Attention is the dynamically weighted historical data matrix; X i represents the i-th segment of data obtained after segmentation according to the timestamp; W i Represents the i-th historical data X i The weight matrix of Attention i Represents the i-th historical data Xi The attention value of Q i Represents the i-th historical data X in the attention mechanism i The query value matrix, W i_Q Q i The corresponding query value weight matrix; K i Represents the i-th historical data X in the attention mechanism i The key value matrix, W i_K K i The corresponding key value weight matrix; d k Q i or K i The length of the vector.

[0095] This embodiment includes three segments of data, namely, real-time data collected before the time to be predicted (this embodiment selects data one hour before the time to be predicted), data from the same period of the day before the time period to be predicted, and data from the same period of the week before the time period to be predicted. The corresponding attention weights are calculated by the above method. w 、Attention d 、Attention h , weighted fusion of the obtained attention weights, including:

[0096] Attention=W 1 *Attention w +W 2 *Attention d +W 3 *Attention h

[0097] Among them, W 1 , W 2 , W 3 They are attention weights Attention w 、Attention d 、Attention h The weighted weight of .

[0098] After obtaining the attention matrix, the previously generated out-degree matrix is ​​used for masking to reduce the noise during model prediction:

[0099] A out =SoftMax(G out ⊙Attention)

[0100] Among them, A out is the dynamic weight matrix of the out-degree matrix; G outis the out-degree matrix; ⊙ represents the calculation of the Hadamard product; Attention is the dynamically weighted historical data matrix; SoftMax is the normalization function, which makes the sum of each row of the dynamic weight matrix 1.

[0101] Similarly, the dynamic weight matrix of the in-degree matrix is ​​generated in the same way, namely:

[0102] A in =SoftMax(G in ⊙Attention)

[0103] Among them, A in is the dynamic weight matrix of the in-degree matrix; G in is the in-degree matrix.

[0104] According to the geographic information of the traffic speed sensors in the real world, an N×N adaptive matrix is ​​generated to obtain the invisible relationship between non-adjacent traffic nodes, where N is the total number of traffic speed sensors. The adaptive matrix is ​​generated as follows:

[0105]

[0106] Among them, A adp is the adaptive matrix; E 1 、E 2 are two trainable embedding vectors; ReLU is the activation function, making After multiplication, values ​​less than zero in the matrix are set to zero.

[0107] Use historical data to generate a mask matrix, sparse the adaptive matrix, and reduce noise. Specifically, multiple segments of historical data are spliced, and then the Pearson correlation coefficient between each historical data is calculated. The calculation formula of the Pearson correlation coefficient is as follows:

[0108]

[0109] in, Any two historical data vectors, represents the covariance between two historical data vectors, express Variance of the vector. After obtaining the Pearson correlation coefficient of any two historical data, the values ​​of the matrix positions corresponding to the traffic flow nodes that are less than the threshold are set to 0, so as to achieve the effect of the mask matrix.

[0110] In the present invention, a RNN-based model is used to transfer information in time and obtain a hidden state vector. Specifically, a variant of the RNN model, GRU, is used, such as Figure 2 , the operation of each unit in GRU is as follows:

[0111] r t =σ(W r *[h t-1 ,x t ])

[0112] z t =σ(W z *[h t-1 ,x t ])

[0113]

[0114]

[0115] Among them, x t Indicates the value of the data at the current moment; h t-1 represents the latent vector output at the previous moment; σ is the sigmoid function, through which the data can be converted into a value in the range of 0-1; W r , W z , and W o are all learning parameters; tanh is the activation function, through which the data can be converted into values ​​in the range of [-1,1].

[0116] In terms of space, this embodiment uses a diffusion graph convolutional network for transfer interaction of spatial learning. In general, the aggregation formula of the diffusion graph convolutional network is as follows: Wherein, Z represents the output of a diffusion graph convolutional network module; M represents the number of diffusions. The longer the propagation distance, the more information each node obtains, but it will also cause the speed of model training to decrease. Therefore, the present invention only considers M to be 2; The dynamic weight matrix A represents the in-degree matrix in m to the power of The dynamic weight matrix A represents the degree matrix out m to the power of is the adaptive matrix after sparseness mth power; W k1 , W k2 , W k3 is the trainable weight matrix in the diffusion graph convolutional network module.

[0117] Considering the complex relationships between nodes in the real world, such as the different impacts of upstream and downstream, the graph convolution aggregation formula with fixed parameters cannot effectively explain the traffic flow in reality, such as Figure 3 In this embodiment, a gated fusion module is introduced to adaptively select and discard upstream and downstream information. The gated fusion module is implemented as follows:

[0118]

[0119]

[0120] in, and Represent the upstream information and downstream information of the kth propagation, respectively, W in and W out is a trainable matrix, and b is a trainable bias matrix; in this way, the information input of the upstream is dynamically balanced; ⊙ represents the calculation of the Hadamard product; * represents the calculation of the product of two matrices.

[0121] Finally, this embodiment uses a new diffusion graph convolution aggregation module to replace the original matrix multiplication of GRU to achieve the purpose of simultaneously aggregating time information and spatial learning. The replaced GRU unit is as follows:

[0122] r t =σ(θ r [h t-1 ,x t ])

[0123] z t =σ(θ z [h t-1 ,x t ])

[0124]

[0125]

[0126] Among them, r t represents the data obtained by resetting the gate at time t; z t Indicates the data obtained in the update gate at time t; represents the candidate hidden state; h t-1 represents the hidden state at time t-1; x t represents the input at the tth time, that is, the traffic flow data collected by the node at the tth time; θ r [h t-1 ,x t ] means to change x t 、h t-1 After splicing, the diffusion graph convolutional network module θ is reset in the gate r The data obtained; θ z [h t-1 ,x t ] means to change x t 、h t-1 After splicing, the diffusion graph convolutional network module θ is updated in the gate z The data obtained; θh [r t *h t-1 ,x t ] means to change x t 、r t *h t-1 After splicing, it passes through the diffusion graph convolutional network module θ in the candidate layer h The data obtained.

[0127] GRU can capture short-term sequence information very well. However, it is not enough to capture only the temporal feature information of recent road segments, because traffic prediction is also affected by long-term dependencies. Therefore, for the previously generated multi-segment hidden layer vector H w =(h w1 ,…,h wT ), H d =(h d1 ,…,h dT ), H h =(h h1 ,…,h hT ), using transformer for integrated prediction, before prediction, using multi-head attention mechanism to capture the global dependency in multiple hidden layer vectors generated by GRU, and this embodiment takes into account the parallelism of self-attention mechanism, in addition to obtaining the global view, it is also necessary to consider the relative position in the hidden layer sequence and add position encoding TE in the hidden vector generated between GRU and multi-head self-attention layer, specifically including:

[0128] MHAttention(H t )=Concat(MHAttention(H v ),TE)

[0129] MHAttention(H v )=Concat(head 1 ,head 2 ,...head n )W O

[0130]

[0131]

[0132] TE={TE 1 ,…,TE i ,…}

[0133] Among them, MHAttention(H t ) represents the output of the multi-head attention mechanism at time t; Concat(·) represents the concatenation operation; W Ois the trainable parameter of multi-head attention; head i represents the output of the i-th head, n is the total number of heads in the multi-head attention, H represents the hidden state vector, and W i Q represents the trainable weight matrix of the i-th head query vector, W i K W represents the trainable weight matrix of the i-th head key vector; i V represents the trainable weight matrix of the i-th head value vector; d represents the length of the hidden state vector; T is the length of the input data.

[0134] In order to minimize the error between the actual traffic flow and the predicted traffic flow in the traffic flow prediction during the model training, the loss function of the traffic flow prediction model for multivariate traffic flow spatiotemporal data information is defined as follows:

[0135]

[0136] in, is the calculated loss value, Y t is the predicted traffic flow information value, is the traffic flow information value in the real world, subtract the two values ​​and take the absolute value; L reg For L 2 Regularization is used to prevent overfitting, and λ is a hyperparameter.

[0137] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A traffic flow prediction method for multivariate traffic flow spatiotemporal data information, characterized in that: The specific steps include: S1. Obtain the original data of traffic flow and interpolate and standardize the missing data to obtain the pre-processed data; S2, segmenting the traffic flow preprocessed data according to the timestamp, and dividing the input data into multiple segments; S3, constructing an adjacency matrix according to the geographic information of the traffic speed sensor, and obtaining an out-degree matrix and an in-degree matrix according to the adjacency matrix; Specifically include: Generate an adjacency matrix according to the geographical location of the sensor. That is, if there are N sensors, an N×N adjacency matrix is ​​generated. The element in the i-th row and j-th column of the matrix indicates whether the i-th sensor is upstream of the j-th sensor. If so, the value of the corresponding element in the matrix is ​​1, otherwise it is 0. Use the current adjacency matrix as the out-degree matrix; Transpose the out-degree matrix to obtain the in-degree matrix; S4. Based on the attention mechanism, each segment of input data is dynamically weighted and summed to obtain a dynamically weighted input data matrix; S5. Using the out-degree matrix and the in-degree matrix, respectively, masking the dynamically weighted input data matrix is ​​performed to obtain the dynamic weight matrix of the out-degree matrix and the dynamic weight matrix of the in-degree matrix. The process of obtaining the dynamic weight matrix of the out-degree matrix and the dynamic weight matrix of the in-degree matrix includes: A out =SoftMax(G out ⊙Attention) A in =SoftMax(G in ⊙Attention) Among them, A out is the dynamic weight matrix of the out-degree matrix; G out is the out-degree matrix; ⊙ indicates the calculation of the Hadamard product; A in is the dynamic weight matrix of the in-degree matrix; G in is the in-degree matrix; Attention is the dynamically weighted historical data matrix. The acquisition process of the dynamically weighted historical data matrix includes: Q i =X i *W i_Q K i =X i *W i_K Among them, X i represents the i-th segment of data obtained after segmentation according to the timestamp; W i Represents the i-th historical data X i The weight matrix of Attention i Represents the i-th historical data X i The attention value of Q i Represents the i-th historical data X in the attention mechanism i The query value matrix, W i_Q Q i The corresponding query value weight matrix; K i Represents the i-th historical data X in the attention mechanism i The key value matrix, W i_K K i The corresponding key value weight matrix; d k Q i The length of the vector; S6, constructing an adaptive matrix, using the Pearson correlation coefficient between the two sensor data to construct a mask matrix, and using the mask matrix to sparse the adaptive matrix; constructing the adaptive matrix includes: Among them, A adp is an adaptive matrix; E1 and E2 are two trainable embedding vectors; S7. Use the Pearson correlation coefficient between the two sensor data to construct a mask matrix, and use the mask matrix to sparse the adaptive matrix, that is, calculate the Pearson correlation coefficient of the data between each sensor. If the Pearson correlation coefficient is greater than the set threshold, the value of the position corresponding to the two sensors in the mask matrix is ​​1, otherwise it is 0. Use the mask matrix to sparse the adaptive matrix; construct a diffusion graph convolutional network module based on the sparse adaptive matrix, the dynamic weight matrix of the out-degree matrix, and the dynamic weight matrix of the in-degree matrix; S8. A GRU gating unit is constructed based on the diffusion graph convolutional network module to extract hidden information from the input data collected in real time and obtain a hidden state vector. The process of extracting hidden information by the GRU gating unit includes: r t =σ(θ r [h t-1 ,x t ]) z t =σ(θ z [h t-1 ,x t ]) Among them, r t represents the data obtained by resetting the gate at time t; z t Indicates the data obtained in the update gate at time t; represents the candidate hidden state; h t-1 represents the hidden state at time t-1; x t represents the input at time t, i.e., the traffic flow data collected by the node at time t; θ r [h t-1 ,x t ] means to change x t 、h t-1 After splicing, the diffusion graph convolutional network module θ is reset in the gate r The data obtained; θ z [h t-1 ,x t ] means to change x t 、h t-1 After splicing, the diffusion graph convolutional network module θ is updated in the gate z The data obtained; θh[r t *h t-1 ,x t ] means to change x t 、r t *h t-1 After splicing, it passes through the diffusion graph convolutional network module θ in the candidate layer h The obtained data; if the input data is X, the diffusion graph convolutional network module processes the data including: Where Z represents the output of a diffusion graph convolutional network module; M represents the number of diffusion times; The dynamic weight matrix A represents the in-degree matrix in m to the power of The dynamic weight matrix A represents the degree matrix out m to the power of is the adaptive matrix after sparseness mth power; W k1 , W k2 , W k3 is the trainable weight matrix in the diffusion graph convolutional network module; S9, using the multi-head attention mechanism to process the acquired hidden state information, and input the output of the multi-head attention into the neural network layer; S10, the neural network layer outputs the predicted speed value of each sensor node at the next moment according to the input data.

2. The traffic flow prediction method for multi-dimensional traffic flow spatiotemporal data information according to claim 1 is characterized in that: Obtaining raw traffic flow data and interpolating and standardizing missing data to obtain preprocessed data includes: Get the data of each node in the traffic sensor and arrange them in chronological order; For the missing data, the mean value method is used for interpolation, that is, the mean value of the sum of the data at the moment before the missing data and the data at the moment after the missing data is used as a substitute for the missing data; After completing the data interpolation, the data is normalized so that all data values ​​are scaled to between [-1, 1]. The process of normalizing the data includes: Among them, x is the value of the original data, mean(x) is the average value of all x, σ′ represents the standard deviation of the data, and x′ is the normalized scaled data.

3. The traffic flow prediction method for multi-dimensional traffic flow spatiotemporal data information according to claim 1, characterized in that: The process of segmenting the traffic flow preprocessed data according to timestamps includes: When constructing the training data set, the real data of the previous hour, the data of the same period of the previous day, and the data of the same period of the previous week corresponding to the data to be predicted in the historical data are used as input to predict the data of the time period to be tested, and the difference between the predicted value and the real data is used to update the prediction network parameters; When making predictions in real time, the data of the previous hour of the time period to be predicted, the data of the same time period of the previous day, and the data of the same time period of the previous week are directly used as input to obtain the predicted value.

4. The traffic flow prediction method for multivariate traffic flow spatiotemporal data information according to claim 1, characterized in that: The multi-head attention mechanism is used to process the acquired hidden state information, including: MHAttention(H t )=Concat(MHAttention(H v ),TE) MHAttention(H v )=Concat(head1,head2,...head n )W O TE={TE1,…,TE i ,…} Among them, MHAttention(H t ) represents the output of the multi-head attention mechanism at time t; Concat(·) represents the concatenation operation; W O is the trainable parameter of multi-head attention; head i represents the output of the i-th head, n is the total number of heads in the multi-head attention, H represents the hidden state vector, represents the trainable weight matrix of the i-th head query vector, Represents the trainable weight matrix of the i-th head key vector; represents the trainable weight matrix of the i-th head value vector; d represents the length of the hidden state vector; T is the length of the input data.