Traffic flow prediction method based on multi-model network coupling

Through the multi-model network coupling method, combined with the encoder-decoder structure and attention mechanism, the spatiotemporal dependencies and multi-scale features of traffic flow data are extracted, which solves the problem of difficulty in capturing nonlinear features and long-term dependencies in traditional methods. Improved traffic flow forecast accuracy and long-term forecast accuracy.

CN118675338APending Publication Date: 2024-09-20ANHUI NORMAL UNIV
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410936407.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-09-20

AI Technical Summary

Technical Problem

Traditional traffic flow prediction methods are difficult to capture nonlinear characteristics and long-term dependencies when processing complex and dynamically changing traffic flow data, resulting in low prediction accuracy and reliability.

Method used

Using a method based on multi-model network coupling, the encoder-decoder architecture is combined with a convolutional neural network and a gated recurrent unit, and the attention mechanism and residual connection are introduced to extract spatiotemporal dependencies and multi-scale features to predict traffic flow. .

Benefits of technology

It improves the accuracy of traffic flow prediction and long-term prediction accuracy, solves the gradient disappearance and gradient expansion problems in traditional methods, enhances the adaptability and efficiency of the model, and has wide applicability and strong generalization ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118675338A
    Figure CN118675338A
Patent Text Reader

Abstract

The invention discloses a traffic flow prediction method based on multi-model network coupling. The method comprises the following steps: processing and inputting road traffic flow original data; inputting the data into a linear layer for preprocessing to obtain linear transformation; inputting into Encoder, and extracting spatial dependency and time dependency; inputting an output result of the encoder into AdjostBlock to extract local features and enhance context information; summing the output result of the AdjostBlock and the original data to obtain a residual error, and taking the residual error as the input data of Decoder to carry out subsequent learning; an output result of the decoder is used as Query data of cross attention, and an output result of the encoder is used as Key data and Value data to be sent into the cross attention to process complex sequence data and then is input into a full connection layer to obtain a final prediction result. According to the invention, the accuracy of traffic flow prediction data prediction can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of traffic flow prediction, and in particular to a traffic flow prediction method based on multi-model network coupling. Background Art

[0002] With the acceleration of global urbanization, urban transportation systems are facing increasingly severe congestion problems, which have affected people's daily lives and the sustainable development of urban economies. The development of intelligent transportation systems (ITS) has made it possible to alleviate traffic congestion and optimize urban traffic management. Traffic flow forecasting, as an important part of ITS, is receiving extensive attention and research. Traditional traffic flow forecasting methods mainly rely on statistical analysis and traffic flow theory models. These methods include time series analysis (such as ARIMA model), regression analysis, and traffic flow theory based on physical models (such as LWR model). However, these traditional methods show certain limitations when dealing with complex and dynamically changing traffic flow data, and it is difficult to capture the nonlinear characteristics and long-term dependencies in the data.

[0003] In recent years, with the rapid development of deep learning technology, especially the great success in image recognition, natural language processing and other fields, researchers have begun to explore the application of deep learning in traffic flow prediction. Deep learning can automatically extract complex features from large-scale data through its deep neural network structure and has the advantage of processing high-dimensional nonlinear data, which provides a new idea for solving the problem of traffic flow prediction.

[0004] For example, convolutional neural networks (CNN) have been introduced into the field of traffic flow prediction due to their outstanding performance in image processing. Traffic flow data can be regarded as multidimensional data related to time and space. By converting these data into gridded image form, CNN can effectively capture spatial features. For example, the urban traffic road network is divided into several grids, each grid corresponds to a geographical area, and CNN is used to model and predict the traffic flow in each area, achieving remarkable results. In terms of processing time series data, recurrent neural networks (RNN) and their improved versions, such as long short-term memory networks (LSTM) and gated recurrent units (GRU), have shown powerful capabilities. Traffic flow data has significant time dependence and periodicity characteristics. RNN can capture the dynamic changes of traffic flow through its internal loop structure. LSTM and GRU further solve the gradient vanishing problem of traditional RNN in long-term dependency learning by introducing memory units, thereby improving the accuracy of prediction.

[0005] In addition, graph convolutional networks (GCN) show unique advantages in processing data with graph structures. The traffic network can be regarded as a graph, where nodes represent intersections or sections and edges represent roads. GCN can make full use of the topological information and spatiotemporal dependencies of the traffic network by performing convolution operations on graph structured data. Combining GCN with RNN or LSTM to form spatio-temporal graph convolutional networks (STGCN) further improves the effect of traffic flow prediction.

[0006] In traditional traffic prediction methods, a single network such as GCN or CNN is generally used for prediction, but its prediction accuracy and reliability are low, resulting in the inability to accurately predict traffic flow. Summary of the invention

[0007] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a traffic flow prediction method based on multi-model network coupling. The traffic flow is predicted by multi-model network coupling, which can effectively improve the accuracy of traffic flow prediction.

[0008] In order to achieve the above-mentioned purpose, the technical solution adopted by the present invention is: a traffic flow prediction method based on multi-model network coupling, which predicts traffic flow through a built and trained multi-model network, and the multi-model network prediction method includes:

[0009] S1, pre-processing the original data of road traffic flow and then feeding it into the multi-model network;

[0010] S2, the input data is preprocessed through the linear layer to obtain the linearly transformed data which is input into the encoder;

