DSTMAN-based traffic prediction method

By adopting dynamic spatiotemporal memory enhancement network (DSTMAN) in traffic flow prediction, combining multi-head temporal attention, diffusion graph convolution and multi-scale time convolution modules, the existing methods are difficult to capture spatial heterogeneity and multi-scale time dependence. The problem of sexual intercourse achieves more accurate and stable traffic flow forecasts.

CN119028127AInactive Publication Date: 2024-11-26GUILIN UNIV OF ELECTRONIC TECH

Patent Information

Application Number
CN202410978941.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-22
Publication Date
2024-11-26
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing traffic flow prediction methods are difficult to effectively capture spatial heterogeneity and multi-scale time dependence, and ignore regional functional differences and temporal background information, resulting in insufficient prediction accuracy.

Method used

Using a traffic prediction method based on dynamic spatiotemporal memory enhancement network (DSTMAN), the data embedding layer, spatiotemporal layer and metamemory enhancement layer are used to dynamically capture spatiotemporal features through data embedding layer, spatiotemporal layer and metamemory enhancement layer, combined with multi-head temporal attention, diffusion graph convolution and multi-scale temporal convolution modules. and spatial heterogeneity, generate more accurate traffic flow prediction results.

Benefits of technology

More accurate traffic flow prediction is achieved, especially in places with large fluctuations in real flow, with small errors, and a higher degree of authenticity to real world conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119028127A_ABST
    Figure CN119028127A_ABST
Patent Text Reader

Abstract

The invention discloses a DSTMAN-based traffic prediction method, and the method comprises the steps: obtaining traffic road network parameters and traffic condition data, carrying out the preprocessing of the traffic road network parameters and the traffic condition data, and obtaining the preprocessed traffic road network data; a traffic flow prediction model is constructed, the preprocessed traffic road network data are input into the traffic flow prediction model for optimization, an optimized traffic flow prediction model is obtained, and the traffic flow prediction model is constructed by adopting a dynamic space-time memory enhanced network DSTMAN; and obtaining traffic network parameters of a to-be-predicted target traffic area, and inputting the traffic network parameters into the optimized traffic flow prediction model to obtain a traffic flow prediction result of a future target traffic area. According to the invention, the traffic flow can be predicted more accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of traffic prediction, and in particular relates to a traffic prediction method based on DSTMAN. Background Art

[0002] Rapid urbanization has led to a continuous increase in the number of vehicles, exerting tremendous pressure on the transportation system, which is the lifeblood of the city. Building an intelligent transportation system has become the main strategy for managing traffic, planning routes, and controlling congestion. Traffic state prediction is the driving force of the background applications of intelligent transportation systems. Accurate prediction can provide a reliable reference for these functions and significantly improve the user service experience. The core of traffic flow prediction lies in spatiotemporal modeling, which aims to capture complex and dynamic spatiotemporal dependencies. Despite a lot of efforts, existing methods still face major challenges: effectively capturing spatial heterogeneity, spatiotemporal context, and multi-scale temporal dependencies.

[0003] Past studies have usually focused on the propagation and diffusion of traffic flows between different spatial locations, while ignoring the differences in traffic patterns caused by basic geographical functions, such as the spatial layout of commercial and residential areas within a city. Due to the differences in road network structure, as well as the diversity and density of points of interest (POIs) in each area, the two areas show significant differences in traffic flow distribution. However, it is very difficult to effectively obtain external data that can capture the spatial heterogeneity caused by regional functional differences. In addition, the formation of traffic data is affected by the travel patterns of urban residents. For example, the traffic status on weekends is significantly lower than that on weekdays, and the traffic peaks at different time periods in a given day are also different. These factors are affected by the time of day, day of the week, and spatial location, collectively referred to as spatiotemporal context. A large part of the existing solutions only consider short-term or long-term temporal dependencies in general, while ignoring the specific context information. Last but not least, relying on a single model such as CNNs, RNNs, or Attention mechanism cannot fully address the problem of multi-scale temporal correlation. Under unconstrained traffic conditions, the recent temporal trend can fully reflect the future traffic flow status. On the contrary, when traffic is congested, the occurrence of congestion may have a long-term impact on the evolution of traffic patterns. Therefore, effectively modeling and addressing these issues is critical to achieving more accurate predictions.

[0004] At present, people have done a lot of research on the above problems. For example, the traditional AGCRN and MTGNN models use adaptive graph learning to reduce the bias introduced by prior knowledge, but lack consideration of spatial heterogeneity. The STID model proposes parameterized embedding combined with simple MLPs to achieve efficient prediction performance. However, it weakens the impact of multi-scale spatiotemporal dependencies. The DSTAGNN model utilizes complex spatiotemporal modeling components, which brings high computational costs despite limited performance improvements. In order to improve the above defects, the present invention designs a traffic prediction method based on the dynamic spatiotemporal memory enhancement network (DSTMAN). Summary of the invention

