Traffic situation prediction method, device and equipment based on space-time attention mechanism

The spatiotemporal attention mechanism enhances traffic situation prediction accuracy by extracting spatiotemporal embedding representations, addressing the limitations of traditional methods in modeling multiple sensor nodes, thereby improving highway traffic control.

CN119252019AInactive Publication Date: 2025-01-03TRANSPORT PLANNING & RES INST MINIST OF TRANSPORT
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411275965.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-12
Publication Date
2025-01-03
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional traffic situation prediction methods based on neural networks struggle to accurately model the traffic situation of road networks with multiple sensor nodes, leading to poor performance and limited prediction accuracy.

Method used

A traffic situation prediction method using a spatiotemporal attention mechanism, involving a densely connected spatiotemporal multi-head attention model that combines spatiotemporal and conversion attention mechanisms, to extract spatiotemporal embedding representations from traffic flow data, reflecting time series and spatial dependency characteristics.

Benefits of technology

The method significantly improves traffic situation prediction accuracy by comprehensively considering time series and spatial dependence characteristics, enhancing the nonlinear relationship modeling between traffic sensing nodes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119252019A_ABST
    Figure CN119252019A_ABST
Patent Text Reader

Abstract

The invention provides a traffic situation prediction method, device and equipment based on a space-time attention mechanism. The method comprises the following steps: acquiring traffic flow data corresponding to each traffic sensing node in a to-be-predicted traffic road network in a historical period; through a pre-trained traffic situation deduction model, space-time embedding representation corresponding to the to-be-predicted traffic road network is extracted, and a traffic situation prediction result corresponding to the to-be-predicted traffic road network is generated based on the traffic flow data and the space-time embedding representation; wherein the traffic situation deduction model is obtained by training a dense connection space-time multi-head attention model combining a space-time attention mechanism and a conversion attention mechanism, and the traffic situation prediction result comprises traffic flow data corresponding to each traffic sensing node in a prediction period. According to the method, the traffic situation prediction precision under the traffic situation deduction scene of the multiple sensing nodes is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of highway traffic situation deduction, and in particular to a traffic situation prediction method, device and equipment based on a spatiotemporal attention mechanism. Background Art

[0002] In order to solve the problem of traffic situation deduction, domestic and foreign scholars have conducted many studies based on mathematical statistics, traditional machine learning and neural network methods. Mathematical statistics methods usually complete short-term traffic flow prediction tasks based on small sample and low-dimensional data, and have strong interpretability, but cannot represent the highly nonlinear and dynamic characteristics in traffic flow data, and can only predict the state of a single sensor node, with limited prediction performance. Traditional machine learning algorithms such as support vector machines (SVM) and decision tree models have strong nonlinear representation capabilities and can better mine the inherent nonlinear relationship of data. However, this method is only suitable for mining the time series characteristics of a single sensor node and cannot be used in multi-sensory node road network scenarios. In recent years, driven by the improvement of computing power and massive traffic data, deep learning-based methods have been widely used, such as convolutional neural networks (CNN), graph convolutional neural networks (GCN), deep belief networks (DBN), stacked autoencoders (SAE), etc. In addition to mining the temporal intrinsic characteristics of a single sensor node, they can also model the spatial relationship of the road network with multiple sensor nodes, which has very important research prospects. However, this method has the limitations of poor performance and inability to accurately model the traffic situation of a road network with multiple sensor nodes. Summary of the invention

[0003] In view of this, the purpose of the present invention is to provide a traffic situation prediction method, device and equipment based on the spatiotemporal attention mechanism, which greatly improves the traffic situation prediction accuracy in the traffic situation deduction scenario of multiple sensing nodes.

[0004] In a first aspect, an embodiment of the present invention provides a traffic situation prediction method based on a spatiotemporal attention mechanism, comprising:

[0005] Obtain the traffic flow data corresponding to each traffic sensing node in the traffic network to be predicted in the historical period;

[0006] Through the pre-trained traffic situation deduction model, the spatiotemporal embedding representation corresponding to the traffic network to be predicted is extracted, and the traffic situation prediction result corresponding to the traffic network to be predicted is generated based on the traffic flow data and the spatiotemporal embedding representation; wherein, the traffic situation deduction model is obtained by training a densely connected spatiotemporal multi-head attention model that combines the spatiotemporal attention mechanism and the conversion attention mechanism, and the traffic situation prediction result includes the traffic flow data corresponding to each traffic perception node in the prediction period.

[0007] In one implementation, obtaining the traffic flow data corresponding to each traffic sensing node in the traffic network to be predicted in a historical period includes:

[0008] Obtain the number of pulses corresponding to each traffic sensing node in the traffic network to be predicted in the historical period;

[0009] Calculate the initial instantaneous vehicle speed data corresponding to each traffic sensing node in the historical period based on the number of pulses;

[0010] Perform missing data patching, smoothing and normalization processing on the initial instantaneous vehicle speed data to obtain the target instantaneous vehicle speed data corresponding to each traffic sensing node in the historical period;

[0011] Among them, the traffic flow data is the target instantaneous vehicle speed data.

[0012] In one embodiment, the densely connected spatiotemporal multi-head attention model includes a spatial feature extraction module and a temporal feature extraction module; extracting the spatiotemporal embedding representation corresponding to the traffic network to be predicted includes:

[0013] Through the spatial feature extraction module, the spatial embedding representation is extracted based on the node adjacency matrix corresponding to the traffic network to be predicted; wherein the node adjacency matrix is ​​used to represent the relative distance between traffic sensing nodes in the traffic network to be predicted;

[0014] Through the spatial feature extraction module, the historical period and the predicted period are sliced ​​to obtain multiple historical time steps and multiple predicted time steps, and the historical time steps and the predicted time steps are processed by one-hot encoding to obtain the time embedding representations corresponding to the historical time steps and the predicted time steps respectively; among which, the time embedding representation is used to reflect the time dynamic correlation between traffic perception nodes;

[0015] The spatial embedding representation and the temporal embedding representation are feature concatenated to obtain the spatiotemporal embedding representation corresponding to the historical time step and the predicted time step respectively.

[0016] In one embodiment, the densely connected spatiotemporal multi-head attention model further includes an encoder module, a conversion attention module, and a decoder module based on a densely connected structure, and the spatiotemporal embedding representation is used as an input of each unit in the encoder module and the decoder module; based on the traffic flow data and the spatiotemporal embedding representation, a traffic situation prediction result corresponding to the traffic network to be predicted is generated, including:

[0017] Through the encoder module, multiple spatiotemporal feature extraction and fusion processing are performed on the traffic flow data, the spatiotemporal embedding representation corresponding to the historical time step, and the spatiotemporal embedding representation corresponding to the predicted time step to obtain the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the predicted time step;

