Traffic Flow Prediction Method Based on Temporal Attention Recurrent Graph Convolutional Neural Network

Through the method of convolutional neural network based on time attention cyclic graph, the problem of poor traffic flow prediction in the prior art is solved, and a higher precision traffic flow prediction is achieved.

CN116434537BActive Publication Date: 2025-07-11HU BEI WU JING GAO SU GONG LU FA ZHAN YOU XIAN GONG SI +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211713940.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-29
Publication Date
2025-07-11
Estimated Expiration
2042-12-29

AI Technical Summary

Technical Problem

The prediction effect of traffic flow prediction methods in the prior art is poor and is not suitable for the current dramatic increase in data volume and more complex traffic flows.

Method used

The method based on the time attention cyclic graph convolution neural network is adopted. By obtaining the traffic flow signal matrix for preprocessing, the node-embedded graph convolution neural network is used for spatial feature extraction, and the time feature extraction is combined with the gated cyclic unit and the time attention layer to obtain the traffic flow prediction value of multiple time steps in the future.

Benefits of technology

Improve the accuracy of traffic flow prediction and can more accurately predict traffic flows in multiple time steps in the future.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116434537B_ABST
    Figure CN116434537B_ABST
Patent Text Reader

Abstract

The present invention provides a traffic flow prediction method based on a time attention recurrent graph convolutional neural network, which relates to the technical field of data processing. The method includes: obtaining traffic flow data to be predicted. Preprocessing the traffic flow data to be predicted and obtaining a traffic flow signal matrix. Extracting spatial features from the traffic flow signal matrix to obtain first feature data of the traffic flow data to be predicted. Extracting temporal features from the first spatial feature data to obtain second feature data of the traffic flow data to be predicted. Extracting temporal features from the second feature data to obtain third feature data of the traffic flow data to be predicted. And, using the third feature data of the traffic flow data to be predicted as an input to obtain an output result of a traffic flow prediction model, and obtaining a traffic flow prediction result according to the output result of the traffic flow prediction model. This method can improve the accuracy of traffic flow prediction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and particularly to a traffic flow prediction method based on a time attention recurrent graph convolutional neural network. Background Art

[0002] Intelligent transportation is the trend requirement for the development of modern transportation industry in the new era. Among them, traffic flow prediction is the basis for urban traffic resource control and optimization, and plays an important role in the intelligent transportation system. At present, a large number of information collection devices such as sensors have been deployed in major cities and highways. These information collection devices can collect a large amount of traffic flow data to be predicted and geographical location information, providing a reliable data source for traffic flow prediction.

[0003] Currently, the prediction methods of traffic flow mainly include statistical methods and traditional machine learning methods. Statistical methods usually rely on independence assumptions or linear assumptions. However, in fact, traffic evolution is a complex non-linear and dynamic process, which does not meet these assumptions. Therefore, the actual prediction effect of traffic flow prediction methods based on statistics is poor. Traditional machine learning methods include methods such as K-Nearest Neighbor (KNN) and Support Vector Regression (SVR). Traditional machine learning methods can model more complex non-linear data and achieve better performance than statistical methods, but they often require expert design and are no longer suitable for current traffic flow with a huge increase in data volume and more complex traffic evolution. Summary of the Invention

[0004] The technical problem to be solved by the present invention is that the prediction effect of the existing traffic flow prediction method is poor or not suitable for the current traffic flow with a huge increase in data volume and more complexity.

[0005] To solve the above technical problem, the present invention provides the following solutions:

