Data Completion Method, System, Electronic Device and Medium Based on Spatiotemporal Attention
By constructing a data completion method based on spatiotemporal attention, and using multi-head self-attention network and graph attention feedforward network to extract spatiotemporal characteristics of traffic data, the existing methods have solved the poor performance problem of the existing methods at high missing rates, and efficient data completion has been achieved, improving the integrity of traffic data and the stability of intelligent traffic systems.
Patent Information
- Application Number
- CN202411858075.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2044-12-17
AI Technical Summary
The existing traffic data completion method cannot effectively extract spatiotemporal correlations when processing missing values, especially in the case of high missing rates, which is difficult to meet the data security needs of intelligent transportation systems.
The data completion method based on space-time attention is adopted, and the latent spatial features and real spatial features are extracted through multi-head self-attention networks and graph attention feedforward networks, and the time correlation is extracted in combination with the time attention module, an iterative completion framework is constructed to optimize the completion results.
It realizes efficient data completion in various data-loss scenarios, improves the integrity and accuracy of traffic data, and supports the stable operation of intelligent transportation systems.
Smart Images

Figure CN119807631B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data security technology, and in particular to a data completion method, system, electronic device and medium based on spatiotemporal attention. Background Art
[0002] Intelligent Transportation Systems (ITS) leverage advanced information and communication technologies, sensors, and smart devices to build a comprehensive network for transportation systems, enabling data collection, analysis, and intelligent control within the traffic environment. They are a key foundation for transforming modern urban transportation, logistics, and other sectors towards efficient and intelligent transportation models. The application of connected vehicles, cloud computing offload, deep big data mining, and high-precision sensing technologies has significantly advanced the development of ITS, resulting in increasingly superior performance and increasing system complexity. Relying on a variety of traffic sensors and the massive transmission of traffic network data, ITS enables vehicle-to-vehicle connectivity, pedestrian interaction, road condition communication, environmental detection, and intelligent analysis. Based on comprehensive and in-depth perception of traffic operation information, massive data flow, real-time and rapid computation, and precise modeling and analysis, ITS enables intelligent traffic control, travel strategy optimization, and innovative management systems. However, in real-world scenarios, data collected from transportation networks is often incomplete due to factors such as extreme weather, equipment failure, and communication outages, severely limiting the development of smart transportation. Therefore, analyzing the spatiotemporal characteristics of traffic data and thus completing the missing traffic data is of great significance for maintaining the data security of intelligent transportation systems.
[0003] In recent years, a large amount of research has been conducted both domestically and internationally on traffic data completion. Existing traffic data completion methods can be roughly divided into five categories: 1) prediction-based methods; 2) interpolation-based methods; 3) statistical learning-based methods; 4) matrix / tensor completion methods; and 5) deep learning methods.
[0004] Among them, deep learning methods are currently a focus of research. These methods leverage various neural networks to extract spatial and temporal correlations in traffic data to complete missing values. Through specialized design, deep learning methods can address the shortcomings of the four aforementioned methods and can handle diverse missing patterns and rates while maintaining good performance. Among these, methods based on denoising autoencoders, such as denoising stacked autoencoders (DSAEs) and variational autoencoders (VAEs), reconstruct the data for infilling by removing noise. Some methods utilize recurrent neural networks (RNNs) to extract temporal correlations in sequential data for data infill, achieving excellent performance. Given the popularity of generative adversarial networks (GANs) in data generation, various data infill methods have employed them to generate missing data, such as the Generative Adversarial Infill Network (GAIN) and GA-GAN. These methods learn the distribution patterns of real data through an adversarial game between a generator and a discriminator. Furthermore, breakthroughs in graph convolutional networks (GCNs) have brought new insights into traffic data inpainting. Because graph convolutional networks (GCNNs) can effectively handle non-Euclidean spatial correlations and extract spatiotemporal features, some studies have incorporated GCNs into their models, such as the Graph Attention Convolutional Network (GACN), the Dynamic Graph Convolutional Recursive Infill Network (DGCRIN), and the Hierarchical Spatiotemporal Graph Convolutional Network (HSTGCN). However, these methods are unable to extract comprehensive spatiotemporal correlations from traffic data with missing values, resulting in unsatisfactory performance. Furthermore, these shortcomings are further amplified when the data missing rate is high. Summary of the Invention
[0005] The present invention provides a data completion method, system, electronic device and medium based on spatiotemporal attention, which are used to solve the problem of poor performance of data completion methods.
[0006] According to one aspect of the present invention, a data completion method based on spatiotemporal attention is provided, comprising:
[0007] The incomplete traffic data input is divided according to the time dimension, and the divided data includes traffic data of multiple time segments;
[0008] Filling missing values in the traffic data based on data collected by the current sensor;
[0009] The first time segment data of the filled traffic data is used as input for training the data completion model;
[0010] S1: Extracting latent spatial features of input data based on the constructed multi-head self-attention network. The latent spatial features are used to characterize the correlation between traffic data collected by sensors in each time segment.
[0011] S2: Convert the sensor topology in the real space into an adjacency matrix, and extract the real space features of the adjacency matrix based on the constructed graph attention feedforward network. The real space features are used to characterize the correlation between sensors in the real space.
[0012] S3: performing feature concatenation on the latent spatial feature and the real spatial feature to obtain a complete spatial feature of the first time segment;
[0013] S4: extracting the temporal correlation of the input data based on the constructed temporal attention module; the input of the temporal attention module is the complete spatial features of the first time segment and the traffic data in the second time segment, and the output is the complete spatiotemporal features of the first time segment;
[0014] S5: Inputting the complete spatiotemporal features of the first time segment into the multi-head self-attention network to extract latent spatial features to obtain a data completion result;
[0015] S6: Re-execute steps S1-S5 to obtain the optimized data completion result;
[0016] Repeat steps S1-S6 until the preset iteration stop condition is met, and then output the final data completion result.
[0017] According to another aspect of the present invention, a data completion device based on spatiotemporal attention is provided, comprising:
[0018] A data partitioning unit is used to partition the input incomplete traffic data according to the time dimension, and the partitioned data includes traffic data of multiple time segments;
[0019] A data filling unit, configured to fill missing values in the traffic data based on data currently collected by the sensor;
[0020] An input unit, configured to take the first time segment data of the filled traffic data as input for training a data completion model;
[0021] A latent space feature extraction unit is used to extract latent space features of input data based on the constructed multi-head self-attention network, wherein the latent space features are used to characterize the correlation between traffic data collected by sensors in each time segment;
[0022] A real space feature extraction unit is used to convert the sensor topology in the real space into an adjacency matrix, and extract real space features of the adjacency matrix based on the constructed graph attention feedforward network, wherein the real space features are used to characterize the correlation between sensors in the real space;
[0023] a splicing unit, configured to perform feature splicing on the latent spatial feature and the real spatial feature to obtain a complete spatial feature of the first time segment;
[0024] a temporal feature extraction unit, configured to extract temporal correlation of input data based on a constructed temporal attention module; the temporal attention module inputs the complete spatial features of the first time segment and the traffic data in the second time segment, and outputs the complete spatiotemporal features of the first time segment;
[0025] a preliminary data completion unit, configured to input the complete spatiotemporal features of the first time segment into the multi-head self-attention network to extract latent spatial features, and obtain a data completion result;
[0026] An optimized data completion unit is used to re-execute the steps in the latent space feature extraction unit, the real space feature extraction unit, the splicing unit, the temporal feature extraction unit, and the preliminary data completion unit to obtain an optimized data completion result;
[0027] The iterative calculation unit is used to repeatedly execute the steps in the spatial feature extraction unit, the real spatial feature extraction unit, the splicing unit, the temporal feature extraction unit, the preliminary data completion unit and the optimized data completion unit until the preset iteration stop condition is met, and output the final data completion result.
[0028] According to another aspect of the present invention, an electronic device is provided, comprising:
[0029] at least one processor; and
[0030] a memory communicatively connected to the at least one processor; wherein,
[0031] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the data completion method based on spatiotemporal attention described in any embodiment of the present invention.
[0032] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data completion method based on spatiotemporal attention described in any embodiment of the present invention when executed.
[0033] The technical solution of the embodiment of the present invention uses self-attention to construct a multi-head self-attention network to extract latent spatial features from traffic data, and uses a graph attention layer and a feedforward neural network to construct a graph attention feedforward network to extract real spatial features from traffic data. By fusing the two features, comprehensive extraction of spatial features is achieved. The temporal attention module is used to extract temporal correlations, and comprehensive extraction of spatiotemporal features is achieved by sequentially extracting spatial and temporal features. The present invention constructs a traffic data completion framework based on spatiotemporal attention, adopts a completion optimization serial mode distribution to perform completion operations, and uses an iterative strategy to optimize the completion results. It can be applied to data completion tasks in a variety of data missing scenarios.
[0034] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0036] Figure 1 is a flow chart of a data completion method based on spatiotemporal attention provided according to embodiment 1 of the present invention;
[0037] Figure 2 Schematic diagram of a data completion model for a data completion method based on spatiotemporal attention in an embodiment of the present invention;
[0038] Figure 3 Schematic diagram of traffic data collected in a random data loss mode and a simulated random power outage mode according to an embodiment of the present invention;
[0039] FIG4( a ) is a schematic diagram of the MAE of the PEMSBAY dataset in a random data missing mode according to an embodiment of the present invention;
[0040] FIG4( b ) is a schematic diagram of the RMSE of the PEMSBAY dataset in a random missing data mode according to an embodiment of the present invention;
[0041] FIG4( c ) is a schematic diagram of the MAE of the PEMSBAY dataset in a simulated random power-off mode according to an embodiment of the present invention;
[0042] FIG4( d ) is a schematic diagram of the RMSE of the PEMSBAY dataset in a simulated random power outage mode according to an embodiment of the present invention;
[0043] FIG5( a ) is a schematic diagram of indicators of the PEMSBAY dataset in a random data missing mode according to an embodiment of the present invention;
[0044] FIG5( b ) is a schematic diagram of indicators of the PEMSBAY dataset in a simulated random power outage mode according to an embodiment of the present invention;
[0045] FIG5( c ) is a schematic diagram of the indicators of the Seattle dataset in the random missing data mode according to an embodiment of the present invention;
[0046] FIG5( d ) is a schematic diagram of indicators of the Seattle dataset in a simulated random power outage mode according to an embodiment of the present invention;
[0047] Figure 6 Schematic diagram showing how the completion effect is affected by loss function parameters in an embodiment of the present invention;
[0048] Figure 7 1 is a schematic diagram of the results of an ablation experiment performed in an embodiment of the present invention;
[0049] Figure 8 This is a flow chart of a data completion device based on spatiotemporal attention provided in an embodiment of the present invention;
[0050] Figure 9 3 is a structural diagram of an electronic device for implementing the data completion method based on spatiotemporal attention according to an embodiment of the present invention. DETAILED DESCRIPTION
[0051] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0052] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0053] In recent years, a large amount of research has been conducted both domestically and internationally on traffic data completion. Existing traffic data completion methods can be roughly divided into five categories: 1) prediction-based methods; 2) interpolation-based methods; 3) statistical learning-based methods; 4) matrix / tensor completion methods; and 5) deep learning methods.
[0054] Prediction-based methods use historical data to construct prediction models to predict missing data. Methods such as linear regression (LR), support vector regression (SVR), autoregressive integrated moving average (ARIMA) models, and Bayesian networks (BNs) all fall into this category. However, these methods are highly dependent on data quality. If the data contains a large amount of noise, the constructed prediction model will be seriously affected. In addition, these methods lack the ability to fully express complex correlations. For example, while Bayesian networks can represent causal relationships between variables to a certain extent, they are still insufficient in expressing the complex and dynamic spatiotemporal correlations in traffic scenarios.
[0055] Interpolation-based methods are historical averaging algorithms. This means that when dealing with missing data, they refer to some average situations in the historical data to make estimates. For example, the K-nearest neighbor algorithm (K-NN) and local least squares (LLS) use temporal proximity or pattern proximity to estimate missing data. The key difficulty of these methods is to use an appropriate distance metric to identify neighbors. For example, when judging the similarity between two data points, whether to use Euclidean distance (the straight-line distance between the two points), Manhattan distance (the sum of the horizontal and vertical distances between the two points on the coordinate axis), or other distance metrics, choosing different distance metrics will result in different neighbors being found, which will have a significant impact on the final result of estimating missing data. In addition, such methods can only consider the proximity of a single level, which will inevitably ignore a large amount of information.
[0056] Statistical learning-based methods include Markov Monte Carlo (MCMC), probabilistic principal component analysis (PPCA), and Bayesian principal component analysis (BPCA). These methods first assume that the data follows a certain probability distribution, such as the normal distribution or Poisson distribution, which is the basic premise for subsequent analysis and processing. They then iteratively estimate the missing data using the existing observed data. However, due to the high instability of traffic data, statistical learning-based methods struggle to assume an accurate probability distribution for traffic data, especially when the data missing rate is high. This is because the relatively small amount of observational data available for analysis and inference makes it difficult to reasonably determine the probability distribution form that the entire data set (including the missing data) should conform to based on this limited observational data. As a result, the accuracy of these statistical learning-based methods in estimating missing data is severely affected.
[0057] The core of matrix / tensor completion methods lies in leveraging various matrix and tensor computational techniques to exploit multidimensional spatiotemporal correlations in data, thereby enabling inference of missing guidance. For example, Bayesian Time Matrix Factorization (BTMF) employs a Gaussian Autoregressive (VAR) process to model the temporal factor matrix. This modeling approach can better handle time-related data features, allowing it to exploit patterns in the temporal dimension to infer missing values when completing the matrix. Bayesian Gaussian CP Factorization (BGCP) further extends the Bayesian probabilistic matrix factorization model to higher-order tensors, specifically for data completion tasks. Higher-order tensors can handle more complex data structures, making it possible to attempt to complete missing data in more complex data scenarios. However, extensive experiments have demonstrated that different missing patterns significantly affect the performance of matrix / tensor completion methods. For example, poor results are observed in the Missing Completely at Random (MCAR) pattern, likely because these methods struggle to capture the characteristics of adjacent structures in the data.
[0058] Based on this, the present invention provides a data completion method based on spatiotemporal attention. By using self-attention to construct a multi-head self-attention network, the latent spatial features in traffic data are extracted. A graph attention feedforward network is constructed using a graph attention layer and a feedforward neural network to extract the real spatial features in traffic data. By fusing the two features, comprehensive extraction of spatial features is achieved. A temporal attention module is used to extract temporal correlations. By extracting spatial features and temporal features in sequence, comprehensive extraction of spatiotemporal features is achieved. The present invention constructs a traffic data completion framework based on spatiotemporal attention, adopts a completion optimization serial mode distribution to perform completion operations, and uses an iterative strategy to optimize the completion results. It can be applied to data completion tasks in a variety of data missing scenarios.
[0059] Example 1
[0060] Figure 1 A flow chart of a data completion method based on spatiotemporal attention is provided for the first embodiment of the present invention. Figure 1 As shown, the method includes:
[0061] S101 : Divide the input incomplete traffic data according to the time dimension, and the divided data includes traffic data of multiple time segments.
[0062] It should be noted that missing data in the collected traffic data is completely random and unrelated to the data values themselves or the values of other variables. This means that missing data may occur at different locations in the data collected during different time periods. Furthermore, each sensor is randomly powered off for a certain period, preventing it from collecting data. The selection of sensors is also completely random. Therefore, data collected during different time periods may be collected by different sensors.
[0063] Specifically, the time segment length F is used as the window length, and the initial traffic data X ori Divide into T groups and get the divided data in T=D / F, where D represents the total duration of traffic data, N represents the amount of data at each time point, and T represents the number of time segments contained in D.
[0064] Then the data in time segment t
[0065] S102: Fill in missing values in the traffic data based on data currently collected by the sensor.
[0066] Since traffic data may be randomly missing and contain certain missing values, a preset filling method may be used in this embodiment to fill in the missing values. For example, real-time data collected by sensors may be used to fill in the missing values in the initial traffic data.
[0067] S103: Using the first time segment data of the filled traffic data as input for training a data completion model.
[0068] The first time segment data may be traffic data of any time segment t, and the traffic data is traffic data after missing values of the initial traffic data are filled, and is used as input of the data completion model to iteratively train the data completion model.
[0069] S104. Extracting latent spatial features of the input data based on the constructed multi-head self-attention network, wherein the latent spatial features are used to characterize the correlation between the traffic data collected by the sensors in each time segment.
[0070] In this embodiment, a multi-head self-attention network is constructed to extract the latent spatial features of the input data. The attention head of the multi-head self-attention network may include multiple linear layers, and the attention mechanism is used to enable the model to focus on the key parts of the input data.
[0071] It should be noted that the attention mechanism calculates the relevance score based on the query vector and the key vector, and then converts the score into weights through the softmax function. Finally, these weights are used to perform weighted summation on the value vector to obtain the attention output, so that the model can focus on the key parts of the input data.
[0072] S105. Convert the sensor topology in the real space into an adjacency matrix, and extract real space features of the adjacency matrix based on the constructed graph attention feedforward network, where the real space features are used to characterize the correlation between sensors in the real space.
[0073] Because traffic data is collected by sensors at different spatial locations, the sensors used in the collected data have a certain degree of spatial correlation. This embodiment uses an adjacency matrix converted from the sensor topology in real space and extracts the real-space features of the adjacency matrix based on a constructed graph attention feedforward network. The graph attention feedforward network combines a graph attention network with a feedforward network to extract the real-space features of the sensor space topology.
[0074] S106: Concatenate the latent spatial features with the real spatial features to obtain a complete spatial feature of the first time segment.
[0075] The complete spatial features of the first time segment can be obtained by concatenating the latent spatial features with the real spatial features. The complete spatial features of the first time segment can represent the complete spatial features obtained during the initial completion of the traffic data for the first time segment, or can represent the complete spatial features of the first time segment obtained by extracting the latent spatial features and the real spatial features from the initial completion results during the optimization data completion process and concatenating the latent spatial features with the real spatial features.
[0076] S107. Extract the temporal correlation of the input data based on the constructed temporal attention module; the input of the temporal attention module is the complete spatial features of the first time segment and the traffic data in the second time segment, and the output is the complete spatiotemporal features of the first time segment.
[0077] It should be noted that the temporal attention module uses the attention mechanism to focus on the temporal feature part of the input data. The input of the temporal attention module is the complete spatial feature of the first time segment and the traffic data in the second time segment.
[0078] The first time segment represents any time segment, and the second time segment represents a time segment different from the first time segment. In a preferred embodiment, the second time segment can be a time segment adjacent to the first time segment, so as to better extract the complete spatial characteristics of the first time segment and the temporal correlation between the traffic data in the second time segment. For example, if a one-hour time interval is divided into a time segment, then assuming that the first time segment is from 1:00 to 2:00, then the second time segment can be from 0:00 to 1:00, or from 2:00 to 3:00.
[0079] In addition, this embodiment inputs the traffic data of the first time segment into the spatial attention module and the temporal attention module in sequence, extracts the spatial features and the temporal features in sequence, and outputs the complete spatiotemporal features of the first time segment.
[0080] S108: Input the complete spatiotemporal features of the first time segment into the multi-head self-attention network to extract latent spatial features and obtain a data completion result.
[0081] After the complete spatiotemporal features of the first time segment are extracted in this embodiment, the complete spatiotemporal features of the first time segment can be input into the multi-head self-attention network to extract latent spatial features, and a preliminary data completion result of the traffic data of the first time segment can be obtained.
[0082] S109: Re-execute steps S104-S108 to obtain an optimized data completion result.
[0083] The preliminary data completion result is then input into the multi-head self-attention network, and the multi-head self-attention network is used to extract the latent space features of the preliminary data completion result. The sensor topology structure in the real space is converted into an adjacency matrix, and the real space features of the adjacency matrix are extracted based on the constructed graph attention feedforward network. The latent space features are feature-concatenated with the real space features to obtain the complete spatial features of the first time segment. The temporal correlation of the input data is extracted based on the constructed temporal attention module. The input of the temporal attention module is the complete spatial features of the first time segment and the traffic data in the second time segment, and the output is the complete spatiotemporal features of the first time segment. The complete spatiotemporal features of the first time segment are then input into the multi-head self-attention network to extract the latent space features, and the optimized data completion result is obtained.
[0084] The preset loss function can be used to calculate the loss in the initial data completion process and the loss in the optimization process, and to adjust the parameters of the data completion model.
[0085] S110 , repeating steps S104 - S109 until a preset iteration stop condition is met, and outputting the final data completion result.
[0086] Re-input traffic data of another first time segment, train the data completion model, repeat the iteration multiple times until the parameters of the data completion model converge or the number of iterations reaches a preset iteration threshold, stop the iteration, and output the trained data completion model.
[0087] The technical solution of the embodiment of the present invention uses self-attention to construct a multi-head self-attention network to extract latent spatial features from traffic data, and uses a graph attention layer and a feedforward neural network to construct a graph attention feedforward network to extract real spatial features from traffic data. By fusing the two features, comprehensive extraction of spatial features is achieved; a temporal attention module is used to extract temporal correlations, and by sequentially extracting spatial and temporal features of traffic data and fusing the two features, comprehensive extraction of spatiotemporal features is achieved. The present invention constructs a traffic data completion framework based on spatiotemporal attention, adopts a completion optimization serial mode distribution to perform completion operations, and uses an iterative strategy to optimize the completion results. It can be applied to data completion tasks in a variety of data missing scenarios.
[0088] Example 2
[0089] Figure 2 This is a diagram of another embodiment of a data completion method based on spatiotemporal attention provided in the second embodiment of the present invention. Figure 2 include:
[0090] S201 : Divide the input incomplete traffic data according to the time dimension, and the divided data includes traffic data of multiple time segments.
[0091] Take the time segment length F as the window length and convert the initial traffic data X ori Divide into T groups and get the divided data in T=D / F, D represents the total duration of traffic data, N represents the amount of data at each time point, and T represents the number of time segments included in D. Then the data in time segment t is
[0092] S202: Fill in missing values of the traffic data based on an average value of data currently collected by the sensor.
[0093] In this embodiment, the data collected by the sensors at the current moment can be weighted and summed, and the weighted summed value can be used to fill the missing positions in the traffic data. In a preferred solution, the average value of the data collected by the sensors at the current moment can be used to fill the missing values in the traffic data.
[0094] S203: Using the first time segment data of the filled traffic data as input for training a data completion model.
[0095] S204, extracting latent spatial features of input data based on the constructed multi-head self-attention network.
[0096] Specifically, step S204 includes:
[0097] S2041. Calculate the attention score of each attention head based on the input data, and generate a reconstruction network based on the attention score of each attention head, where the reconstruction network is used to characterize the correlation between sensors.
[0098] The road network composed of all sensor nodes can be obtained as a complete graph, and the correlation between every two sensors in each time segment can be calculated to generate a reconstructed road network.
[0099] Specifically, in this embodiment, according to Use three linear layers to calculate the query of the i-th attention head in the time segment t. Key Value
[0100]
[0101] The query object and value objects Multiply to get the attention score of the i-th attention head in time segment t Among them, FC is the fully connected layer.
[0102]
[0103] T represents the number of time segments contained in D; F is the window length of the time segment.
[0104] Based on the above formula, the attention scores of all attention heads can be calculated, that is, the reconstructed network is generated.
[0105] It should be noted that in the attention mechanism, Query represents the query object, Value represents the object being checked, and Key represents the key vector used to measure the degree of association between the Query and other vectors. The attention mechanism determines how much attention to allocate when performing weighted aggregation on the Value by calculating the similarity between the Query and the Key. Specifically, by calculating the dot product of the Query and the Key, and then performing a normalization operation (such as the softmax function), weights representing the importance of different Keys are obtained. These weights are then weighted and summed with the corresponding Value to obtain the final representation.
[0106] S2042: Perform a mask operation on the reconstructed network.
[0107] In order to make the current node obtain information from other nodes as much as possible, the diagonal elements in are masked.
[0108] Mask operations include:
[0109] First build the mask matrix:
[0110] M diag =1-I diag
[0111] Among them is I diag Identity matrix, size, and attention score of the i-th attention head consistent.
[0112] Use the mask matrix M diag right Perform mask operations.
[0113]
[0114] Among them, ← represents a mask operation.
[0115] Reconstructing the road network Contains h Where h is the number of attention heads.
[0116] S2043. Perform a normalization operation on the reconstructed network after the mask operation to obtain the features of each attention head.
[0117] According to the attention score of the i-th attention head Get the embedding of the i-th attention head
[0118]
[0119] Among them, softmax() represents regularization calculation, and embedding refers to the mapping from discrete variables to continuous numerical space.
[0120] S2044. Merge the features of each attention head to generate a first merged feature.
[0121] Merge the multi-head attention embeddings to get the first merged feature
[0122]
[0123] In the formula, || represents the concatenation operation; FC is the fully connected layer; Represents traffic data within time segment t.
[0124] S2045. Pass the first merged features through a feedforward neural network with residual connections to obtain the latent space features of the input data.
[0125] It's important to note that residual connections are a key technique in deep learning. In a neural network, they directly add the input of a layer to the transformed output of that layer. This effectively addresses the vanishing and exploding gradient problems of deep neural network training, making it easier to train deep models. They also enable the network to learn residual information in the input signal, enabling rapid model convergence.
[0126] Merge the first feature Latent space embedding via a feed-forward neural network with residual connections
[0127]
[0128] FF MSAN represents a feedforward neural network.
[0129] S205. Convert the sensor topology in the real space into an adjacency matrix, and extract real space features of the adjacency matrix based on the constructed graph attention feedforward network, where the real space features are used to characterize the correlation between sensors in the real space.
[0130] S2051. Use the constructed graph attention layer to extract features between sensor nodes.
[0131] It should be noted that the Graph Attention Network is a deep learning model for graph data that can learn the relationships and representations between nodes. The network introduces an attention mechanism that assigns different weights to the relationships between nodes, allowing the model to automatically focus on nodes that are meaningful to the current task.
[0132] S2052. Input the features between the sensor nodes into a feedforward neural network with residual connections to obtain real space features.
[0133] The sensor topology in the real space is converted into the adjacency matrix Adj.
[0134] The graph attention mechanism is used to extract the real space correlation from the adjacency matrix Adj to obtain the real space embedding
[0135] Specifically, according to the adjacency matrix Adj, the attention coefficient between adjacent sensor nodes i and j is calculated:
[0136] e ij =LeakyReLU(a T [Wx t,i ||Wx t,j ])
[0137] where x t,i and x t,j is the embedding of nodes i and j in time segment t, W is the embedding conversion weight matrix, a is the weight parameter; ReLU is the activation function.
[0138] To make the attention coefficient easier to calculate and compare, the softmax function is used for regularization:
[0139] a ij =softmax(e ij )
[0140] The new embedding of node i is calculated as follows:
[0141]
[0142] where σ is a nonlinear activation function.
[0143] After all nodes are embedded and updated, the graph attention layer ends. The ReLU activation function is used between the two layers of graph attention. The final embedding obtained by the graph attention layer is X t '.
[0144] Embed the output of the graph attention layer into X t 'Input into the feedforward neural network with residual connection to obtain the real space features
[0145]
[0146] Where FF GAT represents a feedforward neural network.
[0147] S206: Input the latent spatial features and the real spatial features into the constructed multi-layer perceptron for feature fusion to obtain the complete spatial features of the first time segment.
[0148] The latent space features and real space characteristics Perform feature splicing and use multi-layer perceptron to fuse features to obtain complete spatial embedding
[0149] Get the latent space embedding and real-space embedding Finally, the two features are concatenated and fused using a multi-layer perceptron to obtain the complete spatial embedding of the time segment t
[0150]
[0151] MLP SAB Computation of a multilayer perceptron representing the spatial self-attention module.
[0152] S207. Extract the time correlation of the input data in the node dimension based on the constructed multi-head cross-attention network, the input of the multi-head cross-attention network is the complete spatial features of the first time segment and the traffic data in the second time segment, and the output is the time features of the node dimension.
[0153] In one embodiment, step S207 includes:
[0154] S2071. Use at least one linear layer to process the complete spatial features of the first time segment, and use at least one linear layer to process the traffic data in the second time segment to obtain features of each attention head.
[0155] S2072. Merge the features of each attention head to obtain the second merged feature.
[0156] S2073. Pass the second merged features through a feedforward neural network with residual connections to obtain node-dimensional time features.
[0157] Specifically, two linear layers are used to process the traffic data of adjacent time segments. Processing, using a linear layer on Processing, get the Query of the i-th attention head Key Value
[0158]
[0159] according to Calculate the features of the i-th attention head
[0160]
[0161] Perform multi-head attention embedding merging to obtain the second merged feature
[0162]
[0163] Merge the second feature Obtain node-dimensional temporal features through a feedforward neural network with residual connections
[0164]
[0165] Where FF represents the feedforward neural network of the multi-head cross attention network.
[0166] S208. Extract the time correlation of the input data in the time dimension based on the constructed multi-head convolutional attention network, the input of the multi-head convolutional attention network is the complete spatial features of the first time segment and the traffic data in the second time segment, and the output is the time features of the time dimension.
[0167] Specifically, step S208 includes:
[0168] S2081: Splicing the complete spatial features of the first time segment and the traffic data of the second time segment and adding a position code to obtain a spliced feature;
[0169] S2082, performing a filling operation on the splicing feature to obtain a filling feature;
[0170] S2083, calculating the features of each attention head based on the splicing features and the filling features;
[0171] S2084. Merge the features of each attention head to obtain a third merged feature;
[0172] S2085. Pass the third merged feature through a feedforward neural network with residual connection to obtain a time dimension time feature.
[0173] Specifically, the complete spatial features of the first time segment and traffic data in the second time segment Splice and add position coding to obtain splicing features
[0174]
[0175] Splice feature Perform the filling operation to obtain the filling feature
[0176]
[0177] Where k is the convolution kernel size, p = k-1, v = 0 means the padding length is k-1 and the padding value is 0;
[0178] Use two convolution layers with kernel k as the Processing, using a convolution layer with a convolution kernel of 1 to splice features Process and get the Query of the first attention head Key Value
[0179]
[0180] according to Calculate the characteristics of the i-th attention head:
[0181]
[0182] Perform multi-head attention embedding merging to obtain the third merged feature
[0183]
[0184] Merge the third feature The time dimension features are obtained through a feedforward neural network with residual connections:
[0185]
[0186] FF CSAN Represents the feedforward neural network computation of a multi-head convolutional attention network.
[0187] S209: Concatenate the time features of the node dimension and the time features of the time dimension to obtain complete spatiotemporal features of the first time segment.
[0188] Get node dimension time characteristics and time dimension time characteristics Finally, the two embeddings are concatenated and fused using a multi-layer perceptron to obtain the complete spatiotemporal features of the time segment t
[0189]
[0190] MLP TAB Computation of the Multilayer Perceptron with the Temporal Attention Module.
[0191] S210: Input the complete spatiotemporal features of the first time segment into the multi-head self-attention network to extract latent spatial features, and obtain a data completion result.
[0192] Specifically, it includes obtaining the reconstruction network of the complete spatiotemporal features of the time segment t in turn; performing masking operations on the reconstruction network; and performing normalization operations on the masked reconstruction network to obtain the features of each attention head. The features of each attention head are merged to generate merged features. The merged features are passed through a feedforward neural network with residual connections to obtain the latent spatial features of the input data and obtain preliminary data completion results. Specifically, Figure 2 The spatial multilayer perceptron in
[15] uses a multi-head self-attention network to extract the latent spatial features of the complete spatiotemporal features of the first time segment.
[0193] S211. Re-execute steps S204-S210 to obtain an optimized data completion result.
[0194] The preliminary data completion result is then input into the multi-head self-attention network, and the multi-head self-attention network is used to extract the latent space features of the preliminary data completion result. The sensor topology structure in the real space is converted into an adjacency matrix, and the real space features of the adjacency matrix are extracted based on the constructed graph attention feedforward network. The latent space features are feature-concatenated with the real space features to obtain the complete spatial features of the first time segment. The temporal correlation of the input data is extracted based on the constructed temporal attention module. The input of the temporal attention module is the complete spatial features of the first time segment and the traffic data in the second time segment, and the output is the complete spatiotemporal features of the first time segment. The complete spatiotemporal features of the first time segment are then input into the multi-head self-attention network to extract the latent space features, and the optimized data completion result is obtained.
[0195] S212: Repeat steps S204-S211 until a preset iteration stop condition is met, and output the final data completion result.
[0196] Re-input traffic data of another first time segment, train the data completion model, repeat the iteration multiple times until the parameters of the data completion model converge or the number of iterations reaches a preset iteration threshold, stop the iteration, and output the trained data completion model.
[0197] In this embodiment, the completion optimization loss function L is calculated as follows:
[0198]
[0199] Where, represents the mean absolute error loss of the initial completion process, Represents the mean absolute error loss of the optimization completion process. Of course, the loss function in this embodiment can also be selected as the root mean square error loss or other loss functions.
[0200] In the above formula, α controls the weights of the two network losses in the initial completion process and the optimized completion process, such as Figure 6 Schematic diagram showing how the completion effect is affected by the loss function parameter α.
[0201] In a specific application example, the present invention can use traffic data collected by multiple sensor nodes within half a year as initial traffic data, divide the initial sample data into time segments of 5 minutes, and obtain a large number of samples. Figure 3 The left figure is the traffic data diagram under the random missing data mode. Figure 3 The figure on the right shows the traffic data in the random sensor power-off mode. The present invention uses the traffic data in the random data loss mode for comparative experiments. The mean absolute error, root mean square error, and mean absolute percentage error of the traffic data completion method STAIRN based on spatiotemporal attention of the present invention are compared with those of other schemes (BGCP, DSAE, MIWAE, GA-GAN, HSTGCN). The comparison results are shown in Table 1 below:
[0202] Table 1 Comparison of MAE, RMSE and MAPE indicators in random missing data mode
[0203]
[0204] It can be seen from Table 1 above that the performance indicators of the present invention are better than all other comparison models on both the PEMSBAY dataset and the Seattle dataset, which proves the effectiveness of the present invention. This is because the present invention can extract comprehensive spatiotemporal features from partially observed traffic data for data completion. Among the comparison models, the completion method based on graph sampling aggregation and generative adversarial networks achieved the best results. This is because this method can comprehensively extract spatial correlations in traffic data and infer missing values through generative adversarial networks. However, this method ignores the temporal features, so the effect is worse than that of the present invention. The completion method based on layered graph convolution can extract fine-grained spatiotemporal information, but the extracted information is not comprehensive, especially ignoring the temporal features of the node dimension, resulting in poor performance of this method. The effects of all comparison models drop sharply when the missing rate is high. This is because these methods cannot extract spatiotemporal features from limited data. The present invention can effectively capture comprehensive spatiotemporal features from sparse traffic data through specially designed spatial and temporal attention modules, thereby maintaining excellent completion effects when the missing rate is high.
[0205] Table 2 shows the results of the comparative experiment under the simulated random power outage mode. It can be seen from the experimental results that the performance indicators of the present invention on the two data sets are better than those of all other comparative models, which proves the effectiveness of the present invention. This is because the present invention can extract comprehensive spatiotemporal features from partially observed traffic data for data completion. Among the comparative models, the completion method based on layered graph convolution has the best effect when the missing rate is low. This is because the macro layer and road layer in this method can capture fine-grained spatiotemporal features from sufficient data. The matrix completion method based on Gaussian vector autoregression also achieved good results. This is because this method uses the Gaussian vector autoregression process to model the time factor matrix and can handle continuous time missingness well. Similarly, the effects of all comparative models drop sharply when the missing rate is high, while the present invention can maintain excellent completion effects when the missing rate is high, which once again proves the effectiveness of the technical solution in the present invention.
[0206] Table 2 Comparison of MAE, RMSE and MAPE indicators under random power outage mode
[0207]
[0208] Figure 4(a) is a schematic diagram of the MAE of the traffic data completion method STAIRN based on spatiotemporal attention of the present invention and other schemes (BTMF, GA-GAN) under the random data missing mode of PEMSBAY dataset; Figure 4(b) is a schematic diagram of the RMSE of the traffic data completion method STAIRN based on spatiotemporal attention of the present invention and other schemes (BTMF, GA-GAN) under the random data missing mode of PEMSBAY dataset; Figure 4(c) is a schematic diagram of the MAE of the traffic data completion method STAIRN based on spatiotemporal attention of the present invention and other schemes (BTMF, GA-GAN) under the simulated random power outage mode of PEMSBAY dataset; Figure 4(d) is a schematic diagram of the RMSE of the traffic data completion method STAIRN based on spatiotemporal attention of the present invention and other schemes (BTMF, GA-GAN) under the simulated random power outage mode of PEMSBAY dataset. Figure 4(a)-Figure 4(d) It can be seen that the solutions of the present invention are superior to other solutions.
[0209] Figure 5(a) is a schematic diagram of the indicators of the PEMSBAY dataset in the random data missing mode; Figure 5(b) is a schematic diagram of the indicators of the PEMSBAY dataset in the simulated random power outage mode; Figure 5(c) is a schematic diagram of the indicators of the Seattle dataset in the random data missing mode; Figure 5(d) is a schematic diagram of the indicators of the Seattle dataset in the simulated random power outage mode.
[0210] The effectiveness of each module of the present invention is verified by ablation experiments. Figure 7The results of the ablation experiment are shown in the figure. Figure 7 In this paper, a simple network IRN containing only a simple multilayer perceptron is used as the base network, and its root mean square error (RMSE) is 2.21. Next, the effects of these modules are studied by gradually integrating the proposed modules into the base network. (2) CAIRN uses a multi-head cross-attention network in the temporal attention module to extract temporal features between different sensors, achieving good improvement results, which proves that the rich temporal features between sensors can greatly help the model reconstruct missing values. Subsequently, by further introducing a convolutional attention network to extract temporal features within the sensor, TAIRN improves the RMSE to 1.97. This shows that the two modules extract temporal features from different perspectives, and through their collaboration, they can capture comprehensive temporal information from traffic data. (3) GTAIRN uses a graph attention feedforward network to obtain real spatial features from the road network structure, and then STAIRN introduces a multi-head self-attention network on top of it to utilize the latent space features between detectors, which reduces the RMSE to 1.91. This means that the spatial features not only cover the geographical proximity in the real road network structure, but also the proximity in the latent space. In summary, the RMSE was gradually optimized from 2.23 to 1.91, which is a 14.3% performance improvement.
[0211] The embodiments of the present invention use self-attention to construct a multi-head self-attention network to extract latent spatial features from traffic data, use a graph attention layer and a feedforward neural network to construct a graph attention feedforward network to extract real spatial features from traffic data, and fuse the two features to achieve comprehensive extraction of spatial features; use cross-attention to construct a multi-head cross-attention network to extract temporal correlation in the node dimension, use attention and convolution to construct a multi-head convolutional attention network to extract temporal correlation in the time dimension, and fuse the two features to achieve comprehensive extraction of temporal features. The present invention constructs a traffic data completion framework based on spatiotemporal attention, adopts completion optimization serial mode distribution to perform completion operations, and uses an iterative strategy to optimize the completion results. It can be applied to data completion tasks in a variety of data missing scenarios.
[0212] Example 3
[0213] Figure 8 This is a structural diagram of a data completion device based on spatiotemporal attention provided by the third embodiment of the present invention. Figure 8 As shown, the device includes:
[0214] The data partitioning unit 401 is configured to partition the input incomplete traffic data according to a time dimension, where the partitioned data includes traffic data of multiple time segments;
[0215] A data filling unit 402 is configured to fill missing values in the traffic data based on data currently collected by the sensor;
[0216] An input unit 403, configured to use the first time segment data of the filled traffic data as input for training a data completion model;
[0217] a latent space feature extraction unit 404 for extracting latent space features of the input data based on the constructed multi-head self-attention network, wherein the latent space features are used to characterize the correlation between the traffic data collected by the sensor in each time segment;
[0218] A real space feature extraction unit 405 is configured to convert the sensor topology in the real space into an adjacency matrix, and extract real space features from the adjacency matrix based on the constructed graph attention feedforward network, wherein the real space features are used to characterize the correlation between sensors in the real space;
[0219] A splicing unit 406 is configured to perform feature splicing on the latent spatial feature and the real spatial feature to obtain a complete spatial feature of the first time segment;
[0220] A temporal feature extraction unit 407 is configured to extract temporal correlations of input data based on a constructed temporal attention module; the temporal attention module inputs the complete spatial features of the first time segment and the traffic data in the second time segment, and outputs the complete spatiotemporal features of the first time segment;
[0221] A preliminary data completion unit 408 is configured to input the complete spatiotemporal features of the first time segment into the multi-head self-attention network to extract latent spatial features, thereby obtaining a data completion result;
[0222] An optimized data completion unit 409 is configured to re-execute the steps in the latent space feature extraction unit, the real space feature extraction unit, the splicing unit, the temporal feature extraction unit, and the preliminary data completion unit to obtain an optimized data completion result;
[0223] The iterative calculation unit 410 is used to repeatedly execute the steps in the spatial feature extraction unit, the real spatial feature extraction unit, the splicing unit, the time feature extraction unit, the preliminary data completion unit and the optimized data completion unit until a preset iteration stop condition is met, and output the final data completion result.
[0224] The message data processing resource scheduling device provided by the embodiment of the present invention can execute the message data processing resource scheduling device method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0225] Example 4
[0226] Figure 9 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0227] like Figure 9 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is communicatively connected to the at least one processor 11. The memory stores a computer program that can be executed by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. Various programs and data required for the operation of the electronic device 10 can also be stored in the RAM 13. The processor 11, ROM 12, and RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0228] Multiple components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0229] The processor 11 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a data completion method based on spatiotemporal attention.
[0230] In some embodiments, a method for data completion based on spatiotemporal attention may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method for data completion based on spatiotemporal attention described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform a method for data completion based on spatiotemporal attention in any other appropriate manner (e.g., by means of firmware).
[0231] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.
[0232] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A data completion method based on spatiotemporal attention, characterized in that: include: The incomplete traffic data input is divided according to the time dimension, and the divided data includes traffic data of multiple time segments; Filling missing values in the traffic data based on data currently collected by the sensor; The first time segment data of the filled traffic data is used as input for training the data completion model; S1: Extracting latent spatial features of input data based on the constructed multi-head self-attention network. The latent spatial features are used to characterize the correlation between traffic data collected by sensors in each time segment. S2: Convert the sensor topology in the real space into an adjacency matrix, and extract the real space features of the adjacency matrix based on the constructed graph attention feedforward network. The real space features are used to characterize the correlation between sensors in the real space. S3: performing feature concatenation on the latent spatial feature and the real spatial feature to obtain a complete spatial feature of the first time segment; S4: extracting the temporal correlation of the input data based on the constructed temporal attention module; the input of the temporal attention module is the complete spatial features of the first time segment and the traffic data in the second time segment, and the output is the complete spatiotemporal features of the first time segment; S5: Inputting the complete spatiotemporal features of the first time segment into the multi-head self-attention network to extract latent spatial features to obtain a data completion result; S6: Re-execute steps S1-S5 to obtain the optimized data completion result; Repeat steps S1-S6 until the preset iteration stop condition is met, and then output the final data completion result.
2. The data completion method based on spatiotemporal attention according to claim 1, characterized in that: Filling missing values in the traffic data based on data currently collected by the sensor includes: The missing values of the traffic data are filled based on the average value of the data currently collected by the sensor.
3. The data completion method based on spatiotemporal attention according to claim 1, characterized in that The multi-head self-attention network constructed based on the extraction of latent spatial features of input data includes: Calculating the attention score of each attention head based on the input data, and generating a reconstruction network based on the attention score of each attention head, wherein the reconstruction network is used to characterize the correlation between sensors; performing a mask operation on the reconstructed network; Performing a normalization operation on the reconstructed network after the mask operation to obtain the features of each attention head; Merge the features of each attention head to generate the first merged feature; The first merged features are passed through a feedforward neural network with residual connections to obtain the latent space features of the input data.
4. The data completion method based on spatiotemporal attention according to claim 1, characterized in that The real spatial features of the adjacency matrix are extracted based on the constructed graph attention feedforward network, including: The constructed graph attention layer is used to extract features between sensor nodes; The features between sensor nodes are input into a feedforward neural network with residual connections to obtain the real spatial features.
5. The data completion method based on spatiotemporal attention according to claim 1, characterized in that The step of performing feature concatenation on the latent spatial features and the real spatial features to obtain a complete spatial feature of the first time segment includes: The latent spatial features and the real spatial features are input into a constructed multi-layer perceptron for feature fusion to obtain the complete spatial features of the first time segment.
6. The data completion method based on spatiotemporal attention according to claim 1, characterized in that: The constructed temporal attention module extracts the temporal correlation of the input data; the input of the temporal attention module is the complete spatial features of the first time segment and the traffic data in the second time segment, and the output is the complete spatiotemporal features of the first time segment, including: Extracting the temporal correlation of input data in the node dimension based on the constructed multi-head cross attention network, wherein the input of the multi-head cross attention network is the complete spatial features of the first time segment and the traffic data in the second time segment, and the output is the temporal features of the node dimension; Extracting the temporal correlation of the input data in the time dimension based on the constructed multi-head convolutional attention network, wherein the input of the multi-head convolutional attention network is the complete spatial features of the first time segment and the traffic data in the second time segment, and the output is the temporal features of the time dimension; The time features of the node dimension and the time features of the time dimension are concatenated to obtain the complete spatiotemporal features of the first time segment.
7. The data completion method based on spatiotemporal attention according to claim 6, characterized in that: The multi-head cross attention network constructed based on the above method extracts the temporal correlation of the input data in the node dimension, including: Processing the complete spatial features of the first time segment using at least one linear layer, and processing the traffic data in the second time segment using at least one linear layer to obtain features of each attention head; Merge the features of each attention head to obtain the second merged feature; The second merged feature is passed through a feedforward neural network with residual connection to obtain the node dimension time feature.
8. The data completion method based on spatiotemporal attention according to claim 6, characterized in that: The multi-head convolutional attention network constructed above extracts the temporal correlation of the input data in the time dimension, including: Splicing the complete spatial features of the first time segment and the traffic data in the second time segment and adding a position code to obtain a spliced feature; Performing a filling operation on the splicing feature to obtain a filling feature; Calculate the features of each attention head based on the splicing features and the filling features; Merge the features of each attention head to obtain the third merged feature; The third merged feature is passed through a feedforward neural network with a residual connection to obtain a time dimension time feature.
9. The data completion method based on spatiotemporal attention according to claim 1, characterized in that: The loss function of the data completion model is: Where α controls the weights of the two network losses in the initial completion process and the optimized completion process; represents the loss function of the initial completion process, Represents the loss function for optimizing the completion process.
10. A data completion device based on spatiotemporal attention, characterized in that: include: A data partitioning unit is used to partition the input incomplete traffic data according to the time dimension, and the partitioned data includes traffic data of multiple time segments; A data filling unit, configured to fill missing values in the traffic data based on data currently collected by the sensor; An input unit, configured to take the first time segment data of the filled traffic data as input for training a data completion model; A latent space feature extraction unit is used to extract latent space features of input data based on the constructed multi-head self-attention network, wherein the latent space features are used to characterize the correlation between traffic data collected by sensors in each time segment; A real space feature extraction unit is used to convert the sensor topology in the real space into an adjacency matrix, and extract real space features of the adjacency matrix based on the constructed graph attention feedforward network, wherein the real space features are used to characterize the correlation between sensors in the real space; a splicing unit, configured to perform feature splicing on the latent spatial feature and the real spatial feature to obtain a complete spatial feature of the first time segment; a temporal feature extraction unit, configured to extract temporal correlation of input data based on a constructed temporal attention module; the temporal attention module inputs the complete spatial features of the first time segment and the traffic data in the second time segment, and outputs the complete spatiotemporal features of the first time segment; a preliminary data completion unit, configured to input the complete spatiotemporal features of the first time segment into the multi-head self-attention network to extract latent spatial features, and obtain a data completion result; An optimized data completion unit is used to re-execute the steps in the latent space feature extraction unit, the real space feature extraction unit, the splicing unit, the temporal feature extraction unit, and the preliminary data completion unit to obtain an optimized data completion result; The iterative calculation unit is used to repeatedly execute the steps in the spatial feature extraction unit, the real spatial feature extraction unit, the splicing unit, the temporal feature extraction unit, the preliminary data completion unit and the optimized data completion unit until the preset iteration stop condition is met, and output the final data completion result.
Citation Information
Patent Citations
Traffic flow prediction model and method based on multi-head self-attention mechanism
CN112990594A
Traffic network coding representation learning method based on mask pattern attention mechanism
CN117690289A