A traffic prediction method based on long-term and short-term spatial-temporal memory

By constructing an adaptive graph and temporal dependency graph of the memory node parameter library, combined with graph convolutional recurrent units and contrastive learning loss functions, the difficult problems of spatiotemporal dependency and dynamic characteristics in traffic data prediction are solved, and higher-precision traffic prediction is achieved.

CN120183176BActive Publication Date: 2025-09-12ANHUI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510184418.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-19
Publication Date
2025-09-12
Estimated Expiration
2045-02-19

AI Technical Summary

Technical Problem

Existing traffic data prediction models are difficult to effectively capture the spatiotemporal dependencies and dynamic characteristics of traffic data, especially ignoring the time-varying interaction relationships in traffic networks, resulting in insufficient prediction accuracy.

Method used

Construct an adaptive graph and temporal dependency graph based on a memory node parameter library, extract the long-term and short-term spatiotemporal information of traffic data through graph convolutional recurrent units, and use multi-level feature adaptive integration and contrastive learning loss function for training to generate more accurate prediction results.

Benefits of technology

It improves the accuracy of traffic data prediction, can better capture the complex dynamic characteristics and spatiotemporal patterns of traffic data, and achieve more reasonable prediction results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120183176B_ABST
    Figure CN120183176B_ABST
Patent Text Reader

Abstract

The present invention discloses a traffic prediction method based on long-term and short-term spatiotemporal memory. First, traffic data is collected and preprocessed, and then converted into a traffic sequence. A traffic prediction model is constructed by first constructing a time-series dependency graph and a memory adaptive graph to obtain two adjacency matrices. The two adjacency matrices are then combined with the input traffic sequence to extract long-term and short-term spatiotemporal features through an encoder, and then multi-level feature adaptive integration is performed to obtain integrated coding features. The long-term spatiotemporal information is then reconstructed using a memory node parameter library, and after being spliced ​​with the integrated coding features, a decoder is used to generate traffic data prediction results. Finally, the traffic prediction model is trained to obtain a prediction error. Back-propagation training is then performed in combination with a contrastive learning loss function to ultimately generate a trained traffic prediction model. The present invention can obtain comprehensive spatial relationships in traffic sequences and can capture the dynamic characteristics of data that change over time, thereby improving prediction accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of traffic data prediction, and in particular to a traffic prediction method based on long-term and short-term spatiotemporal memory. Background Art

[0002] With the acceleration of global urbanization and the rapid growth of the vehicle population, traffic congestion is becoming increasingly serious, making traffic management and forecasting increasingly important. Traffic data (such as speed and volume) are key indicators of the state of the transportation system. This data, collected and transmitted by sensor networks, provides fundamental support for the operation of Intelligent Transportation Systems (ITS). As a core technology of ITS, traffic data forecasting is crucial for urban traffic management and road planning, and has far-reaching practical significance in alleviating traffic congestion.

[0003] Traffic data forecasting tasks are similar to multivariate time series (MTS) forecasting. However, compared to typical MTS, traffic data exhibits significant spatiotemporal heterogeneity and is influenced by a variety of dynamic factors, such as morning and evening rush hours and traffic accidents. This complex non-stationary nature poses significant challenges to forecasting. Therefore, effectively capturing the spatiotemporal dependencies of traffic data while addressing dynamic changes has become a key research topic in this field.

[0004] Traditional time series forecasting methods only consider a single time series and are unsuitable for time series forecasting tasks involving spatial correlations between sequences, such as traffic data. Existing models primarily consist of graph neural networks (GCNs, GATs) and sequence models (such as RNNs and transformers), respectively extracting spatial and temporal dependencies from traffic data. In particular, graph neural networks require additional topological structures to represent the spatial relationships in the data. Most research relies on additional prior knowledge, such as geographic location, to represent the correlations between sensors, but this is insufficiently comprehensive. For example, in a city, while residential and work areas may not be geographically adjacent, traffic flows between them exhibit strong dependencies due to daily commuting, indicating a potential spatial relationship. Some studies measure the topological relationships between traffic sequences by constructing parameter node learning adaptive graphs or calculating Euclidean distances or cosine similarities between sequences. However, the adjacency matrices defined in these works remain static over time, ignoring the time-varying interactions within the traffic network and failing to accurately capture the dynamic characteristics of traffic data that change over time. Summary of the Invention