[0005] In order to solve the above technical problems, the present invention proposes a traffic prediction method based on DSTMAN, which can predict traffic flow more accurately.

[0006] To achieve the above object, the present invention provides a traffic prediction method based on DSTMAN, comprising:

[0007] Acquiring traffic network parameters and traffic condition data, preprocessing the traffic network parameters and traffic condition data, and obtaining preprocessed traffic network data;

[0008] Constructing a traffic flow prediction model, inputting the preprocessed traffic network data into the traffic flow prediction model for optimization, and obtaining an optimized traffic flow prediction model, wherein the traffic flow prediction model is constructed using a dynamic spatiotemporal memory enhancement network DSTMAN;

[0009] The traffic network parameters of the target traffic area to be predicted are obtained, and the optimized traffic flow prediction model is input to obtain the traffic flow prediction result of the future target traffic area.

[0010] According to the DSTMAN-based traffic prediction method provided by the present invention, the traffic flow prediction model consists of a data embedding layer, a spatiotemporal layer, and a meta-memory enhancement layer; wherein,

[0011] The data embedding layer is used to perform encoding and splicing processing according to the pre-processed traffic network data to obtain a spatiotemporal feature vector;

[0012] The spatiotemporal layer is used to perform multi-head temporal attention, diffusion graph convolution and multi-scale temporal convolution processing according to the spatiotemporal feature vector to obtain the spatiotemporal state;

[0013] The meta-memory enhancement layer is used to perform meta-memory enhancement processing on the spatiotemporal state to obtain a prediction result.

[0014] According to the DSTMAN-based traffic prediction method provided by the present invention, the spatiotemporal layer is composed of a multi-head temporal attention module, a diffusion graph convolution module and a multi-scale temporal convolution module;

[0015] The multi-head temporal attention module is used to perform scaling and normalization processing according to the spatiotemporal feature vector, and then perform splicing to obtain the output result of the multi-head temporal attention module;

[0016] The diffusion map convolution module is used to perform diffusion map processing according to the output result of the multi-head temporal attention module to obtain the output result of the diffusion map convolution module;

[0017] The multi-scale time convolution module is used to filter and splice according to the output result of the diffusion map convolution module to obtain the spatiotemporal state.

[0018] According to the DSTMAN-based traffic prediction method provided by the present invention, the method of inputting the pre-processed traffic network data into the data embedding layer in the traffic flow prediction model to obtain the spatiotemporal feature vector includes:

[0019] The preprocessed traffic network data is input into the data embedding layer. After obtaining the input time series traffic data, the time attributes of the time series traffic data in a day are encoded, the road network topology structure and the spatial characteristics of regional functional attributes are extracted, and the time attributes and the spatial characteristics are embedded in the fully connected layer for linear transformation and splicing to obtain a spatiotemporal feature vector.

[0020] According to the DSTMAN-based traffic prediction method provided by the present invention, a method for inputting the spatiotemporal feature vector into the multi-head time attention module in the spatiotemporal layer to obtain the output result of the multi-head time attention module includes:

[0021] The spatiotemporal feature vector is input into the multi-head temporal attention module, using the H of the i-th block i Generate query matrix, key matrix and value matrix;

[0022] Multiply the query matrix and the transpose of the key matrix, scale and normalize, and obtain the attention distribution at each time step to obtain an attention score;

[0023] Based on the attention scores, splicing is performed and linear exchange is performed using the projection matrix to obtain the output result of the multi-head temporal attention module.

[0024] According to the DSTMAN-based traffic prediction method provided by the present invention, a method for inputting the output result of the multi-head time attention module into the diffusion graph convolution module to obtain the output result of the diffusion graph convolution module includes:

[0025] Construct a meta-graph learner, and the meta-node library is represented as Where M represents the number of meta-memory nodes, and d represents the feature dimension of each meta-node;

[0026] By combining the meta-node library Φ with the adaptive weight factor W E Perform matrix calculations between them to generate memory-enhanced node embeddings E adp , building a meta-graph learner using memory-enhanced node embeddings;

[0027] The meta-graph learner is used to cluster the traffic nodes with spatial heterogeneity by:

[0028]

[0029] in represents the adaptive weight factor, Represents meta-memory-enhanced embedding; a meta-graph is generated Feeding the meta-graph back into the diffusion graph convolution module;

[0030] Bidirectional random walks are used on the meta-graph to capture the spatial correlation of multiple hops. The output formula of the diffusion graph convolution module is as follows:

[0031]

[0032] Among them, k represents the order of diffusion convolution, and Represent the forward and backward transfer matrices respectively, H represents the output of the multi-head temporal attention module MultiHead(Q, K, V), W k1 and W k2 is a learnable weight parameter.

[0033] According to the DSTMAN-based traffic prediction method provided by the present invention, the method of inputting the output result of the diffusion graph convolution module into the multi-scale time convolution module to obtain the output result of the multi-scale time convolution module includes:

[0034] The output of the diffusion graph convolution module is filtered on the time axis by a standard one-dimensional convolution kernel. (l) , the one-dimensional convolution kernel is defined as The filtered signal is expressed as in

[0035] The equation for the gated time unit is shown below:

[0036]

[0037] Among them, P and Q are the feature dimensions H (l)The first and second half of and σ(·) represent the tanh function and the sigmoid function, respectively;

[0038] The output result of the multi-scale time convolution module is obtained by splicing the convolution kernels in the multi-scale time convolution module in the time dimension, which is calculated as follows:

[0039] Z (l) =Concat(GConv 1×2 , GConv 1×3 , GConv 1×5 , GConv 1×7 ).

[0040] According to the DSTMAN-based traffic prediction method provided by the present invention, a method for inputting the output result of the multi-scale time convolution module into the meta-memory enhancement layer to obtain the prediction result includes:

[0041] The input spatiotemporal state is represented as Given a linear weight matrix and bias Z (l) Projection to query matrix

[0042]

[0043] Calculate the memory similarity between the query projection and each meta-node, calculate the attention score of the retrieved information, and normalize the attention score using the SoftMax function to obtain the weighted memory feature, which is calculated as follows:

[0044]

[0045] in, represents the similarity between the i-th query and the j-th meta-node, i∈[1,N], j∈[0,M], and the result represents the first memory-enhancing feature;

[0046] Will Used as a new query projection, calculate The memory similarity weight between the meta-node library Φ and the meta-node library Φ is used to obtain the secondary memory enhancement feature

[0047] Enhanced features for secondary memory and Perform weighted fusion and calculate as follows:

[0048]

[0049] The outputs of the spatiotemporal layer and the meta-memory enhancement layer are concatenated and activated with ReLU, and fully connected to obtain the prediction result Y:

[0050] Y=Linear(ReLu(Concat(Z (l) , H aug )))

[0051] Where Y is equal to Q represents the length of the prediction sequence.

[0052] According to the DSTMAN-based traffic prediction method provided by the present invention, the pre-processed traffic network data is input into the traffic flow prediction model for optimization, and the method for obtaining the optimized traffic flow prediction model includes:

[0053] Dividing the preprocessed traffic network data into a training set, a validation set and a test set;

[0054] Inputting the training set into the traffic flow prediction model to train the traffic flow prediction model to obtain a trained traffic flow prediction model;

[0055] Inputting the verification set into the trained traffic flow prediction model to obtain a verification result;

[0056] Based on the comparison between the verification result and the real result, the traffic flow prediction model is adjusted in real time to obtain an adjusted traffic flow prediction model;

[0057] The test set is input into the adjusted traffic flow prediction model to obtain a test result, and the test result is compared with the true result to obtain an optimized traffic flow prediction model.

[0058] Technical effect of the invention: The present invention discloses a traffic prediction method based on DSTMAN, which can dynamically capture spatial heterogeneity and temporal background information, such as distinguishing regional functional attributes (such as commercial areas, residential areas) and time information (working days, weekends, morning and evening rush hours). In addition, the model proposed in the present invention adopts a variety of time models, including a multi-head time attention module for long-term prediction and a multi-scale time convolution module for short-term prediction. Therefore, it is possible to more accurately predict traffic flow, especially in places where the actual traffic fluctuates greatly, and the performance is more stable, more realistic to real-world conditions, and shows smaller errors. The model proposed in the present invention has been verified accordingly on four real-world traffic data sets. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0060] Figure 1 A flow chart of a traffic prediction method based on DSTMAN according to an embodiment of the present invention;

[0061] Figure 2 This is a schematic diagram of metamemory enhancement according to an embodiment of the present invention;

[0062] Figure 3 Embodiment E of the present invention adp =W E ·Schematic diagram of clustering of Φ;

[0063] Figure 4 The traffic prediction visualization curve diagram for each time period of a certain day in an embodiment of the present invention, where (a) is Sensor 142 in METR-LA and (b) is Sensor 53 in PEMS-BAY. DETAILED DESCRIPTION

[0064] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0065] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0066] like Figure 1-4 As shown, this embodiment provides a traffic prediction method based on DSTMAN, including:

[0067] Acquiring traffic network parameters and traffic condition data, preprocessing the traffic network parameters and traffic condition data, and obtaining preprocessed traffic network data;

[0068] Constructing a traffic flow prediction model, inputting the preprocessed traffic network data into the traffic flow prediction model for optimization, and obtaining an optimized traffic flow prediction model, wherein the traffic flow prediction model is constructed using a dynamic spatiotemporal memory enhancement network DSTMAN;

[0069] The traffic network parameters of the target traffic area to be predicted are obtained, and the optimized traffic flow prediction model is input to obtain the traffic flow prediction result of the future target traffic area.