[0006] On the one hand, the present invention provides a traffic flow prediction method based on a time attention recurrent graph convolutional neural network, the method comprising: obtaining traffic flow data to be predicted. Preprocessing the traffic flow data to be predicted and obtaining a traffic flow signal matrix X. According to GCN s (A pre , X) = sigmoid((I N + A pre ) XW s ) ⊙ (I N + A pre ) XW s and Extract the spatial features of the traffic flow signal matrix X to obtain the first feature data of the traffic flow data to be predicted is the traffic network adjacency matrix, I N is an N-dimensional diagonal matrix, W E is a learnable weight matrix, B E is a learnable bias vector, A pre is a predefined adjacency matrix based on geographical distance, ⊙ is the Hadamard product; GCN() represents the graph convolutional neural network embedded in the gated recurrent unit. According to and H t = z t ⊙H t-1 +(1 - z t )⊙h t extract the temporal features of the first spatial feature data of the traffic flow data to be predicted to obtain the second feature data H of the traffic flow data to be predicted t . t is the first moment, z t is the update gate of the first spatial feature data of the traffic flow data to be predicted at the first moment t, σ() is the sigmoid activation function, || is the matrix concatenation operation, r t is the reset gate of the first spatial feature data of the traffic flow data to be predicted at the first moment t, h t is the hidden state of the first spatial feature data of the traffic flow data to be predicted at the first moment t, tanh() is the non-linear activation function. According to H′ t [i, :] = H t [i, :] + e tp and add the time position embedding to the second feature data H of the traffic flow data to be predicted t . According to Y TA = Relu(Attention(Conv(H′ t ), Conv(H′ t ), Linear(H′ t )))+H t extract the temporal features of the second feature data H of the traffic flow data to be predicted t to obtain the third feature data Y of the traffic flow data to be predicted TA . Among them, Attention() is the attention matrix coefficient, Conv() and Linear() respectively represent the convolution operation and the linear transformation; softmax() and Relu() are both non-linear activation functions. And, the third feature data Y of the traffic flow data to be predicted TAAs an input, obtain the output result of the traffic flow prediction model, and obtain the traffic flow prediction result according to the output result of the traffic flow prediction model. The traffic flow prediction result is the prediction result for the next T h time steps; T h is the number of prediction time steps set manually.

[0007] In some embodiments, preprocess the traffic flow data to be predicted and obtain a traffic flow signal matrix, including: obtaining the missing data in the traffic flow data to be predicted. Use the method of sampling linear interpolation to fill in the missing data and obtain the completed traffic flow data to be predicted. Perform normalization processing on the completed traffic flow data to be predicted. And obtain the traffic flow signal matrix according to the completed traffic flow data to be predicted after normalization processing.

[0008] In some embodiments, perform spatial feature extraction on the traffic flow signal matrix to obtain the first feature data of the traffic flow data to be predicted, including: constructing a traffic network adjacency matrix using a node-embedded graph convolutional neural network. And perform spatial feature extraction on the traffic flow signal matrix according to the traffic network adjacency matrix to obtain the first feature data of the traffic flow data to be predicted.

[0009] In some embodiments, constructing a traffic network adjacency matrix using a node-embedded graph convolutional neural network includes: initializing the node embedding matrix to obtain the initialized node embedding matrix E adj . Multiply the initialized node embedding matrix E adj by the transpose of the initialized node embedding matrix matrix to obtain the first square matrix And, according to process the first square matrix and obtain the traffic network adjacency matrix

[0010] In some embodiments, perform temporal feature extraction on the second feature data of the traffic flow data to be predicted to obtain the third feature data of the traffic flow data to be predicted, including: according to map the second feature data of the traffic flow data to be predicted with time position embedding added to query vector Q C , key vector K C and value vector V l ; where

[0011] Q C , K C , V l ∈R N×T×C . Multiply the query vector Q C by the transpose of the key vector Multiply to obtain the time attention coefficient matrix score ∈ R N×T×C ; score ij represents the degree of association between time instants i and j. Normalize the time attention coefficient matrix score; and multiply the normalized time attention coefficient matrix score with the value vector V l to obtain the attention coefficient matrix Attention(Q, K, V). Also, using an activation function and residual operations, based on the attention coefficient matrix, obtain the third feature data of the traffic flow data to be predicted.

[0012] In some embodiments, the output result of the traffic flow prediction model includes traffic flow prediction values for multiple time steps.

[0013] In some embodiments, the method further includes: obtaining historical data of traffic flow. Preprocess the historical data of traffic flow and use the preprocessed historical data of traffic flow as the data set of the traffic flow prediction model. And, based on the data set of the traffic flow prediction model, perform model training through a gated recurrent unit, a time attention layer, and a convolutional layer, and obtain the traffic flow prediction model; in the gated recurrent unit, use a graph convolutional operation of node embedding to replace matrix multiplication; the time attention layer includes a time position embedding module, a time attention layer, and a residual connection.