[0005] The technical problem to be solved by the present invention is to provide a traffic prediction method based on long-term and short-term spatiotemporal memory, which can obtain comprehensive spatial relationships of traffic sequences and capture the dynamic characteristics of data that change over time, thereby improving prediction accuracy.

[0006] The technical solution of the present invention is:

[0007] A traffic prediction method based on long-term and short-term spatiotemporal memory specifically includes the following steps:

[0008] (1) After collecting and preprocessing traffic data, the collected traffic data is converted into a time series form using a sliding window to obtain a traffic sequence;

[0009] (2) Construct a traffic prediction model and input the traffic sequence into the traffic prediction model. First, construct a time-series dependency graph and generate a memory adaptive graph through the memory node parameter library to obtain the adjacency matrix of the time-series dependency graph and the adjacency matrix of the memory adaptive graph. Then, the two adjacency matrices are combined with the input traffic sequence and multi-level feature extraction is performed through the corresponding encoder. The outputs of the two encoders are then multi-level feature adaptively integrated to obtain integrated coding features. Finally, the memory node parameter library is used to reconstruct the long-term spatiotemporal information. After splicing the reconstructed long-term spatiotemporal information with the integrated coding features, the decoder is used to generate the prediction results of the traffic data.

[0010] (3) The real traffic sequence is divided into a training set, a validation set, and a test set to train the traffic prediction model. The prediction error is combined with the contrastive learning loss function to perform back propagation training, and finally a trained traffic prediction model is generated.

[0011] After the traffic data is collected and preprocessed, the collected traffic data is converted into a time series using a sliding window. The specific steps for obtaining the traffic series are as follows:

[0012] S11. Setting sensors in the urban traffic network to sample traffic data of vehicle flow or speed at set intervals, and then aggregating the collected traffic data into increments of set time lengths;

[0013] S12, using a sliding window to divide the sampled traffic data into a time series according to a set step size, and normalizing the data using maximum and minimum standardization;

[0014] S13, divide the normalized data into training set, validation set and test set, input them into the traffic prediction model, and perform model training, validation and testing; the input sequence of the traffic prediction model is X h ∈R N×P , where N represents the number of sensors in the urban traffic network, P is the set step size of the sliding window, and the traffic prediction model is used to predict the traffic data for the next Q time steps. The output sequence of the traffic prediction model is X f ∈R N×Q .

[0015] The specific steps of constructing the timing dependency graph and generating the memory adaptive graph through the memory node parameter library to obtain the adjacency matrix of the timing dependency graph and the adjacency matrix of the memory adaptive graph are as follows:

[0016] S21, first X h ∈R N×P Input into the gated recurrent unit GRU, retain and output the hidden representation F∈R of each time step in the last layer N×h , h is the hidden feature dimension, see the following formula (1):

[0017] F=GRU(X h ) (1);

[0018] Then the hidden representation F is passed through the learnable weights W q ,W k ∈R B×h×c The linear projection of is used to calculate the output query value Q and key value K, and then the self-attention mechanism is used to calculate the attention score Score of Q and K to obtain the similarity between each traffic sequence, as shown in the following formula (2):

[0019]

[0020] In order to avoid gradient instability caused by excessive inner product, Score is divided by the square root of the linear projection dimension c, and finally the inner product is normalized using the softmax function to obtain the adjacency matrix A of the time dependency graph. s , see the following formula (3) for details:

[0021]

[0022] S22. First, build a memory adaptive graph and randomly generate two node embedding vectors E1, E2∈R N×φ , and then construct the memory node parameter library M∈R φ×d , φ represents the number of nodes stored in the memory node parameter library, d is the feature dimension of the stored node, and then the memory node parameter library is introduced into the memory adaptive graph generation to enhance the extended learning of the node embedding vector and provide additional context information for the node embedding vector at the current moment, and obtain the adjacency matrix A of the memory adaptive graph m , the specific processing process is shown in the following formula (4):