[0011] S3, the encoder processes the input data to extract spatial dependency and temporal dependency feature data;

[0012] S4, the output result of the encoder is input into AdjustBlock to extract local features and enhance context information, and the average value of the local area is reduced and smoothed;

[0013] S5, add the output result of AdjustBlock and the original data and the residual as the input data of the decoder;

[0014] S6. The output result of the decoder is used as the query data of the cross attention, and the output result of the encoder is sent to the cross attention block as the key data and value data for processing;

[0015] S7. The output end of the cross attention block is connected to the fully connected layer, and the prediction result is output through the fully connected layer.

[0016] In step S1, original historical traffic flow data is obtained, processed into usable traffic flow prediction data, and input into the multi-model network prediction model.

[0017] In step S2, the data is input into the linear layer for preprocessing to obtain a linear transformation. Through the action of the weight matrix and the bias vector, the dimension and feature distribution of the input data are changed to obtain the data processed by the linear layer.

[0018] The encoder includes TGCNBlock, Residual Block, and self-attention. TGCNBlock includes two TGCN units: TGCN-a and TGCN-b. Each TGCN unit is used to obtain spatial dependency and temporal dependency feature data. The spatial dependency and temporal dependency output feature data obtained by the two TGCN units are H Ta and H TbThen, the output results of the two TGCN units are used to perform Hadamard product operations using different activation functions to obtain the output result X of TGCNBlock Tab ;

[0019] Residual Block uses graph convolutional network GCN for feature extraction and outputs result data X Tab The result after input to the graph convolutional network GCN is combined with the encoder input data XL, and the output result X of the Residual Block is calculated by adding the residual. R ;

[0020] The self-attention mechanism module makes X R Through several linear layers, we get the required query data, key data, and value data. First, we calculate the dot product between query and key to get the attention score. The scores are scaled and converted into weights through the SoftMax function. Finally, the attention weight matrix is ​​multiplied by the Value matrix to complete the weighted sum operation to obtain the feature data Xs. S The output of the encoder can be obtained through the fully connected layer.

[0021] The output result of the encoder is sent to the feature adjustment module AdjustBlock. The feature adjustment module AdjustBlock includes embedded standard convolution, dilated convolution and average pooling layers. The multi-scale feature information is extracted through embedded standard convolution, dilated convolution and average pooling operations, which are Xsta, Xdil and Xpool respectively. Then, the fusion block Fusionblock is used to fuse them to obtain the fusion result X that comprehensively considers local and global information. Aout , where X Aout =ReLU(X sta )*ReLU(X dil )*σ(X pool ).

[0022] The data output by the feature adjustment module AdjustBlock is added to the original data, and the input X of the decoder is obtained through the residual connection Din , where X Din =X Aout *X.

[0023] The decoder has the same structure as the encoder, including TGCNBlock, Residual Block, and self-attention. TGCNBlock includes two TGCN units, each of which is used to obtain spatial dependency and temporal dependency feature data. The output results of the two TGCN units are then used to perform Hadamard product operations using different activation functions to obtain the output results of TGCNBlock.

[0024] The Residual Block uses the graph convolutional network GCN for feature extraction. The output result of TGCNBlock is input into the graph convolutional network GCN and the result after processing is combined with the input data of the decoder. The output result of the Residual Block is calculated by adding the residual.

[0025] The self-attention mechanism module makes the output of the Residual Block pass through the linear layer to obtain the required Query data, Key data, and Value data. First, the dot product between the Query and the Key is calculated to obtain the attention score. The scores are scaled and converted into weights through the SoftMax function. Finally, the attention weight matrix is ​​multiplied by the Value matrix to complete the weighted sum operation to obtain the feature data. The feature data is then passed through the fully connected layer to obtain the output result of the decoder.

[0026] The output result of the decoder is used as the Query data of the cross-attention module, and the output data of the encoder is used as the Key data and Value data of the cross-attention module. After being processed by the cross-attention module and the linear layer, the high-level features are output to the fully connected layer.

[0027] The fully connected layer uses the previously learned weight parameters to perform a deeper level of abstraction and mapping of the input data to produce a more accurate prediction output. The prediction output is:

[0028] X output =W′X Cout +b′.

[0029] When training a multi-model network, the mean square error loss is used for prediction evaluation to optimize the model parameters to minimize the prediction error.

[0030] The advantages of the present invention are: the present invention uses the encoder-decoder architecture to combine spatial feature extraction (such as convolutional neural network) and temporal features (such as gated recurrent unit) to achieve synchronous acquisition of spatiotemporal dependencies and improve prediction accuracy. On this basis, the attention mechanism is introduced into the encoder-decoder framework to achieve prediction of future business flows at various stages, and weighted processing is performed on it to better play its important role in historical data, thereby improving its prediction ability.

[0031] The present invention adopts a combination of encoder and decoder to solve the problems of gradient attenuation and gradient expansion in traditional recurrent neural networks, and combines residual connectivity and other means to obtain richer and more accurate spatial correlation information, thereby improving the adaptability and efficiency of the algorithm for spatial data analysis tasks and improving long-term prediction accuracy.

[0032] The core of the present invention is to introduce a feature extraction module. By combining standard convolution, dilated convolution and average pooling, the module can simultaneously extract multi-scale feature information. Standard convolution captures detailed features, dilated convolution expands the receptive field to obtain global information, and average pooling reduces data redundancy while maintaining important features. This multi-scale feature extraction method makes the model perform better when processing data of different scales and complexities.