[0018] By converting the attention module, the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the prediction time step are transformed to obtain the target spatiotemporal features;

[0019] Through the encoder module, multiple spatiotemporal feature extraction and fusion processing are performed on the target spatiotemporal features, the spatiotemporal embedding representation corresponding to the historical time step, and the spatiotemporal embedding representation corresponding to the prediction time step to obtain the traffic situation prediction result corresponding to the traffic network to be predicted.

[0020] In one embodiment, the encoder module and the decoder both include a plurality of densely connected spatiotemporal attention units; through the encoder module, multiple spatiotemporal feature extraction and fusion processes are performed on the traffic flow data, the spatiotemporal embedding representation corresponding to the historical time step, and the spatiotemporal embedding representation corresponding to the predicted time step to obtain the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the predicted time step, including:

[0021] Through the current spatiotemporal attention unit, the features output by each spatiotemporal attention unit before the current spatiotemporal attention unit, as well as the spatiotemporal embedding representation corresponding to the historical time step and the spatiotemporal embedding representation corresponding to the predicted time step are extracted and fused to obtain the features output by the current spatiotemporal attention unit;

[0022] Among them, the features output by the last spatiotemporal attention unit in the encoder module include the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the predicted time step.

[0023] In one implementation, the spatiotemporal attention unit includes a temporal attention subunit, a spatial attention subunit, and a gated fusion subunit; through the current spatiotemporal attention unit, a spatiotemporal feature extraction and fusion process is performed on the features output by each spatiotemporal attention unit before the current spatiotemporal attention unit, as well as the spatiotemporal embedding representation corresponding to the historical time step and the spatiotemporal embedding representation corresponding to the predicted time step, to obtain the features output by the current spatiotemporal attention unit, including:

[0024] Through the temporal attention subunit, based on the temporal attention mechanism, the features output by each spatiotemporal attention unit before the current spatiotemporal attention unit, as well as the spatiotemporal embedding representation corresponding to the historical time step and the spatiotemporal embedding representation corresponding to the predicted time step are extracted to obtain the time series features;

[0025] Through the spatial attention sub-unit, based on the spatial attention mechanism, the features output by each spatiotemporal attention unit before the current spatiotemporal attention unit, as well as the spatiotemporal embedding representation corresponding to the historical time step and the spatiotemporal embedding representation corresponding to the predicted time step are extracted to obtain the spatial dependency features;

[0026] Through the gated fusion sub-unit, the time series features and spatial dependency features are gated and fused to obtain the features output by the current spatiotemporal attention unit.

[0027] In one embodiment, the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the prediction time step are converted by the conversion attention module to obtain the target spatiotemporal features, including:

[0028] Determine the attention score of the conversion attention module based on the correlation between the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the prediction time step;

[0029] By converting the attention module, the target encoded spatiotemporal features are determined from the encoded spatiotemporal features corresponding to the historical time steps based on the attention scores, and the target encoded spatiotemporal features corresponding to the historical time steps and the encoded spatiotemporal features corresponding to the prediction time steps are converted to obtain the target spatiotemporal features.

[0030] In a second aspect, an embodiment of the present invention further provides a traffic situation prediction device based on a spatiotemporal attention mechanism, comprising:

[0031] A data acquisition module is used to obtain the traffic flow data corresponding to each traffic sensing node in the traffic network to be predicted in the historical period;

[0032] The situation prediction module is used to extract the spatiotemporal embedding representation corresponding to the traffic network to be predicted through a pre-trained traffic situation deduction model, and generate a traffic situation prediction result corresponding to the traffic network to be predicted based on the traffic flow data and the spatiotemporal embedding representation; wherein the traffic situation deduction model is obtained by training a densely connected spatiotemporal multi-head attention model that combines the spatiotemporal attention mechanism and the conversion attention mechanism, and the traffic situation prediction result includes the traffic flow data corresponding to each traffic perception node in the prediction period.

[0033] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement any one of the methods provided in the first aspect.

[0034] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement any one of the methods provided in the first aspect.

[0035] The embodiment of the present invention provides a traffic situation prediction method, device and equipment based on the spatiotemporal attention mechanism, firstly obtaining the traffic flow data corresponding to each traffic sensing node in the traffic network to be predicted in the historical period; then extracting the spatiotemporal embedding representation corresponding to the traffic network to be predicted through the pre-trained traffic situation deduction model, and generating the traffic situation prediction result corresponding to the traffic network to be predicted based on the traffic flow data and the spatiotemporal embedding representation; wherein the traffic situation deduction model is obtained by training a densely connected spatiotemporal multi-head attention model combining the spatiotemporal attention mechanism and the conversion attention mechanism, and the traffic situation prediction result includes the traffic flow data corresponding to each traffic sensing node in the prediction period. The above method aims at the problem of highway traffic situation deduction under the condition of multiple traffic sensing nodes, by extracting the spatiotemporal embedding representation corresponding to the traffic network to be predicted, the spatiotemporal embedding representation can reflect the time series characteristics and spatial dependence characteristics, thereby comprehensively considering the important influence of the time series characteristics and the spatial dependence characteristics in the traffic situation deduction process, mining the nonlinear relationship between the traffic situation and the spatiotemporal characteristics of the traffic sensing nodes, and proposing a more accurate traffic situation deduction model, which greatly improves the traffic situation prediction accuracy. The embodiment of the present invention can be used in the field of highway traffic control and has broad application prospects.

[0036] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.

[0037] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0039] Figure 1 A flow chart of a traffic situation prediction method based on a spatiotemporal attention mechanism provided by an embodiment of the present invention;

[0040] Figure 2 A data cleaning and preprocessing flow chart provided for an embodiment of the present invention;

[0041] Figure 3A schematic diagram of a dense connection structure provided by an embodiment of the present invention;

[0042] Figure 4 A schematic diagram of the structure of a spatiotemporal attention unit provided by an embodiment of the present invention;

[0043] Figure 5 An overall flow chart of a traffic situation prediction method based on a spatiotemporal attention mechanism provided by an embodiment of the present invention;

[0044] Figure 6 A schematic diagram of the structure of a traffic situation prediction device based on a spatiotemporal attention mechanism provided by an embodiment of the present invention;

[0045] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described in combination with the embodiments below. Obviously, the described embodiments are 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 creative work are within the scope of protection of the present invention.

[0047] At present, traditional traffic situation prediction methods based on neural networks have the limitations of poor performance and inability to accurately model the traffic situation of road networks with multiple sensor nodes. Based on this, the present invention implements a traffic situation prediction method, device and equipment based on a spatiotemporal attention mechanism, which greatly improves the traffic situation prediction accuracy in the traffic situation deduction scenario of multiple sensor nodes.

