A traffic flow prediction method based on multi-view spatiotemporal graph convolutional network
Through a multi-view spatiotemporal graph convolutional network combined with static graphs and trend similarity graphs, global and local spatial dependencies in traffic flow are extracted, which solves the problem of global spatial dependencies being ignored in existing methods and achieves more accurate traffic flow. prediction effect.
Patent Information
- Application Number
- CN202310132783.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-20
- Publication Date
- 2024-09-06
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing traffic flow prediction methods are difficult to effectively capture the global spatial dependencies in roads. The traditional adaptive adjacency matrix mainly reflects local spatial dependencies and ignores additional spatial relationships between road segments.
A method based on multi-view spatio-temporal graph convolution network (MVSTGCN) is proposed. By combining static graphs and trend similarity graphs, the multi-view graph convolution module and the gated temporal convolution module are used to extract complex spatial and temporal dependencies to achieve traffic control. Accurate prediction of flow.
On the real traffic data set, the MVSTGCN model performed better than existing methods in terms of MAE, MAPE and RMSE, reducing the error by 5.33% to 6.34%, and improving the accuracy and robustness of traffic flow prediction.
Smart Images

Figure CN115953902B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of traffic flow prediction and relates to a traffic flow prediction method based on a multi-view spatiotemporal graph convolutional network. The prediction method uses a graph convolutional neural network and a convolutional neural network to realize traffic flow prediction. Background Art
[0002] With the development of sensor technology, traffic data has shown an explosive growth trend, and the transportation system has officially entered the era of traffic big data. Intelligent transportation systems use traffic big data to control urban traffic. In recent years, with the support of deep learning technology, intelligent transportation systems have achieved great success. Traffic flow prediction, as one of the basic components of intelligent transportation systems, has also attracted the attention of more and more researchers. The change pattern in traffic data changes with time and space. The traffic flow at the observation point will not only be affected by the historical traffic flow, but also by the traffic flow of surrounding observation points. How to properly deal with these influencing factors is one of the major challenges in achieving accurate traffic flow prediction.
[0003] With the rise of deep learning, deep learning models such as convolutional neural networks and graph convolutional networks are used to mine complex spatial dependencies in traffic data, while when processing temporal dependencies in traffic data, models such as recurrent neural networks are mainly used. Although existing deep learning models have achieved good prediction results in traffic flow prediction tasks, there are still some problems. Traditional traffic flow prediction methods usually use adjacency matrices to describe the spatial dependencies of roads. For example, MTGNN uses an adaptive adjacency matrix when capturing spatial dependencies. However, the adaptive adjacency matrix often reflects the local spatial dependencies in the road and ignores the global spatial dependencies in the road. In the real world, there may be additional spatial relationships between road sections due to regional functions (such as close connections between residential and work areas). In order to better capture local and global spatial dependencies in road networks and solve the problems existing in the MTGNN model, the present invention proposes a multi-view-based spatiotemporal graph convolutional network model MVSTGCN. Summary of the invention
[0004] The present invention aims at the problem of traffic flow prediction on the road network, and proposes a traffic flow prediction method based on a multi-view spatiotemporal graph convolutional network to perform traffic flow prediction. Specifically, the present invention is a new spatiotemporal feature extraction method. In the spatial dimension, the interaction relationship between road observation points is considered from multiple angles to achieve complex spatial dependency extraction, and a gated temporal convolution module is used in the temporal dimension to extract temporal dependencies. In order to reduce the data redundancy caused by multi-angle extraction of spatial dependencies and improve the robustness of the model, the idea of feature separation is introduced. Finally, a large number of experiments are carried out on two real traffic data sets to verify the feasibility and effectiveness of the designed network.
[0005] The technical solution of the present invention is as follows:
[0006] A traffic flow prediction method based on a multi-view spatiotemporal graph convolutional network, characterized in that the prediction method includes the following contents:
[0007] S1. Obtain the traffic data set and construct the static graph adjacency matrix A of the road network road ,The traffic dataset includes the traffic data at each observation point in the road network at different times;
[0008] S2. Obtain the trend similarity graph adjacency matrix A dtw ;
[0009] S3. Build the MVSTGCN model:
[0010] The MVSTGCN model includes an output module and several spatiotemporal feature extraction layers connected in series. Spatiotemporal features at different scales are obtained by stacking multiple spatiotemporal feature extraction layers. The output of the current spatiotemporal feature extraction layer is used as the input of the next spatiotemporal feature extraction layer. At the same time, the output of the current spatiotemporal feature extraction layer is recorded in the output module. When all spatiotemporal feature extraction layers have extracted spatiotemporal features, the output module gives a prediction result.
[0011] Each spatiotemporal feature extraction layer includes a structure in which a gated temporal convolution module and a multi-view graph convolution module are connected in series. The multi-view graph convolution module is used for spatial feature extraction, and the gated temporal convolution module is used for temporal feature extraction.
[0012] The input of the gated time convolution module is the traffic data processed by the linear transformation layer. The output of the gated time convolution module is connected to the multi-view graph convolution module. At the same time, the static graph adjacency matrix A road and trend similarity graph adjacency matrix A dtw It is also used as the input of the multi-view graph convolution module. A residual connection is made between the input of the gated temporal convolution module and the output of the multi-view graph convolution module.
[0013] The output module includes at least two fully connected layers (FC), and the activation function of the output module is ELU;
[0014] S4. Use the traffic dataset to train the MVSTGCN model and finally obtain the MVSTGCN model for traffic flow prediction.
[0015] The specific process of step S1 is:
[0016] S11. Obtain the graph structure information of the road network G = (V, E), V = {v1, v2, ..., v N} represents the set of observation points in the road network, E represents the set of edges, corresponding to the connection relationship between observation points. If <v i , v j >∈E indicates that the observation point v i and v j There is a direct path between them, otherwise it means there is no direct relationship between the two observation points, forming a static graph adjacency matrix A road ;
[0017] S12. Obtain the traffic data of the road network and perform data cleaning;
[0018] S13. Divide the cleaned traffic data into time slices. The traffic data of all observation points in a time slice corresponds to a feature matrix X. (t) , expressed as Represents the observation point v i Traffic data at the tth time slice, N is the number of observation points; N is the number of observation points;
[0019] S14. Stack the time slice data to obtain the final traffic data set X = [X (1) ,X (2) ,...,X (Len) ], Len represents the time step size of traffic data, which is much larger than the time step size T of MVSTGCN model input.
[0020] The calculation process of the gated time convolution module is as follows:
[0021] Z=Tanh(TCN(X′))*σ(TCN(X′)) (2)
[0022] Where: TCN represents the atrous causal convolutional network; X′ represents the feature matrix of traffic data after being processed by the linear transformation layer; Z represents the output of the gated temporal convolution module; Tanh and σ represent the Tanh and Sigmoid activation functions respectively; * represents element-wise multiplication;
[0023] The output module includes two fully connected layers (FC) to perform nonlinear transformation on spatiotemporal features at different scales to obtain the final prediction result.
[0024] The multi-view graph convolution module consists of three multi-scale graph convolution networks and one aggregation layer. Three multi-scale graph convolution networks MS-GCN are used to extract the unique spatial features of static graphs, the unique spatial features of trend-similar graphs, and the common spatial features on the graphs. The formula of the operation process is expressed as:
[0025] Q rs =MS-GCN1(Z,A road ) (7)
[0026] Q ss =MS-GCN2(Z,A dtw ) (8)
[0027] Q rc =MS-GCN3(Z,A road ) (9)
[0028] Q sc =MS-GCN3(Z,A dtw ) (10)
[0029] Among them: MS-GCN1, MS-GCN2 and MS-GCN3 represent three multi-scale graph convolutional networks; Z represents the output of the gated temporal convolution module; A dtw and A road represents the adjacency matrix of the trend similarity graph and the adjacency matrix of the static graph; Q rs , Q ss , Q rc and Q sc They represent the unique spatial features of static graphs, the unique spatial features of trend-similar graphs, the common spatial features of static graphs, and the common spatial features of trend-similar graphs respectively;
[0030] The formula of the multi-scale graph convolutional network is expressed as formula (6):
[0031]
[0032] where θ l represents the weight of the lth layer, obtained by the attention module. When l = 0, θ0 = 1, which represents the residual relationship of the 0th layer; Q represents the output of the multi-scale graph convolutional network MS-GCN; m represents the number of graph convolutional layers; H (l) Represents the output of the lth layer of the graph convolutional network;
[0033] After obtaining the spatial features, the obtained spatial features are spliced, and then the feature vector obtained after splicing is input into the aggregation layer for feature aggregation. The calculation process is as follows:
[0034] Q'=Agg(Concat(Q rs , Q ss , Q rc , Q sc )) (11)
[0035] Wherein: Concat represents a vector concatenation operation; Agg represents a feature aggregation operation, Q′ is the output of the multi-view graph convolution module, and the aggregation layer is a fully connected layer or a channel attention layer.
[0036] The total loss L of the MVSTGCN model is the loss function L of the multi-view graph convolution module gcn and the prediction loss L model Add, L = L mode l+L gcn , L model The calculation formula is:
[0037]
[0038] Where: S represents the time step of prediction; N represents the number of observation points; D represents the dimension of the feature to be predicted. In the traffic flow prediction task, D is fixed to 1, which represents the flow characteristics; is the predicted result; Y is the actual result; t represents the tth time slice; s represents the predicted sth time slice; Represents the parameter set of MVSTGCN;
[0039] The loss function L of the multi-view graph convolution module gcn Defined as:
[0040] L gcn =αL1-βL2 (14)
[0041] Among them, α and β represent hyperparameters, L1 represents the similarity of common spatial features between static graphs and trend similarity graphs, and L2 represents the sum of the similarity of unique spatial features and common spatial features of static graphs and the similarity of unique spatial features and common spatial features in trend similarity graphs. The similarity is calculated using the F-norm.
[0042] In S2, the dynamic time warping algorithm (DTW) is used to calculate the similarity of the data sequences between the observation points and construct a trend similarity matrix Sim, Sim ij Corresponding observation point v i and observation point v j The minimum alignment distance between
[0043] Then use the threshold function to select the connectivity relationship. ij When it is less than the threshold, set the observation point v i and observation point v j There is a direct connection between them, otherwise it is set to have no connection, and finally the adjacency matrix A of the trend similarity graph is obtained. dtw ;
[0044] Or set the value of top K and select Sim in the same row of the trend similarity matrix ij The positions in the adjacency matrix corresponding to the top K values of are set to 1, and the rest are set to 0.
[0045] In the dynamic time warping (DTW) algorithm, it is necessary to set a limit on the search step size of DTW when searching for alignment relationships.
[0046] The present invention also protects a computer-readable storage medium, in which a computer program is stored. The computer program is suitable for executing the traffic flow prediction method based on a multi-view spatiotemporal graph convolutional network when loaded by a computer.
[0047] Compared with the prior art, the present invention has the following beneficial effects:
[0048] The present invention uses the algorithm of deep convolutional neural network to design a multi-view spatiotemporal graph convolutional network for traffic flow prediction. The method takes the traffic data on the road network, the static graph adjacency matrix and the trend similarity graph adjacency matrix as input, extracts temporal features and spatial features alternately, and then uses the output module to perform feature fusion, thereby achieving accurate prediction of traffic flow. Compared with STG-NCDE with the best prediction accuracy in the embodiment, the present invention achieves better prediction performance on the real traffic data sets PeMS03 and PeMS08. Specifically, in the PeMS03 data set, MAE decreased by 5.33%, MAPE decreased by 3.91%, and RMSE decreased by 6.34%; on the PeMS08 data set, MAE decreased by 1.49%, MAPE decreased by 1.51%, and RMSE decreased by 1.57% (the smaller the values of the three evaluation indicators, the better).
[0049] The present invention realizes the extraction of spatial dependency relationships in roads from different angles, the capture of spatial dependency relationships from global and local perspectives, and proposes a multi-view spatiotemporal graph convolution network to achieve traffic flow prediction. By modeling the dependency relationships in road observation points from different angles, and then using a multi-view graph convolution module to extract spatial features, the module's ability to capture spatial dependencies is increased, thereby improving the model's prediction performance.
[0050] The present invention proposes a multi-view spatiotemporal graph convolutional network to extract potential spatial dependencies, which can enhance the prediction effect. The gated temporal convolutional module in the present invention is mainly composed of two void causal convolutional networks, which are activated by different activation functions respectively. The structure is simple, and there is no dependency in the calculation process, which can realize parallel calculation and has the advantages of short training time and no error accumulation. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 Schematic diagram of the structure of the void causal convolutional network TCN.
[0052] Figure 2 Schematic diagram of the structure of the gated temporal convolution module.
[0053] Figure 3 Schematic diagram of the structure of a multi-scale graph convolutional network.
[0054] Figure 4 Schematic diagram of the structure of the multi-view graph convolution module.
[0055] Figure 5 Schematic diagram of the structure of the MVSTGCN model.
[0056] Figure 6 Single-step prediction MAE comparison results.
[0057] Figure 7 Single-step forecast MAPE comparison results.
[0058] Figure 8 Single-step prediction RMSE comparison results. DETAILED DESCRIPTION
[0059] In order to make the technical solution of the present invention clearer, the present invention is further described below in conjunction with the accompanying drawings.
[0060] The present invention extracts potential spatial dependency features in traffic data through a multi-view graph convolution module, uses a gated time convolution module to extract potential time dependency features in traffic data, alternately extracts time and space dependency features, obtains spatiotemporal dependency relationships at different scales, and inputs the spatiotemporal dependency relationships at different scales into an output module for nonlinear data conversion, and finally obtains prediction results. The multi-scale graph convolution network performs message transmission based on the adjacency matrix to capture spatial features; the multi-view graph convolution module is composed of three multi-scale graph convolution networks, which respectively extract unique spatial features and common spatial features from traffic data based on the adjacency matrix, and play a role in feature separation. The adjacency matrix reflects the spatial dependency relationship; the output module is composed of several fully connected layers and activation functions, which are used to perform nonlinear data conversion on the input spatiotemporal features.
[0061] The present invention is specifically implemented according to the following steps:
[0062] The first step is to obtain traffic data of a certain area through crawler scripts or API interfaces provided by traffic management departments, pre-process the obtained traffic data, and then construct a traffic data set;
[0063] Represent the road network: The traffic flow prediction problem is a typical multivariate time series prediction problem, which aims to predict the traffic flow in the future by using historical traffic flow data. The present invention uses an undirected graph G = (V, E) to represent the road network, where V is the set of observation points in the road network, N = |V| represents the number of observation points in the road network, and E is defined as the set of edges, which reflects the connectivity or distance between observation points. A∈R N×N Represents the adjacency matrix of the undirected graph G, where A ij Represents the observation point v i and v j The adjacency relationship of <v i ,v j >∈E, it means that the observation point v i and v j There is a direct road connecting them, without passing through other observation points. ij The value of is 1 or the distance between the two observation points, otherwise it is 0, indicating that there is no direct relationship between the two observation points. (t) ∈R N×D represents the feature matrix composed of the data at each observation point at the tth moment, D represents the number of features of the data at the observation point, and the features usually include flow, speed, and occupancy;
[0064] The traffic data at each observation point in the road network at different times constitutes the traffic data set.
[0065] Road network refers to a road system composed of various roads that are interconnected and interwoven into a network distribution within a certain area. When performing traffic prediction tasks, the area to be predicted will be selected first. The roads in the area and the connectivity between the roads are the road network. The locations where traffic data is collected in the road network are called observation points. The connection relationship between the observation points can be obtained through the road network, and then the static graph adjacency matrix A is used. road Represents the connection relationship between observation points.
[0066] The second step is to determine the input and output of the model: For the traffic flow prediction task, the input of the model is the historical traffic data X of N observation points in the past T time steps. (t-T+1):(t) ∈R N×D×T , the goal is to learn a mapping function f, the output is the traffic flow data X of N observation points in the future S time steps (t+1):(t+S) ∈R N×D×S , expressed using the formula:
[0067]
[0068] Traffic flow prediction uses the traffic data of the past T time steps to predict the traffic data of the future S time steps. The historical data ends at time t, so the output starts from time t+1.
[0069] Step 3: Divide the traffic data set and standardize the data: According to the commonly used proportion division standard, 60% of the data is used for training, 20% of the data is used for verification, and 20% of the data is used for testing. The data is standardized using the Z-Score method and recorded as Temp train , Temp val and Temp test . train Perform the following operations, first take Temp train The traffic flow data of the first T time steps is taken as the input of sample 1, and the traffic flow data of the first T+1 to the first T+S time steps is taken as the true result of sample 1. Then the traffic flow data of the first T+1 to 2T time steps is taken as the input of sample 2, and the traffic flow data of the first 2T+1 to 2T+S time steps is taken as the true result of sample 2, and so on. Finally, the training set X for model training is obtained train and its corresponding true result Y. In the same way, Temp val and Temp test After processing, we get the validation set X val , test set X test and its corresponding true result Y val and Y test At this time, each sample corresponds to the static graph adjacency matrix A road and trend similarity graph adjacency matrix A dtw .
[0070] Step 4: Build the MVSTGCN model, i.e. the multi-view spatiotemporal graph convolutional network model:
[0071] The MVSTGCN model includes an output module and several spatiotemporal feature extraction layers connected in series. Spatiotemporal features at different scales can be obtained by stacking multiple spatiotemporal feature extraction layers. The output of the current spatiotemporal feature extraction layer is used as the input of the next spatiotemporal feature extraction layer. At the same time, the output of the current spatiotemporal feature extraction layer is recorded in the output module. When all spatiotemporal feature extraction layers have extracted spatiotemporal features, the output module gives a prediction result.
[0072] Each spatiotemporal feature extraction layer includes a structure in which a gated temporal convolution module and a multi-view graph convolution module are connected in series. The multi-view graph convolution module is used for spatial feature extraction, and the gated temporal convolution module is used for temporal feature extraction.
[0073] The input of the gated time convolution module is the traffic data processed by the linear transformation layer. The output of the gated time convolution module is connected to the multi-view graph convolution module. At the same time, the static graph adjacency matrix A road and trend similarity graph adjacency matrix A dtw It is also used as the input of the multi-view graph convolution module; a residual connection is made between the input of the gated temporal convolution module and the output of the multi-view graph convolution module.
[0074] The output module includes at least two fully connected layers (FC), and the activation function of the output module is ELU. The final prediction result is obtained by performing nonlinear transformation on spatiotemporal features at different scales.
[0075] The overall structure of the MVSTGCN model is as follows Figure 5 shown. Figure 5 A road , traffic data, A dtw Represents the input of the model; Linear represents the linear transformation layer, which transforms the dimension of the traffic data so that the data matches the input dimension of the model. The residual connection represents that the original input of each feature extraction layer will be connected to the output to prevent the gradient disappearance problem when training the model, that is, O = Z' + g (Z'), where O represents the final output of the spatiotemporal feature extraction layer, Z' represents the input of the spatiotemporal feature extraction layer, and g (Z') represents the output of Z' after passing through the gated time convolution module and the multi-view graph convolution module. ELU represents the ELU activation function, represented by P (x), and the calculation formula of ELU is: x refers to the variable, i.e. the input data of ELU. FC stands for fully connected layer. Two ELUs and two FCs form the output module. + stands for element addition. The incomplete dotted box in the figure represents the multi-layer spatiotemporal feature extraction layer.
[0076] In order to capture the temporal dependency in traffic data, the present invention uses a gated temporal convolution module to extract temporal features. Figure 2 ) consists of two dilated causal convolutional networks (TCNs) with the same structure. The two dilated causal convolutional networks are activated by Tanh and Sigmoid activation functions respectively. The Tanh activation function filters the output of the dilated causal convolutional network, and the Sigmoid activation function acts as a gate to control the proportion of information passed to the next layer. Dilated convolution can ensure that the model can process sufficiently long sequences with a small number of parameters, and causal convolution ensures that the model will not see future information. The calculation process of the final gated temporal convolution module is:
[0077] Z=Tanh(TCN(X′))*σ(TCN(X′)) (2)
[0078] Where: TCN represents the atrous causal convolutional network; X′ represents the feature matrix of the traffic data after the input is processed by the linear transformation layer; Z represents the output of the gated temporal convolution module; Tanh and σ represent the Tanh and Sigmoid activation functions respectively; * represents element-wise multiplication.
[0079] The structure of the dilated causal convolutional network is as follows: Figure 1 shown. Figure 1 Each row in represents the input of the current layer. Taking the input layer as an example, when the input length is 8, a one-dimensional hole causal convolution kernel with a size of 2 and a hole rate of 1 is used for feature extraction. The extracted data is the last seven positions of the second-to-last layer. The first position is a padding position, which is not required in actual construction. The first three positions of the third layer are padding positions. In order to make the picture look simple, some connection relationships are ignored. For example, the circle in the third column of the second-to-last row will have a connection relationship with the second and third columns of the first-to-last row. This connection relationship is omitted here. Causal convolution means that the connection only exists at the current position and some previous positions, which can prevent future data from being seen. The hole rate represents the range of the processing position jump plus 1 when each convolution kernel processes the sequence. The output layer is the first row. In the second row, because a hole causal convolution kernel with a size of 2 and a hole rate of 4 is used, the output layer only receives the calculation results of the 8th and 4th columns of data, and the 5th to 7th columns of data are ignored. The calculation formula for each position is: where x∈R T represents the input, T represents the length of the input sequence, T is 8 in the figure; r∈R k represents the parameter set of the convolution kernel, k is the size of the convolution kernel, and k in the figure is 2; t represents the sequence position of the current calculation; d is the void rate of the convolution kernel; r a Represents the ath parameter of the convolution kernel, and the subscript starts from 0; x (t-d×a) represents the td×ath position of the input, and t represents the tth time slice.
[0080] In order to capture the potential spatial dependencies in traffic data, a multi-view graph convolution module is designed. The graph convolution network generalizes the traditional convolutional neural network from Euclidean spatial data to non-Euclidean structured graphs, which can realize message passing on the graph and then extract spatial dependencies. On this basis, the traditional graph convolution method is extended to capture multi-view information. The multi-view graph convolution module aggregates observation point features through static graphs and trend similarity graphs. When extracting spatial dependencies, the multi-view graph convolution module decomposes the spatial dependencies on a single view (adjacency matrix) into common spatial features and unique spatial features, and then uses the channel attention mechanism to weight all the obtained spatial features, and finally obtains semantically rich spatial features. The process of the multi-view graph convolution module is as follows:
[0081] (1) Constructing a trend similarity graph: Based on the similarity of the traffic change trends between observation points, a trend similarity graph is constructed. The specific process is as follows: Calculate the distance between each observation point separately. Since the interaction between different observation points has a time lag, the commonly used cosine similarity and Euclidean distance metrics cannot align the time series well. In this embodiment, the distance between each observation point is calculated by using the dynamic time warping algorithm (DTW). The dynamic time warping algorithm allows relationship alignment across time steps, and can better handle the distance calculation of sequence inconsistency problems caused by time lag relationships. The dynamic time warping algorithm uses dynamic programming ideas to calculate the minimum distance between sequences. The dynamic programming transfer equation used is expressed as:
[0082] γ(w,h)=dis(q w ,c h )+min(γ(w-1,h-1),γ(w-1,h),γ(w,h-1)) (3)
[0083] Where γ(w,h) represents the distance from the observation point v q The time series and observation point v in (0,w) c The minimum alignment distance of the time series in (0,h); dis(q w ,c h ) represents the observation point v q The w-th time step and observation point v c The distance difference (flow difference) at the hth time step, where w and h represent the time step.
[0084] The above algorithm is used to calculate the minimum distance between the observation point sequences to form the trend similarity matrix Sim, and then the threshold function is used to select the connectivity relationship. ij When it is less than the threshold, Sim ij The corresponding position in the adjacency matrix is set to 1, otherwise it is set to 0, and finally the trend similarity graph adjacency matrix A is obtained.dtw .
[0085] Common distance measurement methods mostly use cosine similarity and Euclidean distance. DTW is used here to achieve cross-time step relationship alignment, because traffic data has a time lag relationship from the perspective of spatial changes. The time complexity of traditional DTW when calculating the distance of a sequence is O(n 2 ), which consumes a lot of time when calculating time series.
[0086] In this embodiment, the search step size of DTW when searching for alignment relationships is preferably limited, for example, searching backward for 12 time steps, so that the complexity will be reduced to O(n). Because the interactions of traffic sequence observation points all occur within a limited time range, limiting the search step size will not affect the final performance. The specific search step size needs to be selected through experiments and analyzed specifically for specific problems.
[0087] The minimum distance between the i-th observation point and the j-th observation point in the road. Assuming that the length of the time series of the two observation points is 12, then Sim ij The value of is γ(12,12), and the threshold is a hyperparameter of the network, because different thresholds will result in different sparsity of the matrix.
[0088] You can also select Sim in the same row of the trend similarity matrix as needed. ij The positions in the adjacency matrix corresponding to the top K values of are set to 1, and the rest are set to 0. K is also a hyperparameter, and different K also determines the sparsity of the matrix.
[0089] (2) Constructing a multi-scale graph convolutional network MS-GCN: Based on the given adjacency matrix A and feature matrix Z, the graph convolutional network GCN is used to extract spatial features from the feature matrix Z. In each graph convolutional layer of the graph convolutional network, the attention module is used to obtain different weight factors assigned according to the amount of information contained in the current layer. The calculation process of the graph convolutional network layer is expressed as follows:
[0090] H (l+1) =f(H (l) ,A)=ReLU(AH (l) W (l+1) +b (l+1) ) (4)
[0091] H (0) =Z∈R N×D (5)
[0092] Among them, H (l) W represents the output of the lth layer of the graph convolutional network, where l is an integer between 0 and m, and is also the input of the l+1th layer; (l+1) and b (l+1)Represents the learnable model parameters of the l+1th layer, and ReLU represents the ReLU activation function. In order to dynamically adjust the influence weights of different layers, the attention module assigns different weight factors according to the amount of information contained in the current layer. The structure of the multi-scale graph convolutional network MS-GCN is as follows: Figure 3 shown. Figure 3 The nodes on each circle in represent the neighbor information to be aggregated in the current layer. The final formula of the multi-scale convolutional network calculation process is expressed as:
[0093]
[0094] where θ l represents the weight of the lth layer, which is obtained by the attention module. When l = 0, θ0 = 1, which represents the residual relationship of the 0th layer; Q represents the output of the multi-scale graph convolutional network MS-GCN; m represents the number of graph convolutional layers.
[0095] (3) Constructing a multi-view graph convolution module: Based on the multi-scale graph convolution network, a multi-view graph convolution module is constructed. The structure of the multi-view graph convolution module is as follows: Figure 4 As shown in Figure 2. Specifically, the multi-view graph convolution module consists of three multi-scale graph convolution networks and an aggregation layer. The three multi-scale graph convolution networks MS-GCN respectively extract the unique spatial features of static graphs, the unique spatial features of trend-similar graphs, and the common spatial features on the graph. The formula for the operation process is expressed as:
[0096] Q rs =MS-GCN1(Z,A road ) (7)
[0097] Q ss =MS-GCN2(Z,A dtw ) (8)
[0098] Q rc =MS-GCN3(Z,A road ) (9)
[0099] Q sc =MS-GCN3(Z,A dtw ) (10)
[0100] Among them: MS-GCN1, MS-GCN2 and MS-GCN3 represent the three multi-scale graph convolutional networks mentioned above; Z represents the feature matrix of traffic data processed by the gated temporal convolution module; A dtw and A road represents the adjacency matrix of the trend similarity graph and the adjacency matrix of the static graph; Q rs , Q ss , Q rc and Q scThey represent the unique spatial features of static graphs, the unique spatial features of trend-similar graphs, the common spatial features of static graphs, and the common spatial features of trend-similar graphs, respectively. The subscript c represents common, the subscript r represents static graphs, the first position of the subscript s represents trend similarity, and the second position of the subscript s represents unique.
[0101] After obtaining the spatial features, the obtained spatial features are spliced, and then the feature vector obtained after splicing is input into the aggregation layer for feature aggregation. The formula of the calculation process is defined as follows:
[0102] Q′=Agg(Concat(Q rs , Q ss , Q rc , Q sc )) (11)
[0103] Among them: Concat represents the vector concatenation operation; Agg represents the feature aggregation operation, and the specific implementation can be replaced by a fully connected layer or channel attention.
[0104] (4) Loss function setting: In order to ensure that the above three multi-scale graph convolutional networks MS-GCN have the function of feature separation, it is necessary to define the corresponding loss function to ensure the learning result of the model. Let Q rc ∈R N×D×T , Q sc ∈R N×D×T , Q rs ∈R N ×D×T ,Q ss ∈R N×D×T They represent the common spatial features of static images, the common spatial features of trend-similar images, the unique spatial features of static images, and the unique spatial features of trend-similar images. First, the two common spatial features Q rc and Q sc Perform dimension conversion and then normalize to get Q′ rc ∈R N×DT and Q′ sc ∈R N×DT Because Q rc and Q sc They represent the common spatial features in the static graph and the trend similarity graph respectively, so the two matrices should have extremely high similarity. The measurement formula is calculated using the F norm, and the formula is:
[0105]
[0106] The above formula can also be used to measure the difference between space-specific information and space-common information. Unique information and common information should have different information representations, so there should be a big difference between the two matrices. rsand Q′ ss They represent the unique spatial features of the static graph and the unique spatial features of the trend similarity graph after dimension conversion and normalization. The measurement formula is also calculated using the F-norm, and the formula is:
[0107]
[0108] The loss function L of the final multi-view graph convolution module is gcn Defined as:
[0109] L gcn =αL1-βL2 (14)
[0110] Among them, α and β represent hyperparameters, which are used to control the influence of the current loss function on the model parameters. L1 represents the similarity of the common spatial features in the static graph and the trend similarity graph. L2 represents the sum of the similarity of the unique spatial features of the static graph and the common spatial features of the static graph and the similarity of the unique spatial features and the common spatial features in the trend similarity graph.
[0111] Step 5: Training model parameters: According to Temp train Construct a trend similarity graph and obtain the adjacency matrix A of the trend similarity graph dtw Then set X train , trend similarity graph adjacency matrix A dtw and the static graph adjacency matrix A road As the input of the MVSTGCN model (the two adjacency matrices are only effective in the multi-view graph convolution module, and the adjacency matrices of other modules are not involved in the calculation), the prediction results of the MVSTGCN model are obtained, the prediction results and the true results Y are used to calculate the loss, and the back propagation algorithm is used to update the parameters of the MVSTGCN model. The specific flow of data is:
[0112] (1) For the training set X train The traffic data in is transformed into X′, and X′ is input into the first spatiotemporal feature extraction layer;
[0113] (2) The spatiotemporal feature extraction layer first uses the gated temporal convolution module to extract the temporal features of the input to obtain the temporal features Z. Then, the multi-view graph convolution module extracts the temporal features based on the trend similarity graph adjacency matrix A. dtw and the static graph adjacency matrix A road Perform spatial feature extraction on the temporal feature Z to obtain the spatiotemporal feature Q′ output by the current layer (p) , Q′ (p) represents the output result of the p-th spatiotemporal feature extraction layer;
[0114] (3) The spatiotemporal feature Q′ (p) Input to the next spatiotemporal feature extraction layer, and the spatiotemporal feature Q′(p) Recorded in the variable Skip;
[0115] (4) Repeat steps (2) and (3) until the data passes through all spatiotemporal feature extraction layers;
[0116] (5) Then input the variable Skip into the output module. The output result of the output module is the prediction result of the model.
[0117] (6) Using the prediction results And the actual result Y calculates the prediction loss L of the model model , adding the loss function of the multi-view graph convolution module and the prediction loss gives the final loss of the model L = L model +L gcn , L model The calculation formula is:
[0118]
[0119] Where: S represents the time step of prediction; N represents the number of observation points; D represents the dimension of the feature to be predicted. In the traffic flow prediction task, D is fixed to 1, which represents the flow characteristics; t represents the tth time slice; s represents the sth time slice of the prediction; Represents all parameters of MVSTGCN; i represents the i-th observation point; u is the u-th feature.
[0120] (7) Use the back-propagation algorithm to update the parameters of the model.
[0121] Step 6: Verify model performance: Set the validation set X val Input into the MVSTGCN model and calculate the prediction loss L of the MVSTGCN model on the validation set model ;
[0122] Step 7: Repeat steps 5 and 7 until the prediction loss on the validation set is L model Less than the set threshold or reaching the maximum number of repetitions.
[0123] Step 8: Test the prediction performance of the MVSTGCN model: test Input into the MVSTGCN model to perform traffic flow prediction and evaluate the performance of the final MVSTGCN model.
[0124] (1) Overall performance evaluation of the MVSTGCN model
[0125] The present invention conducts experiments on two real traffic flow datasets, PeMS03 and PeMS08. The detailed information of the datasets is shown in Table 1. Both datasets use 5 minutes as a time step.
[0126] Table 1: Dataset information
[0127]
[0128] The effectiveness and accuracy of the traffic flow prediction method based on multi-view spatiotemporal graph convolutional network proposed in this paper are verified through comparative experiments on real data sets. The experimental results are shown in Table 2.
[0129] The present invention is compared with other benchmark methods: including FC-LSTM, DCRNN, STGCN, ASTGCN, STG2Seq, Graph Wavenet, STSGCN, STFGNN, ZGCNETS and STG-NCDE (the benchmark methods mentioned are the English abbreviations of the models in the published literature), and three metrics are used for evaluation, including mean absolute error MAE, root mean square error RMSE and mean absolute percentage error MAPE. The values of the above three metrics are all as small as possible, and the corresponding calculation formulas are as follows:
[0130]
[0131]
[0132]
[0133] Where: y s is the observed value of traffic flow, is the predicted value of traffic flow, S represents the length of the time series to be predicted; s represents the sth predicted time step, and its value range is (1, S).
[0134] It can be seen from Table 2 that the prediction performance of the MVSTGCN model is better than other baseline models in all three indicators on the two datasets. MVSTGCN can obtain a more semantically rich spatial feature model by extracting spatial dependencies from multiple angles, which enables the model to have better prediction performance.
[0135] Table 2: Performance comparison between MVSTGCN and baseline models
[0136]
[0137]
[0138] In order to further verify the performance of MVSTGCN, we selected the PeMS08 dataset to compare the single-step prediction error with the two most advanced models ZGCNETS and STG-NCDE, and plotted the experimental comparison results into a line graph. The single-step prediction results of MAE, MAPE and RMSE are shown in the figure. Figure 6-Figure 8 shown.
[0139] (2) In order to evaluate and understand the effects and performance of the key components of the MVSTGCN model proposed in this invention, an ablation study was conducted on the PeMS03 dataset, and the variants of MVSTGCN were named as follows:
[0140] MVSTGCN / woR: Only uses static graph adjacency matrix, no multi-view graph convolution module, has ordinary graph convolution network, and does not consider dependencies constructed from other perspectives.
[0141] MVSTGCN / woC: Based on a single adjacency matrix, a multi-scale graph convolutional network is used to replace the original graph convolutional network. That is, an attention module is added to the ordinary graph convolutional network on the basis of MVSTGCN / woR to form a multi-scale graph convolutional network.
[0142] MVSTGCN / woD: Spatial dependency extraction using static graph adjacency matrix and trend similarity graph, excluding Figure 4 The shared parameter part in , that is, there are only two MS-GCNs.
[0143] The ablation experiment results are shown in Table 3.
[0144] Table 3: Ablation experiments
[0145]
[0146] Experimental results show that the multi-view graph convolution module, multi-scale graph convolution network and feature separation idea are crucial to the performance of MVSTGCN. The spatial feature fusion on the trend similarity graph and the static graph proves the effectiveness of multi-view feature extraction. The multi-scale graph convolution network can dynamically adjust the weight of the intermediate output of the model and play an adaptive role. The MVSTGCN model of the present invention achieves better traffic flow prediction results.
[0147] Any matters not described in the present invention are applicable to the prior art.
Claims
1. A traffic flow prediction method based on multi-view spatiotemporal graph convolutional network, characterized in that: The prediction method includes the following contents: S1. Obtain the traffic data set and construct the static graph adjacency matrix A of the road network road ,The traffic dataset includes the traffic data at each observation point in the road network at different times; S2. Obtain the trend similarity graph adjacency matrix A dtw ; S3. Build the MVSTGCN model: The MVSTGCN model includes an output module and several spatiotemporal feature extraction layers connected in series. Spatiotemporal features at different scales are obtained by stacking multiple spatiotemporal feature extraction layers. The output of the current spatiotemporal feature extraction layer is used as the input of the next spatiotemporal feature extraction layer. At the same time, the output of the current spatiotemporal feature extraction layer is recorded in the output module. When all spatiotemporal feature extraction layers have extracted spatiotemporal features, the output module gives a prediction result. Each spatiotemporal feature extraction layer includes a structure in which a gated temporal convolution module and a multi-view graph convolution module are connected in series. The multi-view graph convolution module is used for spatial feature extraction, and the gated temporal convolution module is used for temporal feature extraction. The input of the gated time convolution module is the traffic data processed by the linear transformation layer. The output of the gated time convolution module is connected to the multi-view graph convolution module. At the same time, the static graph adjacency matrix A road and trend similarity graph adjacency matrix A dtw It is also used as the input of the multi-view graph convolution module. A residual connection is made between the input of the gated temporal convolution module and the output of the multi-view graph convolution module. The output module includes at least two fully connected layers (FC), and the activation function of the output module is ELU; S4. Use the traffic dataset to train the MVSTGCN model and finally obtain the MVSTGCN model for traffic flow prediction.
2. The traffic flow prediction method based on multi-view spatiotemporal graph convolutional network according to claim 1 is characterized in that: The specific process of step S1 is: S11. Obtain the graph structure information of the road network G = (V, E), V = {v1, v2, ..., v N } represents the set of observation points in the road network, E represents the set of edges, corresponding to the connection relationship between observation points. If <v i ,v j >∈E indicates that the observation point v i and v j There is a direct path between them, otherwise it means there is no direct relationship between the two observation points, forming a static graph adjacency matrix A road ; S12. Obtain the traffic data of the road network and perform data cleaning; S13. Divide the cleaned traffic data into time slices. The traffic data of all observation points in a time slice corresponds to a feature matrix X. (t) , expressed as Represents the observation point v i Traffic data at the tth time slice, N is the number of observation points; S14. Stack the time slice data to obtain the final traffic data set X = [X (1) ,X (2) ,...,X (Len) ], Len represents the time step size of traffic data, which is much larger than the time step size T of MVSTGCN model input.
3. The traffic flow prediction method based on multi-view spatiotemporal graph convolutional network according to claim 1 is characterized in that: The calculation process of the gated time convolution module is as follows: z=Tanh(TCN(X′))*σ(TCN(X′)) (2) Where: TCN represents the atrous causal convolutional network; X′ represents the feature matrix of traffic data after being processed by the linear transformation layer; Z represents the output of the gated temporal convolution module; Tanh and σ represent the Tanh and Sigmoid activation functions respectively; * represents element-wise multiplication; The output module includes two fully connected layers (FC) to perform nonlinear transformation on spatiotemporal features at different scales to obtain the final prediction result.
4. The traffic flow prediction method based on multi-view spatiotemporal graph convolutional network according to claim 1 is characterized in that: The multi-view graph convolution module consists of three multi-scale graph convolution networks and one aggregation layer. Three multi-scale graph convolution networks MS-GCN are used to extract the unique spatial features of static graphs, the unique spatial features of trend-similar graphs, and the common spatial features on the graphs. The formula of the operation process is expressed as: Q rs =MS-GCN1(Z,A road ) (7) Q ss =MS-GCN2(Z,A dtw ) (8) Q rc =MS-GCN3(Z,A road ) (9) Q sc =MS-GCN3(Z,A dtw ) (10) Among them: MS-GCN1, MS-GCN2 and MS-GCN3 represent three multi-scale graph convolutional networks; Z represents the output of the gated temporal convolution module; A dtw and A road represents the adjacency matrix of the trend similarity graph and the adjacency matrix of the static graph; Q rs , Q ss , Q rc and Q sc They represent the unique spatial features of static graphs, the unique spatial features of trend-similar graphs, the common spatial features of static graphs, and the common spatial features of trend-similar graphs respectively; The formula of the multi-scale graph convolutional network is expressed as formula (6): where θ l represents the weight of the lth layer, obtained by the attention module. When l = 0, θ0 = 1, which represents the residual relationship of the 0th layer; Q represents the output of the multi-scale graph convolutional network MS-GCN; m represents the number of graph convolutional layers; H (l) Represents the output of the lth layer of the graph convolutional network; After obtaining the spatial features, the obtained spatial features are concatenated, and then the concatenated feature vectors are input into the aggregation layer for feature aggregation. The calculation process is as follows: Q′=Agg(Concat(Q rs ,Q ss ,Q rc ,Q sc )) (11) Wherein: Concat represents a vector concatenation operation; Agg represents a feature aggregation operation, Q′ is the output of the multi-view graph convolution module, and the aggregation layer is a fully connected layer or a channel attention layer.
5. The traffic flow prediction method based on multi-view spatiotemporal graph convolutional network according to claim 4 is characterized in that: The total loss L of the MVSTGCN model is the loss function L of the multi-view graph convolution module gcn and the prediction loss L model Add, L = L model +L gcn , L model The calculation formula is: Where: S represents the time step of prediction; N represents the number of observation points; D represents the dimension of the feature to be predicted. In the traffic flow prediction task, D is fixed to 1, which represents the flow characteristics; is the predicted result; Y is the actual result; t represents the tth time slice; s represents the predicted sth time slice; Represents the parameter set of MVSTGCN; The loss function L of the multi-view graph convolution module gcn Defined as: L gcn =αL1-βL2 (14) Among them, α and β represent hyperparameters, L1 represents the similarity of common spatial features between static graphs and trend similarity graphs, and L2 represents the sum of the similarity of unique spatial features and common spatial features of static graphs and the similarity of unique spatial features and common spatial features in trend similarity graphs. The similarity is calculated using the F-norm.
6. The traffic flow prediction method based on multi-view spatiotemporal graph convolutional network according to claim 1 is characterized in that: In S2, the dynamic time warping algorithm (DTW) is used to calculate the similarity of the data sequences between the observation points and construct a trend similarity matrix Sim, Sim ij Corresponding observation point v i and observation point v j The minimum alignment distance between Then use the threshold function to select the connectivity relationship. ij When it is less than the threshold, set the observation point v i and observation point v j There is a direct connection between them, otherwise it is set to have no connection, and finally the adjacency matrix A of the trend similarity graph is obtained. dtw ; Or set the value of top K and select Sim in the same row of the trend similarity matrix ij The positions in the adjacency matrix corresponding to the top K values of are set to 1, and the rest are set to 0.
7. The traffic flow prediction method based on multi-view spatiotemporal graph convolutional network according to claim 6 is characterized in that: In the dynamic time warping (DTW) algorithm, it is necessary to set a limit on the search step size of DTW when searching for alignment relationships.
8. A computer-readable storage medium, wherein a computer program is stored in the storage medium, and the computer program is suitable for executing the traffic flow prediction method based on a multi-view spatiotemporal graph convolutional network as described in any one of claims 1 to 7 when loaded by a computer.