[0014] In some embodiments, the traffic flow prediction model includes one or more gated recurrent units, one or more time attention layers, and a convolutional layer, and one convolutional layer is the output layer of the traffic flow prediction model.

[0015] In a second aspect, the present invention provides a computer-readable storage medium storing computer program instructions, which when running on a computer, cause the computer to execute the traffic flow prediction method based on a time attention recurrent graph convolutional neural network described in any one of the above embodiments.

[0016] The traffic flow prediction method based on a time attention recurrent graph convolutional neural network provided by the present invention uses a gated recurrent unit and a time attention layer to perform spatial feature extraction and time feature extraction on the traffic flow data to be predicted, and obtains traffic flow prediction values for multiple future time steps, which can improve the accuracy of traffic flow prediction. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings are used to provide a further understanding of the technical solutions of the present invention, and constitute a part of the specification. They are used together with the embodiments of the present invention to explain the technical solutions of the present invention, and do not constitute a limitation to the technical solutions of the present invention.

[0018] Figure 1A Structural diagram of a traffic flow prediction model according to some embodiments of the present invention;

[0019] Figure 1B Flowchart of a traffic flow prediction method based on a time attention recurrent graph convolutional neural network according to some embodiments of the present invention;

[0020] Figure 2 Flowchart of another traffic flow prediction method based on a time attention recurrent graph convolutional neural network according to some embodiments of the present invention;

[0021] Figure 3 Flowchart of yet another traffic flow prediction method based on a time attention recurrent graph convolutional neural network according to some embodiments of the present invention;

[0022] Figure 4 Flowchart of yet another traffic flow prediction method based on a time attention recurrent graph convolutional neural network according to some embodiments of the present invention;

[0023] Figure 5 Flowchart of yet another traffic flow prediction method based on a time attention recurrent graph convolutional neural network according to some embodiments of the present invention;

[0024] Figure 6 Flowchart of yet another traffic flow prediction method based on a time attention recurrent graph convolutional neural network according to some embodiments of the present invention;

[0025] Figure 7 Flowchart of yet another traffic flow prediction method based on a time attention recurrent graph convolutional neural network according to some embodiments of the present invention;

[0026] Figure 8 Flowchart of yet another traffic flow prediction method based on a time attention recurrent graph convolutional neural network according to some embodiments of the present invention;

[0027] Figure 9 Flowchart of yet another traffic flow prediction method based on a time attention recurrent graph convolutional neural network according to some embodiments of the present invention. Detailed implementation manners

[0028] Embodiments of the present invention provide a traffic flow prediction method based on a time attention recurrent graph convolutional neural network, using a traffic flow prediction model as shown in Figure 1A Given a historical traffic signal matrix of length T h the goal of traffic flow prediction is to build a model that takes X as input and outputs a traffic flow matrix Y for the next T' time steps ​pre ∈R N×T′×C . Where N represents the number of traffic network nodes, and C represents the number of traffic characteristics. If only traffic flow data is input into the model, then C = 1. As Figure 1B shown, the method may include steps 101 to 106.

[0029] Step 101, obtain the traffic flow data to be predicted.

[0030] Understandably, the source of the traffic flow data to be predicted can be a large number of information collection devices such as sensors deployed in major cities and highways.

[0031] Step 102, preprocess the traffic flow data to be predicted and obtain a traffic flow signal matrix.

[0032] Understandably, information collection devices are mostly located in outdoor environments. Due to reasons such as weather, there may be cases where information collection devices are damaged, resulting in incomplete data for the traffic flow data to be predicted.

[0033] In this case, as Figure 2 shown, the implementation method of step 102 may include steps 201 to 204.

[0034] Step 201, obtain the missing data in the traffic flow data to be predicted.

[0035] Exemplarily, the data integrity can be checked and the data can be processed into a traffic flow matrix of size N*T. Where N represents the number of data collection points in the traffic network, and T represents the number of time slices.

[0036] Step 202, fill the missing data by sampling the linear interpolation method to obtain the traffic flow data to be predicted after completion.

[0037] Linear interpolation is a commonly used, simple and effective method for filling missing data.

[0038] Step 203, perform normalization processing on the traffic flow data to be predicted after completion.

