Heterogeneity-guided traffic flow completion method, system, medium and equipment
By performing spatiotemporal decoupling and mask comparison learning on traffic flow data, a heterogeneity representation matrix is generated, which solves the problem of complete deviation of traffic flow data in sparse or non-stationary environments in the existing technology, and achieves higher completion accuracy and robustness.
Patent Information
- Application Number
- CN202510353122.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-25
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2045-03-25
AI Technical Summary
The prior art has deviations in capturing the spatiotemporal distribution mode of traffic flow, especially in sparse or non-stationary environments, which affect the accuracy and robustness of traffic flow data completion.
By performing mask encoding of the original traffic flow data in time and space decoupling, time and spatial mask data are generated, and the mask comparison learning method of reconstruction loss is used to generate the time and spatial heterogeneity representation matrix, and the traffic flow data completion of the tensor decomposition model is used as constraints.
Effectively characterize the spatiotemporal heterogeneity of road traffic flow data under different missing modes, improving the accuracy and robustness of traffic flow data completion.
Smart Images

Figure CN119884718A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, system, medium and device for heterogeneity-guided traffic flow completion. Background Art
[0002] Accurate and reliable traffic flow data is particularly important for the research and application of intelligent transportation systems. It is the basic data guarantee for its precise control and decision support functions. At present, the acquisition of road traffic flow information mainly relies on professional fixed detection devices (such as cameras, radar / laser speed meters, etc.). Due to the deployment density and communication transmission conditions, the traffic flow records collected on the roads through fixed detection points are inevitably sparse or missing, which restricts the acquisition of accurate and reliable traffic flow data. Therefore, how to fill in the missing data from some observation data of traffic flow monitoring stations has always been widely concerned by the industry.
[0003] Road traffic flow data completion refers to the use of interpolation, statistical methods, machine learning and other technologies to infer missing traffic data. As an important branch of machine learning, tensor decomposition methods are widely used in traffic flow data completion due to their advantages in high-dimensional data processing. However, this method has deviations in capturing the spatiotemporal distribution patterns of traffic flow, especially in sparse or non-stationary environments, which affects the accuracy and robustness of completion.
[0004] Therefore, it is necessary to provide an improved technical solution to address the above-mentioned deficiencies in the prior art. Summary of the invention
[0005] The purpose of the present application is to provide a heterogeneity-guided traffic flow completion method, system, medium and device to solve or alleviate the problems existing in the above-mentioned prior art.
[0006] In order to achieve the above objectives, this application provides the following technical solutions: In a first aspect, the present application provides a heterogeneity-guided traffic flow completion method, comprising the following steps: Perform spatiotemporal decoupling mask encoding on the original traffic flow data to generate mask data , the mask data includes time mask data and spatial mask data ; The original traffic flow data is traffic flow data with missing values, which is expressed as a tensor to obtain the original traffic flow tensor ; The original traffic flow data and the mask data are respectively subjected to feature embedding and position encoding to obtain a spatiotemporal encoding result; wherein the spatiotemporal encoding result includes the time and space encoding results of the original traffic flow data and the mask data respectively; Based on the spatiotemporal encoding result, a mask contrast learning method with reconstruction loss is used to generate a temporal heterogeneity representation matrix and a spatial heterogeneity representation matrix respectively; The temporal heterogeneity characterization matrix and the spatial heterogeneity characterization matrix are used as constraints, and the traffic flow data is completed based on the tensor decomposition model to obtain the completed traffic flow. .
[0007] Preferably, the mask data is generated as follows: According to the original traffic flow tensor , along the time dimension and the space dimension respectively according to the mask rate Randomly generate time mask tensors and the spatial mask tensor ; The original traffic flow tensor With the time mask tensor , spatial mask tensor Perform element multiplication operations respectively to obtain the mask data .
[0008] Preferably, feature embedding and position encoding are performed on the original traffic flow data and the mask data respectively to obtain a spatiotemporal encoding result, which is specifically: Using a combination of block embedding technology and a fully connected layer to generate high-dimensional embedding features of the original traffic flow data and the mask data respectively; The sinusoidal position coding technique is used to generate the spatiotemporal position coding of the original traffic flow data and the mask data respectively; The high-dimensional embedding features of the time dimension and space dimension of the original traffic flow data and the mask data are element-wise multiplied with the spatiotemporal position codes of the original traffic flow data and the mask data, respectively, and then input into the Transformer to obtain the spatiotemporal coding result.
[0009] Preferably, based on the spatiotemporal coding result, a mask contrast learning method with reconstruction loss is used to generate a temporal heterogeneity representation matrix and a spatial heterogeneity representation matrix respectively, including: The time encoding results of the original traffic flow data and the mask data are respectively subjected to mean and dimension conversion operations to extract the average feature representation of each time step of the original traffic flow data and the mask data. , ; Introducing the first parameter matrix , the second parameter matrix , and the first parameter matrix , the second parameter matrix The average feature values of the original traffic flow data and the mask data are shown in Figure 2. , A multiplication operation is performed on each time dimension to obtain the temporal heterogeneity characterization results of the original traffic flow data and the mask data. , ; calculate and The contrast loss is obtained, and the first loss is obtained ; In the embedding dimension, the spatial encoding results of the original traffic flow data and the mask data are respectively averaged to extract the average feature representation of the original traffic flow data and the mask data at each node position. , ; Introducing the third parameter matrix , the fourth parameter matrix , and the third parameter matrix , the fourth parameter matrix The average feature representation of the original traffic flow data and the mask data at each node position is , Perform multiplication to obtain spatial heterogeneity characterization results , ; calculate and The contrast loss is obtained, and the second loss is obtained ; By iteratively optimizing the first loss The second loss , to generate the final temporal heterogeneity representation matrix , and spatial heterogeneity characterization matrix , .
[0010] Preferably, the tensor decomposition model is a CP decomposition model, which uses the CP decomposition model to decompose the original traffic flow tensor into a first factor matrix , the second factor matrix , the third factor matrix , and optimize its probability distribution through variational Bayesian learning.
[0011] Preferably, the loss function of the CP decomposition model is the sum of the following four parts: a reconstruction error term, a spatial heterogeneity representation constraint term, a temporal heterogeneity representation constraint term, and a regularization term; The reconstruction error term is the reconstruction error between the original traffic flow and the completed traffic flow; The spatial heterogeneity characterization constraint term is used to constrain the spatial relationship of traffic flow between different nodes, and its expression is: , In the formula, is a spatial heterogeneity characterization matrix of the original traffic flow data; is the first factor matrix; The temporal heterogeneity characterization constraint term is used to constrain the temporal relationship of traffic flow between different nodes, and its expression is as follows: , In the formula, is the temporal heterogeneity characterization matrix of the original traffic flow data, , is the first factor matrix The index is ( )、( ), is the second factor matrix The index is ( ) elements; The expression of the regularization term is: .
[0012] Preferably, the first factor matrix , the second factor matrix , the third factor matrix The weights of are initialized using the reparameterization technique, specifically: , , , In the formula, , , The first factor matrix is , the second factor matrix , the third factor matrix The weight of , , The first factor matrix is , the second factor matrix , the third factor matrix The corresponding global parameters, is the variational posterior parameter The standard deviation of It conforms to the Gaussian distribution. , , The first factor matrix is , the second factor matrix , the third factor matrix The corresponding random noise is , , All obey normal distribution.
[0013] In a second aspect, this embodiment provides a heterogeneity-guided traffic flow completion system, including: The mask encoding module is used to perform spatiotemporal decoupling mask encoding on the original traffic flow data to generate mask data. , the mask data includes time mask data and spatial mask data ; The original traffic flow data is traffic flow data with missing values, which is expressed as a tensor to obtain the original traffic flow tensor ; An embedding and position coding module, used to perform feature embedding and position coding on the original traffic flow data and the mask data respectively, to obtain a spatiotemporal coding result; wherein the spatiotemporal coding result includes the time and space coding results of the original traffic flow data and the mask data respectively; A spatiotemporal heterogeneity representation module, for generating a temporal heterogeneity representation matrix and a spatial heterogeneity representation matrix respectively based on the spatiotemporal encoding result and using a mask contrast learning method with reconstruction loss; A decomposition module is used to use the temporal heterogeneity representation matrix and the spatial heterogeneity representation matrix as constraints, and to complete the traffic flow data based on the tensor decomposition model to obtain the completed traffic flow. .
[0014] In a third aspect, this embodiment provides an electronic device, comprising: a memory for storing instructions executed by one or more processors of the electronic device; and a processor, which, when the processor executes the instructions in the memory, enables the electronic device to implement the steps of the heterogeneity-guided traffic flow completion method described in any of the above embodiments.
[0015] In a fourth aspect, this embodiment provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores instructions, which, when executed on a computer, implement the steps of the heterogeneity-guided traffic flow completion method described in any of the above embodiments.
[0016] The technical solution of the embodiment of the present application has the following beneficial effects: By performing spatiotemporal decoupling mask encoding on the original traffic flow data, time mask data and space mask data are obtained, which can capture the spatiotemporal variation characteristics of traffic flow with rich context, and introduce mask contrast learning based on reconstruction loss in the process of spatiotemporal heterogeneity characterization to enhance the model's ability to reconstruct the spatiotemporal heterogeneity characterization of missing locations; the spatiotemporal heterogeneity characterization results (i.e., the temporal heterogeneity characterization matrix and the spatial heterogeneity characterization matrix) are used to constrain the spatiotemporal relationship of traffic flow, and the spatiotemporal characterization process and flow completion process are optimized through self-supervised learning to enhance the completion performance of road traffic flow data. In short, the method provided in this embodiment can effectively characterize the spatiotemporal heterogeneity of road traffic flow data under different missing modes, and exhibit high flow data completion accuracy and robustness. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 A schematic flow chart of a heterogeneity-guided traffic flow completion method provided according to some embodiments of the present application.
[0018] Figure 2 A logical block diagram of a heterogeneity-guided traffic flow completion method provided according to some embodiments of the present application.
[0019] Figure 3 A schematic diagram of the structure of an electronic device provided for some embodiments of the present application. DETAILED DESCRIPTION
[0020] In order to facilitate the understanding of the technical solution of the present application, the relevant terms and the ideas proposed by the present invention are described in detail below.
[0021] Tensor decomposition method is a mathematical tool for processing high-order data (i.e., multidimensional arrays). It decomposes high-dimensional tensors into a combination of multiple low-dimensional structures to extract potential features, reduce dimensionality, or denoise.
[0022] Common tensor decomposition methods include CP model, Tucker model, Bayesian decomposition model and rank minimization model. These methods usually use contextual features such as points of interest (POI) and road networks around monitoring points to model the relationship between traffic flows in different areas, thereby constraining the tensor decomposition process and improving the accuracy of traffic flow completion.
[0023] However, traffic flow is affected nonlinearly by multiple factors such as geographical environment, infrastructure and travel demand, and exhibits obvious spatiotemporal heterogeneity, that is, traffic flow has significant differences in different spatial locations and time periods. For example, commercial areas may have higher traffic on weekends, while residential areas are the opposite; some sections of roads have obvious morning peaks on weekdays, but the traffic is more uniform on weekends. Existing tensor decomposition methods usually rely on the "spatial similarity assumption", that is, it is assumed that areas with similar geographical features have similar trends in traffic flow changes, ignoring the impact of spatiotemporal heterogeneity. This assumption causes the model to have deviations in capturing the spatiotemporal distribution pattern of traffic flow, especially in sparse or non-stationary environments, affecting the accuracy and robustness of completion.
[0024] In recent years, the introduction of spatiotemporal heterogeneity representation methods has significantly promoted the development of road traffic data modeling technology. According to the principle of this method, it can be mainly divided into two categories: meta-learning and representation learning. Among them, the meta-learning method relies on contextual features such as points of interest (POI), monitoring point locations or GPS trajectories, aiming to obtain parameters that can effectively represent the characteristics of different regions, thereby enhancing the model's ability to represent spatiotemporal heterogeneity. However, the effectiveness of these models may be limited by the availability of contextual features. The representation learning method aims to explore the implicit spatiotemporal heterogeneity in traffic data from a data-driven perspective by using feature embedding or spatiotemporal encoding, providing a new reference for traffic volume data completion based on tensor decomposition. Among them, self-supervised learning has become one of the key strategies to improve the generalization ability and adaptability of spatiotemporal heterogeneity representation due to its effectiveness in enhancing the representation of spatiotemporal data features. This type of method helps the model capture the complex spatial and temporal dependencies in spatiotemporal data by designing appropriate pre-training tasks, thereby enhancing the model's understanding and representation of data, and further promoting the accuracy and effectiveness of spatiotemporal heterogeneity representation. Therefore, combining self-supervised learning technology with tensor decomposition is an ideal solution, which is expected to improve the accuracy and adaptability of completion. However, the inventors found that the above combination faces two major challenges in practice: (1) Existing self-supervised learning methods are usually built on complete historical data, allowing the model to find spatiotemporal patterns and dependencies of data across the entire spatiotemporal range. However, the varying degrees of missing traffic flow data may destroy its continuity and consistency, resulting in inaccurate mining of spatiotemporal distribution patterns, thereby affecting the characterization of spatiotemporal heterogeneity. For example, the traffic changes in certain sections during peak hours may be very different from those during non-peak hours, and missing data may mask such changes. Therefore, when combining self-supervised learning techniques with tensor decomposition, the model often finds it difficult to effectively identify and characterize the spatiotemporal heterogeneity characteristics of the missing locations, resulting in the inability to optimize based on the true distribution of the data.
[0025] (2) Since the tensor decomposition method lacks supervision signals for missing positions during the optimization process, it is impossible to reversely optimize the spatiotemporal heterogeneity representation based on the completed traffic flow results. The lack of this feedback mechanism interrupts the mutual promotion of representation learning and data completion, resulting in the model being unable to adaptively adjust the representation of spatiotemporal heterogeneity characteristics based on the completed results, thereby limiting the model's adaptability to different missing patterns and complex traffic flow trends. Especially in data sparse and non-stationary environments, the lack of an effective feedback structure significantly weakens the model's ability to capture heterogeneous features and improve generalization performance.
[0026] In view of this, this application proposes a heterogeneity-guided traffic flow completion method (also known as: heterogeneity-guided tensor decomposition method, abbreviated as: Hg-TD), which effectively characterizes spatiotemporal heterogeneity in the absence of traffic data and lack of supervision information, and is used to constrain the tensor decomposition process, thereby improving the accuracy and robustness of the traffic flow data completion method.
[0027] The terms "first", "second", "third" and "fourth" etc. in the specification and claims of the present application and the drawings are used to distinguish different objects, rather than to describe a specific order. 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 limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0028] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0029] "Multiple" means two or more. "And / or" describes the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.
[0030] The embodiments of the present application are described below in conjunction with the accompanying drawings.
[0031] This embodiment provides a heterogeneity-guided traffic flow completion method, such as Figure 1 As shown, the method comprises the following steps: Step S101: Performing spatiotemporal decoupling mask encoding on the original traffic flow data to generate mask data , the mask data includes the time mask data and spatial mask data .
[0032] Specifically, in this embodiment, the traffic flow is defined as follows: Traffic volume: Traffic volume refers to the number of vehicles passing through the road section where the monitoring point is located within a specific time interval. Monitoring points in Tiantianhe The traffic flow in a time interval can be represented as a tensor .
[0033] Among them, the original traffic flow data is the traffic flow data with missing values, which is expressed as a tensor to obtain the original traffic flow tensor .
[0034] Therefore, the problem definition of this embodiment is as follows: Given a traffic flow with missing values , the goal of this embodiment is to build a model completion The missing values in .
[0035] Next, for the convenience of description, the symbols of this embodiment are defined as follows: Table 1 Symbol Definition
[0036] Step S102: feature embedding and position encoding are performed on the original traffic flow data and the mask data respectively to obtain spatiotemporal encoding results; wherein the spatiotemporal encoding results include the time and space encoding results of the original traffic flow data and the time and space encoding results of the mask data.
[0037] Through feature embedding, the original traffic flow data and mask data are mapped to a high-dimensional feature space, and their deep embedded features in the time and space dimensions are extracted to capture the spatiotemporal characteristics of the data. By introducing a position encoding mechanism, the time and space position encodings corresponding to the original traffic flow data and mask data are constructed to capture their structured position information in the time and space dimensions. By combining feature embedding with position encoding to generate spatiotemporal encoding results, the model's ability to capture temporal periodic features and spatial context information can be enhanced, thereby achieving more efficient completion performance under different missing modes.
[0038] Step S103: Based on the spatiotemporal coding results, a mask contrast learning method with reconstruction loss is used to generate a temporal heterogeneity representation matrix and a spatial heterogeneity representation matrix respectively.
[0039] Among them, reconstruction loss is an objective function that measures the difference between the model's predicted value and the true value. In the data completion task, reconstruction loss is used to evaluate the model's ability to restore the missing part.
[0040] Mask learning masks part of the input data (i.e., "masks"), allowing the model to learn how to infer the masked part from the remaining information, thereby enhancing the model's ability to understand the intrinsic structure of the data. Contrastive learning is a self-supervised learning method, the core idea of which is to learn high-quality feature representations by maximizing the similarity of positive sample pairs and minimizing the similarity of negative sample pairs.
[0041] The masked contrastive learning method with reconstruction loss can generate high-quality feature representations by combining the ideas of mask learning and contrastive learning, thereby improving the model's performance in completing missing data without explicitly constructing positive and negative sample pairs. Instead, this method mainly relies on the mask reconstruction task itself to guide the model to learn useful feature representations.
[0042] Step S104: Using the temporal heterogeneity representation matrix and the spatial heterogeneity representation matrix as constraints, the traffic flow data is completed based on the tensor decomposition model to obtain the completed traffic flow. .
[0043] Figure 2 FIG. 2 shows a logic block diagram of the heterogeneity-guided traffic flow completion method proposed in this embodiment. Figure 2 As shown, the method includes a mask encoding strategy for time-space decoupling, a learning method for representing the time-space heterogeneity of road traffic flow taking into account missing values, and a tensor decomposition method for considering the time-space heterogeneity of road traffic flow. Among them, the mask encoding strategy for time-space decoupling is used to set masks and encode features from the time and space dimensions of the data respectively to obtain the time-space encoding results of the data (including the original data, that is, the time and space encoding of the original traffic flow data and the time and space encoding of the mask data); the learning method for representing the time-space heterogeneity of road traffic flow taking into account missing values is used to capture the time-space distribution pattern of the data from the embedded features of the traffic flow based on mask contrast learning with reconstruction loss, so as to construct a weight matrix representing the heterogeneous relationship between monitoring points and obtain the heterogeneous representation results (including the time heterogeneity representation matrix and the space heterogeneity representation matrix); the tensor decomposition method for considering the time-space heterogeneity of road traffic flow uses the time-space heterogeneity representation results to constrain the time-space relationship of the traffic flow, and optimizes the time-space representation process and the flow completion process through self-supervised learning to enhance the completion performance of road traffic flow data.
[0044] The traffic flow completion task aims to complete the values of missing locations by establishing a relationship between the spatiotemporal distribution patterns of known data and unknown data. However, the diverse missing patterns of data may interfere with the learning of spatiotemporal distribution patterns, resulting in insufficient accuracy in the representation of spatiotemporal heterogeneity, thereby reducing the completion performance. Based on this, this embodiment proposes a spatiotemporal decoupled mask encoding strategy, which includes two parts: mask data generation and spatiotemporal encoding. Randomly set masks along the time and space dimensions to generate mask data , and a spatiotemporal encoder is used to generate and The high-dimensional embedding features in both time and space dimensions enable the model to effectively evaluate the heterogeneous representation results of missing locations.
[0045] The generation of mask data can be performed as follows: Step S101a: Based on the original traffic flow tensor , along the time dimension and the space dimension respectively according to the mask rate Randomly generate time mask tensors and the spatial mask tensor .
[0046] Step S101b: Convert the original traffic flow tensor With the time mask tensor , spatial mask tensor Perform element multiplication operations separately to obtain mask data .
[0047] Specifically, given the original traffic flow tensor , respectively along the spatial dimension , Time Dimension Expand and set the time and space mask data according to the following expression and : (1) (2) In the formula, and is a matrix consisting of only 0s and 1s, Random Mask The time series of sensors, Random Mask A time series with time steps; is the mask rate with a value between 0 and 1.
[0048] exist Figure 2In , the time mask data is represented by T-Mask and the space mask data is represented by S-Mask.
[0049] In some embodiments, feature embedding and position encoding are performed on the original traffic flow data and the mask data respectively to obtain a spatiotemporal encoding result, specifically: Step S102a: using a combination of block embedding technology and a fully connected layer to generate high-dimensional embedding features of the original traffic flow data and the mask data respectively; Step S102b: using sinusoidal position coding technology to generate spatiotemporal position coding of the original traffic flow data and the mask data respectively; Step S102c: element-wise multiplication of the high-dimensional embedding features of the time dimension and space dimension of the original traffic flow data and the mask data with the spatiotemporal position codes of the original traffic flow data and the mask data, respectively, and then input them into the Transformer to obtain the spatiotemporal coding results.
[0050] In this embodiment, the spatiotemporal encoding operation is performed by the temporal encoder and the spatial encoder respectively, such as Figure 2 As shown in the figure, the temporal encoder and the spatial encoder are two parallel branches in the model. They have similar structures and are composed of three parts: patch embedding, position encoding, and Transformer layer connected in sequence. Only the position encoding part is different: the temporal encoder is responsible for performing temporal position encoding, while the spatial encoder performs spatial position encoding. Through the temporal encoder and the spatial encoder, the self-attention mechanism is introduced along the temporal and spatial dimensions respectively, so that the model can effectively capture the long-range dependencies and local features in the data.
[0051] In this embodiment, in step S102a, the original data is first embedded in the block (Patch Embedding) technology. and mask data Cut into time length F patches, and then use a fully connected layer to transform each patch into a representation with a specific embedding dimension.
[0052] Specifically, the original data and mask data The time dimension is based on the length of time Cut into , get the patch input , and , ; Use the fully connected layer to get the embedding dimension of each patch input , and , ,in is the embedding dimension. The introduction of block embedding technology is conducive to enhancing the model's ability to capture complex and diverse features.
[0053] In steps S102b-S102c, sinusoidal position encoding is introduced to learn and Time / Spatial Positional Encoding , and , Then, the position encoding is combined with feature embedding and input into Transformer, which is the spatiotemporal position encoding, and the spatiotemporal encoding result is obtained. , and , , the expression of the above process is as follows: (3) (4) (5) (6) (7) In the formula, , Respectively High-dimensional embedding features in time and space dimensions, , Respectively High-dimensional embedding features in both temporal and spatial dimensions; , Respectively Time coding and spatial position coding; , Respectively Time coding and spatial position coding, is the embedding dimension, represents the element-wise multiplication operation, An index representing a spatial position, represents the index of the feature dimension, and Used to control the frequency of piecewise sine / cosine functions, enhance the diversity of position encoding, and avoid frequency duplication between different dimensions.
[0054] By combining position encoding with feature embedding, the model can more effectively utilize temporal period features and spatial context information, thereby improving its completion performance under different missing patterns.
[0055] Considering the spatiotemporal heterogeneity, the key to learning representations is to accurately mine the spatiotemporal distribution patterns of traffic flow to identify and understand its dynamic changes and spatial differences. Existing spatiotemporal heterogeneity representation learning methods usually assume that the data is complete, but in practical applications, data missing is inevitable, which may lead to incomplete model acquisition of traffic flow patterns, thereby affecting the accuracy and reliability of spatiotemporal heterogeneity representation. Therefore, this embodiment adopts a spatiotemporal heterogeneity representation learning method for road traffic flow that takes into account missing values to obtain temporal and spatial heterogeneity representation results (i.e., temporal heterogeneity representation matrix and spatial heterogeneity representation matrix) to effectively learn and capture clearer heterogeneity representations in the absence of data.
[0056] Specifically, based on the spatiotemporal encoding results, the mask contrastive learning method with reconstruction loss is used to generate the temporal heterogeneity representation matrix and the spatial heterogeneity representation matrix, respectively, including: Step S103a: Perform mean and dimension conversion operations on the time encoding results of the original traffic flow data and the mask data respectively, so as to extract the average feature representation of each time step of the original traffic flow data and the mask data. , .
[0057] Step S103b: Introducing the first parameter matrix , the second parameter matrix , and the first parameter matrix , the second parameter matrix The average features of the original traffic flow data and mask data are shown in Figure 2. , Multiplication is performed on each time dimension to obtain the temporal heterogeneity characterization results of the original traffic flow data and the mask data. , .
[0058] Step S103c: Calculation and The contrast loss is obtained, and the first loss is obtained .
[0059] Step S103d: Perform a mean operation on the spatial encoding results of the original traffic flow data and the mask data in the embedding dimension to extract the average feature representation of the original traffic flow data and the mask data at each node position. , .
[0060] Step S103e: Introducing the third parameter matrix , the fourth parameter matrix , and the third parameter matrix , the fourth parameter matrix The average feature representation of each node position with the original traffic flow data and mask data respectively , Perform multiplication to obtain spatial heterogeneity characterization results , .
[0061] Step S103f: Calculation and The contrast loss is obtained, and the second loss is obtained .
[0062] Step S103g: Optimize the first loss by iteration Second loss , to generate the final temporal heterogeneity representation matrix , and spatial heterogeneity characterization matrix , .
[0063] Exemplarily, the above steps S103a to S103g may be specifically performed as follows: For time coding results and , perform mean and dimension conversion operations on its embedding dimension respectively to extract the average feature representation at each time step and , the formula is as follows: (8) (9) In the formula, , , , which represents the result after the mean and dimension conversion operations at each time step.
[0064] In order to effectively capture the feature differences of different monitoring points in the time dimension and enhance the model's learning ability for temporal heterogeneity features, this embodiment introduces a learnable first parameter matrix , the second parameter matrix ,in, . The first parameter matrix , the second parameter matrix Respectively and Multiply each time dimension of to obtain the temporal heterogeneity characterization result and , the expression is as follows: (10) (11) In the formula, Represents the extraction slice operation, Represents a transpose operation.
[0065] On this basis, the mask contrastive learning method based on reconstruction loss is used to calculate the heterogeneous representation results. and The contrast loss between , that is, the first loss , the expression is as follows: (12) Similarly, the spatial encoding results of the original traffic flow data and the mask data are , , respectively perform the spatial heterogeneity characterization process. That is, perform the mean operation on its embedding dimension to extract the average feature representation of each node position , , the expression is as follows: (13) (14) Similarly, in order to effectively capture the feature differences of different monitoring points in the spatial dimension and enhance the model's ability to learn spatial heterogeneity features, this embodiment introduces the third parameter matrix , the fourth parameter matrix ,in, , and , Respectively , Perform multiplication to obtain spatial heterogeneity characterization results and , the expression is as follows: (15) (16) Using the mask contrast learning method with reconstruction loss, we calculate and The contrast loss between , that is, the second loss : (17) Finally, by continuously iteratively optimizing the above loss function, the model can effectively update the learning parameters, thereby improving the model's ability to capture spatial heterogeneity features. The final temporal heterogeneity representation matrix is generated based on the iterative learning parameters. , and spatial heterogeneity characterization matrix , .
[0066] The tensor decomposition model effectively simplifies the complex high-dimensional data structure into an easy-to-process low-dimensional representation by decomposing the high-dimensional tensor into multiple low-dimensional factors, thereby extracting the potential features and hidden patterns in the data. This feature makes the tensor decomposition method show strong applicability in dealing with the problem of urban traffic flow completion. Urban traffic flow data usually has significant high-dimensional characteristics, involving multiple dimensions such as time and space. The tensor decomposition method can represent these high-dimensional data as a set of low-dimensional factors to identify and extract potential features in traffic flow. However, the existing methods mainly complete the missing data based on the spatiotemporal correlation of traffic flow data, and often ignore its inherent spatiotemporal heterogeneity characteristics, thereby affecting the accuracy and robustness of the completion results. In view of this, this embodiment adopts a tensor decomposition method that takes into account spatiotemporal heterogeneity, and by embedding spatiotemporal heterogeneity representations, it enhances the constraints on the spatiotemporal relationship of traffic flow, thereby improving the performance and robustness of data completion.
[0067] Specifically, in this embodiment, the tensor decomposition model is a CP decomposition model, which uses the CP decomposition model to transform the original traffic flow tensor Decompose into the first factor matrix , the second factor matrix , the third factor matrix , that is, the original traffic flow tensor Expressed as each factor matrix The multilinear combination of latent factors is expressed as follows: (18) In the formula, For tensors an element of , and is an index of three dimensions, is a global parameter used to approximate the overall mean of the tensor elements, , and is a factor matrix that controls the interactions between different dimensions, is the sequence number of the potential factor.
[0068] In order to deal with the non-convex optimization problem of tensor decomposition, this embodiment introduces the probability distribution of the variational Bayesian learning factor matrix, that is, optimizes its probability distribution through variational Bayesian learning. Specifically, first let the variational posterior parameter Gaussian distribution .
[0069] Secondly, in order to be able to use gradient descent for optimization, the first factor matrix is initialized using the reparameterization technique , the second factor matrix , the third factor matrix Weight , and : (19) In the formula, , , The first factor matrix is , the second factor matrix , the third factor matrix The weight of , , The first factor matrix is , the second factor matrix , the third factor matrix The corresponding global parameters, is the variational posterior parameter The standard deviation of It conforms to the Gaussian distribution. , , The first factor matrix is , the second factor matrix , the third factor matrix The corresponding random noise is , , All obey the normal distribution, that is , and is a random variable.
[0070] in, , to ensure that it is always non-negative.
[0071] In step S103, the temporal heterogeneity characterization matrix and the spatial heterogeneity characterization matrix are used as the constraints of the tensor decomposition model, that is, the spatial heterogeneity characterization result is used. as well as To constrain the tensor decomposition process, the loss function can be expressed as the sum of four parts: reconstruction error term, spatial heterogeneity representation constraint term, temporal heterogeneity representation constraint term and regularization term; among them, The reconstruction error term is the reconstruction error between the original traffic flow and the completed traffic flow; Spatial heterogeneity represents the constraint term, which is used to constrain the spatial relationship of traffic flow between different nodes. Its expression is: (20) In the formula, is the spatial heterogeneity representation matrix of the original traffic flow data; is the first factor matrix; Temporal heterogeneity is a constraint term used to constrain the temporal relationship of traffic flow between different nodes. Its expression is as follows: (twenty one) In the formula, is the temporal heterogeneity representation matrix of the original traffic flow data, , is the first factor matrix The index is ( )、( ), is the second factor matrix The index is ( ) elements; The expression of the regularization term is: (twenty two) The above reconstruction error term, spatial heterogeneity representation constraint term, temporal heterogeneity representation constraint term and regularization term are summed up, and the loss function is expressed as follows: (twenty three) In the formula, is the reconstruction error term, used to control The decomposition error, is the constraint term for spatial heterogeneity, and the control factor The decomposition error is used to constrain the spatial relationship of traffic flow between different nodes. is the constraint term representing the temporal heterogeneity, and the control factor The decomposition error is used to constrain the time relationship of traffic flow between different nodes. It is a regularization term to prevent the objective function from overfitting; , and To control the weight of the regularization term; is the completion result of each round.
[0072] Furthermore, the above process is implemented in pseudo code as follows:
[0073] In the above code implementation, the three factor matrices of traffic flow decomposition are first initialized , and ,Will and The mask data in the time and space dimensions are used as the input of the spatiotemporal encoding to obtain the spatiotemporal encoded data , , and (See code lines 1 to 6); then, and Execute the temporal heterogeneity representation module and obtain it through mask contrast learning based on reconstruction loss and The loss value , update the parameters of the temporal heterogeneity characterization module (see lines 7 to 13 of the code); then, and The spatial heterogeneity representation module is executed separately, and the mask contrast learning based on the reconstruction loss is also obtained and The loss value , and update the parameters of the spatial heterogeneity characterization module (see lines 14 to 19 of code); based on this, and It is embedded into the tensor decomposition model as a constraint to control the decomposition error of the objective function (see lines 20 to 24 of the code). The above process is iterated continuously to calculate the error between the completion value and the original tensor, and the loss value is back-propagated to each module of the spatiotemporal heterogeneity representation and factor matrix solution, thereby optimizing the spatiotemporal heterogeneity representation and tensor decomposition process (see lines 25 to 26 of the code).
[0074] In addition, in order to verify the performance of the model, experiments were conducted on a real urban road traffic dataset and compared with the most advanced baseline model. The results show that the method proposed in this embodiment can effectively characterize the spatiotemporal heterogeneity of road traffic flow data under different missing modes, and show high flow data completion accuracy and robustness.
[0075] In summary, the method proposed in this application combines self-supervised learning technology with tensor decomposition, effectively represents spatiotemporal heterogeneity through heterogeneity characterization matrix and spatial heterogeneity characterization matrix, and uses tensor decomposition guided by spatiotemporal heterogeneity to improve the accuracy of traffic flow data completion method.
[0076] By calculating the spatiotemporal heterogeneity representation through the spatiotemporal heterogeneity representation learning method of road traffic flow taking into account missing values, the model's ability to reconstruct the spatiotemporal heterogeneity of missing locations can be enhanced; the spatiotemporal heterogeneity representation results are used to constrain the spatiotemporal relationship of traffic flow, thereby enhancing the completion performance of road traffic flow data.
[0077] Based on the same inventive concept, this embodiment provides a heterogeneity-guided traffic flow completion system, which includes a mask encoding module, an embedding and position encoding module, a spatiotemporal heterogeneity characterization module, and a decomposition module. Among them: The mask encoding module is used to perform spatiotemporal decoupling mask encoding on the original traffic flow data to generate mask data. , the mask data includes time mask data and spatial mask data ; The original traffic flow data is traffic flow data with missing values, which is expressed as a tensor to obtain the original traffic flow tensor ; An embedding and position coding module, used to perform feature embedding and position coding on the original traffic flow data and the mask data respectively, to obtain a spatiotemporal coding result; wherein the spatiotemporal coding result includes the time and space coding results of the original traffic flow data and the mask data respectively; A spatiotemporal heterogeneity representation module, for generating a temporal heterogeneity representation matrix and a spatial heterogeneity representation matrix respectively based on the spatiotemporal encoding result and using a mask contrast learning method with reconstruction loss; A decomposition module is used to use the temporal heterogeneity representation matrix and the spatial heterogeneity representation matrix as constraints, and to complete the traffic flow data based on the tensor decomposition model to obtain the completed traffic flow. .
[0078] The heterogeneity-guided traffic flow completion system provided in this embodiment can implement the steps and processes of the heterogeneity-guided traffic flow completion method provided in any of the above embodiments and achieve the same technical effects, which will not be described in detail here.
[0079] The embodiments of the present application can be applied to Figure 3 Among the electronic devices shown, the electronic device can be but is not limited to mobile terminals such as mobile phones, tablet computers, handheld computers, personal digital assistants (PDAs), smart home devices such as smart TVs and smart cameras, wearable devices such as smart bracelets, smart watches, smart glasses, or other computer devices such as desktops, laptops, notebook computers, ultra-mobile personal computers (UMPCs), netbooks, smart screens, etc.
[0080] like Figure 3 As shown, the electronic device 200 may include one or more of the following components: a processor 201, a memory 203, a communication interface 202, and a communication bus 204. The memory 203 may be connected to the processor 201 via the bus 204. The bus may transmit data between the processor 201 and the memory 203. The bus may be divided into an address bus, a data bus, a control bus, and the like.
[0081] The processor 201 may include one or more processing cores, and the processor 201 may use various interfaces and lines to connect various parts of the entire electronic device 200, and execute various functions and process data of the electronic device 200 by running or executing instructions, programs, code sets or instruction sets stored in the memory 203, and calling data stored in the memory 203. Exemplarily, the processor 201 may include an application processor (application processor, AP), a modem processor, a CPU, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a video codec, a digital signal processor (digital signal processor, DSP), a field programmable gate array (field-programmable gate array, FPGA), a programmable logic array (programmable logic array, PLA) and / or a neural network processor (neural-network processing unit, NPU), etc. Among them, the CPU mainly processes the operating system, user interface and application programs, etc.; the GPU is responsible for rendering and drawing the content to be displayed; the NPU is used to implement artificial intelligence (artificial intelligence, AI) functions; and the modem is used to process wireless communications. Different processing units may be independent devices or integrated into one or more processors. For example, the multiple processing units shown above are integrated into one SoC, or the AP is a separate semiconductor chip and other processing units are integrated into one SoC, which is not limited in this application.
[0082] The memory 203 may include a random access memory (RAM), a read-only memory (ROM), and a non-transitory computer-readable storage medium. The memory 203 may be used to store instructions, programs, codes, code sets, or instruction sets. The memory 203 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function, such as a heterogeneity-guided traffic flow completion method, etc.; the data storage area may store data created according to the use of the electronic device 200, such as road traffic flow data, model output intermediate results, etc.
[0083] In addition, those skilled in the art can understand that the structure of the electronic device 200 shown in the above drawings does not constitute a limitation on the electronic device 200, and the electronic device may include more or fewer components than shown in the drawings, or combine certain components, or arrange the components differently. For example, the electronic device 200 also includes components such as a microphone, a speaker, a radio frequency circuit, a sensor, an audio circuit, a power supply, and a Bluetooth module, which will not be described in detail here.
[0084] The present application also provides a computer program product, which includes computer executable instructions. In one embodiment, the computer executable instructions are used to enable a computer to execute the functions of the above method embodiment.
[0085] The computer executable instructions may be stored in a computer readable storage medium. The present application also provides a computer readable storage medium, wherein the computer readable storage medium stores the executable instructions. In one embodiment, the computer executable instructions are used to enable a computer to execute the functions in the above method embodiment.
[0086] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A heterogeneity-guided traffic flow completion method, characterized in that: The following steps are involved: Perform spatiotemporal decoupling mask encoding on the original traffic flow data to generate mask data , the mask data includes time mask data and spatial mask data ; The original traffic flow data is traffic flow data with missing values, which is expressed as a tensor to obtain the original traffic flow tensor ; Performing feature embedding and position encoding on the original traffic flow data and the mask data respectively to obtain a spatiotemporal encoding result; wherein the spatiotemporal encoding result includes the time and space encoding results of the original traffic flow data and the time and space encoding results of the mask data; Based on the spatiotemporal encoding result, a mask contrast learning method with reconstruction loss is used to generate a temporal heterogeneity representation matrix and a spatial heterogeneity representation matrix respectively; The time heterogeneity characterization matrix and the space heterogeneity characterization matrix are used as constraints, and the traffic flow data is completed based on the tensor decomposition model to obtain the completed traffic flow. .
2. The method according to claim 1, characterized in that: Perform spatiotemporal decoupling mask encoding on the original traffic flow data to generate mask data ,include: According to the original traffic flow tensor , along the time dimension and the space dimension respectively according to the mask rate Randomly generate time mask tensors and the spatial mask tensor ; The original traffic flow tensor With the time mask tensor , spatial mask tensor Perform element multiplication operations respectively to obtain the mask data .
3. The method according to claim 1, characterized in that The original traffic flow data and the mask data are respectively subjected to feature embedding and position encoding to obtain a spatiotemporal encoding result, which is specifically: Using a combination of block embedding technology and a fully connected layer to generate high-dimensional embedding features of the original traffic flow data and the mask data respectively; The sinusoidal position coding technique is used to generate the spatiotemporal position coding of the original traffic flow data and the mask data respectively; The high-dimensional embedding features of the original traffic flow data and the mask data are element-wise multiplied with the spatiotemporal position codes of the original traffic flow data and the mask data, and then input into the Transformer to obtain the spatiotemporal coding result.
4. The method according to claim 1, characterized in that: Based on the spatiotemporal coding result, a mask contrast learning method with reconstruction loss is used to generate a temporal heterogeneity representation matrix and a spatial heterogeneity representation matrix, respectively, including: The time encoding results of the original traffic flow data and the mask data are respectively subjected to mean and dimension conversion operations to extract the average feature representation of each time step of the original traffic flow data and the mask data. , ; Introducing the first parameter matrix , the second parameter matrix , and the first parameter matrix , the second parameter matrix The average feature values of the original traffic flow data and the mask data are shown in Figure 2. , A multiplication operation is performed on each time dimension to obtain the temporal heterogeneity characterization results of the original traffic flow data and the mask data. , ; calculate and The contrast loss is obtained by ; In the embedding dimension, the spatial encoding results of the original traffic flow data and the mask data are respectively averaged to extract the average feature representation of the original traffic flow data and the mask data at each node position. , ; Introducing the third parameter matrix , the fourth parameter matrix , and the third parameter matrix , the fourth parameter matrix The average feature representation of the original traffic flow data and the mask data at each node position is , Perform multiplication to obtain spatial heterogeneity characterization results , ; calculate and The contrast loss is obtained, and the second loss is obtained ; By iteratively optimizing the first loss The second loss , to generate the final temporal heterogeneity representation matrix , and spatial heterogeneity characterization matrix , .
5. The method according to claim 1, characterized in that The tensor decomposition model is a CP decomposition model, which uses the CP decomposition model to decompose the original traffic flow tensor into a first factor matrix , the second factor matrix , the third factor matrix , and optimize its probability distribution through variational Bayesian learning.
6. The method according to claim 5, characterized in that The loss function of the CP decomposition model is the sum of the following four parts: reconstruction error term, spatial heterogeneity representation constraint term, temporal heterogeneity representation constraint term and regularization term; The reconstruction error term is the reconstruction error between the original traffic flow and the completed traffic flow; The spatial heterogeneity characterization constraint term is used to constrain the spatial relationship of traffic flow between different nodes, and its expression is: , In the formula, is a spatial heterogeneity representation matrix of the original traffic flow data; is the first factor matrix; The temporal heterogeneity characterization constraint term is used to constrain the temporal relationship of traffic flow between different nodes, and its expression is as follows: , In the formula, is the temporal heterogeneity characterization matrix of the original traffic flow data, , is the first factor matrix The index is ( )、( ), is the second factor matrix The index is ( ) elements; The expression of the regularization term is: .
7. The method according to claim 5, characterized in that The first factor matrix , the second factor matrix , the third factor matrix The weights of are initialized using the reparameterization technique, specifically: , , , In the formula, , , The first factor matrix is , the second factor matrix , the third factor matrix The weight of , , The first factor matrix is , the second factor matrix , the third factor matrix The corresponding global parameters, is the variational posterior parameter The standard deviation of It conforms to the Gaussian distribution. , , The first factor matrix is , the second factor matrix , the third factor matrix The corresponding random noise is , , All obey normal distribution.
8. A heterogeneity-guided traffic flow completion system, characterized in that: include: The mask encoding module is used to perform spatiotemporal decoupling mask encoding on the original traffic flow data to generate mask data. , the mask data includes time mask data and spatial mask data ; The original traffic flow data is traffic flow data with missing values, which is expressed as a tensor to obtain the original traffic flow tensor ; An embedding and position coding module, used to perform feature embedding and position coding on the original traffic flow data and the mask data respectively, to obtain a spatiotemporal coding result; wherein the spatiotemporal coding result includes the time and space coding results of the original traffic flow data and the mask data respectively; A spatiotemporal heterogeneity representation module, for generating a temporal heterogeneity representation matrix and a spatial heterogeneity representation matrix respectively based on the spatiotemporal encoding result and using a mask contrast learning method with reconstruction loss; A decomposition module is used to use the temporal heterogeneity representation matrix and the spatial heterogeneity representation matrix as constraints, and to complete the traffic flow data based on the tensor decomposition model to obtain the completed traffic flow. .
9. An electronic device, characterized in that: include: a memory for storing instructions executed by one or more processors of the electronic device; The processor, when the processor executes the instructions in the memory, can enable the electronic device to implement the steps of the heterogeneity-guided traffic flow completion method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, which, when executed on a computer, implement the steps of the heterogeneity-guided traffic flow completion method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Traffic data tensor completion method based on space-time constraint
CN115630211A
Anti-missing city spatio-temporal data prediction method and device
CN117520468A
Traffic data completion method based on sequence attention mechanism and electronic equipment
CN117786330A
Traffic prediction method and system based on self-supervised learning
CN118277815A
Graph contrast learning network node classification method and device based on denoising and mask reconstruction, and medium
CN118470411A
Cited By
Precision improvement method for data completion of intelligent electric meter
CN120929732A
Methods to improve the accuracy of smart meter data completion
CN120929732B
Multi-view video compression method
CN121357323A
A multi-view video compression method
CN121357323B