[0048] To facilitate understanding of this embodiment, a traffic situation prediction method based on a spatiotemporal attention mechanism disclosed in an embodiment of the present invention is first described in detail. Figure 1 The flow chart of a traffic situation prediction method based on the spatiotemporal attention mechanism is shown, and the method mainly includes the following steps S102 to S104:

[0049] Step S102, obtaining the traffic flow data corresponding to each traffic sensing node in the traffic network to be predicted in the historical period.

[0050] The traffic flow data here may refer to instantaneous vehicle speed data, and specifically may be an average value of the instantaneous vehicle speed.

[0051] In one example, traffic sensors can be used to collect the number of pulses at each traffic sensing node in the traffic network to be predicted, and the number of pulses in the historical period can be used to calculate the initial value of the average instantaneous vehicle speed at each traffic sensing node. The initial value is preprocessed by missing data patching, smoothing, and normalization, so that the target value of the average instantaneous vehicle speed at each traffic sensing node can be obtained, and the target value is used as the traffic flow data corresponding to each traffic sensing node in the historical period.

[0052] Step S104, extracting the spatiotemporal embedding representation corresponding to the traffic network to be predicted through the pre-trained traffic situation deduction model, and generating a traffic situation prediction result corresponding to the traffic network to be predicted based on the traffic flow data and the spatiotemporal embedding representation.

[0053] Among them, the traffic situation deduction model is obtained by training a densely connected spatiotemporal multi-head attention model that combines the spatiotemporal attention mechanism and the conversion attention mechanism. The spatiotemporal embedding representation can reflect the time series characteristics and spatial dependence characteristics of the traffic network to be predicted. The traffic situation prediction results include the traffic flow data corresponding to each traffic perception node in the prediction period. The traffic flow data here can refer to the instantaneous vehicle speed data, specifically the average value of the instantaneous vehicle speed.

[0054] In one example, the densely connected spatiotemporal multi-head attention model includes a spatial feature extraction module and a temporal feature extraction module, as well as an encoder module, a conversion attention module, and a decoder module based on a densely connected structure. The inputs of the spatial feature extraction module and the temporal feature extraction module are fused and used as the input of each unit in the encoder module and the decoder module of the densely connected structure. Based on this, the spatial dependency features and the time series features are first extracted by the spatial feature extraction module and the temporal feature extraction module respectively, and the spatiotemporal embedding expression is obtained after feature fusion; then, in the encoder module, the average value of the instantaneous vehicle speed and the spatiotemporal embedding expression are subjected to multiple feature extraction and fusion processing to obtain the encoded spatiotemporal features; then, the encoded spatiotemporal features and the spatiotemporal embedding expression are converted into the input of the encoder module through the conversion attention module; finally, the encoder module is subjected to multiple feature extraction and fusion processing on the features output by the conversion attention module and the spatiotemporal embedding expression to obtain the average value of the instantaneous vehicle speed corresponding to each traffic sensing node in the prediction period.

[0055] The traffic situation prediction method of the spatiotemporal attention mechanism provided by the embodiment of the present invention aims at the problem of highway traffic situation deduction with multiple traffic sensing nodes. The spatiotemporal embedding representation corresponding to the traffic network to be predicted is extracted. The spatiotemporal embedding representation can reflect the time series characteristics and spatial dependency characteristics, thereby comprehensively considering the important influence of the time series characteristics and the spatial dependency characteristics in the process of traffic situation deduction, exploring the nonlinear relationship between the traffic situation and the spatiotemporal characteristics of the traffic sensing nodes, and proposing a more accurate traffic situation deduction model, which greatly improves the accuracy of traffic situation prediction. The embodiment of the present invention can be used in the field of highway traffic control and has broad application prospects.

[0056] For ease of understanding, an embodiment of the present invention provides a specific implementation of a traffic situation prediction method based on a spatiotemporal attention mechanism.

[0057] For the aforementioned step S102, the embodiment of the present invention provides a specific implementation method for obtaining the traffic flow data corresponding to each traffic sensing node in the traffic network to be predicted in the historical period, including:

[0058] The original traffic flow data collected by traffic sensors (including the number of pulses at each traffic sensing node) may have problems such as missing data and outliers. The data quality will directly affect the effect of model prediction. Therefore, the original traffic flow data is first subjected to data preprocessing steps such as data aggregation, vehicle speed calculation, missing data repair, smoothing, and normalization. 1) Uncontrollable factors such as weather, environment, and hardware equipment will cause partial missing of traffic flow data. For the problem of filling missing data, the embodiment of the present invention repairs the missing data based on the quadratic spline interpolation method; 2) The original traffic flow data is usually mixed with some noise information and has characteristics such as periodicity and volatility. The embodiment of the present invention smoothes the traffic flow data based on the Lowess algorithm; 3) Standardized input can improve the training speed of the neural network. The embodiment of the present invention uses the Z-Score standardization method to normalize the data. After the data preprocessing is divided into a ratio of 7:1:2, the training set, validation set, and test set are obtained.

[0059] In the specific implementation, the following steps can be referred to: obtaining the number of pulses corresponding to each traffic sensing node in the traffic network to be predicted in the historical time period; calculating the initial instantaneous vehicle speed data corresponding to each traffic sensing node in the historical time period based on the number of pulses, specifically the initial instantaneous vehicle speed average value; performing missing data patching, smoothing and normalization processing on the initial instantaneous vehicle speed data, and obtaining the target instantaneous vehicle speed data corresponding to each traffic sensing node in the historical time period, specifically the target instantaneous vehicle speed average value, and the traffic flow data is the target instantaneous vehicle speed average value.

[0060] For easier understanding, see Figure 2 A data cleaning and preprocessing flow chart shown includes:

[0061] (a) Obtain the original loop detector traffic flow spatiotemporal dataset, that is, the number of pulses corresponding to each traffic sensing node in the traffic network to be predicted in the historical period. In one example, the original loop detector traffic flow spatiotemporal dataset uses the loop detector data of the I-5 Interstate Highway in the United States. The dataset needs to go through data preprocessing steps such as invalid data detection, data aggregation, calculation of average vehicle speed (that is, the average of the initial instantaneous vehicle speed), patching of missing data, smoothing, and normalization.

[0062] (b) Invalid data detection.