[0039] Understandably, normalization is a way to simplify calculations, that is, to transform a dimensional expression into a dimensionless expression to become a scalar. The normalization method adopted in the embodiments of the present invention can be a linear normalization method, or a zero-mean normalization (Z-score standardization) method, or can also be a non-linear normalization method. The present invention does not limit the normalization method.

[0040] Step 204: Obtain a traffic flow signal matrix based on the completed traffic flow data to be predicted after normalization processing.

[0041] Based on the traffic flow matrix obtained in Step 201, through Steps 202 and 203, a traffic flow signal matrix can be obtained.

[0042] Step 103: Extract spatial features from the traffic flow signal matrix to obtain first feature data of the traffic flow data to be predicted.

[0043] In some embodiments, as Figure 3 shown, the implementation method of Step 103 may include Steps 301 to 302.

[0044] Step 301: Construct a traffic network adjacency matrix using a node-embedded graph convolutional neural network.

[0045] The traffic network adjacency matrix obtained in Step 301 can be used to extract spatial features of traffic flow data. The dynamic modeling of the traffic network adjacency matrix is adaptively generated using a learnable node embedding matrix, and the node-embedded graph convolutional neural network can use the spatial domain graph convolutional neural network of Equation (1).

[0046]

[0047] In Equation (1), A represents the standard traffic network adjacency matrix, X represents the normalized traffic flow matrix, σ represents the Relu activation function, I N represents the N-dimensional identity matrix, and w and b represent the learnable weight matrix and bias vector.

[0048] The dynamic modeling of the standard traffic network adjacency matrix A to obtain the traffic network adjacency matrix in the embodiments of the present invention is the key to extracting spatial correlation information of traffic flow. In the present invention, a learnable node embedding matrix is used to adaptively fit the cross-correlation weights between traffic nodes through the training of the prediction model. In this case, as Figure 4 shown, the implementation method of Step 301 may include Steps 401 to 403.

[0049] Step 401: Initialize the node embedding matrix.

[0050] Exemplarily, the initialization method can be a randomly generated method.

[0051] Step 402: Multiply the initialized node embedding matrix by the transposed matrix of the initialized node embedding matrix to obtain a first square matrix.

[0052] Exemplarily, the initialized node embedding matrix can be E adj , and Let \(N\) be the number of nodes in the traffic network, and \(d\) e be the dimension of node embedding. The initialized node embedding matrix is a \(d\times N\) e matrix, and the transpose of the initialized node embedding matrix is an \(N\times d\) e matrix. Multiplying the two can obtain an \(N\times N\) matrix, which is the first square matrix.

[0053] Step 403: Process the first square matrix using an activation function and obtain the traffic network adjacency matrix.

[0054] The activation function in Step 403 can be the Relu function and the softmax function. At this time, the implementation method of Step 403 can be as shown in Equation (2), specifically: removing the values less than 0 in the first square matrix through the Relu function, and using the softmax function to normalize the first square matrix after removing the values less than 0. Thus, the traffic network adjacency matrix is obtained.

[0055]

[0056] Equation (2) fits as a whole to avoid the additional computational resource overhead caused by matrix decomposition.

[0057] The weight matrix \(W\) and the bias vector \(b\) in Equation (1) are shared by all traffic nodes, making the model only able to capture the shared traffic patterns of all nodes. However, in reality, each traffic node has its specific traffic pattern. In the present invention, a parameter is set for each node so that the model can capture the traffic patterns of traffic nodes in a finer granularity. Specifically, two matrices and together with the node embedding matrix \(E\) adj generate the weight matrix \(W\) E and the bias vector \(B\) E for each node, as shown in Equation (3).

[0058] \(W\) E \(=\) \(E\) adj \(\cdot\) \(w\) e \(,\) \(B\) E \(=\) \(E\) adj \(\cdot\) \(b\) e (3)

[0059] Step 302: Extract spatial features from the traffic flow signal matrix according to the traffic network adjacency matrix to obtain the first feature data of the traffic flow data to be predicted.

[0060] Exemplarily, the method for extracting spatial features from the traffic flow signal matrix according to the traffic network adjacency matrix can be as shown in Equations (4) and (5).

[0061] GCN s (A pre , X) = sigmoid((I N + A pre ) XW s ) ⊙ (I N + A pre ) XW s (4)