[0070] Furthermore, to process the data required by the model, we first obtain the original traffic network data set and preprocess the data, dividing it into training set, validation set and test set in a ratio of 7:2:1, which are used for model training, validation and testing respectively. On this basis, the traffic network is simplified into a graph G = (v, E, A). Among them, v is the node set, representing the observation distribution of N = |v| traffic sensors. E represents the edge set, and A represents the adjacency matrix, which is used to describe the relationship between different nodes. Assuming that each time series has a total of T timestamps, the signals of all nodes on the graph G can be represented as a three-dimensional feature matrix Similarly represents the traffic features collected from the i-th sensor at the t-th time stamp. The goal of the prediction task is to establish a mapping from historical observations to future data. Specifically expressed as:

[0071]

[0072] Among them, θ represents the learnable model parameters, P and Q represent the lengths of the historical sequence and the predicted sequence, respectively.

[0073] Furthermore, a dynamic spatiotemporal memory enhancement network (DSTMAN) is constructed. DSTMAN is mainly composed of a data embedding layer, a spatiotemporal layer, and a meta-memory enhancement layer. Among them, the spatiotemporal layer consists of a multi-head temporal attention module, a diffusion graph convolution module, and a multi-scale temporal convolution module. The following will introduce the above five modules in detail:

[0074] The data embedding layer specifically includes: first, the original features are projected through a fully connected layer to obtain a high-dimensional feature embedding E f =FC(X t-T+1:t ),in Then, two learnable time embedding dictionaries are constructed, denoted as and They encode the day of the week and the time of day, respectively. w Indicates the day of the week, and N t Represents the number of time slices in a day. By concatenating and broadcasting the two retrieved embeddings, we will obtain the period embedding It encodes the temporal periodic information of traffic time series. The motivation of temporal embedding is to encode a representation that can implicitly identify and explain the temporal heterogeneity exhibited across multiple time scales.

[0075] Secondly, a spatiotemporal hybrid embedding E st to capture the cascading effects of different time series (i.e., traffic sensors) along the temporal order. Unlike temporal embeddings extracted from a learned dictionary, Directly initialized to the embedding vector. Introducing Est The purpose of is twofold: on the one hand, it takes into account the pattern differences along the temporal order; on the other hand, it reflects the potential service orientation or functional influence among different nodes, thereby encoding contextual information related to the spatial location.

[0076] Finally, E ps Sum and concatenate the above embeddings to obtain the spatiotemporal representation H as follows:

[0077] H=(E f +E pe )||E p ||E st (2)

[0078] Among them, E ps is the cosine position encoding in the next attention module, and d h =d f +2d t +d s .

[0079] The multi-head temporal attention module specifically includes: the output of the data embedding layer is expressed as is fed into this module, which has been equipped with position encoding in the data embedding layer to show the relative position of the sequence. Then, using the H (i) Next, we generate the Query, Key and Value matrices. The formula is as follows:

[0080]

[0081] in, and are learnable projection parameters. The query matrix Q is multiplied by the transpose of the key matrix K, then scaled and normalized to obtain the attention distribution at each time step. Finally, the attention matrix is ​​weighted on the value matrix V to generate the implicit feature representation.

[0082] In order to enable the model to jointly focus on information from different representation subspaces and diverse temporal patterns, using multiple independent attention heads helps capture more comprehensive temporal dependencies. The outputs from multiple heads are then concatenated and projected using the projection matrix W. O A linear transformation is performed to generate the final result. The formula is as follows:

[0083]

[0084] in, and is the linear projection parameter of each attention head, d h =h×d m, where h is the number of attention heads. Finally, the feedforward neural network receives the output from the multi-head attention module, i.e. MultiHead(Q, K, V), and performs further processing.

[0085] The diffusion graph convolution module specifically includes: Predefined graph structures often show biases in their prior knowledge, hindering their ability to capture complex spatial interactions within transportation systems. In contrast, methods of learning adaptive adjacency matrices through node embedding techniques have been widely used in various spatiotemporal prediction tasks. In order to further enhance the performance of node embeddings generated from spatiotemporal graphs in modeling spatial heterogeneity, this paper draws inspiration from the mechanism of memory networks and proposes a meta-graph learner. The core idea is to construct a meta-node library to store representative spatial features extracted from observed samples. These meta-nodes serve as pattern references, facilitating the matching and identification of potential spatial heterogeneity in the process of graph structure learning.

[0086] The metanode library is represented as Where M represents the number of meta-memory nodes, and d represents the feature dimension of each meta-node. E Perform matrix calculations between them to generate memory-enhanced node embeddings E adp , and then use it to build a meta-graph learner. Figure 3 As shown in Figure 2, the meta-graph learner can cluster traffic nodes with spatial heterogeneity. Its equation is expressed as follows:

[0087]

[0088] in represents the adaptive weight factor, represents the meta-memory-enhanced embedding. Here, a meta-graph is generated And feed it into the diffusion graph convolution module.