[0023] A m =softmax(relu((E1*M)(E2*M) T ) (4);

[0024] In formula (4), relu represents the ReLU activation function, softmax represents the exponential normalization function, and T represents transpose.

[0025] The two adjacency matrices are respectively combined with the input traffic sequence and then subjected to multi-level feature extraction by the corresponding encoders. The outputs of the two encoders are then subjected to multi-level feature adaptive integration to obtain the integrated coding features. The specific steps are as follows:

[0026] S23, the encoder is mainly composed of graph convolution cycle units, as shown in the following formula (5):

[0027]

[0028] In formula (5), X t ∈R N ,H t ∈R N×h represents the input and output at time t, h is the hidden feature dimension, ⊙ represents the dot product operation, u t 、r t 、C t They represent the update gate, reset gate, and candidate gate at the current time t in the graph convolution cycle unit, θ u ,θ r ,θ c Represent the kernel parameters required for the update gate, reset gate, and candidate gate convolution respectively, * g represents the graph convolution operation, b u 、b r 、b c Represent the offsets corresponding to the update gate, reset gate, and candidate gate respectively, σ represents the Sigmoid activation function, and tanh represents the tanh activation function;

[0029] The graph convolution operation is specifically shown in the following formula (6):

[0030]

[0031] In formula (6), X is the input signal, θ is the kernel parameter, and θ* g X represents the graph convolution operation on X, θ(L)X represents the graph convolution operation by introducing the adjacency matrix, L represents the symmetric normalized Laplacian matrix of the adjacency matrix of the temporal dependency graph or the adjacency matrix of the memory adaptive graph, T k (L)∈R N×N is the k-order Chebyshev polynomial expansion calculated on L, θ k is the kernel parameter of order k, K represents the highest order of Chebyshev polynomial expansion;

[0032] Two encoders input sequence X h , the initial state is set to zero, and the two encoders respectively output the hidden state h of the last time step obtained by the graph convolution cycle unit s With h m , hidden state hs It is the short-term spatiotemporal information obtained by combining the temporal dependency graph, h m To combine the long-term spatiotemporal information obtained by memorizing adaptive graphs;

[0033] S24, for h s and h m Perform feature weighting, and then perform weighted h s and h m Perform integration to obtain the integrated coding feature h ms , see the following formula (7) for details:

[0034]

[0035] In formula (7), is the parameter space of the attention mechanism back propagation learning, W w ∈R B×N×N Indicates h s Relative to h m The weight score of .

[0036] The specific steps of reconstructing long-term spatiotemporal information using the memory node parameter library, combining the reconstructed long-term spatiotemporal information with the integrated coding features, and then using the decoder to generate traffic data prediction results are as follows:

[0037] S25. Reconstruct long-term spatiotemporal information h using the memory node parameter library m , and the reconstructed long-term spatiotemporal information is obtained, as shown in the following formula (8):

[0038]

[0039] In formula (8), Indicates h m ∈R N×h The i-th node vector, M[j] represents the node memory vector in the memory node parameter library, j∈(1…φ), M T [j] represents the transpose of M[j], Represents the i-th node vector Similarity with the node memory vector M[j], Represents the reconstructed i-th node vector, which is obtained by similarity weighted calculation.

[0040] S26, reconstruct the long-term spatiotemporal information h ma With the integrated encoding feature h ms Splice and get [h ma ,h ms ], and then input to the decoder, which is also composed of graph convolution cycle units, input the predicted Q time steps of daily timestamp embedding vector, and input the initial state [hma ,h ms ], loop decoding to get the output of each time step in the future, and finally use linear projection to get the final prediction result X of Q time steps f ∈R N×Q .

[0041] The specific steps of back propagation training using the prediction error combined with the contrastive learning loss function are as follows:

[0042] S31, first the prediction result X f And the corresponding real traffic data Y f Perform loss calculation to obtain the predicted loss L1, as shown in the following formula (9):

[0043]

[0044] S32. Use contrastive learning loss function to constrain the adjustment of node memory parameters during training. The calculation process is specifically shown in the following formula (10):

[0045]

[0046] In formula (10), Triplet loss represents the Triplet loss function, Compact loss represents the Compactness Loss function, which converts the long-term spatiotemporal information of the i-th node vector into As anchor point i, through the similarity S (i) ∈R φ The two node memory vectors that are most similar to the anchor point i in the memory node parameter library M are selected as the positive sample pos and the negative sample neg, respectively expressed as M[pos] and M[neg]. Margin is used to control the distance difference between positive and negative samples. It is used to set the threshold. λ1 and λ2 are balance factors. The contrastive learning loss function L2 is used to make the node memory vectors as compact as possible.

[0047] S33. Add the contrastive learning loss function L2 to the prediction loss L1 as the target criterion, perform backpropagation training, and achieve training convergence.

[0048] Advantages of the present invention:

[0049] (1) The present invention proposes an adaptive graph construction method based on a memory node parameter library, which enables the graph structure to have long-term spatial memory capabilities. The temporal dependency graph generated by the self-attention mechanism captures short-term spatial relationships, effectively alleviating the problem that traditional traffic data prediction models are difficult to simultaneously handle long-term and short-term spatial dependencies.

[0050] (2) The present invention integrates the outputs of the two encoders into a multi-level feature adaptive integration, overcoming the problems caused by short-term volatility. The short-term spatiotemporal information with strong volatility is effectively integrated into the long-term feature information with stable trends through dynamic weight allocation. The dynamic weight allocation mechanism is used to adjust the short-term spatial fluctuations and long-term traffic trends, thereby more comprehensively identifying the complex dynamic spatiotemporal patterns in traffic data, better adapting to the complexity and non-stationarity of traffic data, and obtaining more reasonable prediction results. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] Figure 1 It is a flow chart of the present invention.