[0033] The invention has wide applicability and strong generalization ability. By utilizing a large and diverse training data set, the model can absorb features and patterns of different types and levels, providing a solid foundation for handling specific tasks in various fields. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] The following is a brief description of the contents expressed in the drawings of the present invention and the symbols in the drawings:

[0035] Figure 1 The overall framework structure of the model defined in the present invention;

[0036] Figure 2 Flowchart of the operation of various linear layers in the present invention;

[0037] Figure 3 It is the TGCN framework structure used to capture dynamic spatiotemporal dependencies in the Encoder and Decoder of the present invention.

[0038] Figure 4 It is the framework structure of AdjustBlock in the present invention;

[0039] Figure 5 This is a workflow diagram of the self-attention model in the Encoder and Decoder of the present invention;

[0040] Figure 6 This is the experimental result of the present invention - the five-minute prediction experimental result of a certain node under the PeMS08 data set;

[0041] Figure 7 This is the experimental result of the present invention - the visualization result within one week of the five-minute prediction of a node in the PeMS08 dataset;

[0042] Figure 8 This is the experimental result of the present invention - the experimental result of the five-minute prediction of a certain node under the PeMS04 data set;

[0043] Fig. 9 The figure is a prediction flow chart of the traffic flow prediction method of the present invention. DETAILED DESCRIPTION

[0044] The specific implementation of the present invention will be further explained in detail below by describing the optimal embodiment with reference to the accompanying drawings.

[0045] This embodiment provides a traffic flow prediction method, which predicts traffic flow data by building a trained model network. The structure of the prediction model after building is as follows: Figure 1 As shown in the figure, the prediction network model built mainly includes the following parts: linear layer Linear, encoder Encoder, feature adjustment module AdjustBlock, decoder Decoder, cross attention block CrossAttentionBlock, full connection layer FC. After the network is built, it is necessary to train the network first, and use the mean square error loss function for prediction evaluation to optimize the model parameters to minimize the prediction error. The weight parameters in the built prediction model are updated through the loss function until the mean square error loss function meets the setting requirements, thereby completing the training of the prediction network model. The trained network model can predict traffic flow data based on the historical data input into the model; the working principle flow chart of each module in the built network model is shown in the figure Fig. 9As shown in the figure, the original data of road traffic flow is first preprocessed to process the data into a usable form, and then sent to the network model, and then the data first enters the linear layer; the input data is preprocessed through the linear layer to obtain the linearly transformed data which is input to the encoder Encoder; the encoder Encoder processes the input data to extract spatial dependency and time dependency feature data; the output result of the encoder Encoder is input into AdjustBlock to extract local features and enhance context information, and the average value of the local area is used for dimensionality reduction and smoothing; the output result of AdjustBlock and the original data are added to the residual as the input data of the decoder Decoder; the output result of the decoder is used as the Query data of the cross attention, and the output result of the encoder is sent to the cross attention block as the Key data and Value data for processing; the output end of the cross attention block is connected to the fully connected layer, and the prediction result is output through the fully connected layer.

[0046] The built network model needs to build training data in advance to train the prediction network model before it can be used. Training means building test sets, training sets and other data sets to train the parameter weights in the network model. The trained model that meets the requirements can be used.

[0047] When training or predicting output, it is necessary to preprocess the historical road traffic data to obtain usable road information. The processing methods include:

[0048] Road traffic information can represent the traffic flow, traffic speed or traffic density of the road. Traffic flow prediction is to predict the road traffic information status at a certain moment in the future by learning the characteristic data of historical time steps.

[0049] Definition 1: Road network. A road network is a transportation network consisting of roads such as highways, streets, and bridges, which is used to connect different places and regions so that vehicles and pedestrians can move between them. Here, each road is regarded as a node and the topological structure of the road network is constructed, which is represented by G = (V, E, A), where V = {v1, v2, ..., v N} represents the set of all road nodes in the road network, where N represents the number of nodes, E represents the set of edges between nodes, and A∈R N*N is an adjacency matrix reflecting the connectivity between roads. i ,v j ∈V and (v i ,v j )∈E, then A i,j =1, otherwise A i,j =0.

[0050] Definition 2: Feature matrix. In the road network G, each node is a road. The traffic information on the road network is regarded as the attribute characteristics of the nodes in the network. The matrix that records the attribute characteristics of all nodes is called the feature matrix, which is expressed as X∈R N *C , where C is the number of node attribute features, then X t ∈R N*C Represents the road information feature matrix at each time step t, which can be traffic flow, traffic speed or traffic density.

[0051] Therefore, the traffic flow prediction problem can be regarded as taking the road network topology G and the feature matrix X as prerequisites, and calculating the traffic information at the next time T by learning the mapping function f, as shown in formula (1):

[0052] [X t+1 ,X t+2 ,...,X t+T ] = f(G; (X t-1 ,...,X t-1 ,X t )).

[0053] When pre-processing road information, the road information is converted into the form of a feature matrix X, which is traffic flow data that can be used by the network model, and the feature matrix X is sent as input data to the network prediction model.

[0054] like Figure 1-5 As shown, a traffic flow prediction method based on multi-model network coupling includes:

[0055] Step S1: Processing and inputting of raw data of road traffic flow:

[0056] Obtain the original historical data of the road, process it into usable traffic flow prediction data X, and input the data X into the model;

[0057] Step S2: Input the data into the linear layer for preprocessing to obtain a linear transformation, which can make the subsequent nonlinear layer (such as activation function) work more effectively:

[0058] Before entering the encoder, all data is first input into the linear layer for preprocessing to obtain linear transformation. Through the action of weight matrix and bias vector, the dimension and feature distribution of input data can be changed, making the data in the new space more suitable for subsequent processing and analysis;

[0059] Step S3: Input into Encoder to extract spatial dependency and temporal dependency:

[0060] Input into the Encoder. Since the encoder is embedded with GCN, GRU, self-attention and other network models, it can better extract complex spatial and temporal dependencies;

[0061] Step S4: Input the output result of the encoder into AdjustBlock to extract local features and enhance context information, and at the same time, perform dimensionality reduction and smoothing on the average value of the local area:

[0062] Input the output of the encoder into AdjustBlock. Using built-in standard convolution, dilated convolution, and average pooling operations, local features can be effectively extracted and context information can be enhanced. At the same time, the average value of the local area can be reduced in dimension and smoothed to reduce noise and model complexity and prevent overfitting.

[0063] Step S5: Add the output result of AdjustBlock and the original data to obtain the residual, which is used as the input data of Decoder for subsequent learning.

[0064] Step S6: The output result of the decoder is used as the query data of the cross-attention, and the output result of the encoder is sent to the cross-attention as the key data and value data, so that the model can process complex sequence data more flexibly and efficiently.

[0065] Step S7: Input to the fully connected layer to obtain the final prediction result:

[0066] The fully connected layer uses the learned weight parameters to map the input data to the corresponding output and obtain the final prediction result.

[0067] All the steps constitute our traffic flow prediction method based on multi-model network coupling. The overall framework is as follows: Figure 1 As shown, the specific execution process is as follows:

[0068] (1) Linear layer

[0069] Since the raw data of traffic flow has problems of noise and high dimensionality, this will have an adverse effect on the training and prediction of the model. Therefore, before model training, the data is usually preprocessed through a linear layer. Through the processing of the linear layer, the raw data can be appropriately linearly transformed to reduce the impact of noise and make the data smoother. In addition, the linear layer can also reduce the dimensionality of the data and reduce the complexity of the data. This not only helps to improve the training efficiency of the model, but also improves the prediction effect of the model. In short, by introducing the linear layer, the raw traffic flow data can be better processed and optimized. The feature matrix after the linear layer processing is X L , after processing the weight matrix and bias vector formed earlier, the feature data X is obtainedL Specific process such as Figure 2 As shown, the formula is expressed as follows:

[0070] X L =W L X+b L (1)

[0071] Among them, the linear measurement W L and b L They are weight matrix and bias vector respectively. Through training, the model can learn the optimal values ​​of W and b, so that the output can better represent the characteristics and rules of the input data. The data is input into the linear layer for preprocessing to obtain linear transformation. Through the action of weight matrix and bias vector, the dimension and feature distribution of the input data are changed to obtain the data XL processed by the linear layer.

[0072] (2) Encoder

[0073] The encoder-decoder architecture performs well in processing variable-length input and output sequences and is suitable for tasks with variable data length, such as traffic flow prediction. Since traffic flow is not only related to time but also to spatial location, the model extracts spatial and temporal features by combining graph convolutional neural networks (GCN) and gated recurrent units (GRU), respectively, so as to effectively capture complex spatiotemporal dependencies and improve prediction accuracy. By introducing the attention mechanism, the encoder-decoder architecture can dynamically select and weight the key parts of historical data in the traffic prediction at each time step, making the model more flexible and accurate in processing complex data and enhancing the ability to capture traffic changes at key moments and specific areas. In addition, combined with the residual connection technology, the encoder-decoder architecture can more effectively train deep neural networks, avoid gradient vanishing and gradient exploding problems, improve the convergence speed and stability of the model, and thus improve the accuracy of long-term predictions. The encoder consists of components such as TGCNBlock, Residual Block, and self-attention mechanism module.

[0074] (21)TGCNBlock

[0075] TGCNBlock extracts spatial and temporal features by combining graph convolutional neural network (GCN) and gated recurrent unit (GRU), thereby effectively capturing complex spatiotemporal dependencies and improving prediction accuracy. TGCNBlock includes two TGCN units: TGCN-a and TGCN-b. Each TGCN unit is used to obtain spatial dependency and temporal dependency feature data. The spatial dependency and temporal dependency output feature data obtained by the two TGCN units are H Ta and H TbThen, the output results of the two TGCN units are used to perform Hadamard product operations using different activation functions to obtain the output result X of TGCNBlock Tab ;

[0076] In the present invention, a 2-layer GCN model and original feature data are mainly selected to obtain spatial dependency. GCN can process data of any structure. Given the adjacency matrix A and the feature matrix X, the GCN model constructs a filter acting on the nodes in the graph in the Fourier domain, captures the spatial features between nodes through the first-order neighborhood, and then constructs the model by stacking multiple convolutions, which can be expressed as:

[0077]