[0062]

[0063] In equations (4) and (5), X is the traffic flow signal matrix; GCN() represents the Graph Convolutional Neural Network (GCN) embedded in the gated recurrent unit, is the first feature data of the traffic flow data to be predicted, I N is an N-dimensional diagonal matrix, W E is a learnable weight matrix, B E is a learnable bias vector, A pre is a predefined adjacency matrix based on geographical distance, and ⊙ is the Hadamard product.

[0064] Exemplarily, the predefined adjacency matrix A based on geographical distance can be obtained according to equation (6) pre .

[0065]

[0066] In equation (4), distance(i, j) is the distance between traffic nodes i and j; τ ∈ (0, 0.1), which can be set according to specific circumstances. The predefined adjacency matrix is calculated based on the physical distances of each traffic node and cannot express the true node associations. Therefore, the gated mechanism shown in equation (2) can filter out some inaccurate information among them.

[0067] Embodiments of the present invention employ a series of cascaded GRU units to capture local temporal correlation information of traffic flow, which will be described in detail below.

[0068] Step 104: Extract the temporal features of the first temporal feature of the traffic flow data to be predicted to obtain the second feature data of the traffic flow data to be predicted.

[0069] Exemplarily, the gated recurrent unit can be used to extract the temporal features in the first spatial feature data of the traffic flow data to be predicted. In this case, as Figure 5 shown, the implementation method of step 104 can include steps 501 to 503.

[0070] Step 501: Obtain the update gate and reset gate of the first spatial feature data of the traffic flow data to be predicted at the first moment.

[0071] Exemplarily, the update gate of the first spatial feature data of the traffic flow data to be predicted at the first moment can be obtained through Equation (7).

[0072]

[0073] In Equation (7), t is the first moment, which can be set according to the actual situation, and z t is the update gate of the first spatial feature data of the traffic flow data to be predicted at the first moment t, σ() is the sigmoid activation function, and || is the matrix concatenation operation.

[0074] Exemplarily, the reset gate of the first spatial feature data of the traffic flow data to be predicted at the first moment can be obtained through Equation (6).

[0075]

[0076] In Equation (8), r t is the reset gate of the first spatial feature data of the traffic flow data to be predicted at the first moment t.

[0077] Step 502: Obtain the hidden state of the first spatial feature data of the traffic flow data to be predicted at the first moment according to the first spatial feature data of the traffic flow data to be predicted and the reset gate of the first spatial feature data of the traffic flow data to be predicted at the first moment.

[0078] Exemplarily, the hidden state of the first spatial feature data of the traffic flow data to be predicted at the first moment can be obtained through Equation (9).

[0079]

[0080] In Equation (9), h t is the hidden state of the first spatial feature data of the traffic flow data to be predicted at the first moment t, and tanh() is the non-linear activation function.

[0081] Step 503: Obtain the second feature data of the traffic flow data to be predicted according to the hidden state of the first spatial feature data of the traffic flow data to be predicted at the first moment and the update gate of the first spatial feature data of the traffic flow data to be predicted at the first moment.

[0082] Exemplarily, the specific implementation method of Step 503 can be as shown in Equation (10).

[0083] H t = zt ⊙H t-1 +(1 - z t )⊙h t (10)

[0084] In Equation (10), H t is the output of the first spatial feature data of the traffic flow data to be predicted at the first moment t. Understandably, H t is the second feature data of the traffic flow data to be predicted.

[0085] Step 105: Extract time features from the second feature data of the traffic flow data to be predicted to obtain the third feature data of the traffic flow data to be predicted.

[0086] In some embodiments, as Figure 6 shown, the implementation method of Step 105 may include Step 601 to Step 605.

[0087] Step 601: Add time position embeddings to the second feature data of the traffic flow data to be predicted.

[0088] Understandably, the self - attention calculation function treats each position equally in the attention mechanism, that is, it ignores the order of the data. Therefore, the embodiments of the present invention use the method of time position embeddings to add time position embeddings to the traffic flow matrix output by the gated recurrent unit. Exemplarily, time position embeddings can be added according to Equation (9) and Equation (10).

[0089] H′ t [i, :] = H t [i, :] + e tp (9)

[0090]

