Traffic flow prediction method based on time trend dynamic attention enhancement mechanism

By adopting a traffic flow prediction method based on a time-trend dynamic enhanced attention mechanism, the problems of low accuracy and insufficient stability in traditional prediction schemes are solved. By capturing global and local time-series features and fusing positive and negative trend features, more efficient traffic flow prediction is achieved.

CN121352152APending Publication Date: 2026-01-16BEIJING EASY TIMES DIGITAL TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511913810.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-18
Publication Date
2026-01-16

AI Technical Summary

Technical Problem

Traditional traffic flow prediction schemes suffer from low prediction accuracy and insufficient stability, making it difficult to capture long-term periodic and trend changes in traffic flow. Furthermore, point-to-point modeling methods are prone to error accumulation, failing to effectively utilize trend information to guide attention weight allocation, and not responding promptly enough to short-term traffic fluctuations.

Method used

A traffic flow prediction method based on a time-trend dynamic enhanced attention mechanism is adopted. By acquiring standardized traffic flow data, time-trend dynamic enhancement processing is performed. The method uses a dual processing mechanism of global attention and local convolution to capture temporal features and fuses positive and negative time trend features to output the traffic flow prediction results for a future set time period.

Benefits of technology

It improves the accuracy and stability of traffic flow forecasting, reduces the error of short-term and long-term forecasts, enhances the reliability of forecast results, adapts to different traffic scenarios, and meets the actual needs of intelligent transportation systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121352152A_ABST
    Figure CN121352152A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of traffic flow prediction, and provides a traffic flow prediction method based on a time trend dynamic attention enhancement mechanism, and the method comprises the steps: obtaining traffic flow standardized data of a to-be-predicted region; performing time trend dynamic enhancement processing on the traffic flow standardized data to obtain a positive and negative time trend enhancement matrix; performing global and local time sequence feature capture on the positive and negative time trend enhancement matrix by using a global attention and local convolution dual-processing mechanism to obtain a positive and negative comprehensive feature matrix; and fusing the positive time trend characteristics and the negative time trend characteristics in the positive and negative comprehensive characteristic matrix to obtain a traffic flow prediction result of a future set time period. According to the scheme provided by the invention, the adaptability to different traffic scenes is improved through the accurate fusion of the positive and negative trend features, the errors of short-term and long-term prediction are reduced, the stability and accuracy of the prediction result are enhanced, and more reliable data support can be provided for intelligent traffic application.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of traffic flow prediction, and particularly relates to a traffic flow prediction method based on dynamic enhancement of attention mechanism according to time trend. BACKGROUND

[0002] Traffic flow prediction, as a core component of intelligent transportation systems, is of great significance for optimizing road resource allocation, relieving traffic congestion, and improving public transportation scheduling efficiency. With the development of deep learning technology, models based on graph neural networks and attention mechanisms have been widely used in traffic flow prediction tasks and have improved the convenience of traffic flow prediction to some extent.

[0003] However, the traditional traffic flow prediction scheme still has obvious limitations. Specifically, traditional time series analysis algorithms such as ARIMA (Auto Regressive Integrated Moving Average) and LSTM (Long Short Term Memory) are difficult to capture long-term periodic and trend changes in traffic flow, and the point-to-point modeling method is prone to error accumulation. Although the traditional attention mechanism can dynamically allocate time weights, it does not fully consider the trend similarity of traffic flow in the time dimension, such as the regular changes in morning and evening peak hours, and cannot effectively use trend information to guide attention weight allocation. At the same time, existing models are insufficient in modeling local time dependence, and are not responsive enough to short-term traffic fluctuations. In addition, when processing long sequence data, the problem of gradient vanishing or high computational complexity easily occurs, resulting in large short-term prediction errors and insufficient long-term prediction stability, which makes it difficult to meet the actual needs of intelligent transportation systems for accurate and efficient prediction.

[0004] Therefore, the traditional traffic flow prediction scheme has the technical problems of low prediction accuracy and insufficient stability. SUMMARY

[0005] The present application provides a traffic flow prediction method based on dynamic enhancement of attention mechanism according to time trend, which solves the defects of low prediction accuracy and insufficient stability of the traditional traffic flow prediction scheme.