[0063] (c) Data aggregation. In one example, the US I-5 traffic flow dataset comes from real-time detection data collected by loop detectors on the US I-5 highway in 2011. I-5 highway has evenly distributed loop detectors on multiple lanes of its main road and major entrance and exit ramps. Multiple loop detectors in the same section are called loop detection stations, and the average distance between adjacent detection stations is about 0.5 miles. The loop detector collects data in a cycle of 20 seconds. In order to improve the calculation efficiency of the subsequent model while retaining sufficient information, this paper aggregates the data to 5 minutes.

[0064] (d) Calculate the average vehicle speed. In one example, the research object of the embodiment of the present invention is the traffic situation of the main road. Here, a total of 119 single-coil detectors on the one-way main road are selected. According to the number of pulses and detection period obtained by the single-coil vehicle detector, the vehicle speed is calculated using the speed measurement principle. According to the basic relationship between the three traffic parameters (traffic flow, density, and speed), the g factor is introduced to calculate the traffic density through time occupancy, and then the average speed is estimated. The instantaneous average vehicle speed is calculated using the constant g factor algorithm based on a single coil, and the formula is as follows:

[0065]

[0066] In the formula, Scan i is the number of pulses, Occupancy i Used to characterize the basic relationship between the three traffic parameters (traffic flow, density, and speed), Speed i Volume is the average instantaneous vehicle speed of vehicles passing through during sampling period i, in km / h; i is the total number of vehicles passing through the detection coil within sampling period i, in units of vehicles; T is the sampling period, T=20s=1 / 180h; g is the average vehicle body length, generally 2.2m.

[0067] (e) Determine whether the detector data inefficiency is less than or equal to 20%; if so, delete the detector data; if not, execute (f).

[0068] (f) Invalid data repair (ie, repairing missing data). In one example, the present invention uses a quadratic spline interpolation method to repair missing data, and a method of obtaining a filling value by fitting a quadratic function can achieve a continuous and smooth filling effect.

[0069] Denoted as formula (1);

[0070] y3-y2=[a(x3+x2)+b](x3-x2), that is: Denoted as formula (2);

[0071] Similarly, we can get: Denoted as formula (3);

[0072] By subtracting formula (2) from formula (3), we can get:

[0073] Substituting coefficient a into formula (2) or formula (3) can obtain coefficient b, and substituting coefficient b into formula (1) can obtain coefficient c;

[0074] Among them, y1, y2, and y3 are the average instantaneous vehicle speeds corresponding to the traffic perception nodes at time x1, x2, and x3, a, b, and c are coefficients, and Δt is the difference between time x3 and time x1.

[0075] (g) Smoothing. In one example, traffic flow data is usually mixed with some noise information, so it needs to be smoothed. For traffic flow data with periodicity and volatility, it cannot be simply smoothed in a linear way, otherwise the model will have a large deviation. The local weighted regression algorithm (Lowess) can better handle this problem. The Lowess algorithm process is as follows:

[0076] Step 1: Take time x i As the center, a segment of data with a length of frac is intercepted forward and backward respectively. Optionally, in the embodiment of the present invention, frac is set to 0.05 as a condition for data smoothing;

[0077] Step 2: Perform weighted linear regression on the data of length 2frac based on the weight function W, and the result is recorded as is the average instantaneous vehicle speed after smoothing; the embodiment of the present invention adopts a cubic function as the weight function W, and its expression is as follows:

[0078]

[0079] Step 3: Repeat the above steps for each data to get Recorded as new data value;

[0080] Step 4: Connect all new data values ​​to form the Lowess curve, which is the sequence of the instantaneous vehicle speed averages after smoothing.

[0081] (h) Normalization. In one example, normalization is also called standardization. Standardized input can make neural network training faster and reduce the probability of falling into local optimality. At the same time, using standardized input can prevent gradient explosion to a certain extent. The embodiment of this article uses the Z-Score normalization method to normalize traffic flow data. The Z-Score normalization method normalizes data through mean and variance. The processed data is a standard normal distribution with a mean of 0 and a standard deviation of 1. The normalization function is:

[0082] In the formula, μ is the sample mean and σ is the sample standard deviation.

[0083] For the aforementioned step S104, the embodiment of the present invention first explains the traffic situation deduction model. In order to achieve traffic flow speed prediction, the embodiment of the present invention draws on the traditional neural network model, the spatiotemporal attention mechanism, and the Transformer attention structure to establish a densely connected spatiotemporal multi-head attention (DSTMA) model that considers the fusion of spatiotemporal features, and uses the model as the traffic situation deduction model.

[0084] Specifically, the densely connected spatiotemporal multi-head attention model includes a spatial feature extraction module and a temporal feature extraction module. The embodiment of the present invention uses spatiotemporal embedding representation (STE) to fuse the spatial feature extraction module and the temporal feature extraction module and use them as the input of each unit in the decoder module and the encoder module to increase the amount of information in the encoder module and the decoder module and reduce the cumulative error of multi-step prediction.

[0085] Based on this, an embodiment of the present invention provides a specific implementation method for extracting a spatiotemporal embedding representation corresponding to a traffic network to be predicted, including the following steps A1 to A3:

[0086] Step A1, extracting a spatial embedding representation based on a node adjacency matrix corresponding to the traffic network to be predicted through a spatial feature extraction module; wherein the node adjacency matrix is ​​used to characterize the relative distances between traffic sensing nodes in the traffic network to be predicted.

[0087] In one example, since the connection relationship between traffic sensing nodes will directly affect the evolution of traffic situation, the embodiment of the present invention embeds the spatial structure information of traffic sensing nodes into the traffic situation deduction model. The embodiment of the present invention uses the node2vec algorithm to learn the traffic sensing node representation and encodes the traffic sensing node into a vector that extracts the graph structure information. In addition, in order to coordinate the training of the spatial embedding vector with the entire traffic situation deduction model, the vector obtained by node2vec is input into a two-layer fully connected neural network to obtain the final spatial embedding representation, which is expressed as in

[0088] Step A2, through the spatial feature extraction module, slice the historical period and the predicted period to obtain multiple historical time steps and multiple predicted time steps, perform one-hot encoding on the historical time steps and the predicted time steps, and obtain the time embedding representations corresponding to the historical time steps and the predicted time steps respectively; wherein the time embedding representation is used to reflect the temporal dynamic correlation between traffic perception nodes.

[0089] In one example, spatial embedding can only provide static spatial information and cannot represent the temporal dynamic correlation between traffic nodes. Therefore, we further consider the different traffic flow characteristics presented by peak hours, off-peak hours, weekdays, and weekends in a day. The embodiment of the present invention uses one-hot encoding to encode and map each complete date to spatial vectors of R^7 and R^T according to the time of the week and the time of the day, and concatenates them into a vector of R^(7+T). For the traffic flow data of the embodiment of the present invention, the traffic flow data is aggregated into 5 minutes during the data preprocessing process. Therefore, the day is sliced ​​in units of 5 minutes. There are T=24*60 / 5=288 time segments in a day, which are then concatenated and mapped to In the spatial vector of , finally, two layers of fully connected layers are used to realize The vector is converted into the input vector required by the traffic situation simulation model Input Vector In the traffic situation deduction model provided by the embodiment of the present invention, each time step of the historical period H and the predicted period P is encoded into a vector, which is expressed as where t j =t1,…,t H ,…,t H+P .