[0078] in, is the adjacency matrix with self-connection added, let I be the identity matrix, that is In traffic flow data, the adjacency matrix is ​​used to represent the connection relationship between different nodes (such as traffic intersections or stations) in the traffic network. Adding the identity matrix I is equivalent to adding a self-loop to each node, indicating that each node is connected to itself. D is the degree matrix, D = ∑ i,j A i,j ,The degree matrix is ​​used to represent the number of connections of each transportation node. (l) is the output of layer l, representing the node representation in the neural network at layer l, W (l) is the weight parameter of the layer, which controls the linear transformation from input features to output features. σ(·) represents the sigmoid function of the nonlinear model, which is used to introduce nonlinearity so that the model can learn more complex features.

[0079] The TGCN module embedded in the encoder of the present invention is as follows Figure 3 As shown, since the linear layer has obtained the data X L , so the spatial dependency captured by the TGCN module can be expressed as:

[0080]

[0081] in, Represents feature data preprocessing, W0∈R M*H Represents the weight matrix from input to hidden layer, which is used to map input features to the hidden feature space of the first layer in traffic flow data. W1∈R H*T Represents the weight matrix from the hidden layer to the output layer, which is used to map the hidden layer features to the final output feature space. M is the length of the feature matrix, H is the number of hidden units, and T is the dimension of the output feature.

[0082] In this framework, we choose GRU units to capture the temporal dependencies in the data, mainly because GRU units have fewer gates and state variables, faster reasoning and calculation speeds, and can store important information for a long time, alleviating the common gradient vanishing problem in RNN. t As a reset gate, it is mainly used to control the degree of ignoring the state information of the previous moment, u t It is the update gate, which is used to control the extent to which the previous state information is brought into the current state. t is the content stored at time t, h t is the output state at time t. GRU can continuously update and correct the input information through these gates to capture temporal dependencies. This mechanism enables the network to effectively learn the intrinsic connections between sequences and provide accurate results when predicting future events. This dynamic information flow control not only improves the flexibility of the model, but also enhances its ability to handle complex dependencies.

[0083] The specific calculation process of capturing the current moment dependency is as follows: Ta ,A) represents the process of capturing spatial dependencies, which has been defined in equation (4). Where W and b represent the weight and bias in the training process respectively:

[0084] u t =σ(W u [f(X Ta ,A),h t-1 ],b u ) (3)

[0085] r t =σ(W r [f(X Ta ,A),h t-1 ],b r ) (4)

[0086] c t =tanh(W c [f(X Ta ,A),(r t *h t-1 )]+b c ) (5)

[0087] h t =u t *h t-1 +(1-u t )*c t (6)

[0088] After multiple cycles of capturing time dependencies, the final output result is h Ta, because the structure and process are the same, we can get h Tb =h Ta .Right now

[0089] In the structure of the present invention, the TGCN structure is used twice respectively, the purpose is to use two different activation functions and perform Hadamard product to increase the expression ability of the model, and to achieve richer information fusion, thereby possibly improving the performance of the model, and finally obtain the feature vector X after the Hadamard product of the output results of the two TGCN structures Tab And sent to the Residual Block, the specific calculation result is shown in formula (9):

[0090] X Tab =tanh(h Ta )*σ(h Tb ) (7)

[0091] In formula (9), tanh(*) represents the tanh activation function; σ is the sigmoid activation function.

[0092] (22)Residual Block

[0093] Residual Block uses graph convolutional network GCN for feature extraction and outputs result data X Tab The result after input to the graph convolutional network GCN is combined with the encoder input data XL, and the output result X of the Residual Block is calculated by adding the residual. R Although we have obtained valuable data containing local temporal and spatial dependencies, in order to more fully reveal the global dependency structure behind the data, we have to take more sophisticated processing methods. To this end, we import these complex data into graph convolutional networks for in-depth analysis. Through this method, we hope to capture the complex connections hidden in the details. After completing the preliminary processing of these data, we will get the results and X L The data is closely combined and the learning ability of the model is enhanced by adding residuals, so that the model can more accurately identify those subtle spatiotemporal dependencies at the global level.

[0094]

[0095] in, represents feature data preprocessing, X Tab is the feature vector data through the TGCNBlock framework, W R Represents the weight parameter of the Residual Block, X LIt is the nonlinear data obtained by passing the original traffic flow data through the linear layer, and ReLU is the activation function.

[0096] (23) self-attention

[0097] The self-attention mechanism module makes X R Through several linear layers, we get the required query data, key data, and value data. First, we calculate the dot product between query and key to get the attention score. The scores are scaled and converted into weights through the SoftMax function. Finally, the attention weight matrix is ​​multiplied by the Value matrix to complete the weighted sum operation to obtain the feature data Xs. S The output of the encoder can be obtained through the fully connected layer. In the task of traffic flow prediction, distant moments may have an important impact on the current prediction, and traffic data usually contains complex nonlinear relationships, all of which will affect the prediction performance of the model. In order to meet these challenges, the present invention embeds a self-attention mechanism in the encoder-decoder architecture. Through global attention distribution, the self-attention mechanism can effectively capture long-range dependencies. In addition, the mechanism allows parallel processing of all positions in the sequence, greatly improving computational efficiency. At the same time, the self-attention mechanism can also generate attention weights, which can be used to explain the time points and spatial positions that the model pays attention to. By analyzing these weights, it can be found which time periods have a greater impact on the current prediction.