[0052] Figure 2 It is a schematic diagram of the framework of the traffic prediction model of the present invention. DETAILED DESCRIPTION

[0053] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0054] See Figure 1 , a traffic prediction method based on long-term and short-term spatiotemporal memory, specifically including the following steps:

[0055] (1) After collecting and preprocessing traffic data, a sliding window is used to convert the collected traffic data into a time series form to obtain a traffic sequence. The specific steps are as follows:

[0056] S11. Set sensors in the urban traffic network to sample traffic data of vehicle flow or speed every 30 seconds, and then aggregate the collected traffic data into increments of every 5 minutes;

[0057] S12, using a sliding window to divide the sampled traffic data into a time series every 12 steps, and normalize the data using maximum and minimum standardization;

[0058] S13, divide the normalized data into training set, validation set and test set, input them into the traffic prediction model, and perform model training, validation and testing; the input sequence of the traffic prediction model is X h ∈R N×P , where N represents the number of sensors in the urban traffic network, P = 12 represents the past P time steps, and the traffic prediction model is used to predict the traffic data for the next Q time steps. The output sequence of the traffic prediction model is X f ∈R N×Q ;

[0059] (2) See Figure 2 , building a traffic prediction model and predicting traffic data, specifically including the following steps:

[0060] S21, first X h ∈R N×P Input into the gated recurrent unit GRU, retain and output the hidden representation F∈R of each time step in the last layer N×h , h is the hidden feature dimension, see the following formula (1):

[0061] F=GRU(X h ) (1);

[0062] Then the hidden representation F is passed through the learnable weights W q ,W k ∈R B×h×c The linear projection of is used to calculate the output query value Q and key value K, and then the self-attention mechanism is used to calculate the attention score Score of Q and K to obtain the similarity between each traffic sequence, as shown in the following formula (2):

[0063]

[0064] In order to avoid gradient instability caused by excessive inner product, Score is divided by the square root of the linear projection dimension c, and finally the inner product is normalized using the softmax function to obtain the adjacency matrix A of the time dependency graph. s , see the following formula (3) for details:

[0065]

[0066] S22. First, build a memory adaptive graph and randomly generate two node embedding vectors E1, E2∈R N×φ , and then construct the memory node parameter library M∈R φ×d , φ represents the number of nodes stored in the memory node parameter library, d is the feature dimension of the stored node, and then the memory node parameter library is introduced into the memory adaptive graph generation to enhance the extended learning of the node embedding vector and provide additional context information for the node embedding vector at the current moment, and obtain the adjacency matrix A of the memory adaptive graph m , the specific processing process is shown in the following formula (4):