[0090] In step A3, feature concatenation is performed on the spatial embedding representation and the temporal embedding representation to obtain the spatiotemporal embedding representations corresponding to the historical time step and the predicted time step, respectively.

[0091] In one example, for the time step t j Traffic sensing node v i , STE can be written as Therefore, the STE of N traffic-aware nodes in H+P time steps will be expressed as It can be seen that STE contains both graph structure information and time information. The concatenated vector is a high-quality data that integrates spatiotemporal features. It will serve as part of the input of the subsequent spatiotemporal attention module and the conversion attention module.

[0092] For details, see Figure 3 A schematic diagram of a densely connected structure is shown, the DSTMA model also includes an encoder module, a conversion attention module, and a decoder module based on the densely connected structure, the encoder module and the decoder both include multiple densely connected spatiotemporal attention units (STABlocks), and the spatiotemporal embedding representation is used as the input of each unit in the encoder module and the decoder module. In order to solve the gradient disappearance problem caused by the deep network, the embodiment of the present invention introduces a densely connected structure in the DSTMA model, that is, a direct connection structure is added between multiple serially connected STABlocks, so that the input of each STABlock comes from the output of all previous STABlocks, thereby realizing information transmission and reuse between various sub-parts in the network.

[0093] First, we draw on the core idea of ​​DenseNet to densely connect layers to solve the problem of gradient disappearance. At the same time, based on the dimension addition method in ResNet, we modify the concatenate operation in the dense connection structure to an add operation to achieve a balance between performance and parameter quantity.

[0094] Based on this, the embodiment of the present invention provides a specific implementation method for generating a traffic situation prediction result corresponding to a traffic network to be predicted based on traffic flow data and spatiotemporal embedding representation, see the following steps B1 to B3:

[0095] Step B1, through the encoder module, multiple spatiotemporal feature extraction and fusion processing are performed on the traffic flow data, the spatiotemporal embedding representation corresponding to the historical time step, and the spatiotemporal embedding representation corresponding to the predicted time step to obtain the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the predicted time step.

[0096] In one example, assuming that the output of the Lth STABlock block is X1, X1 is expressed as:

[0097] X l =H l (X1+X2+...+X l-1), where H1 represents the nonlinear transformation of the feature when it passes through STABlock. After passing through L cascaded STABlocks, it passes through a fully connected layer to achieve the re-integration of feature information.

[0098] In a specific implementation, the Lth spatiotemporal attention unit can be used to extract and fuse the features output by each spatiotemporal attention unit before the Lth spatiotemporal attention unit, as well as the spatiotemporal embedding representation corresponding to the historical time step and the spatiotemporal embedding representation corresponding to the predicted time step, to obtain the features output by the current spatiotemporal attention unit; wherein the features output by the last spatiotemporal attention unit in the encoder module include the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the predicted time step.

[0099] For easier understanding, see Figure 4 The schematic diagram of the structure of a spatiotemporal attention unit is shown in FIG. The spatiotemporal attention unit includes a temporal attention subunit, a spatial attention subunit, and a gated fusion subunit. Based on this, the processing of spatiotemporal feature extraction and fusion processing is shown in steps B1.1 to B1.3 below:

[0100] Step B1.1, through the time attention sub-unit, based on the time attention mechanism, extract the features output by each spatiotemporal attention unit before the current spatiotemporal attention unit, as well as the spatiotemporal embedding representation corresponding to the historical time step and the spatiotemporal embedding representation corresponding to the predicted time step, to obtain time series features;

[0101] Step B1.2, through the spatial attention sub-unit, based on the spatial attention mechanism, extract the features output by each spatiotemporal attention unit before the current spatiotemporal attention unit, as well as the spatiotemporal embedding representation corresponding to the historical time step and the spatiotemporal embedding representation corresponding to the predicted time step, to obtain spatially dependent features;

[0102] Step B1.3, through the gated fusion sub-unit, the time series features and the spatial dependency features are gated and fused to obtain the features output by the current spatiotemporal attention unit.

[0103] In practical applications, in order to solve the problem of simultaneous extraction and fusion of spatiotemporal features, the embodiment of the present invention constructs a spatiotemporal attention module based on a gated fusion mechanism. The input of the first STABlock in the DSTMA model framework is represented as H (1-1) , where traffic sensing node v i At time step t j The hidden state at is represented as The output of the spatial and temporal attention mechanism at block l is expressed as and The traffic node vi At time step t j The hidden states at the time are expressed as and After gated fusion, the output of the lth block is obtained, denoted as H (l) .

[0104] Step B2, through the conversion attention module, the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the prediction time step are converted to obtain the target spatiotemporal features.

[0105] In one example, in order to reduce the error propagation of different prediction time steps in a long time range, the embodiment of the present invention introduces a transform attention module (TA) between the encoder and the decoder. In the specific implementation, refer to the following steps B2.1 to B2.2:

[0106] Step B2.1, based on the correlation between the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the predicted time step, determine the attention score of the conversion attention module.

[0107] In one example, for a traffic sensing node v i , prediction time step t j (t j =t1,…,t H ,…,t H+P ) and the historical time step t(t=t1,…,t H ) is calculated as follows:

[0108]

[0109] In the formula, Respectively represent different nonlinear mapping functions in the k-th attention mechanism, Indicates that it is at time step t j Traffic sensing node v i STE, represents the traffic sensing node v at time step t i STE, <·,·> represents the inner product operation, is the intermediate parameter, is the relevance, or attention score.

[0110] Step B2.2, by converting the attention module, the target encoded spatiotemporal features are determined from the encoded spatiotemporal features corresponding to the historical time steps based on the attention scores, and the target encoded spatiotemporal features corresponding to the historical time steps and the encoded spatiotemporal features corresponding to the prediction time steps are converted to obtain the target spatiotemporal features.

[0111] In one example, the attention score of the TA module is obtained from the above formula. The output of the encoder adaptively selects relevant features in H historical time steps, and then is converted into the input of the decoder through the TA module. Similarly, the hidden state of the TA module is obtained by multi-head attention calculation, as shown below:

[0112]

