A lightweight long- and short-term traffic flow prediction method based on time-space dual compression mechanism
By adopting the space-time dual compression attention mechanism in the traffic flow prediction model, decoupling time and spatial correlations, the problem of inefficient computing in the existing model is solved, and high accuracy prediction of long-term traffic flow is achieved.
Patent Information
- Application Number
- CN202411710875.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-11-27
AI Technical Summary
The existing traffic flow prediction model has insufficient extraction time and spatial correlation, resulting in low computational efficiency and inability to quickly obtain prediction results, especially in long-term traffic flow prediction tasks.
A lightweight long and short-term traffic flow prediction method based on space-time dual compression mechanism is adopted. By constructing a space-time dual compression attention model, the input embedded module and space-time dual compression attention module are used to decouple time and spatial correlations and reduce the computational complexity.
The model's expression ability and generalization ability are improved, the parameter quantity and calculation cost are reduced, and the model can complete traffic predictions for a longer time in the future, which significantly improves the accuracy of traffic flow prediction.
Smart Images

Figure CN119207102B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of smart city traffic flow prediction, and in particular to a lightweight long- and short-term traffic flow prediction method based on a time-space dual compression mechanism. Background Art
[0002] In recent years, traffic congestion has become a global challenge for developing sustainable, intelligent and robust transportation systems. Intelligent Transportation System (ITS) is considered to be a system that can effectively alleviate traffic congestion. Among them, traffic flow prediction technology is the core foundation of the entire intelligent transportation system, providing support for active traffic management decisions. At the government level, accurate traffic flow prediction can improve the efficiency of accident emergency response in the short term, and can be used to optimize road planning and transportation infrastructure construction in the long term. At the individual level, accurate traffic flow prediction enables individuals to choose the best travel time and route, thereby improving travel efficiency, effectively reducing fuel consumption and related travel costs, and improving the quality of life.
[0003] The essence of traffic flow prediction technology research is to better extract the correlation between time and space in traffic data. Existing methods are mainly divided into two categories: statistical learning and deep learning methods. Early research was based on statistical learning methods, such as the SARIMA model suitable for mean and variance stable data. This type of method relies on the stationarity assumption. However, due to the existence of unpredictable traffic accidents and the changes in traffic flow at different times, traffic flow data is non-stationary and often does not meet this assumption. Therefore, statistical learning methods are gradually replaced by deep learning methods. According to the different designs of core functions in deep learning networks, this type of method can be subdivided into three categories based on recurrent neural networks, convolutional neural networks, and attention mechanisms. Although deep learning-based methods have achieved some results, the existing models do not extract enough time and space correlations. A large number of redundant parameters lead to low model calculation efficiency and cannot quickly obtain prediction results. In actual traffic applications, timely prediction results are often more important than a slight improvement in accuracy. In addition, existing models are mostly limited to short-term traffic flow prediction (i.e., prediction time ≤ 1 hour). In long-term traffic flow prediction tasks (i.e., prediction time > 1 hour), they are not effective due to insufficient extraction of long-term time dependencies by the model. Compared with short-term traffic flow forecasts, long-term forecasts are obviously more important for optimizing traffic management and supporting government decision-making. Summary of the invention
[0004] In view of the deficiencies of the prior art, the object of the present invention is to provide a lightweight long- and short-term traffic flow prediction method based on a time-space dual compression mechanism.
[0005] The objective of the present invention is achieved through the following technical solution: A lightweight long- and short-term traffic flow prediction method based on a time-space dual compression mechanism, comprising the following steps:
[0006] Obtain a traffic flow data set of a fixed area; divide the traffic flow data set into a training set, a validation set, and a test set according to a preset ratio;
[0007] The training set, validation set and test set are standardized to obtain a node feature matrix after the standardized processing. ;
[0008] According to the node feature matrix , construct a spatiotemporal dual compression attention model;
[0009] The training set is used to train the spatiotemporal dual compression attention model, the validation set is used to validate the trained spatiotemporal dual compression attention model, and the test set is used to test the validated spatiotemporal dual compression attention model; the optimization is stopped after a stopping condition is met, and the stopping condition includes reaching a set total number of training rounds, or the root mean square error and the mean absolute error of the spatiotemporal dual compression attention model do not significantly decrease after several consecutive rounds; if the stopping condition is not met, the training, validation, and testing steps are repeated to continuously optimize the hyperparameters in the spatiotemporal dual compression attention model until the stopping condition is met;
[0010] The tested spatiotemporal dual compressed attention model is used to perform long-term and short-term traffic flow prediction, and the prediction results are evaluated according to evaluation indicators, including root mean square error (RMSE) and mean absolute error (MAE).
[0011] Furthermore, the spatiotemporal dual compression attention model includes two modules, namely an input embedding module and a spatiotemporal dual compression attention module, which are specifically used for:
[0012] The input embedding module is used to add periodic embedding information and adaptive position embedding information based on existing traffic history data;
[0013] The spatiotemporal dual compression attention module is used to decouple the temporal correlation and spatial correlation in the extracted traffic history data. The computational complexity of the module is much lower than that of the traditional attention mechanism, thereby reducing the computational complexity of the traditional attention mechanism from the exponential level to the linear level.
[0014] Furthermore, the traffic flow dataset is represented as:
[0015] ;
[0016] in, Indicates time, represents the time length of the space-time sequence, Indicates that all nodes are Traffic status characteristics at the moment, represents the number of sensor nodes in the road network, Indicates the number of features that each sensor node can collect; in the real traffic flow dataset, and It is not equal to 1. There are usually multiple road sensors in the road network, and the sensors are used to collect multiple traffic characteristics, such as flow rate, speed, etc.
[0017] Furthermore, the construction of the spatiotemporal dual compression attention model includes the following steps:
[0018] The input embedding module is used to implement the following steps:
[0019] The The node feature matrix obtained after normalization After three layers of embedding, the input embedding of the model is obtained ; Among them, the three layers of embedding are respectively time embedding , Weekly embed and adaptive position embedding ;
[0020] The input embedding process is as follows:
[0021] The moment is embedded , which is used to embed the periodic information within a day and the relative position information between times within a day into the model; assuming Indicates the number of time points in a day. Each hour is divided into 12 time points. The number of time points in a day is ; For time point , the time is embedded as ,but The dimension is ; Take the broadcast action and change it from Expand to , and then mapped to The same dimensions, ;
[0022] The week is embedded , used to embed the periodic information within a week and the relative position information within a week into the model; for time points , the week is embedded as ,but The dimension is ; Take the broadcast action and change it from Expand to , and then mapped to The same dimensions, ;
[0023] The adaptive position embedding , used to enhance the model’s generalization and spatiotemporal correlation modeling capabilities; Generated by randomly initializing tensors, with dimensions Same as , which is gradually tuned during the model training process to capture the complex spatiotemporal relationships in traffic time series;
[0024] The node feature matrix , , and After superposition operation, a variety of spatiotemporal information is comprehensively utilized to obtain a unified model input embedding :
[0025] ;
[0026] For the model input embedding , perform patching operations and map to dimension, the patching operation will Divided into multiple small blocks along the time dimension, each small block captures the local time correlation of the data, and obtains ; Where P represents the sequence obtained after the patching operation The number of patches;
[0027] The Input to the pre-normalization layer The input feature matrix is processed in To ensure the stability and consistency of data;
[0028] The spatiotemporal dual compression attention module is used to implement the following steps:
[0029] The input feature matrix Input to the spatiotemporal dual compression attention module for learning; the spatiotemporal dual compression attention module has layer, is a hyperparameter;
[0030] The input feature matrix After the time compression attention layer, And the residual connection is input to the post-processing network to get the output :
[0031] ;
[0032] in, represents the post-processing network, and the time-compressed attention layer is ;
[0033] The output After spatial compression attention layer , and then go through And the residual connection is input to the post-processing network to obtain the output of the spatiotemporal dual compression attention module :
[0034] ;
[0035] in, represents the post-processing network, and the spatial compression attention layer is ;
[0036] The method for obtaining the output prediction value of the spatiotemporal dual compression attention model is as follows:
[0037] The output of the spatiotemporal dual compression attention module is , After the projection layer and residual link, the output prediction value of the spatiotemporal dual compression attention model is obtained ; among them, among them Represents the length of the forecast time, is the number of sensor nodes in the road network, is the number of features to be predicted;
[0038] Through the above steps, we get the future In this time period, the road network Node The predicted value of traffic flow features is the final output predicted value of the spatiotemporal dual compressed attention model.
[0039] Furthermore, the , for input After the first normalization, the form is as follows:
[0040] ;
[0041] in, Indicates input, and They are two layers of normalization functions, It is a feed-forward neural network.
[0042] Furthermore, the time-compressed attention layer The specific expressions are as follows:
[0043] ;
[0044] in, Input to the temporal compressed attention layer, The sequence length is , the number of nodes is , the model dimension is ; is the time characteristic compression variable, The sequence length is , the number of nodes is , the model dimension is ; , is the middle hidden layer, and its dimensions are the same as Consistency; for The output of Consistency;
[0045] Compress the attention layer at the time middle, It is a hyperparameter and needs to be set before model training and meets ; is a multi-head self-attention function, where the dimension of each attention head is and ; The computational complexity is , The computational complexity is , The computational complexity is ; The time compression attention layer The overall computational complexity is: .
[0046] Furthermore, the time-compressed attention layer The overall computational complexity is , due to satisfaction The computational complexity is further simplified to , the computational complexity of the traditional attention mechanism is , so the temporal compressed attention layer The computational complexity of the traditional attention mechanism is much lower than that of the traditional attention mechanism, which reduces the computational complexity of the traditional attention mechanism from exponential level to linear level.
[0047] Furthermore, the spatial compression attention layer The specific expression is as follows:
[0048] ;
[0049] in, Input to the spatially compressed attention layer, The sequence length is , the number of nodes is , the model dimension is ; is the spatial feature compression variable, The sequence length is , the number of nodes is , the model dimension is ; , is the middle hidden layer, and its dimensions are the same as Consistency; for The output of Consistency;
[0050] Compress the attention layer in the space middle, It is a hyperparameter and needs to be set before model training and meets ; is a multi-head self-attention function, where The computational complexity is , The computational complexity is , The computational complexity is ; The spatial compression attention layer The overall computational complexity is: .
[0051] Furthermore, the spatial compression attention layer The overall computational complexity is , due to satisfaction The computational complexity is further simplified to , the computational complexity of the traditional attention mechanism is , so the spatial compression attention layer The computational complexity of the traditional attention mechanism is much lower than that of the traditional attention mechanism, which reduces the computational complexity of the traditional attention mechanism from exponential level to linear level.
[0052] Further, the continuous optimization of the hyperparameters in the spatiotemporal dual compression attention model includes: the sequence obtained after the patching operation Number of patches , the model input feature matrix The last dimension , the number of layers of the spatiotemporal dual compression attention module , Medium time compression factor , Medium space compression factor , The random dropout rate and learning rate.
[0053] The beneficial effects of the present invention are as follows: the present invention uses adaptive position embedding to capture the complex spatiotemporal relationship in the traffic time series. Its adaptive characteristics enable it to effectively simplify the model design and improve the model's expressiveness and generalization capabilities; by using the time compression attention mechanism and the space compression attention mechanism, the computational complexity of the traditional attention model is effectively reduced from the exponential level to the linear level; the use of the time-space dual compression attention model reduces the number of model parameters, thereby reducing the computational cost of the traffic prediction model, enabling the model to complete traffic predictions for a longer period of time in the future; the use of the time-space dual compression attention model reduces the sparsity of the trainable tensor, effectively removes interference information, and thus greatly improves the accuracy of the model's traffic flow prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 is a flow chart of the present invention;
[0055] Figure 2 It is a structural schematic diagram of the spatiotemporal dual compression attention model of the present invention. DETAILED DESCRIPTION
[0056] The present invention will be described in detail below with reference to the accompanying drawings.
[0057] like Figure 1 As shown, the embodiment of the present invention provides a lightweight long- and short-term traffic flow prediction method based on a time-space dual compression mechanism, comprising the following steps:
[0058] S1. Obtain a traffic flow dataset of a fixed area; the traffic flow dataset is expressed as:
[0059] ;
[0060] in, Indicates time, represents the time length of the space-time sequence, Indicates that all nodes are Traffic status characteristics at the moment, represents the number of sensor nodes in the road network, Indicates the number of features that each sensor node can collect; in the real traffic flow dataset, and It is usually not equal to 1. There are multiple road sensors in the road network, and the sensors are used to collect multiple traffic characteristics, such as flow rate, speed, etc.
[0061] S2. Divide the traffic flow data set into a training set, a validation set, and a test set according to a preset ratio, wherein the preset division ratio is 6:2:2.
[0062] S3, standardize the training set, validation set and test set to obtain a node feature matrix after standardization .
[0063] The calculation formula for Z-score standardization of the training set, validation set, and test set is:
[0064] ;
[0065] in, represents the mean value of the data set, is the standard deviation of the data set, is the original value of the data set, is the node feature matrix obtained after standardization, and Dimensions and Consistent.
[0066] S4, according to the node feature matrix , construct a spatiotemporal dual compression attention model, such as Figure 2 As shown; the spatiotemporal dual compression attention model includes an input embedding module and a spatiotemporal dual compression attention module; the input embedding module is used to add periodic embedding information and adaptive position embedding information on the basis of existing traffic history data; the spatiotemporal dual compression attention module is used to extract time correlation and spatial correlation in traffic history data.
[0067] The input embedding module is used to implement the following steps:
[0068] The The node feature matrix obtained after normalization After three layers of embedding, the input embedding of the model is obtained ; Among them, the three layers of embedding are respectively time embedding (Time-of-DayEmbedding), Week Embedding (Day-of-Week Embedding) and Adaptive Position Embedding (AdaptivePosition Embedding).
[0069] The embedding process is as follows:
[0070] The moment is embedded , which is used to embed the periodic information within a day and the relative position information between times within a day into the model; assuming Indicates the number of time points in a day. Each hour is divided into 12 time points. The number of time points in a day is ; For time point , the time is embedded as ,but The dimension is ; Take the broadcast action and change it from Expand to , and then mapped to The same dimensions, .
[0071] The week is embedded , used to embed the periodic information within a week and the relative position information within a week into the model; for time points , the week is embedded as ,but The dimension is ; Take the broadcast action and change it from Expand to , and then mapped to The same dimensions, .
[0072] The adaptive position embedding , used to enhance the model’s generalization and spatiotemporal correlation modeling capabilities; Generated by random initialization tensor method, dimension is , is gradually tuned during the model training process to capture the complex spatiotemporal relationships in traffic time series. Its adaptive characteristics enable it to effectively simplify the model design and improve the model's expressiveness and generalization capabilities.
[0073] The node feature matrix , , and After superposition operation, a variety of spatiotemporal information is comprehensively utilized to obtain a unified model input embedding :
[0074] ;
[0075] For the model input embedding , perform patching operation and obtain through linear layer mapping , where P represents the sequence obtained after the patching operation The number of patches.
[0076] The Input to the pre-normalization layer The feature matrix is obtained by processing to ensure data stability and consistency.
[0077] The spatiotemporal dual compression attention module is used to implement the following steps:
[0078] The feature matrix Input to the spatiotemporal dual compression attention module for learning; the spatiotemporal dual compression attention module has layer, is a hyperparameter.
[0079] The post-processing network The form is as follows:
[0080] ;
[0081] in, Indicates input, and They are two layers of normalization functions, It is a feed-forward neural network.
[0082] The input feature matrix After the time compression attention layer, it is input into the post-processing network through dropout and residual links to obtain the output :
[0083] ;
[0084] in, represents the post-processing network, and the time-compressed attention layer is .
[0085] The temporal compressed attention layer The specific expression is as follows:
[0086] ;
[0087] in, is a multi-head self-attention mechanism, For input, The sequence length is , the number of nodes is , the model dimension is ; is the time characteristic compression variable, The sequence length is , the number of nodes is , the model dimension is ; , is the middle hidden layer, and its dimensions are the same as consistent; in b is a hyperparameter that needs to be set before model training and meets . Output After dropout, residual link and post-processing network, the output is obtained .
[0088] Said After the spatial compression attention layer, it is input into the post-processing network through dropout and residual link, and finally the output of the spatiotemporal dual compression attention module is obtained. :
[0089] ;
[0090] in, represents the post-processing network, and the spatial compression attention layer is .
[0091] The spatial compression attention layer The specific expression is as follows:
[0092] ;
[0093] in, is the multi-head self-attention function, The sequence length is , the number of nodes is , the model dimension is ; is the spatial feature compression variable, The sequence length is , the number of nodes is , the model dimension is ; , is the middle hidden layer, and its dimensions are the same as Consistency; for The output, After dropout, residual link and post-processing network, the output of the spatiotemporal dual compression attention module is obtained. .
[0094] The output of the spatiotemporal dual compression attention module is , after the fully connected layer FC and residual link, the output of the spatiotemporal dual compression attention model is obtained Among them, Represents the length of the forecast time, is the number of sensor nodes in the road network, is the number of features to predict.
[0095] S5. Use the training set to train the spatiotemporal dual compression attention model, use the validation set to verify the trained spatiotemporal dual compression attention model, and use the test set to test the verified spatiotemporal dual compression attention model; stop the optimization after the stopping condition is met, and the stopping condition includes reaching the set total number of training rounds, or the root mean square error and mean absolute error of the spatiotemporal dual compression attention model do not decrease significantly after several consecutive rounds; if the stopping condition is not met, repeat the training, validation, and testing steps to continuously optimize the hyperparameters in the spatiotemporal dual compression attention model until the stopping condition is met.
[0096] The hyper parameters include: the model input feature matrix The last dimension , the sequence obtained after the patching operation The number of patches P and the number of layers of the spatiotemporal dual compression attention module , The time compression coefficient b, The space compression coefficient c, The random dropout rate and learning rate.
[0097] S6. Use the tested spatiotemporal dual compressed attention model to predict long-term and short-term traffic flows, and evaluate the prediction results according to evaluation indicators, including root mean square error (RMSE) and mean absolute error (MAE).
[0098] In this embodiment, the effects of the present invention are described in combination with experimental results.
[0099] The simulation environment and parameter settings are as follows:
[0100] The model input feature matrix in step S4 The last dimension =64.
[0101] The sequence obtained after the patching operation in step S4 The number of patches P=6.
[0102] The number of layers of the spatiotemporal dual compression attention module in step S4 =4.
[0103] In step S4 The time compression factor b=3.
[0104] In step S4 The medium space compression coefficient c=8.
[0105] In step S5 The dropout rate = 0.2.
[0106] The learning rate in step S5 is 0.001.
[0107] The model is trained using the ADAM optimizer, and the learning rate is reduced by half every two rounds. The optimization is stopped after the total number of training rounds reaches 10 or when the evaluation index does not drop significantly in 5 consecutive rounds; if this stopping condition is not met, the training, verification, and testing steps are repeated to continuously optimize the hyperparameters in the spatiotemporal dual compression attention model until the above conditions are met.
[0108] In order to verify the effectiveness of the present invention, the current mainstream traffic prediction models LSTM, AGCRN, SCINet, Crossformer, TimesNet, and itransformer were respectively subjected to short-term prediction experiments (for traffic flow prediction, the historical 1-hour flow predicts the next 1-hour flow) and long-term prediction experiments (for traffic speed prediction, the historical 8-hour speed predicts the next 60-hour speed) on the traffic data sets PEMS07, PEMS08, PEMS03, and PEMS04, and the parameters required for each model training are listed. The experimental results are compared as shown in Table 1 below:
[0109] Table 1: Performance and parameter count of each model on different tasks (short-term prediction of traffic flow / long-term prediction of traffic speed) and datasets
[0110] It can be concluded from Table 1 that the proposed spatiotemporal dual compression attention model (Ours) shows great advantages in different data sets and tasks (short-term traffic flow prediction and long-term traffic flow speed prediction). In the short-term traffic flow prediction experiment (predicting the future 1-hour traffic flow from the historical 1-hour traffic flow), the RMSE and MAE values of the Ours model on the PEMS07 and PEMS08 data sets are lower than those of other benchmark models (such as LSTM, AGCRN and SCINet), showing excellent prediction accuracy. In the long-term traffic flow speed prediction experiment (predicting the future 60-hour speed from the historical 8-hour speed), the Ours model also achieved lower RMSE and MAE on the PEMS03 and PEMS04 data sets, further verifying the reliability and accuracy of the model in long-term prediction tasks. The experimental results fully verify the advantages of the present invention, that is, by using the temporal compression attention mechanism and the spatial compression attention mechanism, the number of parameters of the traditional attention model is reduced, and the computational complexity is effectively reduced from the exponential level to the linear level, so that the model can still complete the traffic prediction for a longer time in the future in a resource-limited environment. At the same time, the model also effectively reduces the sparsity of the trainable tensor, thereby eliminating interference information and greatly improving the accuracy of traffic flow prediction. Therefore, the model proposed by the present invention is superior to the existing traffic prediction methods in terms of prediction accuracy and computational efficiency, and is particularly suitable for long-term traffic flow prediction.
[0111] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A lightweight long- and short-term traffic flow prediction method based on a dual-space compression mechanism, characterized in that: The following steps are involved: Obtain a traffic flow data set of a fixed area; divide the traffic flow data set into a training set, a validation set, and a test set according to a preset ratio; The training set, validation set and test set are standardized to obtain a node feature matrix after the standardized processing. According to the node feature matrix Construct a spatiotemporal dual compression attention model; The spatiotemporal dual compression attention model includes two modules, namely an input embedding module and a spatiotemporal dual compression attention module, which are specifically used for: The input embedding module is used to add periodic embedding information and adaptive position embedding information based on existing traffic history data; The spatiotemporal dual compression attention module is used to decouple the temporal correlation and spatial correlation in the extracted traffic history data; The training set is used to train the spatiotemporal dual compression attention model, the validation set is used to validate the trained spatiotemporal dual compression attention model, and the test set is used to test the validated spatiotemporal dual compression attention model; the optimization is stopped after a stopping condition is met, and the stopping condition includes reaching a set total number of training rounds, or the root mean square error and the mean absolute error of the spatiotemporal dual compression attention model do not decrease significantly after several consecutive rounds; if the stopping condition is not met, the training, validation, and testing steps are repeated for the spatiotemporal dual compression attention model, and the hyperparameters in the spatiotemporal dual compression attention model are continuously optimized until the stopping condition is met; The tested spatiotemporal dual compressed attention model is used to predict long-term and short-term traffic flows, and the prediction results are evaluated according to evaluation indicators, including root mean square error and mean absolute error.
2. According to claim 1, a lightweight long- and short-term traffic flow prediction method based on a time-space dual compression mechanism is characterized in that: The traffic flow dataset is represented as: Among them, t represents time, T represents the time length of the space-time sequence, represents the traffic status characteristics of all nodes at time t, N represents the number of sensor nodes in the road network, F Indicates the number of features that each sensor node can collect; the sensor is used to collect multiple traffic features.
3. The lightweight long- and short-term traffic flow prediction method based on the time-space dual compression mechanism according to claim 2 is characterized in that: The construction of the spatiotemporal dual compression attention model comprises the following steps: The input embedding module is used to implement the following steps: The The node feature matrix obtained after normalization After three layers of embedding, the input embedding of the model is obtained The three layers of embedding are respectively embedded in the moment E time 、Weekly embed E day and adaptive position embedding E ap ; The input embedding process is as follows: The time is embedded in E time , used to embed the periodic information within a day and the relative position information between times within a day into the model; assuming num time Indicates the number of time points in a day. Each hour is divided into 12 time points, so the number of time points in a day is num time =12×24=288; for time point t, the moment is embedded as e time (t) = t%num time , then e time The dimension is For the e time Take the broadcast action and change it from Expand to Then it is mapped to The same dimensions, The week is embedded in E day , which is used to embed the periodic information within a week and the relative position information within a week into the model; for time point t, the week embedding is Then day The dimension is For the e day Take the broadcast action and change it from Expand to Then it is mapped to The same dimensions, The adaptive position embedding E ap , used to enhance the model’s generalization ability and spatiotemporal correlation modeling capabilities; E ap Generated by randomly initializing tensors, with dimensions Same as The model is gradually fine-tuned during training to capture the complex spatiotemporal relationships in traffic time series; The node feature matrix and After superposition operation, a variety of spatiotemporal information is comprehensively utilized to obtain a unified model input embedding For the model input embedding Perform patching operation and map to d through linear layer model dimension, the patching operation will Divided into multiple small blocks along the time dimension, each small block captures the local time correlation of the data, and obtains Among them, P represents the sequence obtained after the patching operation The number of patches; The Input to the pre-normalization layer The input feature matrix is processed in To ensure the stability and consistency of data; The spatiotemporal dual compression attention module is used to implement the following steps: The input feature matrix Input into the spatiotemporal dual compression attention module for learning; the spatiotemporal dual compression attention module has a total of λ layers, where λ is a hyperparameter; The input feature matrix After the time compression attention layer, it is input into the post-processing network through dropout and residual connection to obtain the output Among them, PPN() represents the post-processing network, and the temporal compression attention layer is TemMSA(); The output After passing through the spatial compression attention layer SpaMSA(), and then through dropout and residual connection, it is input into the post-processing network to obtain the output of the spatiotemporal dual compression attention module. Among them, PPN() represents the post-processing network, and the spatial compression attention layer is SpaMSA(); The method for obtaining the output prediction value of the spatiotemporal dual compression attention model is as follows: The output of the spatiotemporal dual compression attention module is After the projection layer and residual link, the output prediction value of the spatiotemporal dual compression attention model is obtained Among them, represents the length of time for prediction, N is the number of sensor nodes in the road network, and F is the number of features for prediction; Through the above steps, we get the future The predicted values of F traffic flow features of N nodes in the road network within a time period are the final output prediction values of the spatiotemporal dual compressed attention model.
4. The lightweight long- and short-term traffic flow prediction method based on the time-space dual compression mechanism according to claim 3 is characterized in that: The PPN(), after the first normalization of the input x, is as follows: PPN(x)=Norm2(x+FFN(Norm1(x))); Among them, x represents the input, Norm1 and Norm2 are two layers of normalization functions, and FFN is a feedforward neural network.
5. The lightweight long- and short-term traffic flow prediction method based on the time-space dual compression mechanism according to claim 3 is characterized in that: The temporal compression attention layer TemMSA() is specifically expressed as follows: in, Input to the temporal compressed attention layer, The sequence length is P , the number of nodes is N, and the model dimension is d model ; is the time characteristic compression variable, B Tem The sequence length is b, the number of nodes is N, and the model dimension is d model ; is the middle hidden layer, and its dimensions are the same as B Tem Consistency; is the output of TemMSA(), and its dimension is Consistency; In the time-compressed attention layer TemMSA(), b is a hyperparameter that needs to be set in advance before model training and satisfies b<<P; the Attention() is a multi-head self-attention function, in which the dimension of each attention head is And b<<P; The computational complexity is O(bP·N 2 ), The computational complexity is O(b 2 ·N 2 ), The computational complexity is O(Pb·N 2 ); The overall computational complexity of the temporal compression attention layer TemMSA() is: O(bP·N 2 ).
6. A lightweight long- and short-term traffic flow prediction method based on a time-space dual compression mechanism according to claim 5, characterized in that: The overall computational complexity of the temporal compressed attention layer TemMSA() is O(bP·N 2 ), since b<<P, the computational complexity is further simplified to O(P·N 2 ).
7. The lightweight long- and short-term traffic flow prediction method based on the time-space dual compression mechanism according to claim 3 is characterized in that: The spatial compression attention layer SpaMSA() is specifically expressed as follows: in, Input to the spatial compression attention layer, The sequence length is P , the number of nodes is N, and the model dimension is d model ; is the spatial feature compression variable, B Spa The sequence length is P , the number of nodes is c, and the model dimension is d model ; is the middle hidden layer, and its dimensions are the same as B Spa Consistency; is the output of SpaMSA(), and its dimension is Consistency; In the spatial compression attention layer SpaMSA(), c is a hyperparameter that needs to be set before model training and satisfies c<<N; Attention() is a multi-head self-attention function, where The computational complexity is O(P 2 cN), The computational complexity is O(P 2 ·c 2 ), The computational complexity is O(P 2 Nc); the overall computational complexity of the spatial compression attention layer SpaMSA() is: O(P 2 ·cN).
8. The lightweight long- and short-term traffic flow prediction method based on the time-space dual compression mechanism according to claim 7 is characterized in that: The overall computational complexity of the spatial compression attention layer SpaMSA() is O(P 2 ·cN), since c<<N, the computational complexity is further simplified to O(P 2 ·N).
9. The lightweight long- and short-term traffic flow prediction method based on the time-space dual compression mechanism according to claim 3 is characterized in that: The continuous optimization of the hyperparameters in the spatiotemporal dual compression attention model includes: the sequence obtained after the patching operation The number of patches P, the model input feature matrix The dimension of the last dimension is d model , the number of layers λ of the spatiotemporal dual compression attention module, the time compression coefficient b in the TemMSA(), the space compression coefficient c in the SpaMSA(), the random inactivation rate of the dropout(), and the learning rate.
Citation Information
Patent Citations
Real-time traffic road network short-time traffic flow prediction method based on artificial intelligence
CN117437786A
Traffic flow prediction method and system based on time-space synchronization dynamic graph attention network
CN117671952A