[0089] Given the directionality of traffic signal diffusion, a bidirectional random walk is used on the meta-graph to capture the spatial correlation of multiple hops. The formula of the diffusion graph convolution module is as follows:

[0090]

[0091] Among them, k represents the order of diffusion convolution. and Represent the forward and backward transfer matrices respectively. H represents the output of the multi-head temporal attention module MultiHead(Q, K, V). W k1 and W k2 is a learnable weight parameter.

[0092] The multi-scale temporal convolution module specifically includes: In order to extract local temporal patterns at different scales, the present invention designs a multi-scale temporal convolution module. Each standard convolution in the module is followed by a hyperbolic tangent function and a sigmoid function, the former as a filter and the latter as a gating mechanism to control the flow of information transmitted by the convolution. By fusing multi-scale temporal features, this helps to improve the model's perception of the complex temporal dependencies of the road network.

[0093] Let the output of the diffusion graph convolution module be Expressed as Application size: 1×S i The standard one-dimensional convolution kernel filters H on the time axis (l) The one-dimensional convolution kernel is defined as And the filtered signal is expressed as in The equation for the gated time unit is shown below:

[0094]

[0095] Among them, P and Q are the feature dimensions H (l) The first and second half of and σ(·) represent the tanh function and the sigmoid function respectively.

[0096] In practice, a multi-scale temporal convolution module is constructed by using a set of different convolution kernel sizes: 1×2, 1×3, 1×5, and 1×7. This design choice is based on the fact that these convolution kernel sizes can maximize the coverage of different time periods, making the module very suitable for capturing short-term signal patterns. It is defined as follows:

[0097] Z (l) =Concat(GConv 1×2 , GConv 1×3 , GConv 1×5 , GConv 1×7 ) (9)

[0098] Among them, Z (l) It is the output of the four convolution kernels concatenated in the time dimension.

[0099] To ensure the temporal invariance of the input features within the time frame, a fully connected layer is applied for secondary transformation. Finally, residual connections and ReLU activations are added to optimize the performance of the model.

[0100] The meta-memory enhancement layer specifically includes: a meta-memory node library is designed in the diffusion graph convolution module to parameterize the representative prototype features inherent in the learning sample. The meta-memory enhancement layer first applies a linear transformation to the output of the spatiotemporal layer to generate a query projection matrix. This query is then used in a dual retrieval attention mechanism to compare with the memory units stored in the meta-memory node library. Through these two stages of attention calculation, the layer selectively retrieves and integrates relevant memory features from the meta-memory nodes. Finally, the layer fuses the two sets of enhanced memory features along the channel dimension to generate the output. Its processing flow is as follows Figure 2 shown.

[0101] The input spatiotemporal state is represented as is the output of the previous spatiotemporal layer. Given a linear weight matrix and bias Use the following equation to convert Z (l) Projection to query matrix

[0102]

[0103] Subsequently, the memory similarity between the query projection and each meta-node is calculated to calculate the attention score of the retrieved information. These attention scores are then normalized using the SoftMax function to obtain the weighted memory features. The equation is shown below:

[0104]

[0105] in, represents the similarity between the i-th query and the j-th meta-node, i∈[1,N], j∈[0,M]. Represents the first memory-enhancing feature.

[0106] Based on the previous step, is used as a new query projection, similar to the formulas in formula (11) and formula (12). Then calculate The memory similarity weight between the meta-node library Φ and the meta-node library Φ is then used to obtain the secondary memory enhancement feature. In the last step, the secondary memory enhancement features and Perform weighted fusion and then use it as the output of this layer. Details are as follows:

[0107]

[0108] Finally, the outputs of the spatiotemporal layer and the meta-memory enhancement layer are concatenated and ReLU activated, and finally fully connected to obtain the prediction result Y:

[0109] Y=Linear(ReLu(Concat(Z (l) , H aug ))) (14)

[0110] Where Y is equal to Q represents the length of the prediction sequence.

[0111] Furthermore, the effectiveness of the method is verified. In order to verify the rationality and effectiveness of the model, the present invention conducts extensive experiments on four real traffic datasets, namely METR-LA, PEMS-BAY, PeMSD7(M) and PeMSD7(L). For evaluation, the default settings of all baselines are used for experiments. The performance of all methods is evaluated by three widely used evaluation indicators, namely MAE, RMSE and MAPE.

[0112] To further evaluate the effectiveness of each component in DSTMAN, we compare DSTMAN with four different variants of the DSTMAN framework, all of which are evaluated on two established benchmark datasets. The following are the specific details of these four DSTMAN variants:

[0113] w / o DGC: remove the diffuse graph convolutional layers associated with the spatiotemporal patches, thereby eliminating some of the spatial correlation modeling.

[0114] w / o DE: The data embedding layers (e.g., Ed, Ew, and Est) are replaced with a fully connected network, thus abandoning the encoding of spatiotemporal context.

