A method for predicting vehicle speed on urban roads
By constructing a dynamic adjacency matrix and fusing multiple network models, combined with spatial graph convolution and temporal attention layers, the problem of insufficient spatiotemporal correlation processing in urban road vehicle speed prediction is solved, achieving higher prediction accuracy and model generalization ability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- AEROSPACE INFORMATION RES INST CAS
- Filing Date
- 2023-04-18
- Publication Date
- 2026-05-19
AI Technical Summary
Existing technologies fail to effectively handle spatiotemporal correlations in urban road vehicle speed prediction, resulting in low prediction accuracy. In particular, they ignore the diversity of data during holidays and weekends, as well as the spatial dynamics of road dependencies.
A dynamic adjacency matrix is constructed, and by combining spatial graph convolutional layers, temporal attention layers, and the concept of course learning, the spatiotemporal data processing capability of the model is improved through the fusion of multiple network models. The attention mechanism is improved by measuring the difference in probability distribution and feature smoothness. Data from related time periods are selected for training.
It improves the accuracy of vehicle speed prediction and the generalization performance of the model, enhances the reflection of actual connectivity, reduces negative interference, and improves training speed and prediction accuracy.
Smart Images

Figure CN116486611B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of vehicle speed prediction technology, and more particularly to a method for predicting vehicle speed on urban roads. Background Technology
[0002] Traffic congestion significantly reduces the quality of life for urban residents, increases commuting time, and causes frustration. Furthermore, the continuous fuel consumption during congestion not only wastes a large amount of energy but also pollutes the environment with the resulting exhaust fumes. To address this problem, many cities have begun exploring and researching Intelligent Transportation Systems (ITS), and vehicle speed prediction is a fundamental topic in ITS research, as many traffic problems ultimately rely on accurate traffic speed estimation. However, due to the highly complex spatial and temporal correlations, vehicle speed prediction remains extremely challenging.
[0003] In recent years, with the rapid rise of deep learning and artificial intelligence, deep neural network models have received widespread attention due to their ability to effectively capture the spatiotemporal dynamics of traffic data. Recurrent Neural Networks (RNNs) and Long Short-Term Memory (LSTM) have been successfully used for traffic volume prediction. To better consider spatial features, researchers have also introduced CNNs into their models, such as ST-ResNet. However, because CNNs were originally designed for Euclidean spatial structures, the above methods first convert the traffic network into a regular grid structure, which results in the loss of much of the traffic network's topological information. To address this limitation of CNNs, researchers have considered introducing convolutional architectures in the spectral domain, using graph neural networks for traffic flow prediction, such as DCRNN, TGCN, and ASTGCN models.
[0004] An analysis of the current state of research both domestically and internationally reveals that speed prediction in road traffic flow requires both spatial and temporal modeling of historical traffic flow data. Many researchers employ various methods to process spatiotemporal data, such as combining GCN and RNN. However, these methods remain insufficient in handling the dynamic correlations between temporal and spatial traffic data, resulting in low prediction accuracy. This can be summarized as follows: First, at the temporal scale, some existing studies intentionally ignore data from holidays and weekends, and this lack of data diversity limits the model's generalization ability. Second, at the spatial scale, some studies only use adjacency matrices to model the road network as a static graph, neglecting the dynamic spatial dependencies of roads. Summary of the Invention
[0005] Based on the above analysis, the embodiments of the present invention aim to provide a method for predicting vehicle speed on urban roads, in order to solve the problem of low prediction accuracy caused by ignoring the spatiotemporal correlation of vehicle speed in existing methods.
[0006] This invention provides a method for predicting vehicle speed on urban roads, comprising the following steps:
[0007] Collect vehicle speeds at each node in the urban road network to construct a sample set, and then divide the sample set into a training set; construct a dynamic adjacency matrix based on the network topology of each node in the training set and the daily vehicle speed probability.
[0008] The training set is divided into multiple time periods according to time sequence. Multiple network models are constructed according to each time period. The outputs of multiple network models are fused to obtain the prediction model. Based on the training set and the dynamic adjacency matrix, the prediction model is trained to obtain the trained prediction model.
[0009] The vehicle speed of the node to be predicted is collected. Based on the time period to be predicted and the preset number of samples for each time period, the test samples of each time period are selected and fed into the trained prediction model to obtain the vehicle speed of the time period to be predicted.
[0010] Based on the above method, a dynamic adjacency matrix is constructed according to the network topology of each node in the training set and the daily vehicle speed probability, including:
[0011] Construct a static adjacency matrix based on the network topology of each node in the training set;
[0012] Based on the daily vehicle speed ratio of each node in the training set, the daily vehicle speed probability of each node is obtained, forming the vehicle speed probability distribution of each node; using Wasserstein distance and cosine distance as the cost function for probability distribution transition, the distance between the vehicle speed probability distributions of any two nodes is calculated, and a distance matrix is constructed.
[0013] The dynamic adjacency matrix is obtained by multiplying each element value in the distance matrix and the static adjacency matrix with the preset weights of the distance matrix and the static adjacency matrix, and then superimposing the superimposed value according to the threshold.
[0014] Based on the further improvement of the above method, the training set is divided into multiple time periods according to the time sequence, including: according to the prediction time period, and according to the preset number of samples in each time period, training samples are divided into adjacent time periods, daily time periods, weekly time periods, and holiday time periods respectively; among them, the adjacent time period is the time period within [1.5, 2.5] hours before the prediction time period, the daily time period is the time period that is the same as the prediction time period every day before the prediction time period, the weekly time period is the time period that is the same as the prediction time period every other week before the prediction time period, and when the prediction day is a holiday, the holiday time period is the time period that is the same as the prediction time period on the prediction day in the historical year.
[0015] Based on the further improvement of the above method, multiple network models are constructed according to each time period, and the outputs of multiple network models are fused to obtain the prediction model, including: the network model corresponding to the adjacent time period includes a spatial graph convolutional layer, a gated recurrent unit and a first fully connected layer connected in sequence; the daily time period, weekly time period and holiday time period correspond to the same network model, including a spatial graph convolutional layer, a temporal attention layer and a temporal convolutional layer connected in sequence; the outputs of the four network models are weighted and fused through a second fully connected layer to obtain the prediction model.
[0016] Based on the further improvement of the above method, the spatial graph convolutional layer includes a spatial attention layer and a spatial graph convolutional neural network connected in sequence. The spatial attention layer calculates the spatial attention score matrix based on the difference of vehicle speed vectors between nodes in the corresponding time period, and then dynamically smooths the spatial attention score matrix according to the feature smoothness before feeding it into the spatial graph convolutional neural network. The spatial graph convolutional neural network uses Chebyshev polynomials as convolution kernels and performs convolution operations on the training samples in the corresponding time period based on the dynamic adjacency matrix and the smoothed spatial attention score matrix.
[0017] Based on the further improvement of the above method, the temporal attention layer calculates the temporal attention score matrix according to the difference of vehicle speed vectors between time slices in the corresponding time period. Then, based on the temporal attention score matrix, the output of the corresponding spatial graph convolutional layer is dynamically weighted and output to the temporal convolutional layer. The temporal convolutional layer is a convolutional neural network that convolves and merges the output of the temporal attention layer and maps it to the output using the LeakyReLU function.
[0018] Based on the further improvement of the above method, the element values of the spatial attention score matrix are calculated according to the following formula.
[0019]
[0020]
[0021] in, Let represent the vehicle speed vector of node i within the τ time slices of the corresponding time period. V represents the vehicle velocity vector at node j within τ time slices. s ,b s W s1 W s2 σ represents the weight parameter, σ represents the sigmoid activation function, and N represents the total number of nodes.
[0022] Based on the further improvement of the above method, the element values of the time attention score matrix are calculated according to the following formula.
[0023]
[0024]
[0025] in, Indicates the time slice t within the corresponding time period i The vehicle velocity vectors at N nodes, Indicates the time slice t within the corresponding time period j The vehicle velocity vector at N nodes, V q ,b q W q1 and W q2 σ represents the weight parameter, N represents the total number of nodes, and τ represents the number of time slices in the corresponding time period.
[0026] A further improvement to the above method involves dynamically smoothing the spatial attention score matrix based on feature smoothness, including:
[0027] The mean of the sum of the differences between each node and its neighboring nodes is calculated and used as the feature smoothness for the corresponding time period.
[0028] The number of items to be retained is determined based on the feature smoothness and the preset multiplier.
[0029] Based on the number of elements to be retained, the corresponding element values are retained in descending order of the element values in the spatial attention score matrix, and the remaining element values are set to zero, thus obtaining the smoothed spatial attention score matrix.
[0030] Based on further improvements to the above method, a prediction model is trained using the training set and dynamic adjacency matrix to obtain a well-trained prediction model, including:
[0031] By introducing the concept of course learning, in each round of training, all training samples from adjacent time periods are selected and fed into the network model corresponding to the adjacent time periods; according to the training schedulers corresponding to daily time periods, weekly time periods and holiday time periods, the corresponding training samples are selected and fed into the corresponding network models respectively.
[0032] Each network model outputs the predicted vehicle speed based on the input training samples and dynamic adjacency matrix, compares it with the corresponding actual vehicle speed, selects the mean squared error as the loss function of the prediction model, and ends the training when the mean squared error reaches the preset error value, thus obtaining the trained prediction model.
[0033] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0034] 1. Based on historical sequence data, the difference in probability distribution is used to measure the similarity between nodes, defining the dynamic connectivity between road network nodes, which is closer to the actual connectivity relationship;
[0035] 2. The attention mechanism is improved based on feature smoothness, which enables nodes to amplify the useful information brought by their neighbors and suppress the corresponding negative interference;
[0036] 3. Select data from four of the most relevant time periods to increase data diversity. Based on the training scheduling strategy of course learning, gradually increase the data from the more difficult time periods to train. This allows the model to have different focuses in different training processes, which not only improves the training speed and the model's generalization performance, but also improves the prediction accuracy.
[0037] In this invention, the above-described technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of this invention will be set forth in the following description, and some advantages may become apparent from the description or be learned by practicing the invention. The objects and other advantages of this invention can be realized and obtained from what is particularly pointed out in the description and drawings. Attached Figure Description
[0038] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts.
[0039] Figure 1 This is a flowchart of a method for predicting vehicle speed on urban roads according to an embodiment of the present invention;
[0040] Figure 2 This is a schematic diagram of the prediction model structure in an embodiment of the present invention. Detailed Implementation
[0041] Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which form part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not intended to limit the scope of the present invention.
[0042] A specific embodiment of the present invention discloses a method for predicting vehicle speed on urban roads, such as... Figure 1 As shown, it includes the following steps:
[0043] S11. Collect vehicle speeds at each node in the urban road network, construct a sample set, and divide the sample set into a training set; construct a dynamic adjacency matrix based on the network topology and vehicle speed probability distribution of each node in the training set.
[0044] It should be noted that this embodiment uses an undirected graph. To abstract the topology of the urban road network, each sensor on the road is considered a node, V = {v1, v2, ..., v...} N} represents the set of nodes, with a total number of N; every two nodes are connected by an edge, and E represents the set of edges. This represents a dynamic adjacency matrix.
[0045] The data collection period is divided into multiple time slices according to a preset time interval. The average vehicle speed of each node within each time interval is taken as the vehicle speed at each time slice. The vehicle speed of node i at time slice t is... As a sample, then This represents the vehicle velocity vector at n nodes in time slice t. This represents the vehicle velocity vector at node i, in τ time slice order; This represents the set of all vehicle speeds across n nodes within τ time slices. When τ = T and n = N, it represents the speeds of all vehicles across all nodes across all time slices. To improve convergence speed, the collected vehicle speeds are normalized to the interval [0,1] to construct a sample set.
[0046] For example, data was collected from 207 sensors on 1515 roads from March to June 30, 2012 (119 days), resulting in a total of 207 nodes (N). There were 288 time slices per day, spaced at 5-minute intervals. For values not collected by the sensors, linear interpolation was used to supplement the data. Finally, each node acquired 119 * 288 = 34272 time slices of data, with each time slice corresponding to vehicle speed data from 207 nodes. The sample set was divided into training and testing sets proportionally, or a validation set could be created; these are common practices and not limited in this embodiment. For example, the training, testing, and validation sets were divided in a 7:2:1 ratio.
[0047] Furthermore, based on the network topology and vehicle speed probability distribution of each node in the training set, a dynamic adjacency matrix is constructed, including:
[0048] ① Construct a static adjacency matrix based on the network topology of each node in the training set;
[0049] ② Based on the daily vehicle speed ratio of each node in the training set, the vehicle speed probability distribution of each node is obtained; using Wasserstein distance and cosine distance as the cost function for probability distribution transition, the distance between the vehicle speed probability distributions of any two nodes is calculated, and a distance matrix is constructed.
[0050] ③ Multiply each element value in the distance matrix and the adjacency matrix by the preset distance matrix weight and adjacency matrix weight respectively, and then superimpose them. Binarize the superimposed value according to the threshold to obtain the dynamic adjacency matrix.
[0051] Specifically, static adjacency matrix Used to describe the static connectivity between nodes. In this embodiment, when two nodes are adjacent, the element value in the static adjacency matrix is 1, otherwise it is 0.
[0052] The vehicle speeds at each node in the training set are aggregated on a daily basis. Let represent the vehicle speed vector of node i on day d, where d∈[1,D] and D is the total number of days in the training set. Then, the data probability of node i on day d is calculated using the following formula.
[0053]
[0054] In formula (1), the daily vehicle speed vector of each node is transformed into a probability vector based on the ratio of the vehicle speed of node i on that day to the total vehicle speed of node i on all days in the training set. The probability of each node per day constitutes its own probability distribution P. i ,and
[0055] Next, using cosine distance as the cost function for the probability distribution transition between nodes, the probability distribution distance between any two nodes is calculated using Wasserstein distance, and a distance matrix is constructed to represent the spatial correlation between nodes.
[0056] Specifically, the vehicle velocity vector at node i on day d1 is calculated using the following formula. The vehicle velocity vector at node j on day d2 Conversion cost:
[0057]
[0058] Based on the cost function, the probability distribution distance between any two nodes can be calculated using the following formula:
[0059]
[0060]
[0061] Whereinf represents a probability distribution P i Transform into another probability distribution P j The solution that minimizes the cumulative movement distance, γ is the joint probability distribution Π[P i ,P j], whose marginal distributions are P i and P j , This represents the eigenvector of node i on day x. Let represent the eigenvalue vector of node j on day y.
[0062] Furthermore, each element value in the distance matrix and the static adjacency matrix is multiplied by the preset weights of the distance matrix and the static adjacency matrix, and then summed. The summed value is then binarized according to a threshold to obtain the dynamic adjacency matrix. The formula is shown below:
[0063]
[0064] M[i,j]=W1×D Wasserstein [i,j]+W2×A[i,j] Formula (5)
[0065] Where η represents the threshold, W1 represents the distance matrix weight, and W2 represents the adjacency matrix weight. Preferably, W1 is set to 0.45 and W2 is set to 0.55.
[0066] Compared with existing technologies, adjacency matrices are constructed based solely on the topological relationships of traffic networks. However, in reality, similar urban functional areas may lead to correlations in traffic data between network nodes, regardless of the connectivity of the network nodes. Furthermore, the network is also affected by various random factors such as road closures and traffic accidents. Therefore, dynamic adjacency matrices constructed based on time-series data can better reflect the actual connectivity relationships.
[0067] S12. Divide the training set into multiple time periods according to the time sequence, construct multiple network models according to each time period, and fuse the outputs of multiple network models to obtain the prediction model; train the prediction model based on the training set and the dynamic adjacency matrix to obtain the trained prediction model.
[0068] It should be noted that the training set is divided into multiple time periods according to the time sequence, including: according to the prediction time period, and according to the preset number of samples for each time period, training samples are divided into adjacent time periods, daily time periods, weekly time periods, and holiday time periods respectively; among them, the adjacent time period is the time period within [1.5, 2.5] hours before the prediction time period, preferably, 2 hours before the prediction time period is selected as the adjacent time period, the daily time period is the time period that is the same as the prediction time period every day before the prediction time period, the weekly time period is the time period that is the same as the prediction time period every other week before the prediction time period, and when the prediction day is a holiday, the holiday time period is the time period that is the same as the prediction time period on the prediction day in the historical year.
[0069] Specifically, training samples for adjacent time periods, daily time periods, and weekly time periods are obtained according to the following formula:
[0070]
[0071] Among them, t p T represents the start time of the forecast period. q T represents the prediction window, i.e., the number of time slices for prediction. R T represents the number of samples in a nearby time period. D T represents the number of samples in a daily time period. W This represents the number of samples in a weekly period, and m represents the number of time slices per day. For example, if time slices are divided into 5-minute intervals, then m = 288. The current time is 2012 / 5 / 17:00, and T... q =12, then it will predict the speed of 12 vehicles every 5 minutes during the time period from 2012 / 5 / 17:00 to 8:00, and set T R =24,T D =12,T W =24 means that the training samples are selected from 24 time slots from 2012 / 5 / 15:00 to 7:00, the daily time slots are selected from 12 time slots from 2012 / 4 / 30 to 8:00, and the weekly time slots are selected from 24 time slots from 2012 / 4 / 17 to 8:00 and 2012 / 4 / 24 to 7:00 to 8:00.
[0072] For training samples during holiday periods, once the predicted period is identified as a holiday, the number of samples T during the holiday period is used as the basis for the prediction. H Training samples with the same date and time period are extracted from historical years and added to X. H In the middle. For example, T H =12, select training samples corresponding to 12 time slices from 2011 / 5 / 17:00 to 8:00; if it is identified that the prediction period does not belong to a holiday, then it is not necessary to select training samples corresponding to the holiday period.
[0073] Furthermore, such as Figure 2 As shown, multiple network models are constructed according to each time period, and the outputs of multiple network models are fused to obtain the prediction model. The network models corresponding to adjacent time periods include a spatial graph convolutional layer, a gated recurrent unit, and a first fully connected layer connected in sequence. The same network models are corresponding to daily time periods, weekly time periods, and holiday time periods, including a spatial graph convolutional layer, a temporal attention layer, and a temporal convolutional layer connected in sequence. The outputs of the four network models are weighted and fused through a second fully connected layer to obtain the prediction model.
[0074] The structure and function of each layer in the network model are explained in detail below.
[0075] (I) Spatial Graph Convolutional Layer
[0076] It should be noted that the spatial graph convolutional layer structure is the same in the network models corresponding to the four time periods. It is a spatial graph convolutional layer based on feature smoothness attention mechanism and Chebyshev polynomial, which includes a spatial attention layer and a spatial graph convolutional neural network connected in sequence. The spatial attention layer calculates the spatial attention score matrix based on the difference of vehicle speed vectors between nodes in the corresponding time period, and then dynamically smooths the spatial attention score matrix according to feature smoothness before feeding it into the spatial graph convolutional neural network. The spatial graph convolutional neural network uses Chebyshev polynomial as the convolution kernel and performs convolution operation on the training samples of the corresponding time period based on the dynamic adjacency matrix and the smoothed spatial attention score matrix.
[0077] Specifically, the spatial attention layer, based on an attention mechanism, uses the vehicle velocity vector instead of external factor vectors to learn intrinsic attention. Let represent the vehicle speed vector of node i within the τ time slices of the corresponding time period. Let τ represent the vehicle velocity vector at node j within τ time slices. Based on the differences between vectors, the spatial attention score between nodes is calculated using the following formula. Used to represent the degree of influence of node j on node i, measuring the similarity between neighboring road conditions and the current road condition:
[0078]
[0079]
[0080] Among them, V s ,b s W s1 and W s2 These are learnable weight parameters, where σ represents the sigmoid activation function and N represents the total number of nodes; σ is adjusted using softmax. ij Normalization is performed to obtain the spatial attention score. Constructing an attention score matrix
[0081] It should be noted that the existing Graph Attention Network (GAT) utilizes... The attention score is calculated using vectors. This embodiment considers that the less smooth the features, the less similar a node is to its neighbors' features, meaning neighbors can contribute greater information gain. Therefore, the attention mechanism in this embodiment utilizes... The attention score is calculated by the difference between the feature vectors of node i and node j. When the features of node i are less similar to those of its neighbor j, it is easier to obtain a larger or smaller attention score.
[0082] Furthermore, since the neighborhood can provide both positive information and negative interference for a specific task, simply aggregating the feature vectors of neighbors usually does not yield better performance. Therefore, in order to amplify the useful information brought by neighbors and suppress the corresponding negative interference, it is necessary to selectively aggregate the surrounding information. In this embodiment, the attention score matrix is updated according to the feature smoothness of the corresponding time period.
[0083] Specifically, based on the average of the sum of the differences between the vehicle speed vectors of each node and its neighboring nodes, the feature smoothness of the corresponding time period is calculated using formula (9). Based on the feature smoothness and the preset multiple, the number of elements to be retained is obtained using formula (10). Based on the number of elements to be retained, the corresponding element values are retained in descending order of the element values in the attention score matrix, and the remaining element values are set to zero, thus obtaining the smoothed attention score matrix.
[0084]
[0085]
[0086] Where, ξ s The characteristic smoothness of the time period, r s Let V represent the number of nodes to be retained, V represent the set of nodes in the urban road network, and N represent the total number of nodes in V. i Let represent the set of neighboring nodes of node i, and let ∈ represent the total number of edges in the city road network. This indicates rounding up, and ρ represents a preset multiplier. Preferably, ρ is set to 2.
[0087] It should be noted that the larger ξ s The characteristic signals of the graph have a high frequency, indicating that the feature vectors between two connected nodes are more likely to be different and contain more useful information; while the neighbor information that is discarded is considered to contain more interference information, so setting it to zero and discarding it helps to preserve the characteristics of the node itself and suppress the corresponding negative interference.
[0088] Furthermore, the spatial graph convolutional neural network introduces an attention mechanism, using Chebyshev polynomials as convolution kernels. Based on the dynamic adjacency matrix and the smoothed spatial attention score matrix, it performs convolution operations on the training samples for the corresponding time periods using the following formula:
[0089]
[0090]
[0091]
[0092] Where X represents the training sample for the corresponding time period. Represents a dynamic adjacency matrix. This represents the smoothed spatial attention score matrix. λ represents the parameters that are continuously updated during training. max I represents the maximum value of the eigenvalues of the Laplacian matrix. N ★ represents the identity matrix, D represents the degree matrix, and ★ represents the degree matrix. G The graph convolution operation is represented by ⊙, and the dot product between vectors is represented by T. k (·) is a Chebyshev polynomial of order k, preferably k is set to 4.
[0093] (II) Gated Loop Unit and First Fully Connected Layer
[0094] It should be noted that recurrent neural networks are multilayer perceptrons with hidden states. They determine the current output by storing past information and current input through hidden states. However, they can suffer from problems such as numerical instability, vanishing gradients, and exploding gradients. Their ability to acquire information from distant time slices is also very limited. Therefore, this embodiment uses a variant of the recurrent neural network, the gated recurrent unit (GRU), for nearby time slices. It uses a gating mechanism to retain more historical information, and its internal structure is simple and its training speed is fast.
[0095] Specifically, the mathematical expression for the gated loop unit is as follows:
[0096] R t =σ(ΨW xr +H t-1 W hr +b r ) Formula (14)
[0097] Z t =σ(ΨW xz +H t-1 W hz +b z ) Formula (15)
[0098]
[0099]
[0100] Where Ψ represents the output of the spatial graph convolutional layer, and H t-1 R represents the hidden state value at time slice t-1. t Indicates resetting the door, Z t Indicates an update to the door. It is a candidate hidden state at time slice t. W represents the output state at time slice t. xr W hr W xz Whz W xh W hh ,b r ,b z and b h This represents the learnable parameters.
[0101] By comprehensively utilizing the hidden state at time slice t-1 and the current vehicle speed, the gated loop unit can not only capture the vehicle speed in the current time slice, but also capture the dependency relationship of vehicle speeds in time slices that are far apart.
[0102] Furthermore, the first fully connected layer uses the sigmoid function to weight and map the output of the gated recurrent unit to the output Y of the network model corresponding to the adjacent time interval. R , represented as:
[0103]
[0104] Among them, W r This represents the learnable weight parameters. This represents the output of the gated recurrent unit, and σ represents the sigmoid activation function.
[0105] (III) Temporal Attention Layer and Temporal Convolutional Layer
[0106] It should be noted that the spatial graph convolutional layer aggregates the vehicle speeds of adjacent nodes of each node. Then, for the vehicle speeds of each time slice within the corresponding time period between nodes, attention scores are calculated between different time slices to measure the influence of vehicle speeds of different time slices on the vehicle speed of the prediction window. Finally, the temporal convolutional layer aggregates the information from different time points to obtain the output for the corresponding time period.
[0107] Specifically, the time attention layer calculates a time attention score matrix based on the differences in vehicle speed vectors between time slices within the corresponding time period, and calculates the element values of the time attention score matrix according to the following formula.
[0108]
[0109]
[0110] in, Indicates the time slice t within the corresponding time period i The vehicle velocity vectors at N nodes, Indicates the time slice t within the corresponding time period j The vehicle velocity vector at N nodes, V q ,b q W q1W q2 σ represents the weight parameter, N represents the total number of nodes, and τ represents the number of time slices in the corresponding time period. The temporal attention score is normalized by softmax to ensure that the sum of the temporal attention weights of the nodes is 1.
[0111] Time attention matrix element values in This indicates the time point t. i and time point t j The time attention score between, i.e., time t j With respect to time t i The degree of dependency is then determined, and the output of the spatial graph convolutional layer is dynamically weighted to obtain the output of the temporal attention layer. Represented as:
[0112]
[0113] Furthermore, the output of the temporal attention layer is fed into the temporal convolutional layer, which is a convolutional neural network. The output of the temporal attention layer is convolved and merged, and then mapped back to its original value using the Leaky ReLU function, as shown below:
[0114]
[0115] Where * represents the standard convolution operation, and Φ represents the parameters of the convolution kernel in the time dimension, for example: the stride of the convolution kernel is 3 and the number of kernels is 64.
[0116] (iv) Second fully connected layer
[0117] It should be noted that the four time periods correspond to four network models, resulting in four output results Y. R ,Y D ,Y W ,Y H The importance of these four outputs relative to the prediction result is dynamic: for roads with significant peak times within a day, the daily output is more important; for roads with significant differences between Monday and weekend, the weekly output is relatively more critical; for roads experiencing traffic surges during holidays, the holiday output is crucial; and for roads without periodic changes, the daily and weekly outputs are less important. Therefore, the outputs of these four components are weighted and merged, and their respective weights are not fixed. They are initially randomly initialized to values between [0,1] and then iteratively updated during training. Thus, the second fully connected layer is a weighted fusion of multiple outputs to obtain the final prediction result Y, expressed as:
[0118] Y = W R⊙Y R +W D ⊙Y D +W W ⊙Y W +W H ⊙Y H Formula (23)
[0119] Among them, E R W D W w and W H These are learnable weight parameters that reflect the degree of influence of the four outputs on the prediction result.
[0120] After the prediction model is built, it is trained based on the training set and the dynamic adjacency matrix to obtain the trained prediction model, including:
[0121] By introducing the concept of course learning, in each round of training, all training samples from adjacent time periods are selected and fed into the network model corresponding to the adjacent time periods; according to the training schedulers corresponding to daily time periods, weekly time periods and holiday time periods, the corresponding training samples are selected and fed into the corresponding network models respectively.
[0122] Each network model outputs the predicted vehicle speed based on the input training samples and dynamic adjacency matrix, compares it with the corresponding actual vehicle speed, and selects the mean squared error (MSE) as the loss function of the prediction model. When the MSE reaches the preset error value, the training ends and the trained prediction model is obtained.
[0123] It should be noted that, for the training samples divided into adjacent time periods, daily time periods, weekly time periods, and holiday time periods in this embodiment, the specificity of the training samples gradually increases, and the fluctuations in vehicle speed will also be more frequent. Therefore, if the same data distribution is maintained throughout the training process, the prediction model will focus excessively on data with small amounts but large fluctuations. This will not only make the model training more difficult and require a long time to achieve a good result, but also result in poor generalization performance of the model. Therefore, this embodiment introduces the concept of course learning.
[0124] Course learning is a training strategy that can improve the generalization ability and convergence speed of various models in a wide range of scenarios. From the perspective of model optimization, an optimization method is proposed to smooth the objective, which easily finds a global minimum and continuously tracks local minima during training before gradually reducing the smoothing objective. From the perspective of data distribution, it advocates learning from simple samples first and gradually increasing the diversity and information content of the data samples. The core components of course learning are the difficulty measurer and the training scheduler. In this embodiment, different time periods are used to distinguish the difficulty. Training samples from adjacent time periods are defined as the easiest training samples, and training samples from daily, weekly, and holiday time periods are training samples with progressively increasing difficulty. Three training schedulers φ are used for each. D (c),φ W (c),φ H (c) The number of training samples increases with the number of training rounds.
[0125] Specifically, the training scheduler φ for training samples in each daily time period is represented by the following formula. D (c) The training scheduler φ for training samples in each weekly time period D (c) Training scheduler φ for training samples during holiday periods H (c):
[0126]
[0127]
[0128]
[0129] Where c represents the current training epoch, and C represents the total number of training epochs. This represents the scheduling limit of the corresponding scheduler, which is a hyperparameter between [0,1]. Preferably, it is set to...
[0130] In each training round, training samples from all adjacent time periods are selected and fed into the corresponding network model. For the other three time periods, training samples are randomly selected from the corresponding training samples using the values of the corresponding training scheduler as the selection ratio, and then fed into the corresponding network model. Thus, in the early stages of training, with primarily adjacent time period training samples, the training speed is relatively fast. In the middle stages, training samples from the other three time periods are gradually added, at which point the model begins to focus on periods with significant vehicle speed fluctuations and emphasizes improving the prediction performance in these areas. In the later stages of training, the application of four complete datasets allows the model to have a good grasp of the overall trend of vehicle speed, exhibiting good generalization performance, while also providing a more accurate approximation of periods with significant fluctuations, thereby improving overall performance.
[0131] Preferably, after the prediction model training is completed, a test set is used to evaluate the performance of the prediction model to prevent the network from overfitting to the training dataset and undertraining. Based on the prediction results of the test set, the root mean square error (RMSE), mean absolute error (MAE), and mean absolute percentage error (MAPE) are calculated to evaluate the prediction effect of the prediction model. If the prediction effect does not meet the requirements, the prediction model is retrained until the prediction effect requirements are met, and a well-trained prediction model is obtained.
[0132] S13. Collect the vehicle speed of the node to be predicted. Based on the time period to be predicted and the preset number of samples for each time period, select the test samples for each time period and input them into the trained prediction model to obtain the vehicle speed for the time period to be predicted.
[0133] It should be noted that during actual prediction, the dynamic adjacency matrix of the trained prediction model is used. Based on the time period to be predicted and the preset number of samples for each time period, the test samples for each time period are automatically selected from the vehicle speeds of the nodes to be predicted and fed into the trained prediction model. The prediction model then merges the output results of each time period to obtain the vehicle speed for the time period to be predicted.
[0134] For example, the period to be predicted is from 8:00 to 9:00 on April 12, 2022, with a time interval of 5 minutes, and the prediction window T. q =12, the period to be predicted does not fall within a holiday, then according to T R =24,T D =12,T W =24 Select the test samples for the corresponding time period and input them into the trained prediction model to obtain 12 prediction results every 5 minutes: 2022 / 4 / 12 8:05, 2022 / 4 / 12 8:10, ..., 2022 / 4 / 12 9:00.
[0135] Compared with existing technologies, the urban road vehicle speed prediction method provided in this embodiment is based on historical sequence data and uses the difference in probability distribution to measure the similarity between nodes, defining the dynamic connectivity between road network nodes, which is closer to the actual connectivity relationship. It improves the attention mechanism based on feature smoothness, so that nodes amplify the useful information brought by their neighbors and suppress the corresponding negative interference. It selects data from the four most related time periods to increase the diversity of data, and uses a training scheduling strategy based on the idea of curriculum learning to gradually increase the data from the more difficult time periods to train, so that the model has different focuses in different training processes. This not only improves the training speed and the generalization performance of the model, but also improves the prediction accuracy.
[0136] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware, and the program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.
[0137] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for predicting vehicle speed on urban roads, characterized in that, Includes the following steps: Vehicle speeds at each node in the urban road network are collected to construct a sample set, from which a training set is derived. Based on the network topology and daily vehicle speed probabilities of each node in the training set, a dynamic adjacency matrix is constructed. Specifically, this includes: constructing a static adjacency matrix based on the network topology of each node in the training set; and obtaining the daily vehicle speed probability of each node based on the daily vehicle speed ratios of each node in the training set, thus forming the vehicle speed probability distribution for each node. The distance is calculated by using cosine distance as the cost function for probability distribution transition, and the vehicle speed probability distribution distance between any two nodes is constructed to form a distance matrix. The values of each element in the distance matrix and the static adjacency matrix are multiplied by the preset weights of the distance matrix and the static adjacency matrix, respectively, and then superimposed. The superimposed value is binarized according to the threshold to obtain the dynamic adjacency matrix. The training set is divided into multiple time periods according to chronological order. Multiple network models are constructed based on each time period, and the outputs of the multiple network models are fused to obtain the prediction model. Each network model includes a spatial graph convolutional layer, which comprises a spatial attention layer and a spatial graph convolutional neural network connected sequentially. The spatial attention layer calculates a spatial attention score matrix based on the differences in vehicle speed vectors between nodes within the corresponding time period, and dynamically smooths the spatial attention score matrix according to feature smoothness before feeding it into the spatial graph convolutional neural network. The feature smoothness is obtained by averaging the sum of the differences in vehicle speed vectors between each node and its neighboring nodes. Based on the training set and the dynamic adjacency matrix, a course learning concept is introduced, and the training scheduler for daily, weekly, and holiday time periods is calculated using the following formulas. Train the prediction model to obtain a well-trained prediction model: , , , in, Indicates the current training epoch. This represents the total number of training rounds. This represents the scheduling upper limit of the corresponding training scheduler, and is a hyperparameter between [0,1]. The vehicle speed of the node to be predicted is collected. Based on the time period to be predicted and the preset number of samples for each time period, the test samples of each time period are selected and fed into the trained prediction model to obtain the vehicle speed of the time period to be predicted.
2. The urban road vehicle speed prediction method according to claim 1, characterized in that, The step of dividing the training set into multiple time periods according to time sequence includes: dividing the training samples into adjacent time periods, daily time periods, weekly time periods, and holiday time periods according to the prediction time period and the preset number of samples for each time period; wherein, the adjacent time period is the time period within [1.5, 2.5] hours before the prediction time period, the daily time period is the time period that is the same as the prediction time period every day before the prediction time period, the weekly time period is the time period that is the same as the prediction time period every other week before the prediction time period, and when the prediction day is a holiday, the holiday time period is the time period that is the same as the prediction time period on the prediction day in historical years.
3. The urban road vehicle speed prediction method according to claim 2, characterized in that, The process of constructing multiple network models based on different time periods and fusing the outputs of these models to obtain a prediction model includes: the network model corresponding to adjacent time periods includes a spatial graph convolutional layer, a gated recurrent unit, and a first fully connected layer connected in sequence; the same network model corresponds to daily time periods, weekly time periods, and holiday time periods, including a spatial graph convolutional layer, a temporal attention layer, and a temporal convolutional layer connected in sequence; and the outputs of the four network models are weighted and fused through a second fully connected layer to obtain the prediction model.
4. The urban road vehicle speed prediction method according to claim 3, characterized in that, The spatial graph convolutional neural network uses Chebyshev polynomials as convolution kernels and performs convolution operations on training samples for corresponding time periods based on dynamic adjacency matrices and smoothed spatial attention score matrices.
5. The urban road vehicle speed prediction method according to claim 3, characterized in that, The temporal attention layer calculates a temporal attention score matrix based on the difference in vehicle speed vectors between time slices within the corresponding time period. Based on the temporal attention score matrix, the output of the corresponding spatial graph convolutional layer is dynamically weighted and then output to the temporal convolutional layer. The temporal convolutional layer is a convolutional neural network that convolves and merges the output of the temporal attention layer and then maps it to the output using the LeakyReLU function.
6. The urban road vehicle speed prediction method according to claim 4, characterized in that, The element values of the spatial attention score matrix are calculated using the following formula. : , , in, Indicates the corresponding time period Nodes within a time slice The vehicle velocity vector, Indicates in Nodes within a time slice The vehicle velocity vector, and Represents the weight parameters. express Activation function N This represents the total number of nodes.
7. The urban road vehicle speed prediction method according to claim 5, characterized in that, The element values of the time attention score matrix are calculated using the following formula. : , , in, Indicates the time slice within the corresponding time period Place N The vehicle velocity vector at each node, Indicates the time slice within the corresponding time period Place N The vehicle velocity vector at each node, Represents the weight parameters. express Activation function N Indicates the total number of nodes. This indicates the number of time slices within the corresponding time period.
8. The urban road vehicle speed prediction method according to claim 4, characterized in that, The dynamic smoothing of the spatial attention score matrix based on feature smoothness includes: The mean of the sum of the differences between each node and its neighboring nodes is calculated and used as the feature smoothness for the corresponding time period. The number of items to be retained is determined based on the feature smoothness and the preset multiplier. Based on the number of elements to be retained, the corresponding element values are retained in descending order of the element values in the spatial attention score matrix, and the remaining element values are set to zero, thus obtaining the smoothed spatial attention score matrix.
9. The urban road vehicle speed prediction method according to claim 2, characterized in that, The process of training a prediction model based on a training set and a dynamic adjacency matrix to obtain a trained prediction model includes: By introducing the concept of course learning, in each round of training, all training samples from adjacent time periods are selected and fed into the network model corresponding to the adjacent time periods; according to the training schedulers corresponding to daily time periods, weekly time periods and holiday time periods, the corresponding training samples are selected and fed into the corresponding network models respectively. Each network model outputs the predicted vehicle speed based on the input training samples and dynamic adjacency matrix, compares it with the corresponding actual vehicle speed, selects the mean squared error as the loss function of the prediction model, and ends the training when the mean squared error reaches the preset error value, thus obtaining the trained prediction model.