Traffic prediction method and device based on dynamic spatiotemporal graph convolutional attention model
Through the dynamic spatiotemporal graph convolution attention model, using random initialization node embedding and fusion attention modules, we solve the problems of inability to capture dynamic spatial correlation and high computational complexity in the existing technology, and achieve accurate medium- and long-term analysis of traffic data. Period forecast.
Patent Information
- Application Number
- CN202110763398.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-06
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2041-07-06
AI Technical Summary
Existing traffic state prediction methods cannot effectively capture dynamic spatial correlation, and the calculation complexity is high, making it impossible to perform multi-step predictions for medium and long periods.
Using a convolutional attention model based on dynamic spatiotemporal graphs, it adaptively captures the hidden attention scores between nodes by randomly initializing node embedding vectors, and combines the codec structure and fusion attention module to model dynamic spatial and temporal correlations and reduce Computational complexity.
It achieves the accurate capture of non-stationary spatio-temporal relationships in traffic data, surpasses the performance of traditional models in multi-step prediction, and can accurately predict over longer periods of time.
Smart Images

Figure CN113487088B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of intelligent transportation, and specifically relates to a traffic prediction method and device based on a dynamic spatiotemporal graph convolutional attention model. Background Art
[0002] Traffic state prediction is a critical task in the field of intelligent transportation system (ITS). Real-time and accurate prediction of traffic flow and speed plays an important role in alleviating traffic pressure, coordinating transportation management and building smart cities. Traffic data comes from sensors installed on the edge of the road, and the recording period is usually 5 minutes. Due to the connectivity of the road and the inherent serial correlation of data records, traffic data is a typical spatiotemporal data. Early traffic state prediction methods were mainly model-driven, such as linear regression-based methods, sliding window-based autoregressive algorithms, and Kalman filter algorithms. However, these algorithms usually perform single-step predictions independently on a single traffic sensor node, ignoring the spatial dependence between traffic nodes, and are unable to perform multi-step predictions over medium and long periods (30-60 minutes).
[0003] With the development of machine learning and deep learning and the continuous upgrading of hardware computing resources, some data-driven methods are gradually applied to computer vision, natural language processing, speech recognition, and spatiotemporal sequence prediction. In the early stage of deep learning application, some researchers began to use CNN (Convolution Neural Network)-based models and RNN (Recurrent Neural Network)-based models for traffic state prediction modeling. However, CNN is limited to extracting spatial features from raster data, and traffic sensors cannot use regular raster data to model their spatial dependencies.
[0004] GNN (Graph Neural Network) is good at extracting data features in non-Euclidean space. It can be applied to various fields of irregular graph structures such as social networks, molecular structures, road networks, etc. With the proposal and development of graph networks, more and more researchers are modeling traffic data as graph data, considering sensors as nodes on the graph and connectivity between sensors as edges. Here I would like to first introduce the previous research. Some models, such as DCRNN (Diffusion Convolution Recurrent Neural Network Data-Driven Network), use diffusion convolution and random walk strategies to capture the spatial correlation between nodes; STGCN (Spatial-Temporal Graph Convolution Network) uses graph convolution neural network (Graph Convolution Network, GCN) to model spatial correlation and uses multi-scale one-dimensional convolution network (1D-CNN) to model temporal correlation; GraphWaveNet uses an adaptive adjacency matrix to model the hidden spatial dependencies in traffic data; MRA-BGCN (Multi-Range Attentive Bicomponent Graph Convolution Network) models the interactive relationship between edges of graph nodes, while taking into account the flow connectivity and competitiveness between edges; DSTGCN uses a tensor matrix estimator to decompose the Laplacian matrix in real time to model dynamic spatial correlation; STGAT (Spatial-Temporal Graph Attention In the paper, STGAT is an article published by Beijing Jiaotong University in July 2020. It is the SOTA (state-of-the-art) on two public datasets METR-LA and PEMS-BAY.
[0005] However, most of the above GCN-based models and their improvements do not consider dynamic spatial correlation. Even though the latest research has begun to use adaptive adjacency matrices to model hidden spatial dependencies (which cannot be modeled based on the distance and connectivity between sensors), this adaptive matrix has shared parameters at all historical steps, which will cause the spatial correlation to remain unchanged during the training process. However, in a real road network environment, spatiotemporal correlation is non-stationary. The correlation of distant adjacent nodes on the same road section will gradually increase over time, and the correlation of connected nodes on different road sections will continue to change over time. Therefore, the models proposed by previous researchers are not sufficient to model dynamic spatial correlation. Although the authors of DSTGCN have added tensor decomposition operations to the end-to-end learning framework, real-time tensor decomposition will inevitably bring high computational complexity, and the model still relies on a predefined adjacency matrix. Summary of the invention
[0006] In response to the above problems, the present invention provides a traffic prediction method and device based on a dynamic spatiotemporal graph convolutional attention model. First, the embedding vectors of all nodes are randomly initialized at different time steps, and the hidden attention scores between nodes are obtained by vector dot product, so as to adaptively capture dynamic spatial dependencies and accurately capture the non-stationary spatiotemporal relationships in traffic data with a lower complexity.
[0007] The technical solution of the present invention is as follows:
[0008] A traffic prediction method based on a dynamic spatiotemporal graph convolutional attention model includes the following steps:
[0009] (1) The road traffic network is modeled as a graph structure, where the nodes of the graph represent sensors, the edges of the graph represent the connectivity between sensors, and the historical speed data recorded by the sensors are used as graph signals, which include the feature dimensions of the sensor node input data.
[0010] (2) Using the graph structure and graph signal obtained in (1), a dynamic spatiotemporal graph convolutional attention model is modeled. The dynamic spatiotemporal graph convolutional attention model modeling includes sequence time correlation modeling and dynamic spatial correlation modeling. The dynamic spatiotemporal graph convolutional attention model adopts an encoder-decoder structure. The encoder unit of the dynamic spatiotemporal graph convolutional attention model captures the dynamic spatial correlation between sensor nodes at different times, the temporal correlation of historical time steps, and the temporal correlation between multi-step predictions, and obtains a hidden state containing each prediction step.
[0011] (3) The hidden state of each prediction step obtained in (2) is input into the decoder unit, and the scheduling sampling strategy is adopted to obtain the prediction results of the speed values recorded by all sensor nodes in the next hour.
[0012] Furthermore, the correlation modeling of the dynamic spatiotemporal graph convolutional attention model includes two parts: spatial correlation modeling and temporal correlation modeling. The spatial correlation modeling randomly initializes two embedding vectors for two nodes in the graph structure at a certain historical time step, and uses the dot product of the two embedding vectors to obtain the spatial correlation of the two nodes. Then, a time-varying adaptive matrix is generated through a SoftMax normalized exponential function. The time-varying adaptive matrix can adaptively learn the spatial correlation hidden by the nodes at different time steps.
[0013] Furthermore, the spatial correlation modeling also includes predefined spatial dependency modeling, and the predefined spatial dependency modeling uses dynamic aggregation of neighbor nodes to update the hidden layer vector, and the dynamic formula of the hidden layer vector is:
[0014]
[0015] in, is the hidden layer vector of node l+1 in time period t, σ is a nonlinear activation function, A∈R N×N represents the adjacency matrix in the graph convolutional network, I represents the self-connection relationship between nodes, D represents the degree matrix, represents the forward diffusion transfer matrix, represents the reverse diffusion transfer matrix, K is the number of diffusion steps, C (t) is the adaptive matrix for period t, W k1 , W k2 , W k3 , W (t) is the learnable parameter matrix.
[0016] Furthermore, the dynamic spatiotemporal graph convolutional attention model includes a dynamic graph convolutional attention network (DGCAN), a gated recurrent unit (GRU) and a fusion attention module (Fusion Attention). The dynamic graph convolutional attention network is embedded in the gated recurrent unit to obtain a DGAC-GRU module. The DGAC-GRU module includes two layers, both of which output hidden vectors. The hidden vectors output by the first layer and the second layer are spliced, and the splicing result is used as the input of the fusion attention module. The fusion attention module includes a global attention unit and a local attention unit. The global attention unit receives and outputs the hidden vectors of the past 12 time steps, and the local attention unit receives and outputs the hidden vectors of the past 6 time steps. The outputs of the global attention unit and the local attention unit are sent to the first decoder unit after gated fusion.
[0017] Furthermore, the hidden vector H of the input fusion attention module 1 , H 2 ...H 12 As items, each item contains three vectors Q (Query), K (Key) and V (Value). Q, K, V can be obtained by linear transformation of H:
[0018] Q=HW Q , K = HW K , V = HW V
[0019] Wherein, W is a learnable parameter matrix, and the attention calculation formula in the input fusion attention module is as follows:
[0020]
[0021] Among them, Q, d k Represents the dimension of the hidden vector of the input item.
[0022] Furthermore, the fusion attention module also adds a position encoding vector, and adds a predefined position encoding vector PE to each input hidden layer vector H of the fusion attention module. The encoding rule is as follows:
[0023]
[0024]
[0025] Among them, pos represents the position of the item, i represents the dimension of the item, and d model Represents the length of the position encoding vector PE.
[0026] A second aspect of the present invention is a traffic prediction device based on a dynamic spatiotemporal graph convolutional attention model, the device comprising:
[0027] The road traffic network modeling module is used to model the road traffic network as a graph structure. The nodes of the graph represent sensors, and the edges of the graph represent the connectivity between sensors. The historical speed data recorded by the sensors is used as the graph signal, which includes the characteristic dimensions of the sensor node input data.
[0028] A dynamic spatiotemporal graph convolutional attention model modeling module is used to model a dynamic spatiotemporal graph convolutional attention model using the graph structure and graph signal obtained by the road traffic network modeling module. The dynamic spatiotemporal graph convolutional attention model modeling includes sequence time correlation modeling and dynamic space correlation modeling. The dynamic spatiotemporal graph convolutional attention model adopts a codec structure. The encoder unit of the dynamic spatiotemporal graph convolutional attention model captures the dynamic spatial correlation between sensor nodes at different times, the time correlation of historical time steps, and the time correlation between multi-step predictions, and obtains a hidden state containing each prediction step.
[0029] The traffic prediction module is used to input the hidden state of each prediction step obtained by the dynamic spatiotemporal graph convolutional attention model modeling module into the decoder unit, and adopt a scheduling sampling strategy to obtain the prediction results of the speed values recorded by all sensor nodes in the next hour.
[0030] According to a third aspect of the present invention, a traffic prediction device based on a dynamic spatiotemporal graph convolutional attention model comprises: a processor; and a memory, wherein a computer executable program is stored in the memory, and when the computer executable program is executed by the processor, the above-mentioned traffic prediction method based on the dynamic spatiotemporal graph convolutional attention model is executed.
[0031] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, on which instructions are stored. When the instructions are executed by a processor, the processor performs the above-mentioned traffic prediction based on the dynamic spatiotemporal graph convolutional attention model.
[0032] The present invention provides a traffic prediction method and device based on a dynamic spatiotemporal graph convolutional attention model, which has the following beneficial effects:
[0033] 1. The dynamic graph convolutional attention network (DGCAN) is embedded into the gated recurrent unit (GRU) to obtain the DGAC-GCU module. The embedding process replaces the fully connected operation in the smallest unit of the GRU with the dynamic graph correlation feature extraction operation described in the present invention, so that the model described in the present invention can adaptively learn and capture the time-varying latent spatial dependency between nodes according to the optimization task, so that the dynamic spatial dependency modeling of the present invention can more accurately capture the real-time spatial dependency between nodes. Experiments on two public datasets METR-LA and PEMS-BAY have proved that the model described in the present invention surpasses SOTA.
[0034] 2. In the modeling of time dependency, due to the existence of the reset gate of the gated recurrent unit (GRU), the current model is difficult to generalize to the sequence prediction task of a longer period. The model described in the present invention not only uses GRU to capture the contextual correlation between sequences, but also adds a fusion attention module to capture the global time dependency of the sequence and the local correlation of the most recent sequence segment. The fusion attention module includes a global attention unit and a local attention unit, and a gated fusion mechanism is used to merge the outputs of the two. For each output time step of multi-step prediction, the fusion attention module can capture the attention scores of the sequence at different moments of the output moment in a more fine-grained manner. That is, the present invention introduces a fusion attention module when modeling the sequence time dependency, so that the method described in the present invention can be further generalized to predict sequences of a longer period. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 is a flow chart of a traffic prediction method based on a dynamic spatiotemporal graph convolutional attention model in an embodiment of the present invention;
[0036] Figure 2 Schematic diagram of the overall framework of the dynamic spatiotemporal graph convolutional attention model in an embodiment of the present invention;
[0037] Figure 3 is a schematic diagram of spatial correlation of dynamic changes of nodes under traffic control in an embodiment of the present invention;
[0038] Figure 4 is a schematic diagram of the attention layer of the dynamic spatiotemporal graph convolutional attention model in an embodiment of the present invention;
[0039] Figure 5 is a schematic diagram of the structure of a traffic prediction device based on a dynamic spatiotemporal graph convolutional attention model in an embodiment of the present invention;
[0040] Figure 6 It is a computer structure diagram of a traffic prediction device based on a dynamic spatiotemporal graph convolutional attention model in an embodiment of the present invention. DETAILED DESCRIPTION
[0041] In order to further explain the technical solution of the present invention in detail, this embodiment is implemented on the premise of the technical solution of the present invention, and provides a detailed implementation method and specific steps.
[0042] A traffic prediction method based on a dynamic spatiotemporal graph convolutional attention model according to an embodiment of the present invention is as follows: Figure 1 As shown, the following steps are included:
[0043] S01. Model the road traffic network as a graph structure. The nodes of the graph represent sensors, and the edges of the graph represent the connectivity between sensors. The historical speed data recorded by the sensors is used as the graph signal, which includes the characteristic dimensions of the sensor node input data.
[0044] The specific implementation is as follows: Given the historical speed data sequences recorded by N spatially correlated sensor nodes, the locations of the sensors, and the distances between the sensors, the traffic speed prediction task aims to predict the speeds recorded by all sensors in the future. For this task, the road traffic network is modeled as a directed graph The sensors are regarded as nodes on the graph, the connectivity between sensors is regarded as edges, V and E are the sets of nodes and edges respectively. is a weighted adjacency matrix whose value is calculated by the Gaussian kernel function of the distance between sensors. The historical speed data recorded by the sensor is regarded as a graph signal. d is the feature dimension of the node input data. The traffic speed prediction task is expressed by formula (1):
[0045]
[0046] In a specific embodiment, T′=12, T=12, and the traffic data recording period is 5 minutes. That is, given the speed recorded by all road network sensors in the past hour, the dynamic spatiotemporal graph convolutional attention model proposed in the embodiment of the present invention aims to predict the speed values recorded by all sensors in the next hour.
[0047] S02. Modeling a dynamic spatiotemporal graph convolutional attention model using the graph structure and graph signal obtained in S01. The modeling of the dynamic spatiotemporal graph convolutional attention model includes modeling of sequence time correlation and dynamic spatial correlation. The dynamic spatiotemporal graph convolutional attention model adopts a codec structure. The encoder unit of the dynamic spatiotemporal graph convolutional attention model captures the dynamic spatial correlation between sensor nodes at different times, the temporal correlation of historical moment steps, and the temporal correlation between multi-step predictions, and obtains a hidden state containing each prediction step.
[0048] The embodiment is applied to modeling the temporal and spatial correlation in traffic data, and can predict the future long-term traffic speed or flow of all nodes in the road network, and can be further extended to other non-Euclidean spatiotemporal data prediction tasks. The dynamic spatial-temporal graph attention convolution network (DGACN) proposed in the present invention mainly includes two innovative points: 1) The DGACN module is the dynamic graph convolution operation proposed in the present invention. It is embedded in the GRU unit to obtain the DGAC-GCU module. The embedding process replaces the fully connected operation in the GRU minimum unit with the dynamic graph correlation feature extraction operation proposed in the present invention, so that the model can adaptively learn and capture the time-varying latent spatial dependency between nodes according to the optimization task; 2) In the temporal dependency modeling, due to the existence of the GRU unit reset gate, the existing model is difficult to generalize to the sequence prediction task of a longer period. The present invention not only uses GRU to capture the contextual dependency between sequences, but also adds a fusion attention module to capture the global temporal dependency of the sequence and the local dependency of the nearest sequence segment. The fusion attention module includes a global attention unit and a local attention unit. Attention) unit, and a gated fusion mechanism is used to merge the outputs of the two. For each output time step of multi-step prediction, the fusion attention module can capture the attention scores of the output time at different moments of the sequence in a more fine-grained manner. Experiments conducted on two public real-world datasets, METR-LA and PEMS-BAY, show that the model of the present invention is superior to SOTA.
[0049] The overall framework of the dynamic spatiotemporal graph convolutional attention model for long-term traffic speed prediction in the embodiment of the present invention is as follows: Figure 2 As shown in the figure, the model uses an encoder-decoder structure to achieve multi-step prediction. The smallest units of the encoder and decoder are both DGAC-GRU modules. The DGAC-GRU module can capture the dynamic spatial correlation between traffic nodes at different times. The fusion attention module can capture the temporal correlation between the historical moment step and the multi-step prediction in a more fine-grained manner. The decoder unit treats the input value of each prediction step as the input of the next moment. Since multi-step prediction will produce error accumulation, a scheduled sampling strategy is used in the training stage to speed up the convergence speed in the early stage of training and correct the direction of gradient descent.
[0050] The dynamic spatiotemporal graph convolutional attention model proposed in this invention can be further decomposed into two modules from the perspective of correlation modeling, namely spatial correlation modeling and temporal correlation modeling.
[0051] The specific implementation steps of spatial correlation modeling are as follows:
[0052] Graph Convolutional Network (GCN) is an operation that aggregates node features in the spectral domain. Its adjacency matrix depends on the predefined and remains unchanged during the training process. Given an adjacency matrix A∈R N×N and the hidden layer vector of layer l The parameter matrix is To represent, the hidden layer vector of the (l+1)th node in the graph structure can be expressed as follows:
[0053]
[0054] Where σ is a nonlinear activation function. ReLU(·) is used in the dynamic spatiotemporal graph convolutional attention model, D is the degree matrix and I represents the self-connection relationship between nodes.
[0055] Graph convolutional neural networks focus on aggregating first-order neighbor features, but their ability to capture correlations between distant nodes is weak. A K-step diffusion process is used to model the spatial correlation between directed graph nodes, which can capture the impact of upstream and downstream traffic conditions at the same time. The formula for the diffusion convolution layer is as follows:
[0056]
[0057] in, represents the forward diffusion transfer matrix, represents the back-diffusion transfer matrix, and K is the number of diffusion steps.
[0058] In general, the extraction of spatial correlation relies on a predefined adjacency matrix. However, the adjacency matrix defined based on node distance cannot fully reflect the complex spatial correlation between nodes in real situations. The actual traffic conditions are very complex and it is difficult to give a strict node interaction relationship. The data-based adaptive adjacency matrix can be used to capture the corresponding hidden spatial correlation for the optimization goal.
[0059] All previous studies have regarded the spatial correlation between traffic nodes as static. However, due to the influence of weather, passenger density, holidays, traffic accidents, traffic control, etc., the correlation between nodes will change dynamically over time. Figure 3An example of a change in node correlation caused by traffic control in a specific embodiment is given. This change is highly nonlinear and difficult to capture, so it is impossible to give a specific modeling formula for its time-varying characteristics. In the dynamic spatiotemporal graph convolutional attention model of the present invention, two embedding vectors are randomly initialized for each node in the road traffic network graph structure in different historical periods, and the method of obtaining the node attention score is referred to the Graph Attention Network (GAT), that is, the dot product of the embedding vector is used to obtain the correlation between the two, and then a time-varying adaptive matrix is generated after SoftMax normalization. At different historical time steps, we randomly initialize different embedding vectors, and the model can adaptively learn the hidden spatial dependencies of nodes in different time periods according to the optimization index, thereby capturing more fine-grained dynamic spatial correlations, rather than sharing the same adjacency matrix at each time step. The calculation formula of node correlation is as follows:
[0060]
[0061] in, and Represents the embedding vector of node i and node j in the tth time period, σ is the activation function, preferably ReLU, and SoftMax represents the normalized exponential function.
[0062] In addition to the modeling of adaptive dynamic correlation, the modeling of node similarity predefined according to the distance between nodes is also crucial. Since a single-layer GCN can only aggregate the features of one-hop neighbors, and multi-layer GCN will cause over-smoothing, K graph convolution kernels are used in a single layer to extract features of different sizes, which can aggregate the features of neighbor nodes under different receptive fields. And since the message propagation is still in the first layer of convolution operation, there will be no over-smoothing problem. The spatial correlation modeling of the present invention comprehensively considers the predefined fixed spatial correlation and the dynamic hidden spatial correlation. When modeling the predefined spatial dependency, multi-step diffusion random walks and graph convolution operations are considered to aggregate the features of nodes in different subspaces. The formula of the dynamic graph convolution of the present invention is shown in formula (5):
[0063]
[0064] in, is the hidden layer vector of node l+1 in time period t, σ is a nonlinear activation function, A∈R N×N represents the adjacency matrix in the graph convolutional network, I represents the self-connection relationship between nodes, D represents the degree matrix, represents the forward diffusion transfer matrix, represents the reverse diffusion transfer matrix, K is the number of diffusion steps, C(t) is the adaptive matrix for period t, W k1 , W k2 , W k3 , W (t) is a learnable parameter matrix. In summary, this method of dynamically aggregating neighbor nodes to update the hidden layer vector allows the target node to pay attention to the nodes that are truly relevant to it in different time periods.
[0065] The specific implementation steps of time correlation modeling are as follows:
[0066] In addition to the spatial correlation between nodes, the historical data recorded by a single sensor is also typical time series data with strong time series correlation. The model based on the recurrent neural network (RNN) structure can be applied to modeling and capturing time correlation. The dynamic graph convolutional attention network (DGCAN) is combined with the recurrent unit (GRU) and called the DGAC-GRU module to jointly model the spatiotemporal correlation. Figure 2 As shown, in both the encoder and decoder stages, two layers of DGAC-GRU modeling are adopted, and each layer includes 12 basic units. The DGAC-GRU module proposed in the embodiment can be expressed as:
[0067] u (t) =Sigmoid(g A ([X (t) ;H (t-1) ])+b u )
[0068] r (t) =Sigmoid(g A ([X (t) ;H (t-1) ])+b r )
[0069] C (t) =tanh(g A ([X (t) ; r (t) ⊙H (t-1) ])+b c )
[0070] H (t) =u (t) ⊙H (t-1) +(1-u (t) )⊙C (t) (6)
[0071] Among them, g A (·) represents the dynamic spatial correlation graph convolution operation of the Dynamic Graph Convolutional Attention Network (DGCAN), X(t) represents the input of the current time step, H (t) Represents the hidden vector of the current time step output, ⊙ represents the Hadamard product, the cell in the DGAC-GRU module receives two inputs at each time step and generates an output, and maintains an update gate u in each cell (t) and a forget gate (t) , where Sigmoid represents the S-type activation function and tanh is the hyperbolic tangent activation function.
[0072] In the past, when using the autoencoder framework to model spatiotemporal prediction, the decoder would receive the output of the hidden state of the last unit of the encoder, and the hidden vectors output by the encoder at other times would be discarded. However, this recurrent neural network (Recurrent Neural Network) tends to capture the correlation between temporal contexts in the sequence, and some information will also be lost in the process of continuous forgetting and updating. Therefore, these discarded hidden vectors still contain some useful information for modeling sequence correlation. In addition, the memory capacity of the RNN structural model is difficult to propagate over longer sequences, so it is difficult to generalize to prediction tasks for longer sequences. Traffic data has serial dependency and global correlation in the time dimension. The traffic speed value recorded by the node at the current moment depends not only on the traffic speed at the previous moment, but also on the speed recorded by the node several moments earlier. Therefore, using a simple RNN structural model to extract time correlation can only extract a dependency relationship between adjacent time steps. In the model of the embodiment of the present invention, Figure 2 As shown in the figure, the hidden layer vector of the output of each DGAC-GRU unit is retained, and the output of the first layer and the output of the second layer are concatenated and used as the input of the fusion attention module. The global attention unit and the local attention unit of the fusion attention module receive the hidden layer outputs of the past 12 time steps and the hidden layer outputs of the most recent 6 time steps respectively. The outputs of the two modules are sent to the first decoder unit after the gated fusion operation, so that the global correlation of the first step output with the historical data and the local correlation with the most recent period data in the multi-step prediction can be obtained.
[0073] The Fusion Attention module is based on the encoder module of Transformer. Transformer was originally applied to machine translation tasks in the field of natural language processing (NLP). A point-product self-attention model was proposed to capture the relevance of words in sentences. In order to better adapt to traffic time series data, the present invention modifies the calculation method of self-attention and adds weighted-attention on the basis of point-product attention, which can be used to capture attention scores in different modes. Related ablation experiments have proved the effectiveness of the new calculation method of the present invention. Analogous to the machine translation task, the hidden vector output at each time step is regarded as the item of the input Fusion Attention. For each item, we maintain the three vectors of Query, Key and Value at the same time as Transformer. The attention calculation formula in the FusionAttention module is shown in formula (7):
[0074]
[0075] Among them, Q, d k represents the hidden vector dimension of the input item, W is the learnable parameter matrix, and the hidden layer output of the cell in the first layer DGAC-GRU module is And the hidden layer output in the cell in the second layer module Splice and get the input H of the Fusion Attention module 1 , H 2 ...H 12 , then Q, K, and V can be obtained from H through linear transformation.
[0076] Q=HW Q , K = HW K , V = HW V (8)
[0077] in, is the learnable parameter matrix.
[0078] Furthermore, a multi-head attention mechanism is added to the model of the present invention to capture the correlation between items in different subspaces, where the output of each head is merged through a splicing operation. Since the attention mechanism cannot capture the sequential dependency between sequences, a position encoding vector is also added to introduce the encoded position information, such as Figure 4As shown in Figure 1, a predefined position embedding vector P is added to each input item vector H of the fusion attention module. The encoding rule is consistent with that of the Transformer, as shown in formula (9):
[0079]
[0080] Among them, pos represents the position of the item, i represents the dimension of the item, and d model Represents the length of the position encoding vector PE.
[0081] S03, inputting the hidden state of each prediction step obtained in S02 into the decoder unit, adopting the scheduling sampling strategy, and obtaining the prediction result of the speed values recorded by all sensor nodes in the next hour.
[0082] After the Fusion-Attention module extracts the temporal correlation, its output is sent to the first unit of the decoder after passing through the gated fusion unit, and multi-step output is generated through recursive prediction. In order to reduce the error accumulation caused by forward propagation, a scheduling sampling strategy is adopted. In addition, the loss function of the model in the specific implementation of the present invention selects the mean absolute error (MAE).
[0083] Below, refer to Figure 5 To describe the embodiment of the present disclosure Figure 1 The device corresponding to the method shown is a traffic prediction device 100 based on a dynamic spatiotemporal graph convolutional attention model, Figure 5 1 is a schematic diagram of the structure of a traffic prediction device based on a dynamic spatiotemporal graph convolutional attention model in an embodiment of the present invention. Figure 1 The details of the methods described are the same, so for the sake of simplicity, detailed descriptions of the same contents are omitted here. Figure 5As shown, the device 100 includes: a road traffic network modeling module 101, which is used to model the road traffic network as a graph structure, the nodes of the graph represent sensors, the edges of the graph represent the connectivity between sensors, and the historical speed data recorded by the sensors are used as graph signals, and the graph signals include the feature dimensions of the sensor node input data; a dynamic spatiotemporal graph convolutional attention model modeling module 102, which is used to use the graph structure and graph signal obtained by the road traffic network modeling module 101 to model the dynamic spatiotemporal graph convolutional attention model, wherein the dynamic spatiotemporal graph convolutional attention model modeling includes sequence time correlation modeling and dynamic spatial correlation modeling, and the dynamic spatiotemporal graph convolutional attention model adopts a codec structure, and through the encoder unit of the dynamic spatiotemporal graph convolutional attention model, the dynamic spatial correlation between sensor nodes at different times is captured, the time correlation of the historical time step and the time correlation between multi-step predictions are captured, and the hidden state containing each prediction step is obtained; a traffic prediction module 103, which is used to input the hidden state of each prediction step obtained by the dynamic spatiotemporal graph convolutional attention modeling module 102 into the decoder unit, and adopt a scheduling sampling strategy to obtain the prediction result of the speed values recorded by all sensor nodes in the next hour. In addition to these three modules, the device 100 may also include other components. However, since these components are irrelevant to the content of the embodiment of the present disclosure, their illustration and description are omitted here.
[0084] The specific working process of the traffic prediction device 100 based on the dynamic spatiotemporal graph convolutional attention model refers to the description of the traffic prediction method based on the dynamic spatiotemporal graph convolutional attention model, which will not be repeated here.
[0085] In addition, the device according to the embodiment of the present invention can also be used Figure 6 The architecture of the computing device shown is implemented. Figure 6 The architecture of the computing device is shown. Figure 6 As shown, a computer system 201, a system bus 203, one or more CPUs 204, an input / output component 202, a memory 205, etc. The memory 205 can store various data or files used for computer processing and / or communication and program instructions executed by the CPU. Figure 6 The architecture shown is only exemplary and can be adjusted according to actual needs when implementing different devices. Figure 6 One or more components in .
[0086] The embodiment of the present invention may also be implemented as a computer-readable storage medium. The computer-readable storage medium according to the embodiment stores computer-readable instructions. When the computer-readable instructions are executed by a processor, the method according to the embodiment of the present invention described with reference to the above figures may be executed.
[0087] The traffic prediction method and device based on the dynamic spatiotemporal graph convolutional attention model proposed in the present invention are verified on two public data sets, PEMS-BAY and METR-LA. PEMS-BAY records the traffic speed data recorded by 325 traffic sensors in the Bay Area from January 1, 2017 to May 31, 2017 for a total of 6 months, and METR-LA records the traffic speed data recorded by 207 sensors in Los Angeles from March 1, 2012 to June 30, 2012 for a total of 4 months. In order to compare fairly with previous studies, the present invention adopts the same Z-Score normalization processing method as the predecessors in preprocessing, and divides the training set, test set and validation set in chronological order, among which the first 70% of the samples are used as the training set, the next 10% of the data are used as the validation set, and the remaining samples are used as the test set. The detailed records of the two data sets are shown in Table 1:
[0088] Table 1 Data information of PEMS-BAY and METR-LA
[0089]
[0090] The performance of the model proposed in this invention on the public dataset is shown in Table 2:
[0091] Table 2 Comparison of multi-step prediction performance
[0092]
[0093]
[0094] As can be seen from Table 2, the model of the present invention achieves the best performance in the medium and long term prediction (60 minutes) on the two data sets, and is also very close to the best model in the short term prediction.
[0095] In summary, the present invention proposes a traffic prediction method and device based on a dynamic spatiotemporal graph convolutional attention model, which has the following advantages: dynamic spatial correlation modeling can more accurately capture the real-time spatial dependency between nodes, and the experiments on two public datasets surpass the SOTA, demonstrating the effectiveness of the present invention; the Fusion-Attention module is introduced in the modeling of sequence temporal correlation, so the model can be further extended to sequence prediction tasks over longer periods of time.
[0096] In this document, the terms "comprises," "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, such that a step or method that includes a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such step or method.
[0097] The above contents are further detailed descriptions of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, several simple deductions or substitutions can be made without departing from the concept of the present invention, which should be regarded as falling within the protection scope of the present invention.
Claims
1. A traffic prediction method based on a dynamic spatiotemporal graph convolutional attention model, characterized in that: The steps include: (1) The road traffic network is modeled as a graph structure, where the nodes of the graph represent sensors, the edges of the graph represent the connectivity between sensors, and the historical speed data recorded by the sensors are used as graph signals, which include the feature dimensions of the sensor node input data. (2) using the graph structure and graph signal obtained in step (1), modeling a dynamic spatiotemporal graph convolutional attention model, wherein the modeling of the dynamic spatiotemporal graph convolutional attention model includes modeling of sequence time correlation and modeling of dynamic spatial correlation. The dynamic spatiotemporal graph convolutional attention model adopts a codec structure, and through the encoder unit of the dynamic spatiotemporal graph convolutional attention model, the dynamic spatial correlation between sensor nodes at different times is captured, the temporal correlation of historical time steps and the temporal correlation between multi-step predictions are captured, and the hidden state containing each prediction step is obtained; (3) Input the hidden state of each prediction step obtained in step (2) into the decoder unit, and adopt the scheduling sampling strategy to obtain the prediction results of the speed values recorded by all sensor nodes in the next hour; The dynamic spatiotemporal graph convolutional attention model includes a dynamic graph convolutional attention network, a gated recurrent unit and a fusion attention module. The dynamic graph convolutional attention network is embedded in the gated recurrent unit to obtain a DGAC-GRU module. The DGAC-GRU module includes two layers, both of which output hidden layer vectors. The hidden layer vectors output by the first layer and the second layer are spliced, and the splicing result is used as the input of the fusion attention module. The fusion attention module includes a global attention unit and a local attention unit. The global attention unit receives and outputs the hidden layer vectors of the past 12 time steps, and the local attention unit receives and outputs the hidden layer vectors of the past 6 time steps. The outputs of the global attention unit and the local attention unit are sent to the first decoder unit after gated fusion. The dynamic spatial correlation modeling also includes predefined spatial dependency modeling, and the predefined spatial dependency modeling uses dynamic aggregation of neighbor nodes to update the hidden layer vector. The dynamic formula of the hidden layer vector is: in, is the hidden layer vector of node in layer l+1 during time period t, is the hidden layer vector of node in layer l during time period t, σ is a nonlinear activation function, A∈R N×N represents the adjacency matrix in the graph convolutional network, I represents the self-connection relationship between nodes, D represents the degree matrix, represents the forward diffusion transfer matrix, represents the reverse diffusion transfer matrix, K1 is the number of diffusion steps, C (t) is the adaptive matrix for period t, W k1 , W k2 , W k3 , W (t) is the learnable parameter matrix.
2. The traffic prediction method based on the dynamic spatiotemporal graph convolutional attention model according to claim 1 is characterized in that: The correlation modeling of the dynamic spatiotemporal graph convolutional attention model includes two parts: dynamic spatial correlation modeling and serial time correlation modeling. The dynamic spatial correlation modeling randomly initializes two embedding vectors for two nodes in the graph structure at a certain historical time step, and uses the dot product of the two embedding vectors to obtain the spatial correlation of the two nodes. Then, a time-varying adaptive matrix is generated through the SoftMax normalized exponential function. The time-varying adaptive matrix can adaptively learn the spatial correlation hidden in the nodes at different time steps.
3. The traffic prediction method based on the dynamic spatiotemporal graph convolutional attention model according to claim 2 is characterized in that: The hidden vectors H1, H2…H of the input fusion attention module 12 As terms, each term contains three vectors: vector Q, vector K and vector V. Q, K and V can be obtained by linear transformation of H: Q=HW Q ,K=HW K ,V=HW V Among them, W is a learnable parameter matrix, and the attention calculation formula in the input fusion attention module is as follows: in, d k and d v Both represent the hidden vector dimension of the input item, and SoftMax represents the normalized exponential function.
4. The traffic prediction method based on the dynamic spatiotemporal graph convolutional attention model according to claim 3 is characterized in that: The fusion attention module also adds a position encoding vector, and adds a predefined position encoding vector PE to each input hidden layer vector H of the fusion attention module. The encoding rules are as follows: Among them, pos represents the position of the item, i represents the dimension of the item, and d model Represents the length of the position encoding vector PE.
5. A traffic prediction device based on a dynamic spatiotemporal graph convolutional attention model, characterized in that: include: The road traffic network modeling module is used to model the road traffic network as a graph structure. The nodes of the graph represent sensors, and the edges of the graph represent the connectivity between sensors. The historical speed data recorded by the sensors is used as the graph signal, which includes the characteristic dimensions of the sensor node input data. A dynamic spatiotemporal graph convolutional attention model modeling module is used to model a dynamic spatiotemporal graph convolutional attention model using the graph structure and graph signal obtained by the road traffic network modeling module. The dynamic spatiotemporal graph convolutional attention model modeling includes sequence time correlation modeling and dynamic space correlation modeling. The dynamic spatiotemporal graph convolutional attention model adopts a codec structure. The encoder unit of the dynamic spatiotemporal graph convolutional attention model captures the dynamic spatial correlation between sensor nodes at different times, the time correlation of historical time steps, and the time correlation between multi-step predictions, and obtains a hidden state containing each prediction step. The traffic prediction module is used to input the hidden state of each prediction step obtained by the dynamic spatiotemporal graph convolutional attention model modeling module into the decoder unit, and adopt a scheduling sampling strategy to obtain the prediction results of the speed values recorded by all sensor nodes in the next hour; The dynamic spatiotemporal graph convolutional attention model includes a dynamic graph convolutional attention network, a gated recurrent unit and a fusion attention module. The dynamic graph convolutional attention network is embedded in the gated recurrent unit to obtain a DGAC-GRU module. The DGAC-GRU module includes two layers, both of which output hidden layer vectors. The hidden layer vectors output by the first layer and the second layer are spliced, and the splicing result is used as the input of the fusion attention module. The fusion attention module includes a global attention unit and a local attention unit. The global attention unit receives and outputs the hidden layer vectors of the past 12 time steps, and the local attention unit receives and outputs the hidden layer vectors of the past 6 time steps. The outputs of the global attention unit and the local attention unit are sent to the first decoder unit after gated fusion. The dynamic spatial correlation modeling also includes predefined spatial dependency modeling, and the predefined spatial dependency modeling uses dynamic aggregation of neighbor nodes to update the hidden layer vector. The dynamic formula of the hidden layer vector is: in, is the hidden layer vector of node l+1 in time period t, σ is a nonlinear activation function, A∈R N×N represents the adjacency matrix in the graph convolutional network, I represents the self-connection relationship between nodes, D represents the degree matrix, represents the forward diffusion transfer matrix, represents the reverse diffusion transfer matrix, K1 is the number of diffusion steps, C (t) is the adaptive matrix for period t, W k1 , W k2 , W k3 , W (t) is the learnable parameter matrix.
6. A traffic prediction device based on a dynamic spatiotemporal graph convolutional attention model, characterized in that: include: Processor; and A memory, wherein a computer executable program is stored in the memory, and when the computer executable program is executed by the processor, the method according to any one of claims 1 to 4 is executed.
7. A computer-readable storage medium having instructions stored thereon, wherein when the instructions are executed by a processor, the processor is caused to execute the method according to any one of claims 1 to 4.