[0113] in, represents the traffic sensing node v i At time step t, the hidden state is input into the lth STABlock, represents the traffic sensing node v i At time step t, the hidden state is input into the l-1th STABlock, They represent different nonlinear mapping functions in the kth attention mechanism, and K represents the number of heads in the multi-head attention mechanism.

[0114] Step B3, through the encoder module, multiple spatiotemporal feature extraction and fusion processing are performed on the target spatiotemporal features, the spatiotemporal embedding representation corresponding to the historical time step, and the spatiotemporal embedding representation corresponding to the predicted time step to obtain the traffic situation prediction result corresponding to the traffic network to be predicted. In the specific implementation, please refer to the aforementioned step 2A, which will not be described in detail in the embodiment of the present invention.

[0115] Furthermore, an embodiment of the present invention also provides a specific process for model training and hyperparameter determination, in which the DSTMA model is trained based on a training set to implement iterative updating of model parameters, the optimal hyperparameters of the model are determined based on a validation set, and the optimal DSTMA model is obtained after the hyperparameters are determined.

[0116] Specifically include:

[0117] In one example, minimizing the mean absolute error (MAE) between the predicted value and the true value is used as the loss function to better guide model training.

[0118] In one example, the Adam optimizer is used to perform end-to-end training through an error back-propagation mechanism.

[0119] In one example, by using the control variable method, under the same training configuration, L is set to 1, 2, 3, and 4, and four models are obtained to represent A, B, C, and D, respectively. The best performing one is the DSTMA model in this chapter. Finally, the prediction results of each model for 15 minutes, 30 minutes, and 1 hour are listed in Table 1.

[0120] From the ablation experiment comparison results, it can be seen that when L increases from 1 to 2, that is, for models A and B, the indicators of B are better than A, indicating that increasing L improves the performance of the model; when L = 3, the performance of model C is further improved; when L = 4, the dense connections are the most and most complex, and the number of model parameters is also the largest, but the indicators reflect that the performance of the model has decreased significantly. In summary, the depth of the model is not the deeper the better. When L = 3, that is, when DenseSTABlock is composed of 3 STABlocks and used for the encoder and decoder, the performance of the model reaches the best. Therefore, the embodiment of the present invention determines that the parameter L of the DSTMA model is 3.

[0121] Table 1 Comparison of results of different models

[0122]

[0123] In order to verify the effectiveness of the embodiment of the present invention, three widely used regression task evaluation indicators are used, namely, mean absolute error MAE, root mean square error RMSE, and mean absolute percentage error MAPE. GMAN is used as a comparison model. This model is a simplified version of DSTMA and is most similar to the DSTMA structure. However, this model does not use a dense connection structure and add operation. The comparison results of the evaluation indicators of the two models are listed in Table 2.

[0124] Table 2

[0125]

[0126] Furthermore, taking the traffic flow data of detector No. 1474 in the I5 data set on a certain day as an example, the prediction effects of the DSTMA model and the GMAN model were plotted respectively. Among them, the DSTMA model has a better fitting effect on the true value, the change range of the prediction curve is more stable than that of GMAN, and the prediction performance is better than GMAN. This also proves that the embodiment of the present invention can support the practical application of highway traffic situation prediction.

[0127] Based on this, the embodiment of the present invention uses the best model obtained through training for testing and application, and can deduce the traffic situation of the highway by acquiring the spatiotemporal characteristics of the highway sensing nodes.

[0128] For ease of understanding, the present invention also provides Figure 5The overall flow chart of a traffic situation prediction method based on the spatiotemporal attention mechanism shown in the figure includes: obtaining the original coil detector traffic flow spatiotemporal data set, performing data preprocessing, obtaining a traffic situation deduction data set, using 70% of it as training data, 10% as verification data, and 20% as test data to divide it into training set, verification set, and test set; using the training set to train the DSTMA model, iteratively updating the model parameters, and using the verification set to verify whether the indicators converge. If the judgment result is no, continue to train the DSTMA model. If the judgment result is yes, output the prediction result for the test set through the best DSTMA model, and calculate the model evaluation index.

[0129] In summary, the embodiment of the present invention aims to solve the problem that the complex spatiotemporal dependency of traffic data leads to the difficulty of deducing the traffic situation of highways, and aims to construct a highway traffic situation deduction model that considers the fusion of spatiotemporal features. Compared with the existing single traffic perception node prediction method, a traffic situation deduction method based on the spatiotemporal attention mechanism for multiple perception nodes is proposed, which has the advantages of being more real-time, accurate, scientific, and highly generalizable, and provides a more economical and convenient solution for the scientific operation and management of highways, and has broad application prospects.

[0130] Based on the above embodiments, the present invention provides a traffic situation prediction device based on spatiotemporal attention mechanism. Figure 6 The schematic diagram of the structure of a traffic situation prediction device based on the spatiotemporal attention mechanism is shown in FIG. The device mainly includes the following parts:

[0131] The data acquisition module 602 is used to obtain the traffic flow data corresponding to each traffic sensing node in the traffic network to be predicted in the historical period;

[0132] The situation prediction module 604 is used to extract the spatiotemporal embedding representation corresponding to the traffic network to be predicted through a pre-trained traffic situation deduction model, and generate a traffic situation prediction result corresponding to the traffic network to be predicted based on the traffic flow data and the spatiotemporal embedding representation; wherein the traffic situation deduction model is obtained by training a densely connected spatiotemporal multi-head attention model that combines the spatiotemporal attention mechanism and the conversion attention mechanism, and the traffic situation prediction result includes the traffic flow data corresponding to each traffic perception node in the prediction period.

[0133] The traffic situation prediction device with a spatiotemporal attention mechanism provided by the embodiment of the present invention aims at the problem of highway traffic situation deduction under the condition of multiple traffic sensing nodes. By extracting the spatiotemporal embedding representation corresponding to the traffic network to be predicted, the spatiotemporal embedding representation can reflect the time series characteristics and spatial dependency characteristics, thereby comprehensively considering the important influence of the time series characteristics and the spatial dependency characteristics in the process of traffic situation deduction, and exploring the nonlinear relationship between the traffic situation and the spatiotemporal characteristics of the traffic sensing nodes, a more accurate traffic situation deduction model is proposed, which greatly improves the accuracy of traffic situation prediction. The embodiment of the present invention can be used in the field of highway traffic control and has broad application prospects.

[0134] In one implementation, the data acquisition module 602 is specifically used to:

[0135] Obtain the number of pulses corresponding to each traffic sensing node in the traffic network to be predicted in the historical period;

[0136] Calculate the initial instantaneous vehicle speed data corresponding to each traffic sensing node in the historical period based on the number of pulses;