[0098] The working mechanism of self-attention is as follows Figure 4 As shown, we make X R Through several linear layers to obtain the required query data (X Q Matrix), Key data (X K Matrix) and Value data (X V ), where W (φ) and b (φ) (φ=Q,K,V) represents the learnable weight matrix and bias vector corresponding to the linear layer network, which is specifically expressed as follows:

[0099]

[0100] First, calculate the dot product between Query and Key to get the attention score, using Scaling the score is used to prevent the input value from being too large, making the gradient more stable. K For X K The dimensions of the matrix, is the transpose of the Key matrix. The scaled scores are converted into weights through the SoftMax function, and finally the attention weight matrix is ​​multiplied by the Value matrix to complete the weighted sum operation to obtain X S , specifically expressed as follows:

[0101]

[0102] X S The output of the encoder can be obtained through the fully connected layer:

[0103] X Eout =W E X S +b E (11)

[0104] The meanings of the letters in the above formulas 12 and 13 are: E is the weight matrix of the fully connected layer, b E is the bias vector of the fully connected layer, and SoftMax is the activation function used to normalize the attention score to make it a probability distribution.

[0105] (3)AdjustBlock

[0106] The output result of the encoder is sent to the feature adjustment module AdjustBlock. The feature adjustment module AdjustBlock includes embedded standard convolution, dilated convolution and average pooling layers. The multi-scale feature information is extracted through embedded standard convolution, dilated convolution and average pooling operations, which are Xsta, Xdil and Xpool respectively. Then, the fusion block Fusionblock is used to fuse them to obtain the fusion result X that comprehensively considers local and global information. Aout The fusion record is the output of the feature adjustment module AdjustBlock. The output result of the encoder is sent to the feature adjustment module. The present invention uses embedded standard convolution, dilated convolution and average pooling operations to extract multi-scale feature information. The framework structure is as follows Figure 5 As shown in Figure 2, dilated convolution aims to expand the receptive field of the convolution kernel by inserting the dilation rate without increasing the size of the convolution kernel or increasing the computational cost.

[0107] Specifically, the dilated convolution inserts gaps between the elements of the standard convolution kernel, allowing the convolution kernel to cover a larger input area. In this way, the dilated convolution can capture a wider range of contextual information. Assuming that the size of the convolution kernel is k*k and the dilation rate is d, the receptive field actually covered by the dilated convolution is (k+(k-1)×(d-1))×(k+(k-1)×(d-1)). When d=1, it becomes a standard convolution. Average pooling is a downsampling operation that reduces the spatial size of the data by calculating the average value in a local area.

[0108] (31)Standard convolution

[0109] Standard convolution performs local weighted summation on the input data through a sliding window method to extract local features, reduce random noise in the data, and improve the stability and predictability of the data.

[0110] X sta =Conv1d(X Eout ,W sta ,b sta ) (12)

[0111] (32)Dilated convolution

[0112] Dilated convolution helps preserve detail information by expanding the receptive field of the convolution kernel, allowing the model to capture a wider range of spatiotemporal dependencies.

[0113] X dil = DitatedConv1d(X Eout ,W dil ,b dil ,d) (13)

[0114] (33)Average pooling

[0115] The average pooling operation further reduces the impact of noise and outliers by calculating local averages, helping to extract the main trends and patterns of the data and ignore minor fluctuations and changes, thereby better making long-term predictions.

[0116] X pool =AvgPool1d(X Eout ,k) (14)

[0117] For the above operations, W (λ) and b (λ) (λ=sta,dil) is the corresponding learnable weight matrix and bias vector, d is the void rate, and k is the pooling window.

[0118] (34)Fusion block

[0119] Since the convolution layer captures local features and the average pooling layer summarizes the global trend, they are fused by the Hadamard product while retaining their respective features, so that the model can comprehensively consider local and global information to enhance the expressiveness of features, so that the model can better distinguish and predict complex traffic flow patterns, as shown below:

[0120] X Aout =ReLU(X sta )*ReLU(X dil )*σ(X pool ) (15)

[0121] σ is the sigmoid activation function, and ReLU(*) represents the ReLU activation function.

[0122] (4)Decoder

[0123] Considering that the original data may contain some effective information or low-level features that the model fails to capture. The present invention adds the data output by the adjustment module to the original data, and through the residual connection, the model can directly learn the residual related to the target (i.e., the difference between the predicted value and the actual value), rather than directly learning the entire predicted value. This method can make better use of the information that may exist in the original data, so that the model can learn effective high-level features or patterns during the training process, and correct and improve the prediction results through residual learning, thereby improving the accuracy and stability of the prediction. The data output by the feature adjustment module AdjustBlock is added to the original data, and the input X of the decoder is obtained through the residual connection. Din ,in:

[0124] X Din =X Aout *X (16)