[0091] In Equation (10), H t ′ is the second feature data of the traffic flow data to be predicted with time position embeddings added, d mode1 is the time position embedding dimension.

[0092] Next, input the second feature data of the traffic flow data to be predicted with time position embeddings added into the time attention layer to capture global time - correlation information.

[0093] Step 602: Use the methods of convolution operation and linear transformation to map the second feature data of the traffic flow data to be predicted with time position embeddings added into query vectors, key vectors, and value vectors.

[0094] Exemplarily, the second feature data of the traffic flow data to be predicted with time position embedding can be mapped to a query vector Q according to Equation (11). C , a key vector K C and a value vector V1

[0095]

[0096] In Equation (11), Q C , K C , V l ∈R N×T×C , where Conv() and Linear() represent a convolution operation and a linear transformation respectively.

[0097] Step 603: Multiply the query vector by the transpose of the key vector to obtain a time attention coefficient matrix.

[0098] Exemplarily, multiplying the query vector Qc by the transpose of the key vector can obtain a time attention coefficient matrix where score ∈ R N×T×C , and score ij represents the degree of association between time instants i and j.

[0099] Step 604: Normalize the time attention coefficient matrix; and multiply the normalized time attention coefficient matrix by the value vector to obtain an attention coefficient matrix.

[0100] Exemplarily, the time attention coefficient matrix can be normalized by the softmax function and then multiplied by the value vector V1 to obtain an attention coefficient matrix.

[0101] Step 605: Use an activation function and a residual operation to obtain the third feature data of the traffic flow data to be predicted according to the attention coefficient matrix.

[0102] Exemplarily, the third feature data of the traffic flow data to be predicted can be obtained according to Equation (12) and Equation (13) based on the attention coefficient matrix.

[0103]

[0104] Y TA = Relu(Attention(Conv(H′ t ), Conv(H′ t ), Linear(H′ t )))+H t (13)

[0105] In Formula (12) and Formula (13), Attention() is the attention matrix coefficient, and both softmax() and Relu() are non-linear activation functions.

[0106] Step 106: Use the third feature data of the traffic flow data to be predicted as the input, obtain the output result of the traffic flow prediction model, and obtain the traffic flow prediction result according to the output result of the traffic flow prediction model.

[0107] Exemplarily, the traffic flow prediction model may include: a node-embedded graph convolutional neural network, a series of cascaded gated recurrent units, a temporal attention layer, and a prediction layer based on a convolutional neural network. The node-embedded graph convolutional neural network is used to extract the spatial features of the traffic flow, and then the gated recurrent unit (GRU) is used to capture the local temporal correlation information of the traffic flow. Then, a temporal position embedding is added to the traffic flow matrix output by the GRU, and the attention mechanism is used in the temporal dimension to calculate the cross-correlation degree between each time slice. Finally, a one-dimensional convolutional neural network is used as the output layer to predict the traffic flow of all traffic nodes in the next T' time slices. Here, T' is the target prediction length.

[0108] In some embodiments, a traffic flow prediction original model based on a temporal attention recurrent graph convolutional neural network can be constructed using the pytorch deep learning framework. By training this original model, a traffic flow prediction model can be obtained. As Figure 7 shown, the method for obtaining the traffic flow prediction model may include steps 701 to 703.

[0109] Step 701: Obtain the historical data of the traffic flow.

[0110] It can be understood that the historical data of the traffic flow can be obtained by an information collection device. For example, the data collected by the information collection device in the past year can be used as the historical data of the traffic flow.

[0111] Step 702: Preprocess the historical data of the traffic flow, and use the preprocessed historical data of the traffic flow as the dataset of the traffic flow prediction model.

[0112] It can be understood that the dataset of the traffic flow prediction model may include a training set, a validation set, and a test set. Exemplarily, the ratio of the data volume of the training set, the data volume of the validation set, and the data volume of the test set can be 6:2:2.

[0113] Step 703: According to the dataset of the traffic flow prediction model, perform model training through a gated recurrent unit, a temporal attention layer, and a convolutional layer, and obtain the traffic flow prediction model.

[0114] Understandably, the original traffic flow prediction can be trained using the training set, and then the trained model can be evaluated using the validation set until the trained model converges. During the training process, the L1 loss function can be used for loss calculation, and Adam can be used as the optimizer.