[0006] The present application provides a traffic flow prediction method based on dynamic enhancement of attention mechanism according to time trend, which includes: Obtaining traffic flow standardized data of a region to be predicted; Performing time trend dynamic enhancement processing on the traffic flow standardized data to obtain a positive and negative time trend enhancement matrix; Using a global attention and local convolution dual processing mechanism, capturing global and local time sequence features of the positive and negative time trend enhancement matrix to obtain a positive and negative comprehensive feature matrix; Fusing the positive time trend feature and the negative time trend feature in the positive-negative comprehensive feature matrix to obtain a traffic flow prediction result of a future set period.

[0007] According to the traffic flow prediction method based on the time trend dynamic attention mechanism provided by the application, the traffic flow standardized data of the region to be predicted is obtained, including: Collecting traffic flow original data of the region to be predicted; Performing data preprocessing on the traffic flow original data to obtain traffic flow standardized data; The data preprocessing includes missing value completion and standardization processing.

[0008] According to the traffic flow prediction method based on the time trend dynamic attention mechanism provided by the application, the traffic flow standardized data is processed by time trend dynamic enhancement to obtain a positive-negative time trend enhancement matrix, including: Position coding is performed on the traffic flow standardized data to obtain a position coding feature matrix; According to the position coding feature matrix, a positive-negative time trend similarity matrix is determined by one-hot coding; Integrating the position coding feature matrix and the positive-negative time trend similarity matrix to obtain a positive-negative time trend enhancement matrix.

[0009] According to the traffic flow prediction method based on the time trend dynamic attention mechanism provided by the application, the traffic flow standardized data is processed by position coding to obtain a position coding feature matrix, including: Different frequency sine functions and cosine functions are used to calculate the position coding values of each position point in all dimensions in the traffic flow standardized data, to obtain a position coding feature matrix.

[0010] According to the traffic flow prediction method based on the time trend dynamic attention mechanism provided by the application, according to the position coding feature matrix, a positive-negative time trend similarity matrix is determined by one-hot coding, including: For any time point combination in the position coding feature matrix, the flow difference value between the first time point and the second time point in the time point combination is calculated; According to the flow difference value, the matrix elements corresponding to each time point combination are valued according to a first element valuation condition to obtain a positive similarity matrix; wherein the first element valuation condition is that the flow difference value is greater than or equal to 0, and the value is 1, and the flow difference value is less than 0, and the value is 0; According to the flow difference value, the corresponding matrix element of each time point combination is valued according to a second element valuation condition, to obtain a negative similarity matrix; wherein the second element valuation condition is: when the flow difference value is greater than or equal to 0, it is valued as 0, and when the flow difference value is less than 0, it is valued as 1; The positive similarity matrix and the negative similarity matrix are taken as a positive-negative time trend similarity matrix.

[0011] According to the traffic flow prediction method based on the time trend dynamic enhancement attention mechanism provided by the application, the position coding feature matrix and the positive-negative time trend similarity matrix are integrated to obtain a positive-negative time trend enhancement matrix, including: The positive similarity matrix and the position coding feature matrix are point multiplied to obtain a positive enhancement matrix; The negative similarity matrix and the position coding feature matrix are point multiplied to obtain a negative enhancement matrix; The positive enhancement matrix and the negative enhancement matrix are taken as a positive-negative time trend enhancement matrix.

[0012] According to the traffic flow prediction method based on the time trend dynamic enhancement attention mechanism provided by the application, the global attention and the local convolution double processing mechanism are used to capture the global and local time sequence features of the positive-negative time trend enhancement matrix to obtain a positive-negative comprehensive feature matrix, including: The positive-negative time trend enhancement matrix is input into a pre-constructed scaled dot product attention module to obtain a positive-negative attention enhancement matrix; The positive-negative attention enhancement matrix is input into an inflation causal convolution module with a gating mechanism to obtain a positive-negative comprehensive feature matrix.

[0013] According to the traffic flow prediction method based on the time trend dynamic enhancement attention mechanism provided by the application, the scaled dot product attention module contains multiple attention heads; The positive-negative time trend enhancement matrix is input into a pre-constructed scaled dot product attention module to obtain a positive-negative attention enhancement matrix, including: The positive-negative time trend enhancement matrix is converted into a positive-negative query matrix, a positive-negative key matrix and a positive-negative value matrix; According to the positive-negative query matrix and the positive-negative key matrix, a positive-negative attention weight matrix is calculated by scaled dot product operation; The positive-negative attention weight matrix and the positive-negative value matrix are multiplied to obtain a positive-negative output feature matrix of each attention head; The positive-negative output feature matrices of all attention heads are spliced and linearly transformed to obtain a positive-negative attention enhancement matrix.