[0125] Since the encoder and decoder are structurally the same, we can refer to the encoder's workflow to get the decoder's output as X DoutThat is, the decoder and the encoder have the same structure, including TGCNBlock, ResidualBlock, and self-attention. TGCNBlock includes two TGCN units: TGCN-a and TGCN-b. Each TGCN unit is used to obtain spatial dependency and temporal dependency feature data. Then, the output results of the two TGCN units are used to perform Hadamard product operations using different activation functions to obtain the output results of TGCNBlock. The Residual Block uses the graph convolution network GCN for feature extraction. The output result of TGCNBlock is input into the graph convolution network GCN. The result after processing is combined with the encoder input data XL. The output result of the Residual Block is calculated by adding the residual error. Then, based on the self-attention mechanism module, X is used to extract the feature of the image. R Through several linear layers, we get the required query data, key data, and value data. First, we calculate the dot product between query and key to get the attention score. The scores are scaled and converted into weights through the SoftMax function. Finally, the attention weight matrix is ​​multiplied by the Value matrix to complete the weighted sum operation to obtain the feature data. The decoder output is X after passing through the fully connected layer. Dout .

[0126] (5) Cross-Attention

[0127] The output of the decoder is used as the query data of the cross-attention module, and the output data of the encoder is used as the key data and value data of the cross-attention module. After being processed by the cross-attention module and the linear layer, the high-level features are output to the fully connected layer. This is similar to the self-attention mechanism, but the decoder output data itself is no longer used to generate the key and value data. By using the output of the decoder as the query data of the cross-attention module and no longer performing linear transformation, the output data of the encoder is used as the key data and value data of the cross-attention module. Through this operation, not only the input of the decoder can be paid attention to, but also the output of the encoder, and the encoder's global information and semantic information of the input sequence can be maximized, which can effectively enhance the model's ability to understand the input sequence, improve the model's modeling ability, and improve the performance of long sequence tasks.

[0128]

[0129] In addition, it is necessary to introduce additional nonlinear capabilities to the attention weights through a linear layer so that it can better learn high-level features and patterns in the data, thereby improving the accuracy and generalization ability of the overall prediction. The output result Xcout of the cross-attention mechanism is:

[0130]

[0131] Among them, X CQ is the output of the decoder, X CV is the output of the encoder, Represents the transposed data of the encoder output, d K is the dimension size of the Key data matrix, W C The weight matrix of the linear layer, b C is the corresponding bias vector, and SoftMax is the activation function.

[0132] (6) Fully connected layer

[0133] After successfully capturing dynamic spatiotemporal dependencies, the role of the fully connected layer becomes crucial. Through this layer, the model can use the previously learned weight parameters to perform a deeper level of abstraction and mapping of the input data to produce more accurate prediction results. This process involves nonlinear transformation of the data in a high-dimensional space, so that the model can better understand the complex relationship of the input data and convert it into corresponding outputs. The fully connected layer uses the previously learned weight parameters to perform a deeper level of abstraction and mapping of the input data to produce a more accurate prediction output. The prediction output is:

[0134] X output =W′X Cout +b′ (19)

[0135] Where W` and b` are the weight matrix and bias matrix of the fully connected layer, respectively, which can be obtained through training updates.

[0136] The goal of the present invention is to minimize the error between the actual road traffic information and the predicted information. t and Z t ′ represents the actual target value and model prediction value of each type of traffic information at time t, N represents the number of samples. The present invention selects the mean squared error loss function for prediction evaluation, which is a common loss function used for regression problems and is used to optimize model parameters to minimize prediction errors. The calculation method is shown in formula (22):

[0137]

[0138] MSE measures the squared difference between the model's predicted value and the actual value, and then takes the average. The smaller the average squared error, the closer the model's prediction is to the actual value, and vice versa. This is also a common loss function used for regression problems, used to optimize model parameters to minimize prediction errors.

[0139] In order to further explore the effectiveness of the experimental model of the present invention, we decided to use the publicly released PeMS08 and PeMS04 datasets on the Internet as the experimental benchmark. This dataset was collected in California, USA, and it contains a series of data records about road traffic flow. These data come from sensor devices installed on the road, which can monitor specific road sections every five minutes, thereby continuously providing relevant information. These three datasets cover three different types of data in different time periods, including traffic volume, speed, and other data that do not directly reflect traffic conditions. Considering the importance of flow data to the prediction performance of the model, as well as the relative sparsity and relevance of the other two types of data, we finally chose flow as the main research object, hoping to verify the accuracy and practicality of our experimental model by effectively predicting it. For more information on each dataset, see Table 1.

[0140] Table 1 PEMS series data set information

[0141]

[0142] Before conducting our required experiments, we carefully analyzed the characteristics of all data records and conducted a detailed examination of various factors that may affect the results to ensure that our research results can accurately reflect real-world traffic conditions.

[0143] The present invention sets the original label data as a gray solid line, the predicted data as a black dotted line, and selects some experimental results as follows Figure 6 , 7 , 8. Through in-depth and meticulous interpretation of the experimental results, we can be sure that the present invention has achieved remarkable results in traffic flow prediction. This technology not only successfully achieves accurate prediction of traffic flow, but also the experimental model constructed by it shows excellent prediction performance. More importantly, the model shows good data convergence ability, which means that it can continuously improve the accuracy and stability of the prediction results as the training process progresses. These findings are of great significance for understanding and improving traffic management systems, and also provide valuable experience and reference for future related research.

[0144] Obviously, the specific implementation of the present invention is not limited to the above-mentioned methods. As long as various non-substantial improvements are made using the method concept and technical solution of the present invention, they are all within the protection scope of the present invention.

Claims