[0067] A m =softmax(relu((E1*M)(E2*M) T ) (4);

[0068] In formula (4), relu represents the ReLU activation function, softmax represents the exponential normalization function, and T represents transpose;

[0069] Adjacency Matrix The i-th row of the matrix represents the spatial correlation degree between node i and other nodes. ij Represents the unique spatial relationship between node i and node j;

[0070] S23 and the two adjacency matrices are combined with the input traffic sequence and then multi-level feature extraction is performed through the corresponding encoder. The encoder is mainly composed of a graph convolutional recurrent unit (GCRU). The graph convolutional recurrent unit is improved by the gated recurrent unit (GRU) using graph convolution operations instead of matrix multiplication operations. Graph convolution can efficiently capture the relationship between nodes in non-Euclidean space, while the gated recurrent unit can model the time dependency in sequence data. The combination of the two enables GCRU to simultaneously process complex spatiotemporal patterns in traffic data, as shown in the following formula (5):

[0071]

[0072] In formula (5), X t ∈R N ,H t ∈R N×h represents the input and output at time t, h is the hidden feature dimension, ⊙ represents the dot product operation, u t 、r t 、C t They represent the update gate, reset gate, and candidate gate at the current time t in the graph convolution cycle unit, θ u ,θ r ,θ c Represent the kernel parameters required for the update gate, reset gate, and candidate gate convolution respectively, * g represents the graph convolution operation, b u 、b r 、b c Represent the offsets corresponding to the update gate, reset gate, and candidate gate respectively, σ represents the Sigmoid activation function, and tanh represents the tanh activation function;

[0073] The graph convolution operation is specifically shown in the following formula (6):

[0074]

[0075] In formula (6), X is the input signal, θ is the kernel parameter, and θ* g X represents the graph convolution operation on X, θ(L)X represents the graph convolution operation by introducing the adjacency matrix, L represents the symmetric normalized Laplacian matrix of the adjacency matrix of the temporal dependency graph or the adjacency matrix of the memory adaptive graph, T k (L)∈R N×N is the k-order Chebyshev polynomial expansion calculated on L, θk is the kernel parameter of order k, K represents the highest order of Chebyshev polynomial expansion;

[0076] The input sequence has P time steps. If the current GCRU input is X i , then k∈(t-P+1,…,t-1,t), according to formula (5), the current input information X i and the hidden state H at the previous moment i-1 Perform graph convolution operation to get the reset gate r i , determines the degree of integration between the current input information and the previous memory; from the calculated candidate gate C i Come and see, i The smaller the value of r i ⊙H i-1 The smaller the value of , the more information of the previous moment needs to be discarded. On the contrary, the more hidden state of the previous moment is retained, which helps to capture the short-term relationship of the time series. The current input information X i and the hidden state H at the previous moment i-1 Perform graph convolution operation and get the update gate u i Used to control the extent to which the state information of the previous moment is brought into the current state, u i ⊙H i-1 Indicates the retained historical information, (1-u i )⊙C i Indicates new information, using u i Calculate and update the current hidden state H i ;

[0077] Two encoders input sequence X h , the initial state is set to zero, and the two encoders respectively output the hidden state h of the last time step obtained by the graph convolution cycle unit s With h m , hidden state h s It is the short-term spatiotemporal information obtained by combining the temporal dependency graph, h m To combine the long-term spatiotemporal information obtained by memorizing adaptive graphs;

[0078] S24, for h s and h m Perform feature weighting, and then perform weighted h s and h m Perform integration to obtain the integrated coding feature h ms , see the following formula (7) for details:

[0079]

[0080] In formula (7), is the parameter space of the attention mechanism back propagation learning, Ww ∈R B×N×N Indicates h s Relative to h m The weight score of

[0081] S25. In order to further enhance the memory node parameter library’s ability to remember and distinguish different nodes and different time points, the memory node parameter library is used to reconstruct the long-term spatiotemporal information h m , and the reconstructed long-term spatiotemporal information is obtained, as shown in the following formula (8):

[0082]

[0083] In formula (8), Indicates h m ∈R N×h The i-th node vector, M[j] represents the node memory vector in the memory node parameter library, j∈(1…φ), M T [j] represents the transpose of M[j], Represents the i-th node vector Similarity with the node memory vector M[j], Represents the reconstructed i-th node vector, which is obtained by similarity weighted calculation.

[0084] S26, reconstruct the long-term spatiotemporal information h ma With the integrated encoding feature h ms Splice and get [h ma ,h ms ], and then input to the decoder, which is also composed of graph convolution cycle units, input the predicted Q time steps of daily timestamp embedding vector, and input the initial state [h ma ,h ms ], loop decoding to get the output of each time step in the future, and finally use linear projection to get the final prediction result X of Q time steps f ∈R N×Q ;

[0085] (3) Divide the real traffic sequence into a training set, a validation set, and a test set to train the traffic prediction model. The prediction error is combined with the contrastive learning loss function to perform back propagation training, and finally generate a trained traffic prediction model.

[0086] Among them, the specific steps of back propagation training based on the prediction error combined with the contrastive learning loss function are as follows:

[0087] S31, first the prediction result X f And the corresponding real traffic data Y f Perform loss calculation to obtain the predicted loss L1, as shown in the following formula (9):

[0088]

[0089] S32. Use contrastive learning loss function to constrain the adjustment of node memory parameters during training. The calculation process is specifically shown in the following formula (10):

[0090]

[0091] In formula (10), Triplet loss represents the Triplet loss function, Compact loss represents the Compactness Loss function, which converts the long-term spatiotemporal information of the i-th node vector into As anchor point i, through the similarity S (i) ∈R φ The two node memory vectors that are most similar to the anchor point i in the memory node parameter library M are selected as the positive sample pos and the negative sample neg, respectively expressed as M[pos] and M[neg]. Margin is used to control the distance difference between positive and negative samples. It is used to set the threshold. λ1 and λ2 are balance factors. The contrastive learning loss function L2 is used to make the node memory vectors as compact as possible.

[0092] S33. Add the contrastive learning loss function L2 to the prediction loss L1 as the target criterion, perform backpropagation training, and achieve training convergence.

[0093] Performance evaluation:

[0094] The PEMSBAY traffic speed dataset and the PEMS03 traffic flow dataset were used to train the model, and the traffic prediction model MDGCRN of the present invention was verified to have significantly better performance than other neural network prediction models. The evaluation indicators were mean absolute error (MAE), root mean square error (RMSE), and mean percentage error (MAPE). The performance evaluation results are shown in Table 1 below:

[0095]

[0096] Table 1

[0097]

[0098] In Table 1, DCRNN is a diffuse convolutional recurrent neural network, which proposes graph convolution of the diffusion process and combines GCN with recurrent neural network; GWNet is the first to use adaptive graph for graph convolution operation, combined with dilated causal convolution to extract temporal features; StemGNN combines graph Fourier transform and discrete Fourier transform to jointly capture sequence spatial correlation and temporal dependence in the spectral domain; PDFormer is a Transformer that can perceive the propagation of traffic delays; HimNet proposes a spatiotemporal meta-parameter pool to learn the spatiotemporal heterogeneity information of traffic sequences.

[0099] The smaller the three evaluation indicators are, the better the model prediction performance is. From the performance evaluation results in Table 1, it can be seen that DCRNN and PDFormer only use traffic maps defined based on geographic locations to construct models, GWNet and HimNet only use adaptive graphs, and StemGNN only uses instantaneous graphs. The average evaluation indicators of the MDGCRN model of the present invention for predicting 12 time steps on the PEMSBAY and PEMS03 datasets are both smaller than those of these neural network prediction models, indicating that the memory adaptive graph and time-dependent graph constructed by the MDGCRN model of the present invention can simultaneously capture long-term trend characteristics and short-term dynamic changes, and through multi-level feature adaptive integration, a dynamic weight distribution mechanism can be established to effectively balance the information contribution of different graph structures, thereby improving the modeling ability of complex traffic scenarios and achieving more accurate predictions.

[0100] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.

Claims

1. A traffic prediction method based on long-term and short-term spatiotemporal memory, characterized by: The specific steps include: (1) After collecting and preprocessing traffic data, the collected traffic data is converted into a time series form using a sliding window to obtain a traffic sequence; (2) Construct a traffic prediction model, divide the real traffic sequence into a training set, a validation set and a test set, so as to train the traffic prediction model, and obtain the prediction error combined with the contrast learning loss function, perform back propagation training, and finally generate a trained traffic prediction model; when predicting, input the traffic sequence into the traffic prediction model, first construct a time-series dependency graph, and generate a memory adaptive graph through the memory node parameter library, obtain the adjacency matrix of the time-series dependency graph and the adjacency matrix of the memory adaptive graph, and then the two adjacency matrices are respectively combined with the input traffic sequence to perform multi-level feature extraction through the corresponding encoders, and the outputs of the two encoders are respectively the short-term spatiotemporal information obtained by combining the time-series dependency graph and the long-term spatiotemporal information obtained by combining the memory adaptive graph. The outputs of the two encoders are then multi-level feature adaptively integrated to obtain integrated coding features, and finally the long-term spatiotemporal information is reconstructed using the memory node parameter library, and the reconstructed long-term spatiotemporal information is spliced ​​with the integrated coding features, and the decoder is used to generate the prediction results of the traffic data.

2. The traffic prediction method based on long-term and short-term spatiotemporal memory according to claim 1, characterized in that: After the traffic data is collected and preprocessed, the collected traffic data is converted into a time series using a sliding window. The specific steps for obtaining the traffic series are as follows: S11. Setting sensors in the urban traffic network to sample traffic data of vehicle flow or speed once every set time interval, and then aggregating the collected traffic data into increments of a set time length; S12, using a sliding window to divide the sampled traffic data into a time series according to a set step size, and normalizing the data using maximum and minimum standardization; S13, divide the normalized data into training set, validation set and test set, input them into the traffic prediction model, and perform model training, validation and testing; the input sequence of the traffic prediction model is X h ∈R N×P , where N represents the number of sensors in the urban traffic network, P is the set step size of the sliding window, and the traffic prediction model is used to predict the traffic data for the next Q time steps. The output sequence of the traffic prediction model is X f ∈R N×Q .

3. The traffic prediction method based on long-term and short-term spatiotemporal memory according to claim 2, characterized in that: The specific steps of constructing the timing dependency graph and generating the memory adaptive graph through the memory node parameter library to obtain the adjacency matrix of the timing dependency graph and the adjacency matrix of the memory adaptive graph are as follows: S21, first X h ∈R N×P Input into the gated recurrent unit GRU, retain and output the hidden representation F∈R of each time step in the last layer N×h , h is the hidden feature dimension, see the following formula (1): F=GRU(X h ) (1); Then the hidden representation F is passed through the learnable weights W q ,W k ∈R B×h×c The linear projection of is used to calculate the output query value Q and key value K, and then the self-attention mechanism is used to calculate the attention score Socre of Q and K to obtain the similarity between each traffic sequence, as shown in the following formula (2): In order to avoid gradient instability caused by excessive inner product, Score is divided by the square root of the linear projection dimension c, and finally the inner product is normalized using the softmax function to obtain the adjacency matrix A of the time dependency graph. s , see the following formula (3) for details: S22. First, build a memory adaptive graph and randomly generate two node embedding vectors E1, E2∈R N×φ , and then construct the memory node parameter library M∈R φ×d , φ represents the number of nodes stored in the memory node parameter library, d is the feature dimension of the stored node, and then the memory node parameter library is introduced into the memory adaptive graph generation to enhance the extended learning of the node embedding vector and provide additional context information for the node embedding vector at the current moment, and obtain the adjacency matrix A of the memory adaptive graph m , the specific processing process is shown in the following formula (4): YOUR m =softmax(lag((E1*M)(E2*M) T ) (4)? In formula (4), relu represents the ReLU activation function, softmax represents the exponential normalization function, and T represents transpose.

4. The traffic prediction method based on long-term and short-term spatiotemporal memory according to claim 3, characterized in that: The two adjacency matrices are respectively combined with the input traffic sequence and then subjected to multi-level feature extraction by the corresponding encoders. The outputs of the two encoders are then subjected to multi-level feature adaptive integration to obtain the integrated coding features. The specific steps are as follows: S23, the encoder is mainly composed of graph convolution cycle units, as shown in the following formula (5): In formula (5), X t ∈R N ,H t ∈R N×h represents the input and output at time t, h is the hidden feature dimension, ⊙ represents the dot product operation, u t 、r t 、C t They represent the update gate, reset gate, and candidate gate at the current time t in the graph convolution cycle unit, θ u ,θ r ,θ c Represent the kernel parameters required for the update gate, reset gate, and candidate gate convolution respectively, * g represents the graph convolution operation, b u 、b r 、b c Represent the offsets corresponding to the update gate, reset gate, and candidate gate respectively, σ represents the Sigmoid activation function, and tanh represents the tanh activation function; The graph convolution operation is specifically shown in the following formula (6): In formula (6), X is the input signal, θ is the kernel parameter, and θ* g X represents the graph convolution operation on X, θ(L)X represents the graph convolution operation by introducing the adjacency matrix, L represents the symmetric normalized Laplacian matrix of the adjacency matrix of the time-dependent graph or the adjacency matrix of the memory-adaptive graph, T k (L)∈R N×N is the k-order Chebyshev polynomial expansion calculated on L, θ k is the kernel parameter of order k, K represents the highest order of Chebyshev polynomial expansion; Two encoders input sequence X h , the initial state is set to zero, and the two encoders output the hidden state g of the last time step obtained by the graph convolution cycle unit respectively s With h m , hidden state h s It is the short-term spatiotemporal information obtained by combining the temporal dependency graph, h m To combine the long-term spatiotemporal information obtained by memorizing adaptive graphs; S24, for h s and h m Perform feature weighting, and then perform weighted h s and h m Perform integration to obtain the integrated coding feature h ms , see the following formula (7) for details: In formula (7), is the parameter space of the attention mechanism back propagation learning, W w ∈R B×N×N Indicates h s Relative to h m The weight score of .

5. The traffic prediction method based on long-term and short-term spatiotemporal memory according to claim 4, characterized in that: The specific steps of reconstructing long-term spatiotemporal information using the memory node parameter library, combining the reconstructed long-term spatiotemporal information with the integrated coding features, and then using the decoder to generate traffic data prediction results are as follows: S25. Reconstruct long-term spatiotemporal information h using the memory node parameter library m , and the reconstructed long-term spatiotemporal information is obtained, as shown in the following formula (8): In formula (8), Indicates h m ∈R N×h The i-th node vector, M[j] represents the node memory vector in the memory node parameter library, j∈(1…φ), M T [j] represents the transpose of M[j], Represents the i-th node vector Similarity with the node memory vector M[j], Represents the reconstructed i-th node vector, which is obtained by similarity weighted calculation. S26, reconstruct the long-term spatiotemporal information h ma With the integrated encoding feature h ms Splice and get [h ma ,h ms ], and then input to the decoder, which is also composed of graph convolution cycle units, input the predicted Q time steps of daily timestamp embedding vector, and input the initial state [h ma ,h ms ], loop decoding to get the output of each time step in the future, and finally use linear projection to get the final prediction result X of Q time steps f ∈R N×Q .

6. The traffic prediction method based on long-term and short-term spatiotemporal memory according to claim 2, characterized in that: The specific steps of back propagation training using the prediction error combined with the contrastive learning loss function are as follows: S31, first the prediction result X f And the corresponding real traffic data Y f Perform loss calculation to obtain the predicted loss L1, as shown in the following formula (9): S32. Use contrastive learning loss function to constrain the adjustment of node memory parameters during training. The calculation process is specifically shown in the following formula (10): In formula (10), Triplet loss represents the Triplet loss function, Compact loss represents the CompactnessLoss loss function, and the long-term spatiotemporal information of the i-th node vector is converted into As anchor point i, through the similarity S (i) ∈R φ The two node memory vectors that are most similar to the anchor point i in the memory node parameter library M are selected as the positive sample pos and the negative sample neg, respectively expressed as M[pos] and M[neg]. Margin is used to control the distance difference between positive and negative samples. It is used to set the threshold. λ1 and λ2 are balance factors. The contrastive learning loss function L2 is used to make the node memory vectors as compact as possible. S33. Add the contrastive learning loss function L2 to the prediction loss L1 as the target criterion, perform backpropagation training, and achieve training convergence.

Citation Information

Patent Citations

  • Traffic speed prediction method and device, electronic equipment and computer readable medium

    CN112863180A

  • Generative adversarial network-based urban local carbon emission hotspot prediction and regulation method

    CN118982155A