[0014] The traffic flow prediction method based on time trend dynamic attention mechanism enhancement provided by the application comprises a plurality of sub-processing layers formed by stacking; The positive and negative attention enhancement matrix is input into the dilated causal convolution module with a gating mechanism to obtain a positive and negative comprehensive feature matrix, which comprises: For the first sub-processing layer, the dilated causal convolution operation is performed on the positive and negative attention enhancement matrix to obtain a positive and negative convolution feature matrix, and the positive and negative convolution feature matrix is subjected to a gating screening operation to obtain a positive and negative gating feature matrix; The positive and negative gating feature matrix output by the previous sub-processing layer is taken as the input data of the next sub-processing layer, and finally the positive and negative comprehensive feature matrix is output.

[0015] The traffic flow prediction method based on time trend dynamic attention mechanism enhancement provided by the application comprises a plurality of sub-processing layers formed by stacking; The positive and negative comprehensive feature matrix is subjected to a parallel splicing operation to obtain a spliced feature; The spliced feature is subjected to a nonlinear transformation and target dimension mapping to obtain a traffic flow prediction result of a future set period.

[0016] The traffic flow prediction method based on time trend dynamic attention mechanism enhancement provided by the application comprises a plurality of sub-processing layers formed by stacking; BRIEF DESCRIPTION OF DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the application or prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.

[0018] Figure 1 is the overall flowchart of the traffic flow prediction method based on time trend dynamic attention mechanism enhancement provided by the embodiment of the application; Figure 2 is a flowchart of a process for determining a positive and negative time trend enhancement matrix; Figure 3 is a flowchart of a process for determining a positive and negative comprehensive feature matrix. DETAILED DESCRIPTION

[0019] In order to make the objectives, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described clearly and completely below with reference to the drawings in the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the present application.

[0020] The details of the traffic flow prediction method based on time trend dynamic enhancement attention mechanism provided by the embodiments of the present application will be described below. Figures 1 to 3 The details of the traffic flow prediction method based on time trend dynamic enhancement attention mechanism provided by the embodiments of the present application will be described below.

[0021] As shown in Figure 1 The traffic flow prediction method based on time trend dynamic enhancement attention mechanism provided by the embodiments of the present application mainly includes the following steps: Step 110: Obtain traffic flow standardized data of a region to be predicted.

[0022] In this step, by obtaining high-quality traffic flow standardized data, effective data basis can be provided for subsequent flow prediction.

[0023] Step 120: Perform time trend dynamic enhancement processing on the traffic flow standardized data to obtain a positive and negative time trend enhancement matrix.

[0024] In this step, by time trend dynamic enhancement processing, an enhanced input with trend characteristics, i.e., a positive and negative time trend enhancement matrix, can be generated, which can solve the problem of insufficient trend modeling in the prior art.

[0025] Step 130: Use a global attention and local convolution dual processing mechanism to capture global and local time sequence features of the positive and negative time trend enhancement matrix to obtain a positive and negative comprehensive feature matrix.

[0026] In this step, by using the global attention and local convolution dual processing mechanism, dynamic time dependence and local time dependence of traffic flow can be captured at the same time, and thus the prediction accuracy can be improved.

[0027] Step 140: Fuse the positive time trend feature and the negative time trend feature in the positive and negative comprehensive feature matrix to obtain a traffic flow prediction result for a future set period.

[0028] In this step, by fusing positive and negative time trend features, accurate traffic flow prediction results can be output.

[0029] In one embodiment, obtaining standardized traffic flow data for the area to be predicted specifically includes: First, collect raw traffic flow data for the area to be predicted.

[0030] In practical applications, raw traffic flow data can be collected using fixed detectors or floating car GPS devices.

[0031] Then, the raw traffic flow data is preprocessed to obtain standardized traffic flow data.

[0032] Data preprocessing includes missing value completion and standardization.

[0033] In the missing value completion stage, methods such as linear interpolation or mean filling can be used to fill in missing data to ensure the integrity and accuracy of the data.

[0034] In the standardization process, the original traffic flow data after missing values ​​have been filled in can be standardized to ensure the uniformity of the data format.