[0115] w / o TC: Remove the multi-scale temporal convolutional layers from DSTMAN.

[0116] w / o MA: exclude the memory enhancement process and contrastive loss calculation during the training phase.

[0117] As shown in Table 1, the removal or modification of specific modules in the model architecture leads to a significant degradation in the performance of the entire system. The significant performance degradation caused by w / o DE on both datasets highlights the key role of specialized encoding of spatiotemporal features, which enables the model to grasp the underlying spatiotemporal context. The different impacts of w / o DGC on the performance on the two datasets reflect the inherent differences in the underlying data distributions. The METR-LA dataset exhibits more obvious data correlation. In addition, the memory-augmented module (w / o MA) is observed to improve the performance of the model beyond the capabilities provided by the existing spatiotemporal components. These design choices together emphasize the holistic and indivisible nature of DSTMAN, enabling it to achieve superior spatiotemporal prediction performance.

[0118] Table 1

[0119]

[0120] The present invention specifically comprises the following steps:

[0121] Step 1: Preprocess the original traffic flow data. The specific steps are as follows:

[0122] (1) Collect data collected by data collection devices in the traffic network; clean the original traffic data, remove duplicate records, erroneous data or abnormal data, etc., to ensure the accuracy and completeness of the data, and process the data into a data matrix of size T×N. Where T represents the number of time slices and N represents the number of data collection devices in the traffic network. Learn a function by taking the historical traffic data of N collection devices in a given traffic network at P time steps. It can predict the traffic conditions of all collection devices in the next Q time steps.

[0123] (2) The data matrix is ​​standardized and then divided into training set, validation set and test set. The ratio of data used is 70% for training, 20% for validation and 10% for testing to ensure the training, tuning and evaluation of the model.

[0124] Step 2: Load the training set and validation set data, initialize the model parameters according to the parameter file, and prepare to start training the model.

[0125] Step 3: The training set is input into the traffic flow prediction model in batches to start a round of training. The specific steps are as follows:

[0126] (1) After the data is sent to the data embedding layer and the input time series traffic data is obtained, the data is first encoded with time attributes such as time characteristics of the day (such as hours and minutes) and day of the week; then spatial features such as road network topology and regional functional attributes (such as commercial areas and residential areas) are extracted; finally, the time embedding and spatial embedding are fully connected and linearly transformed to form an expressive spatiotemporal feature vector.

[0127] (2) The output H of the data embedding layer is fed to the spatiotemporal layer (the spatiotemporal layer consists of a multi-head temporal attention module, a diffusion graph convolution module, and a multi-scale temporal convolution module).

[0128] (3) In the multi-head temporal attention module, the query vectors Q, K and V are obtained according to formula (3).

[0129] (4) Multiply the query matrix Q obtained in (3) by the transpose of the key matrix K, and then scale and normalize it to obtain the attention distribution at each time step to obtain the attention score, as shown in formula (4).

[0130] (5) In order to enable the model to jointly focus on information from different representation subspaces and diverse temporal patterns, using multi-head attention helps capture more comprehensive temporal dependencies. The outputs from multiple heads are then concatenated and projected using the projection matrix W. O A linear transformation is performed to generate the final result, as shown in formula (5), and the output result of the multi-head temporal attention module is MultiHead(Q, K, V).

[0131] (6) The output of the multi-head temporal attention module MultiHead(Q, K, V) is input into the diffusion graph convolution module to model the spatiotemporal feature relationship between adjacent nodes in space. Given the directionality of traffic signal diffusion, a bidirectional random walk is used on the graph to capture the spatial correlation of multiple hops. As shown in formula (7), the output result is

[0132] (7) The output result of the diffusion graph convolution module The input is sent to the multi-scale temporal convolution module. In this module, a set of 1×2, 1×3, 1×5 and 1×7 convolution kernels are applied to filter the output of (6) on the time axis, which can maximize the coverage of different time periods, making this module very suitable for capturing short-term signal patterns. Finally, the four convolution kernels are spliced ​​in the time dimension and the output is Z (l) , as shown in formula (9).

[0133] (8) In order to ensure the time invariance of the output features in (7) within the time frame, a fully connected layer is applied for secondary transformation. Then, residual connection and ReLU activation are added to optimize its performance.

[0134] (9) The optimized output result Z in (8) (l) Feed it to the meta-memory enhancement layer. First, a linear transformation is applied to it to generate the query projection matrix The specific operation is shown in formula (10).

[0135] (10) Calculate the query projection matrix based on the result in (9) The memory similarity between each meta-node is used to calculate the attention score of the retrieved information. These attention scores are then normalized using the SoftMax function to obtain weighted memory features, as shown in formulas (11) and (12).

[0136] (11) Based on (10), is used as a new query projection, similar to the formulas in formula (11) and formula (12). Then calculate The memory similarity weight between the meta-node library Φ and the meta-node library Φ is then used to obtain the secondary memory enhancement feature.

