A traffic spatio-temporal sequence prediction method and system based on CNN-BiLSTM-Attention
By using the CNN-BiLSTM-Attention model, the accuracy and stability issues of traffic spatiotemporal sequence prediction in complex urban traffic scenarios are addressed. It achieves accurate prediction of peak hours and hotspot areas, improving the accuracy and engineering practicality of traffic demand forecasting.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- YANGZHOU UNIV
- Filing Date
- 2026-05-14
- Publication Date
- 2026-07-31
AI Technical Summary
Existing traffic spatiotemporal sequence prediction models struggle to accurately depict non-proximity spatial relationships and two-way temporal interactions in complex urban traffic scenarios, and lack dynamic weight allocation mechanisms, resulting in insufficient prediction accuracy and stability.
The CNN-BiLSTM-Attention model is adopted. By dividing the traffic area into multiple sub-regions, a three-dimensional tensor is constructed for feature extraction. Dimensionality is reduced by combining convolutional and pooling layers. BiLSTM is used to capture time dependence, and feature weights are dynamically allocated through the attention mechanism. Finally, the traffic demand prediction sequence is output through a fully connected layer.
It improves the accuracy and stability of traffic demand forecasting, can flexibly focus on peak hours and hot spots, reduces mean square error, mean absolute error and mean absolute percentage error, and adapts to complex road network environments without the need for special prior data.
Smart Images