[0035] In one embodiment, such as Figure 2 As shown, time trend dynamic enhancement processing is performed on standardized traffic flow data to obtain positive and negative time trend enhancement matrices, specifically including: Step 210: Perform location coding on the traffic flow standardization data to obtain the location coding feature matrix.

[0036] In one specific implementation, traffic flow standardized data is location-encoded to obtain a location-encoded feature matrix, which specifically includes: By using sine and cosine functions of different frequencies, the location coding values ​​of each location point in the traffic flow standardized data are calculated in all dimensions, thus obtaining the location coding feature matrix.

[0037] It is understandable that, in order to make full use of the sequential information in the time series corresponding to the traffic flow standardization data, this embodiment uses location coding technology to inject the relative or absolute location information of the monitoring points in the sequence.

[0038] In this embodiment, sine and cosine functions of different frequencies can be used to label position information. When the dimension of the position encoding is an even number of 2... m Specifically, it can be expressed as follows: (1) When the dimension of the position encoding is an odd number of 2 m When +1 is added, it can be represented as follows: (2) in, pos Indicates the location of the monitoring point. m The dimension index representing the location encoding. d model This represents the total dimension of the location encoding.

[0039] By using position encoding, for any fixed offset l , It can be represented as A linear function.

[0040] In practical applications, the location of each monitoring point in the time series can be traversed from the first time step to the last time step. pos That is, for each location point, traverse all dimensional indices. m Indexing each dimension m Substitute each value into the formula for even-numbered dimensions to calculate. PE ( pos , 2 m Substitute into the formula for odd-numbered dimensions to calculate. PE ( pos , 2 m +1), to get the position. pos Location-encoded values ​​across all dimensions.

[0041] Repeat the above steps until the location coding values ​​for all dimensions at all locations are calculated, ultimately forming the location coding feature matrix. X pos .

[0042] Step 220: Based on the location coding feature matrix, determine the positive and negative time trend similarity matrix through one-hot coding.

[0043] This embodiment introduces time trend information on the basis of location encoding and defines a set of time trend similarity matrices, which are then extracted through one-hot encoding.

[0044] In one specific implementation, based on the positional encoding feature matrix, the positive and negative time trend similarity matrix is ​​determined through one-hot encoding, including: First, for any combination of time points in the location coding feature matrix, calculate the difference in traffic flow between the first and second time points in the combination of time points.

[0045] On the one hand, based on the flow difference value, the matrix elements corresponding to each time point combination are assigned values ​​according to the first element assignment condition to obtain a positive similarity matrix; where the first element assignment condition is: when the flow difference value is greater than or equal to 0, it is assigned a value of 1, and when the flow difference value is less than 0, it is assigned a value of 0.

[0046] In this embodiment, the first time point is used. a Second time point b For example, positive similarity matrix I + ab It can be represented as follows: (3) On the other hand, based on the flow difference value, the matrix elements corresponding to each time point combination are assigned values ​​according to the second element assignment condition to obtain the negative similarity matrix; wherein, the second element assignment condition is: when the flow difference value is greater than or equal to 0, it is assigned a value of 0, and when the flow difference value is less than 0, it is assigned a value of 1.

[0047] In this embodiment, the first time point is used. a Second time point b For example, negative similarity matrix I - ab It can be represented as follows: (4) in, x na Indicates the first time point a Traffic, x nb Indicates the second time point b Traffic, n Indicates the node index. N This indicates the total number of monitoring points.

[0048] If the time point a Total flow relative to a point in time b If it shows an upward trend, then I + ab =1; otherwise I + ab =0. Conversely, if the time point a Total traffic compared to time b Reduce, then I - ab =0, otherwise I - ab =1.

[0049] Finally, the positive and negative similarity matrices are used as the positive and negative time trend similarity matrices.

[0050] Step 230: Integrate the location coding feature matrix with the positive and negative time trend similarity matrix to obtain the positive and negative time trend enhancement matrix.

[0051] In one specific implementation, the location encoding feature matrix is ​​integrated with the positive and negative time trend similarity matrix to obtain the positive and negative time trend enhancement matrix, which specifically includes: On the one hand, the positive similarity matrix and the positional encoding feature matrix are multiplied by a dot product to obtain the positive enhancement matrix.

[0052] In this embodiment, the positive enhancement matrix can be represented as follows: (5) On the other hand, the negative similarity matrix is ​​multiplied by the positional encoding feature matrix to obtain the negative enhancement matrix.

[0053] In this embodiment, the negative enhancement matrix can be represented as follows: (6) in, X + Represents the positive enhancement matrix. X - This represents a negative enhancement matrix. X pos This represents the positional encoding feature matrix.

[0054] Finally, the positive and negative enhancement matrices are used as positive and negative time trend enhancement matrices.

[0055] Understandably, through the matrix operations described above, location information can be bound to positive and negative time trend information, allowing subsequent prediction processes to simultaneously perceive both time location and trend direction, thus solving the problem of existing technologies ignoring trend characteristics.

[0056] In one embodiment, such as Figure 3 As shown, a dual processing mechanism of global attention and local convolution is used to capture global and local temporal features of the positive and negative time trend enhancement matrix, resulting in a comprehensive positive and negative feature matrix, specifically including: Step 310: Input the positive and negative time trend enhancement matrix into the pre-built scaled dot product attention module to obtain the positive and negative attention enhancement matrix.

[0057] In a specific implementation, the scaling dot product attention module contains multiple attention heads.

[0058] Furthermore, the positive and negative time trend enhancement matrices are input into a pre-constructed scaled dot product attention module to obtain positive and negative attention enhancement matrices, specifically including: The first step is to convert the positive and negative time trend enhancement matrix into a positive and negative query matrix, a positive and negative key matrix, and a positive and negative value matrix.

[0059] In this embodiment, the positive enhancement matrix in the positive and negative time trend enhancement matrix X+ and negative enhancement matrix X - All dimensions are ,in, batch Indicates the sample batch size. N This indicates the total number of monitoring points. F' This indicates the feature dimension after the trend is enhanced. T i This represents the total number of time points.

[0060] In practical applications, for positive enhancement matrices X + and negative enhancement matrix X - Three independent sets of learnable parameter matrices can be set separately. W Q , W K , W V ,in, d q , d k , d v Each represents a feature dimension of a different attention head. H This indicates the number of attention heads.

[0061] Then, the positive and negative query matrices, positive and negative key matrices, and positive and negative value matrices can be determined by matrix multiplication, as follows: (7) (8) (9) in, X This represents the positive and negative attention enhancement matrix. Q This represents a positive and negative query matrix. K Represents the positive and negative bond matrix. V Represents a matrix of positive and negative values. , .

[0062] Understandably, due to the positive and negative attention enhancement matrices X Involves positive enhancement matrix X + and negative enhancement matrix X - Therefore, the positive and negative query matrix, the positive and negative key matrix, and the positive and negative value matrix can be based on the positive enhancement matrix. X + and negative enhancement matrixX - Divided into forward query matrix Q + Forward bond matrix K + and positive value matrix V + and negative query matrix Q - Negative bond matrix K - and negative value matrix V - .

[0063] The second step is to calculate the positive and negative attention weight matrices by scaling dot product operations based on the positive and negative query matrices and the positive and negative key matrices.

[0064] The third step is to multiply the positive and negative attention weight matrices with the positive and negative value matrices to obtain the positive and negative output feature matrices for each attention head.

[0065] The fourth step is to concatenate and linearly transform the positive and negative output feature matrices of all attention heads to obtain the positive and negative attention enhancement matrices.

[0066] In this embodiment, the dot product of the positive and negative query matrices and the transposes of the positive and negative key matrices is calculated, each dot product is divided by the square root of the key dimension, and then applied. softmax The function obtains the weights of the values. To avoid large key dimensions... softmax To push the function toward the region of minimum gradient, the dot product needs to be scaled. The positive and negative attention weight matrices are then multiplied by the positive and negative value matrices to obtain the positive and negative output feature matrices for each attention head. The specific calculation formula is as follows: (10) in, This represents the positive and negative output feature matrices.

[0067] Understandably, since there was a prior division between positive and negative time trends, the positive and negative output feature matrices also involve positive and negative output feature matrices.

[0068] Due to the availability of highly optimized matrix multiplication operations, the dot product attention mechanism is more efficient than additive attention in practical applications. The scaled dot product attention module consists of multiple attention heads, capable of capturing multiple temporal features of traffic flow. Unlike independent attention mechanisms, this embodiment can independently learn different linear projection sets.

[0069] The outputs of different attention heads are then concatenated and transformed via linear projection. The final output positive and negative attention enhancement matrices can be represented as follows: (11) in, This represents the positive and negative composite feature matrix. This indicates a splicing operation. i This indicates that attention should be paid to the number of heads. , , W O This represents a linear transformation matrix used to map the outputs of multiple attention heads to the target output size. .

[0070] Understandably, due to the positive and negative attention enhancement matrices X Involves positive enhancement matrix X + and negative enhancement matrix X - Therefore, the positive and negative attention enhancement matrices include both the positive attention enhancement matrix and the negative attention enhancement matrix.

[0071] Step 320: Input the positive and negative attention enhancement matrices into the dilated causal convolution module with gating mechanism to obtain the positive and negative comprehensive feature matrix.

[0072] In one specific implementation, the dilated causal convolution module with gating mechanism contains multiple sub-processing layers stacked together.

[0073] Furthermore, the positive and negative attention enhancement matrices are input into a dilated causal convolution module with a gating mechanism to obtain a comprehensive positive and negative feature matrix, specifically including: First, for the first sub-processing layer, dilated causal convolution operation is performed on the positive and negative attention enhancement matrices to obtain positive and negative convolution feature matrices. Then, gating filtering operation is performed on the positive and negative convolution feature matrices to obtain positive and negative gated feature matrices.

[0074] Then, the positive and negative gated feature matrices output from the previous sub-processing layer are used as input data for the next sub-processing layer, and finally, a positive and negative comprehensive feature matrix is ​​output.

[0075] In practical applications, while attention mechanisms can capture global temporal dependencies, they are not conducive to understanding short-term changes in traffic networks. Therefore, this embodiment further introduces a dilated causal convolution module with a gating mechanism to capture local temporal dependencies. As a special form of one-dimensional convolution, dilated causal convolution establishes data associations over longer distances by skipping parts of the input, thereby achieving a wider perceptual range. Unlike RNN-based methods, dilated causal convolution can correctly process time series in a non-recursive manner; its computation results do not depend on the computation results of previous states, which facilitates parallel computation and alleviates the gradient explosion problem.

[0076] For the input sequence In the film p Step to X and f The dilated causal convolution operation can be specifically represented as: (12) in, d This represents the expansion coefficient that controls the jump distance, used to adjust the model's perceptual range in the time dimension to learn local temporal dependencies. k This represents the summation index variable, with values ​​ranging from 0 to... K -1 indicates the end. K This represents the kernel size.

[0077] Furthermore, to effectively control the information flow and suppress the influence of irrelevant or redundant information, this embodiment introduces a gating mechanism after the dilated causal convolution operation. For a given input... The gating and filtering operation can be represented as: (13) in, Indicates model parameters, Indicates the proportion of information transmitted. sigmoid function, It is used as the output activation function to realize the properties of the hyperbolic tangent function.

[0078] Through the above process, this embodiment employs a scaling dot product attention mechanism with temporal trend enhancement to capture dynamic temporal dependencies, and simultaneously uses dilated causal convolution with gating mechanism to capture local temporal dependencies.

[0079] In one embodiment, the positive and negative time trend features in the positive and negative integrated feature matrix are fused to obtain the traffic flow prediction result for a future set time period, specifically including: First, the positive and negative time trend features in the positive and negative composite feature matrix are concatenated in parallel to obtain the concatenated features.

[0080] Then, the spliced ​​features are subjected to nonlinear transformation and target dimension mapping to obtain the traffic flow prediction results for the future set time period.

[0081] In this embodiment, the positive and negative time trend features in the positive and negative composite feature matrices can be concatenated in parallel through a join operation. After processing by a linear layer, the predicted output value of the target dimension, i.e., the traffic flow prediction result, can be obtained, as follows: (14) in, YIndicates the predicted output value. Indicates a positive time trend characteristic. Indicates a negative time trend characteristic. W , b All of these represent learnable parameters. This indicates a parallel splicing operation.

[0082] The advantages of the traffic flow prediction method based on the time-trend dynamic enhanced attention mechanism provided in this embodiment will be explained in detail below through a specific application example.

[0083] The area to be predicted was set along a 15-kilometer-long highway. Data collection spanned from February 1, 2023 to February 21, 2023. Raw traffic flow data was collected from eight radar detectors on the road at 5-minute intervals.

[0084] Since traffic flow prediction is a classic problem in intelligent transportation systems, this paper selects several representative existing prediction schemes and compares them with the prediction method proposed in this embodiment.

[0085] Specifically, the network structure used in the selected existing prediction scheme is as follows: STGCN, Spatial Temporal Graph Convolutional Network, utilizes GCN to capture spatial dependencies while processing time-series data through convolutional neural networks.

[0086] ASTGCN, Attention based Spatial Temporal Graph Convolutional Network, introduces an attention mechanism on top of STGCN, making the model pay more attention to important nodes and time steps when dealing with spatial and temporal dependencies.

[0087] STSGCN, Spatial Temporal Synchronous Graph Convolutional Network, is a network that captures spatial and temporal dependencies. This method improves prediction accuracy by synchronously updating temporal and spatial information.

[0088] GRAMODE, Graph-based Multi-ODE Neural Networks, is a network that comprises multiple ODE-GNN modules and learns better representations by capturing different views containing complex local and global dynamic spatiotemporal dependencies.

[0089] In the evaluation process, this embodiment uses three widely used metrics, namely mean absolute error. MAE Root mean square error RMSE and mean absolute percentage error MAPE To evaluate the performance of different methods, the specific definitions are as follows: (15) (16) (17) in, n Indicates the number of samples. Indicates the first i The predicted value for each sample, Indicates the first i The true value of each sample.

[0090] All data processing in the prediction process was performed on a computer equipped with two Nvidia GeForce RTX 3090 GPUs with 24GB of RAM each, based on the PyTorch framework. This embodiment used the Adam optimizer to train the model, with an initial learning rate of 0.001, a batch size of 64, a vector dimension of 64, and an attention head of 8. In the dilated causal convolution operation, the temporal convolution kernel was set to 3, and a zero-padding strategy was used for the convolution operation. Traffic flow was predicted using observation data from 12 monitoring points over the past hour, and an early stopping mechanism was used to avoid overfitting.

[0091] Table 1 below lists the average prediction results of the method of the present invention and six state-of-the-art baseline models over the next 15 minutes, 30 minutes, and 60 minutes.

[0092] Table 1. Average prediction results of various prediction methods

[0093] In 15-minute short-term forecasting, compared with the state-of-the-art baseline model, the method of this invention achieves performance improvements of 8.001%, 6.595%, and 5.865% in MAE, RMSE, and MAPE, respectively. In 60-minute long-term forecasting, the method of this invention achieves performance improvements of 2.547%, 1.018%, and 8.126% in MAE, RMSE, and MAPE, respectively.

[0094] In summary, the traffic flow prediction method based on a time-trend dynamic enhanced attention mechanism provided in this embodiment systematically solves several technical problems existing in the prior art by introducing key technologies such as a time-trend-aware attention mechanism and local time-dependent optimization modeling. Compared with traditional traffic flow prediction methods based on fixed graph structures and point-to-point attention mechanisms, this invention achieves key breakthroughs in model structure design and information fusion mechanism, thereby significantly improving prediction accuracy.

[0095] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A traffic flow prediction method based on time trend dynamic enhancement attention mechanism, characterized in that, The method comprises the following steps: acquiring traffic flow standardized data of a region to be predicted; performing time trend dynamic enhancement processing on the traffic flow standardized data to obtain a positive and negative time trend enhancement matrix; using a global attention and local convolution dual processing mechanism to capture global and local time sequence features of the positive and negative time trend enhancement matrix to obtain a positive and negative comprehensive feature matrix; fusing positive and negative time trend features in the positive and negative comprehensive feature matrix to obtain a traffic flow prediction result of a future set period.

2. The traffic flow prediction method based on time trend dynamic enhancement attention mechanism according to claim 1, characterized in that, The method comprises the following steps: acquiring traffic flow standardized data of a region to be predicted; performing data preprocessing on the traffic flow original data to obtain traffic flow standardized data; wherein the data preprocessing comprises missing value completion and standardization processing. 3.The traffic flow prediction method based on time trend dynamic enhancement attention mechanism according to claim 1, characterized in that, The method comprises the following steps: performing position encoding on the traffic flow standardized data to obtain a position encoding feature matrix; determining a positive and negative time trend similarity matrix according to the position encoding feature matrix through one-hot encoding; integrating the position encoding feature matrix and the positive and negative time trend similarity matrix to obtain a positive and negative time trend enhancement matrix.

4. The traffic flow prediction method based on time trend dynamic enhancement attention mechanism according to claim 3, characterized in that, The method comprises the following steps: using different frequency sine functions and cosine functions to calculate position encoding values of each position point in all dimensions in the traffic flow standardized data to obtain a position encoding feature matrix.

5. The traffic flow prediction method based on time trend dynamic enhancement attention mechanism according to claim 3, characterized in that, The method comprises the following steps: for any time point combination in the position encoding feature matrix, calculating a flow difference value between a first time point and a second time point in the time point combination; according to a first element assignment condition, assigning a matrix element corresponding to each time point combination according to the flow difference value to obtain a positive similarity matrix; wherein the first element assignment condition is that the flow difference value is greater than or equal to 0, and the element is assigned a value of 1, or the flow difference value is less than 0, and the element is assigned a value of 0; according to a second element assignment condition, assigning a matrix element corresponding to each time point combination according to the flow difference value to obtain a negative similarity matrix; wherein the second element assignment condition is that the flow difference value is greater than or equal to 0, and the element is assigned a value of 0, or the flow difference value is less than 0, and the element is assigned a value of 1; the positive similarity matrix and the negative similarity matrix are taken as the positive and negative time trend similarity matrix.

6. The traffic flow prediction method based on time trend dynamic enhancement attention mechanism according to claim 5, characterized in that, The method comprises the following steps: point-multiplying the positive similarity matrix and the position encoding feature matrix to obtain a positive enhancement matrix; point-multiplying the negative similarity matrix and the position encoding feature matrix to obtain a negative enhancement matrix; the positive enhancement matrix and the negative enhancement matrix are taken as the positive and negative time trend enhancement matrix.

7. The traffic flow prediction method based on time trend dynamic enhancement attention mechanism according to claim 1, characterized in that, The global attention and local convolution dual processing mechanism is used to capture the global and local time sequence features of the positive and negative time trend enhancement matrix, and a positive and negative comprehensive feature matrix is obtained, including: The positive and negative time trend enhancement matrix is input into a pre-constructed scaled dot-product attention module to obtain a positive and negative attention enhancement matrix. The positive and negative attention enhancement matrix is input into an inflation causal convolution module with a gating mechanism to obtain a positive and negative comprehensive feature matrix.

8. The traffic flow prediction method based on time trend dynamic enhancement attention mechanism according to claim 7, characterized in that, The scaled dot-product attention module includes multiple attention heads. The positive and negative time trend enhancement matrix is input into a pre-constructed scaled dot-product attention module to obtain a positive and negative attention enhancement matrix, including: The positive and negative time trend enhancement matrix is converted into a positive and negative query matrix, a positive and negative key matrix, and a positive and negative value matrix. According to the positive and negative query matrix and the positive and negative key matrix, the positive and negative attention weight matrix is calculated by scaled dot-product operation. The positive and negative attention weight matrix is multiplied by the positive and negative value matrix to obtain the positive and negative output feature matrix of each attention head. The positive and negative output feature matrices of all attention heads are spliced and linearly transformed to obtain the positive and negative attention enhancement matrix.

9. The traffic flow prediction method based on time trend dynamic enhancement attention mechanism according to claim 7, characterized in that, The inflation causal convolution module with a gating mechanism includes multiple sub-processing layers formed by stacking; The positive and negative attention enhancement matrix is input into an inflation causal convolution module with a gating mechanism to obtain a positive and negative comprehensive feature matrix, including: For the first sub-processing layer, the positive and negative attention enhancement matrix is subjected to inflation causal convolution operation to obtain a positive and negative convolution feature matrix, and the positive and negative convolution feature matrix is subjected to gating selection operation to obtain a positive and negative gating feature matrix. The positive and negative gating feature matrix output by the previous sub-processing layer is used as the input data of the next sub-processing layer, and finally the positive and negative comprehensive feature matrix is output.

10. The traffic flow prediction method based on time trend dynamic enhancement attention mechanism according to claim 1, characterized in that, The positive and negative comprehensive feature matrix is fused to obtain the traffic flow prediction result of the future set period, including: The positive and negative comprehensive feature matrix is subjected to parallel splicing operation to obtain a splicing feature. The splicing feature is subjected to nonlinear transformation and target dimension mapping to obtain the traffic flow prediction result of the future set period.

Citation Information

Patent Citations

  • Traffic flow prediction method based on attention mechanism

    CN114822027A

  • Traffic flow prediction method and system based on trend space-time diagram convolution, and medium

    CN116895157A