[0137] Perform missing data patching, smoothing and normalization processing on the initial instantaneous vehicle speed data to obtain the target instantaneous vehicle speed data corresponding to each traffic sensing node in the historical period;

[0138] Among them, the traffic flow data is the target instantaneous vehicle speed data.

[0139] In one embodiment, the densely connected spatiotemporal multi-head attention model includes a spatial feature extraction module and a temporal feature extraction module; the situation prediction module 604 is specifically used to:

[0140] Through the spatial feature extraction module, the spatial embedding representation is extracted based on the node adjacency matrix corresponding to the traffic network to be predicted; wherein the node adjacency matrix is ​​used to represent the relative distance between traffic sensing nodes in the traffic network to be predicted;

[0141] Through the spatial feature extraction module, the historical period and the predicted period are sliced ​​to obtain multiple historical time steps and multiple predicted time steps, and the historical time steps and the predicted time steps are processed by one-hot encoding to obtain the time embedding representations corresponding to the historical time steps and the predicted time steps respectively; among which, the time embedding representation is used to reflect the time dynamic correlation between traffic perception nodes;

[0142] The spatial embedding representation and the temporal embedding representation are feature concatenated to obtain the spatiotemporal embedding representation corresponding to the historical time step and the predicted time step respectively.

[0143] In one embodiment, the densely connected spatiotemporal multi-head attention model further includes an encoder module, a conversion attention module, and a decoder module based on a densely connected structure, and the spatiotemporal embedding representation is used as the input of each unit in the encoder module and the decoder module; the situation prediction module 604 is specifically used for:

[0144] Through the encoder module, multiple spatiotemporal feature extraction and fusion processing are performed on the traffic flow data, the spatiotemporal embedding representation corresponding to the historical time step, and the spatiotemporal embedding representation corresponding to the predicted time step to obtain the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the predicted time step;

[0145] By converting the attention module, the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the prediction time step are transformed to obtain the target spatiotemporal features;

[0146] Through the encoder module, multiple spatiotemporal feature extraction and fusion processing are performed on the target spatiotemporal features, the spatiotemporal embedding representation corresponding to the historical time step, and the spatiotemporal embedding representation corresponding to the prediction time step to obtain the traffic situation prediction result corresponding to the traffic network to be predicted.

[0147] In one embodiment, both the encoder module and the decoder include a plurality of densely connected spatiotemporal attention units; the situation prediction module 604 is specifically used to:

[0148] Through the current spatiotemporal attention unit, the features output by each spatiotemporal attention unit before the current spatiotemporal attention unit, as well as the spatiotemporal embedding representation corresponding to the historical time step and the spatiotemporal embedding representation corresponding to the predicted time step are extracted and fused to obtain the features output by the current spatiotemporal attention unit;

[0149] Among them, the features output by the last spatiotemporal attention unit in the encoder module include the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the predicted time step.

[0150] In one embodiment, the spatiotemporal attention unit includes a temporal attention subunit, a spatial attention subunit, and a gated fusion subunit; the situation prediction module 604 is specifically used for:

[0151] Through the temporal attention subunit, based on the temporal attention mechanism, the features output by each spatiotemporal attention unit before the current spatiotemporal attention unit, as well as the spatiotemporal embedding representation corresponding to the historical time step and the spatiotemporal embedding representation corresponding to the predicted time step are extracted to obtain the time series features;

[0152] Through the spatial attention sub-unit, based on the spatial attention mechanism, the features output by each spatiotemporal attention unit before the current spatiotemporal attention unit, as well as the spatiotemporal embedding representation corresponding to the historical time step and the spatiotemporal embedding representation corresponding to the predicted time step are extracted to obtain spatially dependent features;

[0153] Through the gated fusion sub-unit, the time series features and spatial dependency features are gated and fused to obtain the features output by the current spatiotemporal attention unit.

[0154] In one implementation, the situation prediction module 604 is specifically used to:

[0155] Determine the attention score of the conversion attention module based on the correlation between the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the prediction time step;

[0156] By converting the attention module, the target encoded spatiotemporal features are determined from the encoded spatiotemporal features corresponding to the historical time steps based on the attention scores, and the target encoded spatiotemporal features corresponding to the historical time steps and the encoded spatiotemporal features corresponding to the prediction time steps are converted to obtain the target spatiotemporal features.

[0157] The device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.

[0158] An embodiment of the present invention provides an electronic device. Specifically, the electronic device includes a processor and a storage device. The storage device stores a computer program, and when the computer program is executed by the processor, it executes the method described in any one of the above-mentioned implementation methods.

[0159] Figure 7 A structural diagram of an electronic device provided in an embodiment of the present invention, the electronic device 100 includes: a processor 70, a memory 71, a bus 72 and a communication interface 73, wherein the processor 70, the communication interface 73 and the memory 71 are connected via the bus 72; the processor 70 is used to execute an executable module stored in the memory 71, such as a computer program.

[0160] The memory 71 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 73 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.

[0161] The bus 72 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0162] Among them, the memory 71 is used to store programs, and the processor 70 executes the program after receiving the execution instruction. The method executed by the device for flow process definition disclosed in any embodiment of the above-mentioned embodiment of the present invention can be applied to the processor 70 or implemented by the processor 70.

[0163] The processor 70 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 70. The above processor 70 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiments of the present invention can be directly embodied as a hardware decoding processor to be executed, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 71, and the processor 70 reads the information in the memory 71 and completes the steps of the above method in combination with its hardware.

[0164] The computer program product of the readable storage medium provided in the embodiment of the present invention includes a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the methods described in the previous method embodiments. The specific implementation can be referred to the previous method embodiments, which will not be repeated here.

[0165] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.

[0166] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A traffic situation prediction method based on spatiotemporal attention mechanism, characterized in that: include: Obtain the traffic flow data corresponding to each traffic sensing node in the traffic network to be predicted in the historical period; Through a pre-trained traffic situation deduction model, the spatiotemporal embedding representation corresponding to the traffic network to be predicted is extracted, and the traffic situation prediction result corresponding to the traffic network to be predicted is generated based on the traffic flow data and the spatiotemporal embedding representation; wherein the traffic situation deduction model is obtained by training a densely connected spatiotemporal multi-head attention model that combines the spatiotemporal attention mechanism and the conversion attention mechanism, and the traffic situation prediction result includes the traffic flow data corresponding to each of the traffic perception nodes in the prediction period.