1. A traffic flow prediction method based on multi-model network coupling, characterized by: Traffic flow is predicted through the built and trained multi-model network. The multi-model network prediction method includes: S1, pre-processing the original data of road traffic flow and then feeding it into the multi-model network; S2, the input data is preprocessed through the linear layer to obtain the linearly transformed data which is input into the encoder; S3, the encoder processes the input data to extract spatial dependency and temporal dependency feature data; S4, the output result of the encoder is input into AdjustBlock to extract local features and enhance context information, and the average value of the local area is reduced and smoothed; S5, add the output result of AdjustBlock and the original data and the residual as the input data of the decoder; S6. The output result of the decoder is used as the query data of the cross attention, and the output result of the encoder is sent to the cross attention block as the key data and value data for processing; S7. The output end of the cross attention block is connected to the fully connected layer, and the prediction result is output through the fully connected layer.

2. The traffic flow prediction method based on multi-model network coupling according to claim 1, characterized in that: In step S1, original historical traffic flow data is obtained, processed into usable traffic flow prediction data, and input into the multi-model network prediction model.

3. The traffic flow prediction method based on multi-model network coupling according to claim 1, characterized in that: In step S2, the data is input into the linear layer for preprocessing to obtain a linear transformation. Through the action of the weight matrix and the bias vector, the dimension and feature distribution of the input data are changed to obtain the data processed by the linear layer.

4. The traffic flow prediction method based on multi-model network coupling according to claim 1, characterized in that: The encoder includes TGCNBlock, Residual Block, and self-attention. TGCNBlock includes two TGCN units: TGCN-a and TGCN-b. Each TGCN unit is used to obtain spatial dependency and temporal dependency feature data. The spatial dependency and temporal dependency output feature data obtained by the two TGCN units are H Ta and H Tb Then, the output results of the two TGCN units are used to perform Hadamard product operations using different activation functions to obtain the output result X of TGCNBlock Tab ; Residual Block uses graph convolutional network GCN for feature extraction and outputs result data X Tab The result after input to the graph convolutional network GCN is combined with the encoder input data XL, and the output result X of the Residual Block is calculated by adding the residual. R ; The self-attention mechanism module makes X R Through several linear layers, we get the required query data, key data, and value data. First, we calculate the dot product between query and key to get the attention score. The scores are scaled and converted into weights through the SoftMax function. Finally, the attention weight matrix is ​​multiplied by the Value matrix to complete the weighted sum operation to obtain the feature data Xs. S The output of the encoder can be obtained through the fully connected layer.

5. The traffic flow prediction method based on multi-model network coupling according to claim 1, characterized in that: The output of the encoder is sent to the feature adjustment module AdjustBlock, which includes embedded standard convolution, dilated convolution and average pooling layers. The multi-scale feature information is extracted through embedded standard convolution, dilated convolution and average pooling operations, which are Xsta, Xdil and Xpool respectively. Then, the fusion block is used to fuse them to obtain the fusion result X that comprehensively considers local and global information. Aout , where X Aout =ReLU(X sta )*ReLU(X dil )*σ(X pool ).

6. The traffic flow prediction method based on multi-model network coupling according to claim 1, characterized in that: The data output by the feature adjustment module AdjustBlock is added to the original data, and the input X of the decoder is obtained through the residual connection Din , where X Din =X Aout *X.

7. The traffic flow prediction method based on multi-model network coupling according to claim 6 is characterized in that: The decoder has the same structure as the encoder, including TGCNBlock, Residual Block, and self-attention. TGCNBlock includes two TGCN units, each of which is used to obtain spatial dependency and temporal dependency feature data. The output results of the two TGCN units are then used to perform Hadamard product operations using different activation functions to obtain the output results of TGCNBlock. The Residual Block uses the graph convolutional network GCN for feature extraction. The output result of TGCNBlock is input into the graph convolutional network GCN and the result after processing is combined with the input data of the decoder. The output result of the Residual Block is calculated by adding the residual. The self-attention mechanism module makes the output of the Residual Block pass through the linear layer to obtain the required Query data, Key data, and Value data. First, the dot product between the Query and the Key is calculated to obtain the attention score. The scores are scaled and converted into weights through the SoftMax function. Finally, the attention weight matrix is ​​multiplied by the Value matrix to complete the weighted sum operation to obtain the feature data. The feature data is then passed through the fully connected layer to obtain the output result of the decoder.

8. The traffic flow prediction method based on multi-model network coupling according to claim 1, characterized in that: The output result of the decoder is used as the Query data of the cross-attention module, and the output data of the encoder is used as the Key data and Value data of the cross-attention module. After being processed by the cross-attention module and the linear layer, the high-level features are output to the fully connected layer.

9. The traffic flow prediction method based on multi-model network coupling according to claim 1, characterized in that: The fully connected layer uses the previously learned weight parameters to perform a deeper level of abstraction and mapping of the input data to produce a more accurate prediction output. The prediction output is: X output =W′X Cout +b′。 10. A traffic flow prediction method based on multi-model network coupling according to any one of claims 1 to 9, characterized in that: When training a multi-model network, the mean square error loss is used for prediction evaluation to optimize the model parameters to minimize the prediction error.

Citation Information

Cited By

  • Traffic flow prediction method based on space-time sequence

    CN119479312A

  • Traffic flow prediction method and device based on multi-level space-time and perception fusion

    CN121092937A

  • Traffic flow prediction method and device based on multi-level space-time and perception fusion

    CN121092937B