[0137] (12) Based on (11), the secondary memory enhancement feature and The weighted fusion is then used as the output of this layer, i.e. H aug The details are shown in formula (13).

[0138] (13) Finally, the outputs of the spatiotemporal layer and the meta-memory enhancement layer are concatenated and ReLU activated, and finally fully connected to obtain the prediction result Y. The specific operation is shown in formula (14). Where Y is equal to Q represents the length of the prediction sequence.

[0139] (13) The loss is calculated by comparing the predicted result Y with the true value, L1 loss is used as the loss function and three widely used evaluation indicators are used for evaluation, namely MAE, RMSE and MAPE.

[0140] Step 4: The prediction model uses the back propagation algorithm to update the model parameters.

[0141] Step 5: Validate the model parameters saved in the training set on the validation set, calculate the validation loss and save the model parameters. In subsequent rounds, the model parameters are saved only when the validation loss is lower than the minimum validation loss. No backpropagation is performed during the validation process.

[0142] Step 6: Repeat steps 3 to 5 until the current number of training rounds is greater than the set maximum number of training rounds or the early stopping strategy is executed, that is, the training is terminated when 20 consecutive training rounds do not reduce the validation set loss.

[0143] Step 7: Predict traffic flow for the test set data. The specific steps are as follows:

[0144] (1) Load the model parameter file with the smallest validation loss value saved during the training process to initialize the model and predict

[0145] The model is changed from training mode to prediction mode and testing mode without backpropagation.

[0146] (2) Load the test set data and input it into the model, and make predictions based on the test set data.

[0147] (3) The true value and the predicted value are evaluated by three widely used evaluation indicators, namely, mean absolute error (MAE), root mean square error (RMSE), and mean absolute percentage error (MAPE).

[0148] (4) Save the model parameter file.

[0149] The present invention discloses a traffic prediction method based on DSTMAN, which can more accurately predict traffic flow, especially in places where the real flow fluctuates greatly, and performs more stably, has higher authenticity to real-world conditions, and exhibits smaller errors.

[0150] The above are only preferred specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A traffic prediction method based on DSTMAN, characterized in that: include: Acquiring traffic network parameters and traffic condition data, preprocessing the traffic network parameters and traffic condition data, and obtaining preprocessed traffic network data; Constructing a traffic flow prediction model, inputting the preprocessed traffic network data into the traffic flow prediction model for optimization, and obtaining an optimized traffic flow prediction model, wherein the traffic flow prediction model is constructed using a dynamic spatiotemporal memory enhancement network DSTMAN; The traffic network parameters of the target traffic area to be predicted are obtained, and the optimized traffic flow prediction model is input to obtain the traffic flow prediction result of the future target traffic area.

2. The traffic prediction method based on DSTMAN as claimed in claim 1, characterized in that: The traffic flow prediction model consists of a data embedding layer, a spatiotemporal layer, and a meta-memory enhancement layer; wherein, The data embedding layer is used to perform encoding and splicing processing according to the pre-processed traffic network data to obtain a spatiotemporal feature vector; The spatiotemporal layer is used to perform multi-head temporal attention, diffusion graph convolution and multi-scale temporal convolution processing according to the spatiotemporal feature vector to obtain the spatiotemporal state; The meta-memory enhancement layer is used to perform meta-memory enhancement processing on the spatiotemporal state to obtain a prediction result.

3. The traffic prediction method based on DSTMAN as claimed in claim 2, characterized in that: The spatiotemporal layer consists of a multi-head temporal attention module, a diffusion graph convolution module, and a multi-scale temporal convolution module; The multi-head temporal attention module is used to perform scaling and normalization processing according to the spatiotemporal feature vector, and then perform splicing to obtain the output result of the multi-head temporal attention module; The diffusion map convolution module is used to perform diffusion map processing according to the output result of the multi-head temporal attention module to obtain the output result of the diffusion map convolution module; The multi-scale time convolution module is used to filter and splice according to the output result of the diffusion map convolution module to obtain the spatiotemporal state.

4. The traffic prediction method based on DSTMAN as claimed in claim 3, characterized in that: The method of inputting the preprocessed traffic network data into the data embedding layer in the traffic flow prediction model to obtain the spatiotemporal feature vector includes: The preprocessed traffic network data is input into the data embedding layer. After obtaining the input time series traffic data, the time attributes of the time series traffic data in a day are encoded, the road network topology structure and the spatial characteristics of regional functional attributes are extracted, and the time attributes and the spatial characteristics are embedded in the fully connected layer for linear transformation and splicing to obtain a spatiotemporal feature vector.