[0115] Exemplarily, the training process may include: initializing the model by loading the data parameter file. Loading the training set and validation set data to start training. Conducting the first round of training, i.e., epoch = 1, and initializing the parameters E adj , w e , b e and other model parameters according to the parameter file. The training set is input into the traffic flow prediction model in batches to start the first round of training. The prediction model performs backpropagation to update the model parameters. The validation set data is input into the model after the first round of training for validation, the validation loss is calculated, and the training parameter file of the traffic flow prediction model is saved (except for the first round of training, the prediction model training parameter file is only saved in the subsequent training when the validation loss is less than the current minimum validation loss). In addition, during the validation phase, no backpropagation is performed, and only the loss is calculated. The training set is cyclically trained and the validation set is used for verification until the current training round number is greater than the set maximum training round number or the validation set loss has not decreased for 50 consecutive training rounds, at which point the training ends. Finally, traffic flow prediction is performed on the test set data.

[0116] Exemplarily, as Figure 8 shown, the specific steps for the first round of training on the training set are as follows:

[0117] 1) Input the data X, E adj , w e , b e into the graph convolutional layer.

[0118] 2) Multiply E adj by its transpose, and obtain the first-round dynamic adjacency matrix through the Relu and softmax functions; Multiply E adj by w e , b e to obtain the weight matrix W E and the bias matrix B E .

[0119] 3) Calculate the output of the node-embedded graph convolutional layer.

[0120] 4) Input the output matrix of the node-embedded graph convolutional layer into a series of cascaded GRU units to update the hidden state;

[0121] 5) Add a temporal position embedding to the hidden state output by the last gated recurrent unit.

[0122] 6) Input the traffic flow matrix with the added temporal position embedding into the temporal attention layer, and distributively map it into a query vector Q C , a key vector K C and a value vector V l .

[0123] 7) Multiply the query vector Q C by the transpose of the key vector , then divide by the feature dimension, and normalize the attention coefficient matrix through the softmax function. Finally, multiply it by the value vector V l to obtain the output score of the temporal attention layer.

[0124] 8) Activate the score with the Relu function and add a residual connection, that is, add it to the traffic flow matrix without the added temporal position embedding to obtain Y TA .

[0125] 9) Input Y TA into the final one-dimensional convolutional prediction layer to obtain the prediction result of the first round and calculate the loss. Use the L1 loss as the loss function.

[0126] Exemplarily, as Figure 9 shown, for traffic flow prediction of the test set data, the specific steps are as follows:

[0127] 1) Build a traffic flow prediction model, load the model parameter file with the minimum validation loss saved during training to initialize the model; change the prediction model from the training mode to the prediction mode.

[0128] 2) Load the test set data and input it into the model to make predictions on the test set.

[0129] 3) Calculate the mean absolute error MAE, root mean square error RMSE, and mean absolute percentage error MAPE of the predicted values based on the true traffic flow values and output them.

[0130] 4) Save the traffic flow prediction data file.

[0131] In the gated recurrent unit of step 703, use the graph convolutional operation with node embeddings to replace the matrix multiplication. The temporal attention layer includes a temporal position embedding module, a temporal attention layer, and a residual connection.

[0132] It can be understood that the gated recurrent unit block can combine the temporal and spatial features of the traffic flow data to be predicted. The operations of the temporal attention layer can refer to the relevant descriptions in steps 104 and 105.

[0133] In some embodiments, the traffic flow prediction model includes one or more gated recurrent units, one or more temporal attention layers, and a convolutional layer, and the convolutional layer is the output layer of the traffic flow prediction model.

[0134] Understandably, when dealing with traffic flow data to be predicted in more complex or specific scenarios, more gated recurrent units can be cascaded in the model and more temporal attention layers can be stacked.

[0135] Understandably, using a one-dimensional convolutional neural network as the prediction layer of this traffic flow prediction method, this convolutional operation predicts the traffic flow values of multiple time steps at once instead of step by step, and this method can avoid the error accumulation caused by step-by-step prediction. In this case, the output result of the traffic flow prediction model includes the traffic flow prediction values of multiple time steps.

[0136] Exemplarily, a one-dimensional convolutional neural network can be adopted to input the traffic flow signal matrix of the past 12 time slices and output the traffic flow signal matrix of the future 12 time slices.

