Road traffic flow prediction method based on multi-angle fusion of encoder and decoder
Through the multi-angle fusion attention network model MFAN based on the encoder and decoder, the traffic flow data, road network, weather and holiday information are integrated, and the spatiotemporal attention mechanism is used for traffic flow prediction, which solves the problem of insufficient prediction accuracy in the existing technology. , achieving higher traffic flow prediction accuracy.
Patent Information
- Application Number
- CN202111420461.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-26
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2041-11-26
AI Technical Summary
Existing traffic flow prediction methods are difficult to quickly adapt to short-term traffic flow changes, and fail to effectively consider the impact of emergencies, weather, holidays and other factors, resulting in insufficient prediction accuracy.
The multi-angle fusion attention network model MFAN based on the encoder-decoder is used to collect and integrate historical traffic flow data, road network information, weather and holiday information, and combine the spatio-temporal attention mechanism to predict traffic flow, forming a multi-angle spatio-temporal embedding representation. Used to train traffic flow prediction models.
It improves the accuracy of traffic flow prediction, can dynamically consider the interaction between different time points and intersections, adapt to various emergencies, and improves the accuracy of prediction.
Smart Images

Figure CN114091772B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of traffic flow prediction, and in particular to a road traffic flow prediction method based on a multi-angle fusion of encoders and decoders. Background Art
[0002] With the continuous increase in the number of motor vehicles, traffic congestion has become a huge challenge faced by urban construction and management in the current national urbanization process. Analyzing and predicting dynamic traffic conditions is of great significance to the planning and construction of new roads in the new era and the traffic management of smart cities.
[0003] However, traffic flow prediction has become increasingly challenging. First, it relies on the volatility and uncertainty of vehicle flow in the temporal dimension. Vehicle traffic often has long-term periodicity, so it is easier to summarize and predict in the long-term case. However, there are many uncertainties in the short term, and the existing methods are difficult to quickly adapt the prediction model to the rapid changes of such traffic flow in sudden situations such as traffic accidents and special events. Secondly, the complex relationship between roads and vehicles also plays an important role in the spatial dimension. For example, the time evolution of traffic flow caused by an event on a certain road will affect distant roads in the near future. In addition, due to the complexity of road intersections or lanes, the interaction between roads is not easy to identify, resulting in difficulties in predicting the direction of traffic flow. Most of the existing methods only consider the historical traffic flow data and time information of the road for modeling, and learn a general law from it, but do not comprehensively consider the dynamic changes of various factors such as sudden traffic conditions, weather conditions, holidays, etc. Summary of the invention
[0004] In view of the problems existing in the prior art, the present invention provides a road traffic flow prediction method based on a multi-view fusion of encoder-decoder, and proposes a multi-view fusion attention network model MFAN (Multi-View Fuse Attention Network) based on an encoder-decoder structure, which comprehensively considers various sudden traffic conditions, weather conditions, holidays and other factors to achieve dynamic and accurate prediction of road network traffic flow.
[0005] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0006] A road traffic flow prediction method based on multi-angle fusion of encoder and decoder, comprising the following steps:
[0007] Step 1: Collect historical traffic flow data of the intersection to be predicted within a specified time period to form a two-dimensional traffic flow matrix;
[0008] The historical GPS data of vehicles passing through the intersection to be predicted within a specified time period is matched with the road network data and converted into historical traffic flow data to obtain the traffic flow sequence {V1, V2, V3, … V p}, p is the number of intersections in the city, and the traffic flow sequence of the intersection i to be predicted is V i = {v i,1 ,v i,2 ,v i,3 ,…,v i,n}, n is the number of time intervals, v i,n represents the traffic flow of the i-th intersection in the n-th period of time;
[0009] Step 2: Collect the road network information of the area where the intersection to be predicted is located, and obtain the spatial representation information of the road network;
[0010] The road network is a directed graph G = (V, E, A), where V represents the number of nodes in the road network, i.e., the number of intersections, V = p, E represents the edge, i.e., the road section in the road network, and A∈R V*V , A represents the adjacency matrix of the generation weight, R V*V The dimension of A is V*V; the spatial vector is sent into a two-layer fully connected network to obtain the spatial embedding representation of the road network information, that is, the spatial representation information of the road network The intersection point v i ∈V, S marking is the spatial embedding representation vector of the road network, with a dimension of D;
[0011] Step 3: Collect weather and holiday information of the area where the intersection to be predicted is located, and obtain weather information and holiday information of the road network;
[0012] The weather information of the road network includes six types of weather conditions that vehicles may encounter while driving on the road: strong wind, light rain, moderate rain, heavy rain, heavy snow, and sunny days. The weather embedded representation information of the road network is obtained The intersection point vi∈V, marked by W is the weather embedding representation vector of the road network, with dimension D;
[0013] Under the condition that the holiday representation information of the road network is the national statutory holiday information, the holiday embedded representation information of the road network is obtained. The intersection point vi∈V, H marks is the weather embedding representation vector of the road network, with dimension D;
[0014] Step 4: Perform multi-angle fusion of quarterly, monthly, weekly, date, and hourly information within the historical time period to obtain the time embedded representation of the road network information, that is, the time representation information of the road network The intersection point vi ∈V, T label It is the time embedding representation vector of the road network, and its dimension is D.
[0015] Step 5: Fuse the multi-angle temporal and spatial information. Fuse the embedding representations of the four angles of space, weather, holidays, and time of the intersection obtained in steps 2-4 to form a multi-angle spatiotemporal embedding representation MTSE. j Lower intersection point v i , MTSE is defined as MTSE includes road network information as well as time, weather, and holiday information.
[0016] Step 6: Perform z-score normalization on the traffic flow data and divide the normalization results into training set, validation set, and test set;
[0017] The z-score standardization process is to divide the difference between each value in the original traffic flow data and the average value of all data by the standard deviation;
[0018] Step 7: Design a multi-angle fusion attention neural network MFAN for predicting traffic flow and train it using the training set;
[0019] The neural network includes an input layer, a fully connected layer, an attention mechanism encoder, a conversion attention layer, an attention mechanism decoder, and an output layer; the traffic flow data X∈R of the historical intersection of A time steps is converted into AxPxC Passed into the input layer, a two-layer fully connected layer converts X into H (0) ∈R AxPxD As the input of the attention mechanism encoder, the attention mechanism encoder consists of K spatiotemporal attention blocks TSAB, where each spatiotemporal attention block consists of a spatial attention block, a temporal attention block and a gated fusion unit; H (0) Through K spatiotemporal attention blocks TSAB, the output of the attention encoder is H (K) ∈R AxPxD , H (K) Passed into the conversion attention layer, the encoded feature H is converted through a conversion attention layer (K) Generate future traffic flow feature sequence representation H (K+1) ∈R BxPxD , which is used as the input of the attention mechanism decoder. The attention mechanism decoder consists of K spatiotemporal attention blocks TSAB, H (K+1) Through the attention mechanism decoder, the output is H (2K+1) ∈RR BxPxD , and then H (2K+1) After a two-layer fully connected network, the predicted traffic flow value of the intersection in the next B time steps is generated
[0020] Step 8: Use the validation set to test the model trained with the training set and evaluate the model error. If the error is greater than the set threshold, readjust the model hyperparameters and return to step 7 to train again. If it is less than the set threshold, jump to step 9.
[0021] Step 9: Use the test set to evaluate the prediction effect of the model. The test set is divided into a historical data set and a prediction result set. The traffic flow data of the road section to be predicted at a set time in the historical data set is input into the trained model to obtain the traffic flow situation at the intersection at the set time predicted by MFAN. The traffic flow situation is compared with the data in the prediction result set to perform traffic flow prediction.
[0022] The beneficial effects produced by the present invention are:
[0023] The present invention proposes a road traffic flow prediction method based on a multi-angle fusion of encoders and decoders. The present invention considers various possible situations that affect road traffic flow, regards the entire road network as a dynamic directed graph, and dynamically considers the impact of different time points on the same intersection and the mutual impact between different intersections at the same time point. The method of the present invention has a high accuracy rate in predicting future dynamic traffic flow. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 This is an overall flow chart of the traffic flow prediction method in an embodiment of the present invention;
[0025] Figure 2 This is a schematic diagram of the structure of the multi-angle fusion attention network model MFAN in an embodiment of the present invention;
[0026] Figure 3 This is a multi-angle spatiotemporal information fusion diagram in an embodiment of the present invention;
[0027] Figure 4 Schematic diagram of the spatiotemporal attention block structure in an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The specific implementation of the present invention is further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0029] A road traffic flow prediction method based on multi-angle fusion of encoder-decoder, such as Figure 1 As shown, the following steps are included:
[0030] Step 1: Collect historical traffic flow data of the intersection to be predicted within a specified time period to form a two-dimensional traffic flow matrix;
[0031] The historical GPS data of vehicles passing through the intersection to be predicted within a specified time period is matched with the road network data and converted into historical traffic flow data to obtain the traffic flow sequence {V1, V2, V3, … V p}, p is the number of intersections in the city, and the traffic flow sequence of the intersection i to be predicted is V i = {v i,1 ,v i,2 ,v i,3 ,…,v i,n}, n is the number of time intervals, v i,n represents the traffic flow of the i-th intersection in the n-th period of time;
[0032] Step 2: Collect the road network information of the area where the intersection to be predicted is located, and obtain the spatial representation information of the road network;
[0033] The road network is a directed graph G = (V, E, A), where V represents the number of nodes in the road network, i.e., the number of intersections, V = p, E represents the edge, i.e., the road section in the road network, and A∈R V*V , A represents the adjacency matrix of the generation weight, R V*V The dimension of A is V*V; the spatial vector is sent into a two-layer fully connected network to obtain the spatial embedding representation of the road network information, that is, the spatial representation information of the road network The intersection point v i ∈V, S marking is the spatial embedding representation vector of the road network, with a dimension of D;
[0034] Step 3: Collect weather and holiday information of the area where the intersection to be predicted is located, and obtain weather information and holiday information of the road network;
[0035] The weather information of the road network includes six types of weather conditions that vehicles may encounter while driving on the road: strong wind, light rain, moderate rain, heavy rain, heavy snow, and sunny days. The weather embedded representation information of the road network is obtained The intersection point vi∈V, marked by W is the weather embedding representation vector of the road network, with dimension D;
[0036] Under the condition that the holiday representation information of the road network is the national statutory holiday information, the holiday embedded representation information of the road network is obtained. The intersection point vi∈V, H marks is the weather embedding representation vector of the road network, with dimension D;
[0037] Step 4: Multi-angle integration of quarterly, monthly, weekly, date, and hourly information within the historical time period, such as Figure 3 As shown in the figure, the time embedding representation of the road network information is obtained, that is, the time representation information of the road network The intersection point v i ∈V, T label It is the time embedding representation vector of the road network, and its dimension is D.
[0038] In this embodiment, each time interval of the historical traffic flow is encoded as a vector. Each day is set as M time intervals, and one-hot encoding is used to encode according to the four seasons of the year, three months of a season, four weeks of a month, seven days of a week, and M segments of a day as time steps, encoded as R 4+3+4+7+M Dimensional Use a two-layer fully connected network to convert temporal features into an R D dimensional vector.
[0039] Step 5: Fuse the multi-angle temporal and spatial information. In order to obtain a comprehensive representation of the intersection in terms of specific time, weather, and holidays, the embedded representations of the four angles of space, weather, holidays, and time of the intersection obtained in steps 2-4 are fused to form a multi-angle spatiotemporal embedding representation MTSE. j Lower intersection point v i , MTSE is defined as MTSE includes road network information as well as time, weather, and holiday information.
[0040] Step 6: Perform z-score normalization on the traffic flow data and divide the normalization results into training set, validation set, and test set;
[0041] The z-score standardization process is to divide the difference between each value in the original traffic flow data and the average value of all data by the standard deviation; in this embodiment, the training set accounts for 70% of the total data volume, the validation set accounts for 20%, and the test set accounts for 10%.
[0042] Step 7: Design a multi-angle fusion attention neural network MFAN for predicting traffic flow and train it using the training set;
[0043] The neural network includes an input layer, a fully connected layer, an attention mechanism encoder, a conversion attention layer, an attention mechanism decoder, and an output layer; its structure diagram is as follows Figure 2 As shown, the traffic flow data X∈R of the historical intersection of A time steps AxPxC Passed into the input layer, a two-layer fully connected layer converts X into H (0) ∈R AxPxD As the input of the attention mechanism encoder, the attention mechanism encoder consists of K spatiotemporal attention blocks TSAB, such as Figure 4 As shown in Figure 2, each spatiotemporal attention block consists of a spatial attention block, a temporal attention block, and a gated fusion unit; H (0)Through K spatiotemporal attention blocks TSAB, the output of the attention encoder is H (K) ∈R AxPxD , H (K) Passed into the conversion attention layer, the encoded feature H is converted through a conversion attention layer (K) Generate future traffic flow feature sequence representation H (K+1) ∈R BxPxD , which is used as the input of the attention mechanism decoder. The attention mechanism decoder consists of K spatiotemporal attention blocks TSAB, H (K+1) Through the attention mechanism decoder, the output is H (2K+1) ∈RR BxPxD , and then H (2K+1) After a two-layer fully connected network, the predicted traffic flow value of the intersection in the next B time steps is generated
[0044] In this embodiment, the input layer: input the historical intersection traffic flow value X∈R AxPxC
[0045] Fully connected layer: X is output as H through two layers of fully connected networks (0) ∈R AxPxD .
[0046] Attention Mechanism Encoder: It consists of K spatiotemporal attention blocks (TSABs). (0) After K TSABs, the output is H (K) ∈R AxPxD . One of the TSAB blocks, such as Figure 3 As shown, it consists of a temporal attention block, a spatial attention block and a gated fusion unit.
[0047] Temporal attention block: Since the current traffic state of a location is associated with the previous traffic state of this location, and this association changes nonlinearly over time, the temporal attention block can capture the changing characteristics between different time steps and the common relationship between the traffic state and time at the intersection. The temporal attention block connects the multi-angle spatiotemporal embedding and applies the attention mechanism to calculate the attention score. Specifically, considering the intersection node vi, the relationship between time steps tj and t is defined as follows:
[0048]
[0049] Among them, h is the hidden state between the multi-angle spatiotemporal embedding and traffic flow learned in the previous layer. v,tj is the multi-angle spatiotemporal embedding obtained in step 5. || represents the concatenation operation, and <,> represents the inner product operation.
[0050] The output of the temporal attention block is as follows Indicates the newly learned node v at layer k i At time step t j The hidden state below.
[0051]
[0052]
[0053] Where N tj Indicates that all j The previous time collection, Yes The attention score obtained by regularizing with the softmax activation function indicates that all other time steps t have an effect on time step t j The sum of the attention scores is 1.
[0054] Spatial attention block: Since the traffic status of a road is dynamically affected by other roads, and this influence changes over time, the spatial attention block can capture this changing feature and can capture the impact of the current traffic conditions and road network on the traffic flow between intersections at a specific time. The spatial attention block connects the multi-angle spatiotemporal embeddings and applies the attention mechanism to calculate the attention score. Specifically, considering a specific time step t j In the case of intersection node v i The relationship between and v is defined as follows:
[0055]
[0056] Among them, h is the hidden state between the multi-angle spatiotemporal embedding and traffic flow learned in the previous layer. v,tj is the multi-angle spatiotemporal embedding obtained in step 5. || represents the concatenation operation, and <, > represents the inner product operation. 2D is Dimension.
[0057] The output of the spatial attention block is as follows Indicates the hidden state between the newly learned multi-angle spatiotemporal embedding and the traffic flow at layer k.
[0058]
[0059]
[0060] In the formula, V represents the set of all intersection nodes, Yes The attention score obtained by regularizing with the softmax activation function indicates the importance of all other nodes v to node vi. The sum of the attention scores is 1.
[0061] Gated fusion unit: Since the traffic status of a road at a specific time is related to the previous traffic status of this road and the traffic status of other roads, a gated fusion method is designed to fuse the above temporal attention block with the spatial attention block. In the kth block, and The fusion is performed as follows:
[0062]
[0063]
[0064] Where W z,1 ∈R DxD , W z,2 ∈R DxD , b z ∈R D , are all parameters to be learned. ⊙ represents the multiplication of corresponding elements of the matrix, σ(·) represents the sigmoid activation function, and z is the gate. The gated fusion mechanism can adaptively control the traffic flow of each vertex and time step on the multi-fusion spatiotemporal dependencies.
[0065] Conversion attention layer: Models the mapping relationship between each future time step and the historical time step, thereby converting the encoded traffic features into the input of the decoder that can generate future representations. (K) Generate future traffic flow feature sequence representation H (K+1) ∈R BxPxD .
[0066] Attention mechanism decoder: consists of K TSABs. (K+1) After K TSABs, the output is H (2K+1) ∈R BxPxD .
[0067] Fully connected layer: H generated by the attention mechanism decoder (2K+1) Generate B time-step intersection traffic flow prediction values through a two-layer fully connected network
[0068] Step 8: Use the validation set to test the model trained with the training set, and use the Huber loss function to evaluate the model error. If the error is greater than the set threshold, readjust the model hyperparameters and return to step 7 to train again. If it is less than the set threshold, jump to step 9.
[0069] Step 9: Use the test set to evaluate the prediction effect of the model, divide the test set into a historical data set and a prediction result set, input the traffic flow data of the road section to be predicted in the previous 7 days from the historical data set into the trained model, obtain the traffic flow situation of the intersection in the next 7 days predicted by MFAN, and compare it with the data in the prediction result set to predict the traffic flow. In this embodiment, the trained model supports the prediction of intersection traffic flow in the next 5 minutes, 10 minutes, 15 minutes, 30 minutes, and one hour.
[0070] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some or all of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope defined by the claims of the present invention.
Claims
1. A road traffic flow prediction method based on encoder-decoder multi-angle fusion, characterized in that: The following steps are involved: Step 1: Collect historical traffic flow data of the intersection to be predicted within a specified time period to form a two-dimensional traffic flow matrix; Step 2: Collect the road network information of the area where the intersection to be predicted is located, and obtain the spatial representation information of the road network; Step 3: Collect weather and holiday information of the area where the intersection to be predicted is located, and obtain weather information and holiday information of the road network; Step 4: Perform multi-angle fusion of quarterly, monthly, weekly, date, and hourly information within the historical time period to obtain the time embedded representation of the road network information, that is, the time representation information of the road network The intersection point v i ∈V, T label is the time embedding representation vector of the road network, with a dimension of D; Step 5: Fuse the multi-angle temporal and spatial information, and fuse the embedded representations of the four angles of space, weather, holidays, and time of the intersection obtained in steps 2-4 to form a multi-angle spatiotemporal embedding representation MTSE; Step 6: Perform z-score normalization on the traffic flow data and divide the normalization results into training set, validation set, and test set; Step 7: Design a multi-angle fusion attention neural network MFAN for predicting traffic flow and train it using the training set; The multi-angle fusion attention neural network MFAN includes an input layer, a fully connected layer, an attention mechanism encoder, a conversion attention layer, an attention mechanism decoder, and an output layer; the traffic flow data X∈R of the historical intersection of A time steps is converted into AxPxC Passed into the input layer, a two-layer fully connected layer converts X into H (0) ∈R AxPxD As the input of the attention mechanism encoder, the attention mechanism encoder consists of K spatiotemporal attention blocks TSAB, where each spatiotemporal attention block consists of a spatial attention block, a temporal attention block and a gated fusion unit; H (0) Through K spatiotemporal attention blocks TSAB, the output of the attention encoder is H (K) ∈R AxPxD , H (K) Passed into the conversion attention layer, the encoded feature H is converted through a conversion attention layer (K) Generate future traffic flow feature sequence representation H (K+1) ∈R BxPxD , which is used as the input of the attention mechanism decoder. The attention mechanism decoder consists of K spatiotemporal attention blocks TSAB, H (K+1) Through the attention mechanism decoder, the output is H (2K +1) ∈RR BxPxD , and then H (2K+1) After a two-layer fully connected network, the predicted traffic flow value of the intersection in the next B time steps is generated Step 8: Use the validation set to test the model trained with the training set and evaluate the model error. If the error is greater than the set threshold, readjust the model hyperparameters and return to step 7 to train again. If it is less than the set threshold, jump to step 9. Step 9: Use the test set to evaluate the prediction effect of the model. The test set is divided into a historical data set and a prediction result set. The traffic flow data of the road section to be predicted at a set time in the historical data set is input into the trained model to obtain the traffic flow situation at the intersection at the set time predicted by MFAN. The traffic flow situation is compared with the data in the prediction result set to perform traffic flow prediction.
2. The multi-angle fusion road traffic flow prediction method based on encoder-decoder according to claim 1 is characterized in that: The two-dimensional traffic flow matrix in step 1 is obtained by matching the historical GPS data of vehicles passing through the intersection to be predicted within a specified time period with the road network data and converting them into historical traffic flow data to obtain a traffic flow sequence {V1, V2, V3, ... V p }, p is the number of intersections in the city, and the traffic flow sequence of the intersection i to be predicted is V i = {v i,1 ,v i,2 ,v i,3 ,…,v i,n }, n is the number of time intervals, v i,n Represents the traffic flow at the i-th intersection in the n-th period of time.
3. The multi-angle fusion road traffic flow prediction method based on encoder-decoder according to claim 1 is characterized in that: The road network described in step 2 is a directed graph G = (V, E, A), where V represents the number of nodes in the road network, i.e., the number of intersections, V = p, E represents the edge, i.e., the road section in the road network, and A∈R V*V , A represents the adjacency matrix of the generation weight, R V*V The dimension of A is V*V; the spatial vector is sent into a two-layer fully connected network to obtain the spatial embedding representation of the road network information, that is, the spatial representation information of the road network The intersection point v i ∈V, S marking It is the spatial embedding representation vector of the road network, and its dimension is D.
4. The multi-angle fusion road traffic flow prediction method based on encoder-decoder according to claim 1 is characterized in that: The weather information of the road network described in step 3 includes six types of weather conditions that vehicles may encounter while driving on the road: strong wind, light rain, moderate rain, heavy rain, heavy snow, and sunny days. The weather embedding representation information of the road network is obtained. The intersection point vi∈V, marked by W is the weather embedding representation vector of the road network, with dimension D; Under the condition that the holiday representation information of the road network is the national statutory holiday information, the holiday embedded representation information of the road network is obtained. The intersection point vi∈V, H marks It is the weather embedding representation vector of the road network, and its dimension is D.
5. The multi-angle fusion road traffic flow prediction method based on encoder-decoder according to claim 1 is characterized in that: The MTSE in step 5 is j Lower intersection point v i , including road network information and time, weather, and holiday information, MTSE is defined as 6. The multi-angle fusion road traffic flow prediction method based on encoder-decoder according to claim 1 is characterized in that: The z-score normalization process described in step 6 is to divide the difference between each value in the original traffic flow data and the average value of all data by the standard deviation.
Citation Information
Patent Citations
Traffic flow prediction method based on deep learning nerve network structure
CN105160866A
Traffic flow prediction method based on stacked auto-encoder-support vector regression
CN108921343A
Traffic characteristic prediction method and system suitable for long-time prediction based on control information
CN113408786A
Large-scale real-time traffic flow prediction method based on fuzzy logic and deep LSTM
US20210209939A1