5. The traffic prediction method based on DSTMAN as claimed in claim 4, characterized in that: The method of inputting the spatiotemporal feature vector into the multi-head temporal attention module in the spatiotemporal layer to obtain the output result of the multi-head temporal attention module includes: The spatiotemporal feature vector is input into the multi-head temporal attention module, using the H of the i-th block (i) Generate query matrix, key matrix and value matrix; Multiply the query matrix and the transpose of the key matrix, scale and normalize, and obtain the attention distribution at each time step to obtain an attention score; Based on the attention scores, splicing is performed and linear exchange is performed using the projection matrix to obtain the output result of the multi-head temporal attention module.

6. The traffic prediction method based on DSTMAN as claimed in claim 5, characterized in that: The method of inputting the output result of the multi-head temporal attention module into the diffusion graph convolution module to obtain the output result of the diffusion graph convolution module includes: Construct a meta-graph learner, and the meta-node library is represented as Where M represents the number of meta-memory nodes, and d represents the feature dimension of each meta-node; By combining the meta-node library Φ with the adaptive weight factor W E Perform matrix calculations between them to generate memory-enhanced node embeddings E adp , building a meta-graph learner using memory-augmented node embeddings; The meta-graph learner is used to cluster the traffic nodes with spatial heterogeneity by: in represents the adaptive weight factor, Represents meta-memory-enhanced embedding; a meta-graph is generated Feeding the meta-graph back into the diffusion graph convolution module; Bidirectional random walks are used on the meta-graph to capture the spatial correlation of multiple hops. The output formula of the diffusion graph convolution module is as follows: Among them, k represents the order of diffusion convolution, and Represent the forward and backward transfer matrices respectively, H represents the output of the multi-head temporal attention module MultiHead(Q, K, V), W k1 and W k2 is a learnable weight parameter.

7. The traffic prediction method based on DSTMAN as claimed in claim 6, characterized in that: The method of inputting the output result of the diffusion map convolution module into the multi-scale time convolution module to obtain the output result of the multi-scale time convolution module includes: The output of the diffusion graph convolution module is filtered on the time axis by a standard one-dimensional convolution kernel. (l) , the one-dimensional convolution kernel is defined as The filtered signal is expressed as in The equation for the gated time unit is shown below: Among them, P and Q are the feature dimensions H (l) The first and second half of and σ(·) represent the tanh function and the sigmoid function, respectively; The output result of the multi-scale time convolution module is obtained by splicing the convolution kernels in the multi-scale time convolution module in the time dimension, which is calculated as follows: Z (l) =Concat(GConv 1×2 ,GConv 1×3 ,GConv 1×5 ,GConv 1×7 )。 8. The traffic prediction method based on DSTMAN as claimed in claim 7, characterized in that: The method of inputting the output result of the multi-scale temporal convolution module into the meta-memory enhancement layer to obtain the prediction result includes: The input spatiotemporal state is represented as Given a linear weight matrix and bias Z (l) Projection to query matrix Calculate the memory similarity between the query projection and each meta-node, calculate the attention score of the retrieved information, and normalize the attention score using the SoftMax function to obtain the weighted memory feature, which is calculated as follows: in, represents the similarity between the i-th query and the j-th meta-node, i∈[1,N], j∈[0,M], and the result represents the first memory-enhancing feature; Will Used as a new query projection, calculate The memory similarity weight between the meta-node library Φ and the meta-node library Φ is used to obtain the secondary memory enhancement feature Enhanced features for secondary memory and Perform weighted fusion and calculate as follows: The outputs of the spatiotemporal layer and the meta-memory enhancement layer are concatenated and activated with ReLU, and fully connected to obtain the prediction result Y: Where Y is equal to Q represents the length of the prediction sequence.

9. The traffic prediction method based on DSTMAN as claimed in claim 8, characterized in that: The method of inputting the preprocessed traffic network data into the traffic flow prediction model for optimization, and obtaining the optimized traffic flow prediction model comprises: Dividing the preprocessed traffic network data into a training set, a validation set and a test set; Inputting the training set into the traffic flow prediction model to train the traffic flow prediction model to obtain a trained traffic flow prediction model; Inputting the verification set into the trained traffic flow prediction model to obtain a verification result; Based on the comparison between the verification result and the real result, the traffic flow prediction model is adjusted in real time to obtain an adjusted traffic flow prediction model; The test set is input into the adjusted traffic flow prediction model to obtain a test result, and the test result is compared with the true result to obtain an optimized traffic flow prediction model.

Citation Information

Patent Citations

  • Traffic flow prediction method based on machine vision fused with road network spatio-temporal information

    CN114743375A

  • Traffic flow prediction method based on multi-scale spatial feature mining

    CN116070778A

  • Traffic volume prediction method and device based on lightweight space-time diagram convolution model

    CN116206448A

  • Transform-based diffusion diagram attention network traffic flow prediction method

    CN116504060A

  • Adaptive learning traffic flow prediction method under dynamic traffic condition

    CN116721538A

Cited By

  • Traffic flow prediction method based on deep learning

    CN121281279A