Figure CN122491601A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of transportation engineering technology, specifically to a method and system for predicting traffic spatiotemporal sequences based on CNN-BiLSTM-Attention. Background Technology
[0002] With the acceleration of urbanization and the explosive growth of motorized travel demand, urban transportation systems exhibit typical characteristics of strong spatial correlation, complex temporal dynamics, and diverse influencing factors. Accurate traffic spatiotemporal sequence prediction (including taxi and ride-hailing demand prediction, short-term traffic flow prediction, etc.) serves as a key support component of intelligent transportation systems, providing decision-making basis for dynamic scheduling and assisting in road network congestion early warning and signal timing optimization.
[0003] Early traffic sequence predictions relied heavily on single models, focusing only on a single spatiotemporal dimension and failing to capture the spatiotemporal coupling characteristics of traffic flow. With technological advancements, hybrid architectures combining spatial feature extraction and time-series modeling modules have become mainstream. For example, CNNs are used to extract local spatial relationships, while LSTMs or BiLSTMs are employed to capture temporal dynamics, effectively achieving a preliminary fusion of spatiotemporal features. However, these traditional hybrid models still have significant limitations in practical applications: on the one hand, they often fall short in characterizing non-proximity spatial relationships and bidirectional temporal interactions; on the other hand, most models lack dynamic weight allocation mechanisms for key traffic features such as peak hours and congested areas, resulting in significantly limited accuracy and stability in predicting non-stationary traffic flow scenarios.
[0004] In recent years, emerging technologies such as Graph Neural Networks (GCNs) and Generative Adversarial Networks (GANs) have further expanded the boundaries of prediction, with research focusing more on refined spatiotemporal correlation characterization and adaptation to complex scenarios. Graph-based models can deeply mine road network topological features and improve the accuracy of characterizing multi-regional correlations, while generative models such as GANs are applied to the prediction of large-scale road networks. However, facing the complexity and diversity of urban traffic scenarios, these emerging models generally rely on specific prior data such as road network topology, which has a high data acquisition threshold and is difficult to adapt to different urban environments. In addition, these models generally suffer from training instability (such as GAN mode collapse) or excessive model complexity, making it difficult to balance the practical needs of high-precision prediction and actual engineering deployment. Summary of the Invention
[0005] Purpose of the invention: The first purpose of this invention is to provide a traffic spatiotemporal sequence prediction method based on CNN-BiLSTM-Attention to improve the accuracy of traffic demand prediction under complex road network conditions. The second purpose is to provide a traffic spatiotemporal sequence prediction system based on CNN-BiLSTM-Attention.
[0006] Technical solution: A traffic spatiotemporal sequence prediction method based on CNN-BiLSTM-Attention, including the following steps:
[0007] S1. Divide the target area into multiple traffic areas, divide the statistical time window into multiple time steps, and count the traffic demand of each traffic area in each time step. Set a traffic area as the central area. For each time window, construct a two-dimensional matrix including the traffic demand of the central area and its adjacent traffic areas. Treat each two-dimensional matrix as a channel to form a three-dimensional tensor.
[0008] S2. Input the three-dimensional tensor into the convolutional neural network, extract features through the convolutional layer, reduce the dimensionality through the pooling layer, and output a two-dimensional tensor.
[0009] S3. Input the two-dimensional tensor into the BILSTM model and extract the time step feature vector matrix;
[0010] S4. Input the time step feature vector matrix into the attention fusion layer. Based on the dot product similarity between the query vector and the time step feature vector matrix, obtain the weight of each feature vector. After weighted summation based on the weights, output the fused feature vector sequence.
[0011] S5. Input the fused feature vector sequence into the fully connected layer and output the traffic demand prediction sequence for several future time steps.
[0012] Specifically, traffic demand includes the originating traffic demand and the destination traffic demand within each traffic area, as shown in the following formula:
[0013]
[0014]
[0015] In the formula: Traffic demand at the starting point The destination traffic demand, Represents the transportation area. Represents the starting point of the traffic trajectory. Represents a time step. Represents the endpoint of a traffic trajectory. A set representing traffic trajectories. Represents the time coordinate. Represents spatial coordinates, Represents a time window, This represents a collection of transportation areas.
[0016] Specifically, the three dimensions of the three-dimensional tensor include the number of time steps, the number of traffic areas considered in each time step, and the traffic demand of each traffic area in each time step.
[0017] Specifically, step S2 includes: inputting the three-dimensional tensor into the convolutional layer, performing a sliding window operation to obtain a set of sub-matrices, performing an inner product operation between the sub-matrices and the unfolded convolutional kernel to obtain an output matrix, reshaping the output matrix to obtain an output tensor, dividing the output tensor into multiple regions, performing global average pooling on the entire two-dimensional feature map of each channel, taking the maximum pooling value to retain the most significant spatial features, and outputting a two-dimensional tensor.
[0018] Specifically, step S3 includes: at any time step, the BILSTM model receives the current two-dimensional tensor and the hidden state of the previous time step, calculates the retention degree of the memory unit of the previous time step and the degree of input information of the current time step entering the memory unit through the gating mechanism, generates candidate memory information of the current time step, updates the new memory unit of the current time step, and outputs the extracted time step feature vector.
[0019] Specifically, step S4 includes: given a query vector, calculating the dot product similarity between the time step feature vector matrix and the query vector, converting it into a probability distribution score vector through the Softmax function, using it as the weight of each feature vector, then performing a weighted summation of the feature vectors, and outputting a fused feature vector.
[0020] Specifically, step S5 includes: flattening the fused feature vector sequence, inputting it into a fully connected layer, and outputting a traffic demand prediction sequence for several future time steps after linear transformation and ReLU activation function.
[0021] Preferably, step S5 further includes: evaluating the prediction accuracy of the traffic demand prediction sequence using multiple evaluation indicators, and iteratively updating the parameters of the convolutional neural network, BILSTM model and attention fusion layer by minimizing the evaluation indicators until the set prediction accuracy threshold is reached.
[0022] Specifically, the evaluation indicators include mean absolute error, mean square error, and mean absolute percentage error.
[0023] This invention also provides a traffic spatiotemporal sequence prediction system based on CNN-BiLSTM-Attention, comprising:
[0024] Input Tensor Construction Module: This module is used to divide the target area into multiple traffic areas, divide the statistical time window into multiple time steps, calculate the traffic demand of each traffic area within each time step, set a traffic area as the central area, construct a two-dimensional matrix including the traffic demand of the central area and its adjacent traffic areas for each time window, and treat each two-dimensional matrix as a channel to form a three-dimensional tensor.
[0025] Convolutional Neural Network Module: This module is used to input three-dimensional tensors into a convolutional neural network, extract features through convolutional layers, perform dimensionality reduction through pooling layers, and output two-dimensional tensors.
[0026] Bidirectional Long Short-Term Memory Network Module: Used to input two-dimensional tensors into the BILSTM model and extract the time step feature vector matrix;
[0027] Attention mechanism module: It is used to input the time step feature vector matrix into the attention fusion layer, obtain the weight of each feature vector based on the dot product similarity between the query vector and the time step feature vector matrix, and output the fused feature vector sequence after weighted summation based on the weights.
[0028] Prediction output module: This module takes the fused feature vector sequence as input to the fully connected layer and outputs a traffic demand prediction sequence for several future time steps.
[0029] Beneficial Effects: Compared with existing technologies, the significant advantages of this invention are: This invention effectively extracts the local spatial correlations of the traffic network through CNN, accurately captures the bidirectional temporal dependence of traffic flow through BiLSTM, and dynamically allocates feature weights through an attention mechanism during the fusion stage. This allows the CNN-BiLSTM-Attention model to flexibly and accurately focus on key traffic scenarios such as peak hours and congested hotspots while ensuring global prediction stability. It demonstrates superior performance in dealing with complex, non-stationary traffic flows and improving prediction accuracy. Furthermore, the spatiotemporal three-dimensional tensor data structure constructed in this invention aligns with actual traffic data collection and scheduling processes. Compared to existing graph neural networks that rely on complex road network topologies or generative adversarial networks (GANs) prone to pattern collapse, the quantitative modeling method of this invention not only has higher accuracy but also requires no special prior data, making it more practical for engineering applications. It can provide scientific digital decision support for precise taxi scheduling, reducing ineffective cruising, and road network congestion early warning. In an application scenario based on 9,900,246 taxi trajectory data points from New York City, the mean squared error (MSE), mean absolute error (MAE), and mean absolute percentage error (MAPE) of the proposed solution were reduced by 36%, 36%, and 16% respectively compared to the traditional LSTM model, and by 12%, 16%, and 8% respectively compared to the CNN-GRU hybrid model. The empirical analysis of this large-scale real vehicle trajectory data demonstrates that, compared to traditional single-time-series prediction models and spatiotemporal hybrid prediction models, the traffic spatiotemporal sequence prediction method provided by this invention can significantly improve prediction accuracy and reduce the impact of errors. Attached Figure Description
[0030] Figure 1 This is a flowchart of the method in Embodiment 1 of the present invention.
[0031] Figure 2 This is a schematic diagram of the model framework of Embodiment 1 of the present invention.
[0032] Figure 3 This is a schematic diagram of traffic area division in Embodiment 2 of the present invention.
[0033] Figure 4 This is a flowchart of taxi trajectory data preprocessing in Embodiment 2 of the present invention.
[0034] Figure 5 This is a comparison chart of taxi demand in the central area of Embodiment 2 of the present invention.
[0035] Figure 6 This is a schematic diagram comparing the predicted values and actual values of different models in Embodiment 2 of the present invention. Detailed Implementation
[0036] A preferred embodiment of the present invention will be further described below with reference to the accompanying drawings.
[0037] Example 1
[0038] Please see Figure 1 As shown, this embodiment provides a traffic spatiotemporal sequence prediction method based on CNN-BiLSTM-Attention, including the following steps:
[0039] S1. Divide the target area into multiple traffic zones, divide the statistical time window into multiple time steps, and calculate the traffic demand of each traffic zone in each time step. Set a traffic zone as the central area. For each time window, construct a two-dimensional matrix including the traffic demand of the central area and adjacent areas. Treat each two-dimensional matrix as a channel to form a three-dimensional tensor.
[0040] Traffic demand includes the originating traffic demand and the destination traffic demand within each traffic area, as shown in the following formula:
[0041]
[0042]
[0043] In the formula: Traffic demand at the starting point The destination traffic demand, Represents the transportation area. Represents the starting point of the traffic trajectory. Represents a time step. Represents the endpoint of a traffic trajectory. A set representing traffic trajectories. Represents the time coordinate. Represents spatial coordinates, Represents a time window, , This represents a collection of transportation areas.
[0044] Set a region For the central region, extract its adjacent traffic regions to form a set. For each time window, construct a two-dimensional matrix containing the traffic demand of all regions within the set:
[0045]
[0046] This two-dimensional matrix is treated as a channel, forming a three-dimensional tensor used as input to the deep learning model. Its dimensions are (m, e, c). Where m represents the number of time steps; e represents the number of traffic areas considered in each time step, including the target area and its surrounding e-1 neighboring areas; and c represents the number of features of each traffic area in each time step, i.e., traffic demand data.
[0047] S2. Input the three-dimensional tensor into the convolutional neural network, extract features through the convolutional layer, perform dimensionality reduction through the pooling layer, and output a two-dimensional tensor.
[0048] Three-dimensional tensor Inputting data into a 2D convolutional neural network (CNN) allows for feature extraction and dimensionality reduction, further reducing data dimensionality and computational complexity. The input data for the 2D CNN is defined as follows: The size of the convolution kernel is .
[0049] 3D tensor Perform a sliding window operation based on the size of the convolution kernel to obtain a window of size... A set of submatrices, each submatrix having a size of . The submatrix is multiplied by the expanded convolution kernel to obtain the output matrix. The output matrix Reshape the shape to obtain a size of Output Tensor , This represents the number of channels in the output tensor.
[0050] To avoid overfitting the data, the output tensor Divided into multiple regions, the subsampling function is defined as follows: ,in, and Given trainable weights and bias parameters, perform global average pooling on the entire 2D feature map for each channel, and apply the operator. Take the max pooling value: To preserve the most significant spatial features, a two-dimensional tensor is output.
[0051] By feeding data into a convolutional neural network, the model can extract features from traffic demand data while considering spatial dependencies between regions. After extracting feature information in the convolutional layers, pooling layers are used to reduce the dimensionality of neuron activation values to enhance the model's generalization ability and reduce the dependence on local features.
[0052] S3. Input the two-dimensional tensor into the BILSTM model and extract the time step feature vector matrix.
[0053] At any time step t, the BILSTM model receives the current two-dimensional tensor. The hidden state of the previous time step The memory unit of the previous time step is calculated through a gating mechanism. degree of preservation (The Gate of Oblivion):
[0054]
[0055] The input information for the current time step is calculated and stored in the memory unit. degree (Input Gate):
[0056]
[0057] And generate candidate memory information for the current time step. :
[0058]
[0059] Then, by combining the forget gate and the input gate, the new memory unit at the current time step is updated: Output the extracted time-step feature vector :
[0060]
[0061] In the formula: This is the sigmoid function.
[0062] The final output is the time-step feature vector matrix. .
[0063] S4. Input the time step feature vector matrix into the attention fusion layer. Based on the dot product similarity between the query vector and the time step feature vector matrix, obtain the weight of each feature vector. After weighted summation based on the weights, output the fused feature vector sequence.
[0064] In traffic demand forecasting, different features contribute differently to the final prediction result at different time periods. At a specific moment, the demand in a certain traffic area may have a higher weight because the demand in that area has a greater impact on the prediction result. Conversely, for adjacent moments, factors such as weather may have a higher weight because their impact is more significant within that time period. Different training focuses during model training can greatly affect prediction accuracy. Therefore, this invention introduces an attention fusion mechanism, which weights and fuses features according to the importance of demand at different times to obtain more accurate prediction results. When extracting spatiotemporal dependencies, the similarity between features is calculated, and weights are assigned to features at each moment based on the magnitude of the similarity.
[0065] Specifically, given a query vector Calculate the time step eigenvector matrix and The dot product similarity between them is converted into a probability distribution score vector using the Softmax function. : Each feature vector is used as a weight, and then the feature vectors are summed using weighted averages to output a fused feature vector. :
[0066]
[0067] In the formula: This represents the number of features in the eigenvector matrix at each time step.
[0068] S5. Input the fused feature vector sequence into the fully connected layer and output the traffic demand prediction sequence for several future time steps.
[0069] To obtain the final traffic demand prediction result, the fused feature vector sequence is flattened and input into a fully connected layer. The fully connected layer contains multiple neurons, each of which is connected to all neurons in the previous layer, and each connection is assigned a weight. After linear transformation and ReLU activation function, the output is the traffic demand prediction sequence for the next T time steps. .
[0070] Please refer to Figure 2 As shown, this embodiment completes the construction of the CNN-BiLSTM-Attention model, realizing the full function of predicting future traffic demand from raw traffic demand data.
[0071] To quantify the prediction error and optimize the network parameters in reverse, this embodiment uses multiple evaluation metrics to assess the prediction accuracy of the traffic demand prediction sequence. The CNN-BiLSTM-Attention model iteratively updates the network parameters by minimizing the evaluation metrics until the set prediction accuracy threshold is reached.
[0072] In this embodiment, the evaluation metrics used include mean absolute error, mean square error, and mean absolute percentage error.
[0073] Example 2
[0074] This embodiment provides an application case of the traffic spatiotemporal sequence prediction method based on CNN-BiLSTM-Attention described in Embodiment 1 in a real-world scenario.
[0075] This embodiment focuses on the operation of yellow taxis in New York City's transportation network. The dataset spans from September 1, 2021 to November 30, 2021 (91 days), covering 24 hours a day. The study includes 13,587 yellow taxis in New York City, totaling 9,900,246 trajectory data points. The data field structure of the original trajectory data is shown in Table 1 below, including multiple fields such as time, spatial location, and trip characteristics.
[0076] Table 1. Raw taxi trajectory data
[0077] Serial Number Data field name Chinese name 0 VendorID itinerary number 1 Pickup_datetime Boarding time 2 Dropoff_datetime Disembarkation time 3 Passenger count Passenger numbers 4 Trip_distance Travel distance 5 PULocationID Boarding area 6 DOLocationID Disembarkation area 7 RateCodeID End code 8 Payment_type Payment type
[0078] In this dataset, New York City is divided into 265 transportation zones, distributed across 5 boroughs and hub areas. Specific division parameters are shown in Table 2. Please refer to the table for details. Figure 3 The image shows the specific traffic zone division results, with the numbers in the image representing traffic zone numbers.
[0079] Table 2 Taxi District Division Data
[0080] Serial Number Regional Classification name Regional Longitude Regional Dimension 1 EWR Newark International Airport 40°69'N 74°17'W 2 Queens South Latitude Queens 40°72'N 73°79'W 3 Bronx Bronx 40°54'N 73°54'W 4 Manhattan Manhattan 40°44'N 105°36'W 5 Brooklyn Brooklyn 41°47'N 71°57'W 6 Staten Island Staten Island 40°35'N 74°09'W 7 Unknown Unrecorded areas ------- -------
[0081] Due to noise and other factors in the data acquisition equipment, the raw data in the dataset contains redundancy and errors. Please refer to [link / reference needed]. Figure 4 As shown, this embodiment first excludes abnormal data such as identical pick-up and drop-off times, trip durations less than 5 minutes, and data outside the specified time range, and then fills in blank values. To further improve prediction efficiency, statistical calculations are performed on the cleaned data to calculate the taxi demand ratio of the five municipal districts, as shown in Table 3 below.
[0082] Table 3. Percentage of Taxi Demand in the New York City Area
[0083] Manhattan Queens Brooklyn Bronx Staten Island Unknown 3259733 291309 47156 24172 4644 868 89.85% 8.02% 1.29% 0.66% 0.12% 0.06%
[0084] Because Manhattan accounts for 89.85% of the total taxi demand in New York City, far exceeding other boroughs, it is defined as the predicted core hotspot area in this example. Please refer to [link / reference needed]. Figure 5 As shown, this is a comparison of taxi demand distribution in various transportation areas within Manhattan. The numbers represent transportation area numbers. The taxi demand data for Manhattan is divided into 15-minute time windows to construct a three-dimensional spatiotemporal tensor.
[0085] After constructing the 3D tensor, the hyperparameters of the CNN-BiLSTM-Attention model need to be optimized. The number of CNN layers is a key parameter affecting spatial feature extraction capability. Evaluation was conducted using a random search strategy, and the errors for different CNN layer numbers are shown in Table 4. The results show that when the CNN has 2 layers, its mean squared error (MSE), mean absolute error (MAE), and mean absolute percentage error (MAPE) are all optimal.
[0086] Table 4
[0087] CNN layers MSE MAE MAPE 1 16.18 7.6 50.5237 2 15.218 5.32 41.52 3 16.58 5.879 48.217 4 16.389 5.8 47.31
[0088] Similarly, the optimal number of layers for BiLSTM is determined to be 3. The final global hyperparameters of the model determined in this embodiment are shown in Table 5 below.
[0089] Table 5 Hyperparameter Configuration
[0090] Parameter settings in the model The values of parameters in the model Learning rate 0.01 Model Optimizer Adam Initial offset value (b) 0.01 Gradient weights (lr) 0.001 Number of training sessions (epochs) 1000 The number of samples used in a single training session (batch size) 64 The probability of randomly deleting multiple branches (drop prob) 0.5
[0091] Using a CNN-BiLSTM-Attention model with optimized parameters, a three-dimensional tensor constructed based on the taxi demand matrix of different traffic areas is used as the model input for training. The model outputs the taxi demand per 15 minutes for all traffic areas in Manhattan over the next 7 days. To demonstrate the performance advantage of this invention over existing technologies, this embodiment selects the traditional single prediction model LSTM and the hybrid prediction model CNN-GRU for comparative experiments on the same dataset. The model prediction results output as the taxi demand per 15 minutes for all traffic areas in Manhattan over the next 7 days. The comprehensive evaluation results of each model across the four traffic areas of Manhattan (237th, 236th, 161st, and 142nd boroughs) are shown in Tables 6-9 below.
[0092] Table 6 Comparison of Model Evaluation Indicators for Zone 237
[0093] Model MAE MAPE MSE LSTM 23.57 218.60 58.45 CNN-GRU 6.30 49.76 16.59 CNN+BILSTM+Attention 6.61 43.52 16.47
[0094] Table 7 Comparison of Model Evaluation Indicators for Zone 236
[0095] Model MAE MAPE MSE LSTM 27.57 219.60 56.45 CNN-GRU 6.30 49.16 17.12 CNN+BILSTM+Attention 9.63 44.43 14.41
[0096] Table 8 Comparison of Model Evaluation Indicators in Zone 161
[0097] Model MAE MAPE MSE LSTM 23.57 216.4 59.12 CNN-GRU 6.30 49.76 17.19 CNN+BILSTM+Attention 6.61 43.52 15.43
[0098] Table 9 Comparison of Model Evaluation Indicators in Zone 142
[0099] Model MAE MAPE MSE LSTM 23.57 217.30 54.45 CNN-GRU 7.35 49.76 16.19 CNN+BILSTM+Attention 5.32 42.52 15.22
[0100] Please refer to Figure 6 As shown, in the appendix Figure 6 The horizontal axis represents the time step (with each time step spanning 15 minutes), and the vertical axis represents the traffic demand within the traffic area. Figure 6 Subgraph (a) shows the comparison results of the model output for Manhattan's 237th borough. Figure 6 Subgraph (b) shows the comparison results of the model output for Manhattan's 236th borough. Figure 6 Subgraph (c) shows the comparison results of the model output for Manhattan's 161st borough. Figure 6 Subplot (d) shows the model output comparison results for the 142nd borough of Manhattan. Through in-depth comparative analysis of the demand output curves and actual value curves for the four traffic areas under different models, the prediction results of the model of this invention show an extremely high degree of fit, specifically reflected in the following three aspects:
[0101] In terms of macro-prediction error control: the MSE, MAE, and MAPE indices of the model of this invention are significantly reduced by 36%, 36%, and 16% respectively compared with the traditional LSTM model, and by 12%, 16%, and 8% respectively compared with the CNN-GRU model. This indicates that the model can effectively suppress the divergence effect of single time series prediction in traffic change scenarios.
[0102] At the level of spatiotemporal feature extraction mechanism: Compared with the LSTM model, this model benefits from the sliding window operation of the front-end two-dimensional CNN, which successfully incorporates the spatial dependence of the surrounding adjacent areas into the evaluation system, explaining the significant improvement in prediction accuracy when facing the spread of road network congestion; at the same time, bidirectional LSTM makes up for the shortcomings of unidirectional temporal modeling.
[0103] Focusing on key traffic characteristics: By combining the characteristics of real demand fluctuations, it can be found that during peak hours or periods of drastic fluctuations in taxi demand caused by extreme weather (the peak area of the curve), the prediction curve of the model in this invention is closer to the actual value than that of the CNN-GRU model. This proves that the Attention mechanism introduced in this model can dynamically assign higher feature weights at key moments based on the dot product similarity between features, breaking the limitation of fixed weights in traditional hybrid models, thereby accurately depicting the dynamic evolution of urban traffic demand.
[0104] Example 3
[0105] This embodiment provides a traffic spatiotemporal sequence prediction system based on CNN-BiLSTM-Attention, corresponding to the traffic spatiotemporal sequence prediction method described in Embodiment 1, including:
[0106] Input Tensor Construction Module: This module is used to divide the target area into multiple traffic areas, divide the statistical time window into multiple time steps, calculate the traffic demand of each traffic area within each time step, set a traffic area as the central area, construct a two-dimensional matrix including the traffic demand of the central area and its adjacent traffic areas for each time window, and treat each two-dimensional matrix as a channel to form a three-dimensional tensor.
[0107] Convolutional Neural Network Module: This module is used to input three-dimensional tensors into a convolutional neural network, extract features through convolutional layers, perform dimensionality reduction through pooling layers, and output two-dimensional tensors.
[0108] Bidirectional Long Short-Term Memory Network Module: Used to input two-dimensional tensors into the BILSTM model and extract the time step feature vector matrix;
[0109] Attention mechanism module: It is used to input the time step feature vector matrix into the attention fusion layer, obtain the weight of each feature vector based on the dot product similarity between the query vector and the time step feature vector matrix, and output the fused feature vector sequence after weighted summation based on the weights.
[0110] Prediction output module: This module takes the fused feature vector sequence as input to the fully connected layer and outputs a traffic demand prediction sequence for several future time steps.
Claims
1. A CNN-BiLSTM-Attention-based traffic spatiotemporal sequence prediction method, characterized in that, Includes the following steps: S1. Divide the target area into multiple traffic areas, divide the statistical time window into multiple time steps, and count the traffic demand of each traffic area in each time step. Set a traffic area as the central area. For each time window, construct a two-dimensional matrix including the traffic demand of the central area and its adjacent traffic areas. Treat each two-dimensional matrix as a channel to form a three-dimensional tensor. S2. Input the three-dimensional tensor into the convolutional neural network, extract features through the convolutional layer, reduce the dimensionality through the pooling layer, and output a two-dimensional tensor. S3. Input the two-dimensional tensor into the BILSTM model and extract the time step feature vector matrix; S4. Input the time step feature vector matrix into the attention fusion layer. Based on the dot product similarity between the query vector and the time step feature vector matrix, obtain the weight of each feature vector. After weighted summation based on the weights, output the fused feature vector sequence. S5. Input the fused feature vector sequence into the fully connected layer and output the traffic demand prediction sequence for several future time steps.
2. The traffic spatio-temporal sequence prediction method according to claim 1, characterized in that: The traffic demand includes the originating traffic demand and the destination traffic demand within each traffic area, as shown in the following formula: wherein: is the origin traffic demand amount, is the destination traffic demand amount, represents a traffic region, represents an origin of a traffic trajectory, represents a time step, represents a destination of a traffic trajectory, represents a set of traffic trajectories, represents a time coordinate, represents a space coordinate, represents a time window, represents a set of traffic regions.
3. The traffic spatiotemporal sequence prediction method according to claim 1, characterized in that: The three dimensions of the three-dimensional tensor include the number of time steps, the number of traffic areas considered in each time step, and the traffic demand of each traffic area in each time step.
4. The traffic spatiotemporal sequence prediction method according to claim 1, characterized in that, Step S2 includes: inputting a three-dimensional tensor into a convolutional layer, performing a sliding window operation to obtain a set of sub-matrices, performing an inner product operation between the sub-matrices and the unfolded convolutional kernel to obtain an output matrix, reshaping the output matrix to obtain an output tensor, dividing the output tensor into multiple regions, performing global average pooling on the entire two-dimensional feature map of each channel, taking the maximum pooling value to retain the most significant spatial features, and outputting a two-dimensional tensor.
5. The traffic spatiotemporal sequence prediction method according to claim 1, characterized in that, Step S3 includes: at any time step, the BILSTM model receives the current two-dimensional tensor and the hidden state of the previous time step, calculates the retention degree of the memory unit of the previous time step and the degree of input information of the current time step entering the memory unit through the gating mechanism, generates candidate memory information of the current time step, updates the new memory unit of the current time step, and outputs the extracted time step feature vector.
6. The traffic spatiotemporal sequence prediction method according to claim 1, characterized in that, Step S4 includes: given a query vector, calculating the dot product similarity between the time step feature vector matrix and the query vector, converting it into a probability distribution score vector through the Softmax function, using it as the weight of each feature vector, then performing a weighted summation of the feature vectors, and outputting a fused feature vector.
7. The traffic spatiotemporal sequence prediction method according to claim 1, characterized in that, Step S5 includes: flattening the fused feature vector sequence, inputting it into a fully connected layer, and outputting a traffic demand prediction sequence for several future time steps after linear transformation and ReLU activation function.
8. The traffic spatiotemporal sequence prediction method according to claim 1, characterized in that, Step S5 further includes: evaluating the prediction accuracy of the traffic demand prediction sequence using multiple evaluation indicators, and iteratively updating the parameters of the convolutional neural network, BILSTM model and attention fusion layer by minimizing the evaluation indicators until the set prediction accuracy threshold is reached.
9. The traffic spatiotemporal sequence prediction method according to claim 8, characterized in that, The evaluation metrics include mean absolute error, mean square error, and mean absolute percentage error.
10. A traffic spatiotemporal sequence prediction system based on CNN-BiLSTM-Attention, characterized in that, include: Input Tensor Construction Module: This module is used to divide the target area into multiple traffic areas, divide the statistical time window into multiple time steps, calculate the traffic demand of each traffic area within each time step, set a traffic area as the central area, construct a two-dimensional matrix including the traffic demand of the central area and its adjacent traffic areas for each time window, and treat each two-dimensional matrix as a channel to form a three-dimensional tensor. Convolutional Neural Network Module: This module is used to input three-dimensional tensors into a convolutional neural network, extract features through convolutional layers, perform dimensionality reduction through pooling layers, and output two-dimensional tensors. Bidirectional Long Short-Term Memory Network Module: Used to input two-dimensional tensors into the BILSTM model and extract the time step feature vector matrix; Attention mechanism module: It is used to input the time step feature vector matrix into the attention fusion layer, obtain the weight of each feature vector based on the dot product similarity between the query vector and the time step feature vector matrix, and output the fused feature vector sequence after weighted summation based on the weights. Prediction output module: This module takes the fused feature vector sequence as input to the fully connected layer and outputs a traffic demand prediction sequence for several future time steps.