[0137] Exemplarily, when using the traffic flow prediction model to predict traffic flow, the mean absolute error (MAE), root mean square error (RMSE), and mean absolute percentage error (MAPE) can be used as evaluation criteria.

[0138] The traffic flow prediction method based on the temporal attention recurrent graph convolutional neural network provided by the embodiments of the present invention uses gated recurrent units and temporal attention layers to extract spatial features and temporal features from the traffic flow data to be predicted, and obtains the traffic flow prediction values of multiple future time steps, which can improve the traffic flow prediction accuracy.

[0139] The embodiments of the present invention also provide a computer-readable storage medium. The computer-readable storage medium stores computer program instructions. When the computer program instructions run on a computer, the computer is enabled to execute the traffic flow prediction method based on the temporal attention recurrent graph convolutional neural network described in any one of the above embodiments.

[0140] For the specific scheme and beneficial effects of the computer-readable storage medium provided by the embodiments of the present invention, reference can be made to the related descriptions of the traffic flow prediction method based on the temporal attention recurrent graph convolutional neural network in the above embodiments, and details are not described herein again.

[0141] As described above, it is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims

1. A traffic flow prediction method based on a time attention recurrent graph convolutional neural network, characterized in that Including: Obtain the traffic flow data to be predicted; Preprocess the traffic flow data to be predicted and obtain the traffic flow signal matrix X; According to GCN s (A pre , X) = sigmoid((I N + A pre ) XW s ) ⊙ (I N + A pre ) XW s and extract spatial features from the traffic flow signal matrix X to obtain the first feature data of the traffic flow data to be predicted Specifically: Initialize the node embedding matrix to obtain the initialized node embedding matrix E adj ; Embed the node embedding matrix E after initialization adj with the transpose of the node embedding matrix after initialization and multiply them to obtain the first square matrix and According to process the first square matrix and obtain the traffic network adjacency matrix and According to the traffic network adjacency matrix perform spatial feature extraction on the traffic flow signal matrix to obtain first feature data of the traffic flow data to be predicted; wherein, is the traffic network adjacency matrix, I N is an N-dimensional diagonal matrix, W E is a learnable weight matrix, B E is a learnable bias vector, A pre is a predefined adjacency matrix based on geographical distance, and The distance between traffic nodes i and j; τ ∈ (0, 0.1), ⊙ is the Hadamard product; GCN() represents the graph convolutional neural network embedded in the gated recurrent unit; According to and H t = z t ⊙ H t-1 + (1 - z t ) ⊙ h t Perform time feature extraction on the first spatial feature data of the traffic flow data to be predicted to obtain the second feature data H of the traffic flow data to be predicted t ; t is the first moment, z t is the update gate of the first spatial feature data of the traffic flow data to be predicted at the first moment t, σ() is the sigmoid activation function, || is the matrix concatenation operation, r t is the reset gate of the first spatial feature data of the traffic flow data to be predicted at the first moment t, h t is the hidden state of the first spatial feature data of the traffic flow data to be predicted at the first moment t, tanh() is the non-linear activation function; According to H′ t [i, :] = H t [i, :] + e tp and Add time position embedding to the second feature data H of the traffic flow data to be predicted t therein; According to Y TA = Relu(Attention(Conv(H′ t ), Conv(H′ t ), Linear(H′ t )))) + H t Extract time features from the second feature data H of the traffic flow data to be predicted, and obtain the third feature data Y of the traffic flow data to be predicted t ; where Attention() is the attention matrix coefficient, Conv() and Linear() are convolution operations and linear transformations; softmax() and Relu() are both non-linear activation functions; and TA ​ Take the third feature data Y of the traffic flow data to be predicted TA as input, obtain the output result of the traffic flow prediction model, and obtain the traffic flow prediction result according to the output result of the traffic flow prediction model. The traffic flow prediction result is the prediction result for the next T h time steps; T h is the number of prediction time steps set artificially.

Citation Information

Patent Citations

  • Traffic prediction method and device based on dynamic space-time diagram convolution attention model

    CN113487088A

  • Network traffic prediction method based on attention mechanism and graph convolutional neural network

    CN113852492A