2. The traffic situation prediction method based on spatiotemporal attention mechanism according to claim 1 is characterized in that: Obtain the traffic flow data corresponding to each traffic sensing node in the traffic network to be predicted in the historical period, including: Obtain the number of pulses corresponding to each traffic sensing node in the traffic network to be predicted in the historical period; Calculating the initial instantaneous vehicle speed data corresponding to each of the traffic sensing nodes in the historical period based on the pulse number; Performing missing data repair processing, smoothing processing and normalization processing on the initial instantaneous vehicle speed data to obtain target instantaneous vehicle speed data corresponding to each of the traffic sensing nodes in the historical period; Wherein, the traffic flow data is the target instantaneous vehicle speed data.

3. The traffic situation prediction method based on spatiotemporal attention mechanism according to claim 1 is characterized in that: The densely connected spatiotemporal multi-head attention model includes a spatial feature extraction module and a temporal feature extraction module; Extracting the spatiotemporal embedding representation corresponding to the traffic network to be predicted, including: Extracting a spatial embedding representation based on a node adjacency matrix corresponding to the traffic network to be predicted by the spatial feature extraction module; wherein the node adjacency matrix is ​​used to characterize the relative distances between the traffic sensing nodes in the traffic network to be predicted; The historical time period and the predicted time period are sliced ​​by the spatial feature extraction module to obtain a plurality of historical time steps and a plurality of predicted time steps, and the historical time steps and the predicted time steps are subjected to one-hot encoding processing to obtain time embedding representations corresponding to the historical time steps and the predicted time steps, respectively; wherein the time embedding representations are used to reflect the temporal dynamic correlation between the traffic sensing nodes; Feature concatenation is performed on the spatial embedding representation and the temporal embedding representation to obtain spatiotemporal embedding representations corresponding to the historical time step and the predicted time step, respectively.

4. The traffic situation prediction method based on spatiotemporal attention mechanism according to claim 3 is characterized in that: The densely connected spatiotemporal multi-head attention model further includes an encoder module, a conversion attention module, and a decoder module based on a densely connected structure, and the spatiotemporal embedding representation is used as an input of each unit in the encoder module and the decoder module; Generating a traffic situation prediction result corresponding to the traffic network to be predicted based on the traffic flow data and the spatiotemporal embedding representation, including: Through the encoder module, multiple spatiotemporal feature extraction and fusion processing are performed on the traffic flow data, the spatiotemporal embedding representation corresponding to the historical time step, and the spatiotemporal embedding representation corresponding to the predicted time step to obtain the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the predicted time step; By means of the conversion attention module, feature conversion is performed on the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the predicted time step to obtain target spatiotemporal features; Through the encoder module, multiple spatiotemporal feature extraction and fusion processing are performed on the target spatiotemporal features, the spatiotemporal embedding representation corresponding to the historical time step, and the spatiotemporal embedding representation corresponding to the predicted time step to obtain the traffic situation prediction result corresponding to the traffic network to be predicted.

5. The traffic situation prediction method based on spatiotemporal attention mechanism according to claim 4 is characterized in that: The encoder module and the decoder both include a plurality of densely connected spatiotemporal attention units; through the encoder module, multiple spatiotemporal feature extraction and fusion processes are performed on the traffic flow data, the spatiotemporal embedding representation corresponding to the historical time step, and the spatiotemporal embedding representation corresponding to the predicted time step to obtain the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the predicted time step, including: Through the current spatiotemporal attention unit, a spatiotemporal feature extraction and fusion process is performed on the features output by each of the spatiotemporal attention units located before the current spatiotemporal attention unit, the spatiotemporal embedding representation corresponding to the historical time step, and the spatiotemporal embedding representation corresponding to the predicted time step, to obtain the features output by the current spatiotemporal attention unit; Among them, the features output by the spatiotemporal attention unit located at the last position in the encoder module include the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the predicted time step.

6. The traffic situation prediction method based on spatiotemporal attention mechanism according to claim 5 is characterized in that: The spatiotemporal attention unit includes a temporal attention subunit, a spatial attention subunit and a gated fusion subunit; through the current spatiotemporal attention unit, a spatiotemporal feature extraction and fusion process is performed on the features output by each of the spatiotemporal attention units located before the current spatiotemporal attention unit, the spatiotemporal embedding representation corresponding to the historical time step and the spatiotemporal embedding representation corresponding to the predicted time step, to obtain the features output by the current spatiotemporal attention unit, including: By means of the time attention subunit, based on the time attention mechanism, feature extraction is performed on the features output by each of the spatiotemporal attention units located before the current spatiotemporal attention unit, as well as the spatiotemporal embedding representation corresponding to the historical time step and the spatiotemporal embedding representation corresponding to the predicted time step, to obtain time series features; By means of the spatial attention subunit, based on the spatial attention mechanism, feature extraction is performed on the features output by each of the spatiotemporal attention units located before the current spatiotemporal attention unit, as well as the spatiotemporal embedding representation corresponding to the historical time step and the spatiotemporal embedding representation corresponding to the predicted time step to obtain spatially dependent features; Through the gated fusion subunit, the time series features and the spatial dependency features are gated and fused to obtain the features output by the current spatiotemporal attention unit.

7. The traffic situation prediction method based on spatiotemporal attention mechanism according to claim 4 is characterized in that: By means of the conversion attention module, the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the predicted time step are subjected to feature conversion to obtain target spatiotemporal features, including: Determining an attention score of the conversion attention module based on a correlation between the encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the predicted time step; Through the conversion attention module, the target encoded spatiotemporal features are determined from the encoded spatiotemporal features corresponding to the historical time step based on the attention score, and the target encoded spatiotemporal features corresponding to the historical time step and the encoded spatiotemporal features corresponding to the predicted time step are feature converted to obtain the target spatiotemporal features.

8. A traffic situation prediction device based on spatiotemporal attention mechanism, characterized in that: include: A data acquisition module is used to obtain the traffic flow data corresponding to each traffic sensing node in the traffic network to be predicted in the historical period; A situation prediction module is used to extract the spatiotemporal embedding representation corresponding to the traffic network to be predicted through a pre-trained traffic situation deduction model, and generate a traffic situation prediction result corresponding to the traffic network to be predicted based on the traffic flow data and the spatiotemporal embedding representation; wherein the traffic situation deduction model is obtained by training a densely connected spatiotemporal multi-head attention model that combines the spatiotemporal attention mechanism and the conversion attention mechanism, and the traffic situation prediction result includes the traffic flow data corresponding to each of the traffic sensing nodes in the prediction period.

9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Traffic flow prediction method

    CN111260919A

  • Traffic flow prediction model construction method and prediction method based on adaptive dynamic graph

    CN116187555A

  • Traffic flow prediction method based on space-time embedded attention network

    CN117688453A

  • System and method of vehicle speed estimation using moving camera and time series neural network

    US11861853B1

  • Traffic state prediction method and apparatus, and device, medium and program

    WO2023088131A1