Trajectory generation method based on diffusion model
Through the trajectory generation method based on the diffusion model, the problem that the existing technology is difficult to characterize the multi-scale characteristics of complex urban mobile behavior is solved, and high-quality and diverse trajectory data is generated, which improves the availability and diversity of data.
Patent Information
- Application Number
- CN202510198510.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-23
- Publication Date
- 2025-06-10
AI Technical Summary
The existing trajectory generation methods are difficult to effectively characterize the multi-scale characteristics of complex urban mobility behavior, resulting in insufficient availability and diversity of generated trajectory data.
Using the trajectory generation method based on the diffusion model, the four stages of data preparation, forward and backward processes of the diffusion model, and trajectory generation, the trajectory condition input method and the loss function required for the training of the new noise prediction network are designed to improve the noise prediction performance, thereby generating high-quality and diverse trajectory data.
The generated trajectory data is realized to better maintain the original trajectory data characteristics, have higher data availability and diversity, and is suitable for research and application in related fields.
Smart Images

Figure CN120123770A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data generation, and more specifically, to a trajectory generation method based on a diffusion model. Background Art
[0002] As an important information resource in the field of urban science, trajectory data has key application values in aspects such as the construction of intelligent transportation systems, the optimization of public spaces, and the analysis of residents' behaviors. By recording the spatio-temporal characteristics of moving objects, trajectory data can reveal the laws of group behaviors and the dynamic mechanisms of cities, providing decision-making support for modern urban governance. However, trajectory data contains sensitive characteristics such as permanent addresses and medical visit trajectories, making its open sharing face severe privacy compliance challenges, resulting in the current scarcity of available trajectory datasets in the academic and industrial communities.
[0003] To address this issue, trajectory generation technology has emerged, and its core goal is to construct a synthetic trajectory dataset that can both maintain data utility and meet privacy protection requirements. Early research methods mostly adopted technical paths based on rule-based modeling, such as simulating the probability of moving state transitions through Markov chains. Although such methods can achieve basic pattern reproduction, they have significant limitations in depicting the multi-scale characteristics of complex urban moving behaviors and are difficult to meet the requirements of generating high-fidelity data.
[0004] In recent years, some researchers have used deep learning generation models such as generative adversarial networks (GANs), recurrent neural networks (RNNs), and variational autoencoders (VAEs) to achieve trajectory generation. Although these methods have made certain progress in trajectory generation, there is still room for improvement in terms of the availability and diversity of trajectory data. The diffusion model, which has emerged in the field of deep learning in recent years, has shown excellent performance in the modeling and generation of continuous-mode data such as images, audio, and video, generating high-quality and diverse samples. Currently, there is relatively little research and limited application of the diffusion model in discrete time series fields such as trajectories, and it is very difficult to directly use the diffusion model to learn the high-dimensional and complex spatio-temporal characteristics of trajectory data. Therefore, a new trajectory generation method is needed to generate a trajectory dataset with higher practicality and better diversity to provide data support for research and applications in related fields.
[0005] In addition, Chinese patent documents with patent application numbers CN202411403485.9, titled "A Method for Generating GPS Trajectories Based on a Distributed Parallel Inference Diffusion Model"; CN202411249233.5, titled "Trajectory Processing Method and Device Based on Diffusion Model"; CN202410907531.2, titled "Autonomous Driving Vehicle Trajectory Generation Method and System Based on Adaptive Segment Division and Data Evolution of Diffusion Model"; CN202410475811.0, titled "Vehicle Trajectory Generation Method and Device Based on Diffusion Model and Lightweight Federated Learning"; and CN202410318803.5, titled "A Road Network Constraint Trajectory Generation Method and System Based on Diffusion Model" also involve trajectory generation methods based on diffusion models, but they are different from the method adopted in this patent application. Summary of the Invention
[0006]
Purpose of the Invention
[0007] A trajectory generation method based on a diffusion model is proposed. This method includes four stages: data preparation, the forward process of the diffusion model, the backward process of the diffusion model, and trajectory generation. The forward process of the diffusion model is used to inject noise into the input original trajectory to convert the original trajectory distribution into a specified noise distribution; the purpose of the backward process of the diffusion model is to restore the noise distribution back to the original trajectory distribution. This process realizes the prediction of noise by training a noise prediction network, and then removes the noise. By designing a trajectory-conditioned input method for the noise prediction network and combining the trajectory pattern to design a new loss function required for training the noise prediction network, the present invention improves the noise prediction performance, and thus the generated trajectory can not only better maintain the characteristics of the original trajectory data, have good data availability, but also have good diversity. It is a practical method for enhancing trajectory data.
[0008]
Technical Solution
[0009] To achieve the above object, the present invention provides a trajectory generation method based on a diffusion model, including the following steps:
[0010] (1) Data preparation;
[0011] Construct a trajectory dataset, a trajectory pattern dataset, and a trajectory condition dataset for training the noise prediction network from the original trajectory dataset.
[0012] (2) The forward process of the diffusion model;
[0013] Randomly select a time step t for each trajectory in the trajectory dataset, and inject t times of noise into it to obtain a noisy trajectory.
[0014] (3) Backward process of the diffusion model;
[0015] The backward process of the diffusion model is a denoising process. By constructing a noise prediction network, the noise for the noisy trajectory is predicted and removed t times to obtain the generated trajectory.
[0016] (4) Trajectory generation;
[0017] Using the noise prediction network trained in step (3), with random noise, time steps, and conditional information as inputs, a trajectory is generated.
[0018]
Beneficial effects
[0019] A trajectory generation method based on a diffusion model is proposed. By designing a trajectory conditional input method for the noise prediction network and combining the trajectory pattern to design a new loss function required for training the noise prediction network, the noise prediction performance is improved, so that the generated trajectory has better data availability and diversity, which is a practical method for enhancing trajectory data. Compared with other trajectory generation methods based on deep learning, the present invention has the following advantages:
[0020] 1. The present invention generates trajectories based on a diffusion model, and the training process of the noise prediction network is more stable, which can more accurately describe the characteristics of the trajectory dataset and has better data generation quality;
[0021] 2. The present invention designs a trajectory conditional input method for the noise prediction network and combines the trajectory pattern to design a new loss function required for training the noise prediction network, which can further improve the availability and diversity of the generated trajectory data. Description of the drawings
[0022] Figure 1 Flowchart of the trajectory generation method based on a diffusion model.
[0023] Figure 2 Structure diagram of the noise prediction network.
[0024] Figure 3 Flowchart of calculating the total loss in the training process of the noise prediction network.
[0025] Figure 4 Structure diagram of the main components of the noise prediction network.
[0026] Figure 5 x t to x t-1 Denoising process diagram. Detailed implementation manners
[0027] The technical solution of the present invention will be further described below in conjunction with the drawings and examples:
[0028] As Figure 1As shown in the figure, the flowchart of the trajectory generation method based on the diffusion model of the present invention is as follows:
[0029] (1) Data preparation;
[0030] Construct a trajectory dataset, a trajectory pattern dataset, and a trajectory condition dataset for training the noise prediction network from the original trajectory dataset. The specific steps are as follows:
[0031] S1: Prepare the trajectory dataset. Assume that the trajectory dataset X = {x i ∣i = 0, 1,..., |X| - 1} consists of |X| trajectories, where |X| represents the number of trajectories in the trajectory dataset X, is the i-th trajectory of the trajectory dataset X, and l i represents the number of trajectory points of the trajectory x i , is the j-th trajectory point of x i , and are the longitude and latitude of the trajectory point respectively.
[0032] S2: Construct the trajectory pattern dataset. According to the spatial range of the trajectory dataset X, calculate the spatial grid for each trajectory point to obtain the grid trajectory, and record the grid trajectory as its pattern, thereby obtaining the trajectory pattern dataset. Assume that R is the spatial range of the trajectory dataset X, and R is defined by the longitude range (left, right) and the latitude range (bottom, top). left is the minimum longitude of R, right is the maximum longitude of R, bottom is the minimum latitude of R, and top is the maximum latitude of R. Divide the longitude range of the spatial range R into u w segments, and divide the latitude range into u h segments, for a total of u w ×u h spatial grids. Denote the spatial grid set as Cell = {cell i ∣i = 0, 1,..., u h ×u w - 1}, where cell i (cell i .row, cell i .column) is the i-th grid of the spatial range R, and cell i .row and cell i .column represent the row number and column number of cell i respectively. Assume that the spatial grid corresponding to the trajectory point i of the trajectory x is Represent respectively The row number and column number of The calculation method of
[0033]
[0034] Denote the trajectory x i The pattern of as Denote the trajectory pattern dataset as Pattern = {pattern i ∣i = 0, 1,..., |X| - 1}.
[0035] S3: Construct the trajectory condition dataset. Calculate the trajectory condition information for each trajectory, and then construct the trajectory condition dataset. The condition information of each trajectory includes the starting point, ending point, and standardized trajectory length of the trajectory. Denote the condition information corresponding to the trajectory x i as where is the starting point of x i , is the ending point of x i , len i is the standardized trajectory length, and the calculation method of len i is as follows:
[0036]
[0037] where, l i is the trajectory length of the trajectory x i (i.e., the number of trajectory points), μ length is the mean of the trajectory lengths of all trajectories in X, and σ length is the standard deviation of the trajectory lengths of all trajectories in X. Denote the condition information dataset as Attr = {h i ∣i = 0, 1,..., |x| - 1}.
[0038] (2) The forward process of the diffusion model;
[0039] Randomly select a time step t for each trajectory in the trajectory dataset, and inject t times of noise into it to obtain the noisy trajectory.
[0040] Denote the initial state of the trajectory x i as (i.e., ), and after injecting t times of noise into it, the obtained noisy trajectory The calculation formula of is:
[0041]
[0042] where, is a manually set hyperparameter, and ∈ represents random noise that follows a Gaussian distribution.
[0043] (3) The backward process of the diffusion model;
[0044] The backward process of the diffusion model is a denoising process. By constructing a noise prediction network, the noisy trajectory is predicted and then t times the noise is removed to obtain the generated trajectory.
[0045] like Figure 2 As shown in Figure 1, the present invention uses UNet as the backbone to construct a noise prediction network. The UNet network consists of three downsampling modules, one intermediate module and three upsampling modules. The input of the noise prediction network is the noisy trajectory. Time step t and condition information h i , the output is the predicted noise ∈ θ , The vector processed by the input module is related to the time step t and the condition information h i The values obtained by adding the time step embedding module and the conditional embedding module are used as the input of the UNet network, and then the output of the UNet network is obtained by the output module to obtain the noise ∈ added to the trajectory when the time step is t θ .
[0046] like Figure 3 As shown, the noise prediction network calculates the noise loss function and trajectory mode loss function Optimize its parameters, The calculation formula is as follows:
[0047]
[0048] Among them, p(x) represents the distribution of the original trajectory, represents Gaussian noise distribution, ∈ θ (·) is the noise prediction network, θ is the parameter of the network, Right now The noisy trajectory and time step t is input to the denoising network ∈ θ (·) The noise vector predicted after The actual noise ∈ added and the noise prediction network ∈ θ (·) Mean squared error between the predicted and the noise.
[0049] The calculation method of is: in each training round, the noisy trajectory Time step t and condition information h i As input, use the current noise prediction network to predict the noise added at each time step, estimating Initial state And calculate its trajectory pattern using the method in step (1). Furthermore, combine with the true trajectory pattern pattern i Calculate Its calculation formula is:[[]]
[0050]
[0051] Among them, q(x) represents the distribution of the original trajectory pattern. Using the noise loss function and the trajectory pattern loss function Calculate the total loss function That is:[[]]
[0052]
[0053] The training objective of the noise prediction network is to update the parameters θ of the noise prediction network ∈ θ (·) using the gradient descent method, so that the total loss function obtained by training has as small a value as possible.
[0054] The main component structure of the noise prediction network is as Figure 4 shown. The input of the input module is the noisy trajectory The module consists of a group normalization layer, SiLU, and a convolutional layer, and the output is a vector The input of the time step embedding module is the time step t, and this module consists of a linear layer, SiLU, and a linear layer, and the output is a vector t emb ; The input of the conditional embedding module is the conditional information h i , the vector obtained by processing the start point and the end point through the embedding layer, linear layer, ReLU layer and linear layer and the vector obtained by processing the number of trajectory points through the linear layer are added together to obtain the output vector The downsampling module consists of a residual block, a Transformer, and a downsampling layer; the input of the residual block is the vector vector t emb and the vector sum (denote this vector as ), in the residual block, the output of the vector after passing through the group normalization layer, SiLU and convolutional layer is added to the output of the vector after passing through the embedding layer, linear layer, ReLU layer, and the resulting vector, after passing through the group normalization layer, SiLU layer and convolutional layer, is combined with the vector Add them to obtain the output of the residual block, which is the input of the Transformer; the input of the middle module is the output of the last downsampling module. The middle module consists of residual blocks, a Transformer, and residual blocks, and its output is the input of the upsampling module. The structure of the upsampling module is the same as that of the downsampling module; the structure of the output module is the same as that of the input module, and the output is the predicted noise ∈ θ .
[0055] For example: a noisy trajectory with a length of 120 and a dimension of 2 Pass through the input module to obtain a vector with a length of 120 and a dimension of 128 The time step t with a dimension of 1 is input into the time embedding module to obtain a vector t with a dimension of 512 emb , and the trajectory conditional information h with a dimension of 3 i After being processed by the conditional embedding module, a vector with a dimension of 512 is output Vector t emb Is added to the vector To obtain a vector with a dimension of 512 Vector And the vector Are jointly input into the downsampling module. After passing through three downsampling modules, a vector with a length of 15 and a dimension of 256 is obtained; this vector then passes through the middle module to obtain a vector with a length of 15 and a dimension of 256; then, after 3 upsampling processes, a vector with a length of 120 and a dimension of 128 is obtained; finally, through the output module, the predicted noise ∈ with a length of 120 and a dimension of 2 is obtained θ .
[0056] (4) Trajectory generation;
[0057] Use the noise prediction network trained in step (3), with random noise, time step, and conditional information as inputs, to generate a trajectory
[0058] Denote the trajectory to be generated as x 0 , and its corresponding conditional information as h. Assume that after adding noise t times to x 0 , the noisy trajectory x t Is obtained. As Figure 5 Shown, the process of trajectory generation is the process of removing noise t times from the noisy trajectory x t . The specific method is: regard the random noise that satisfies the Gaussian distribution as the noisy trajectory x t , and based on the time step t and the input conditional information h, predict the noise ∈ θ ′ through the noise prediction network, and subtract ∈ t ′ from x θ To obtain x t-1 , and repeat this process t times. Finally, the generated trajectory x 0。
Claims
1. A trajectory generation method based on a diffusion model, characterized in that: (1) Data preparation; Constructing a trajectory dataset, a trajectory pattern dataset and a trajectory condition dataset for training a noise prediction network from the original trajectory dataset; (2) Forward process of diffusion model; Randomly select a time step t for each trajectory in the trajectory dataset, inject noise into it t times to obtain a noisy trajectory; (3) The backward process of the diffusion model; The backward process of the diffusion model is a denoising process, which constructs a noise prediction network to predict the noisy trajectory and then removes the t-fold noise to obtain the generated trajectory; (4) Trajectory generation; Using the noise prediction network trained in step (3), the trajectory is generated with random noise, time step and condition information as input.
2. The trajectory generation method based on the diffusion model according to claim 1, characterized in that: Constructing a trajectory dataset, a trajectory pattern dataset and a trajectory condition dataset for training a noise prediction network from the original trajectory dataset; The specific steps are: S1: Prepare trajectory dataset; Assume that trajectory dataset X = {x i |i=0,1,...,|X|-1} consists of |X| trajectories, where |X| represents the number of trajectories in the trajectory dataset X. is the ith trajectory of the trajectory dataset X, l i Represents the trajectory x i The number of trajectory points, For x i The jth trajectory point of Track points longitude and latitude; S2: Construct a trajectory pattern dataset; according to the spatial range of the trajectory dataset X, calculate the spatial grid for each trajectory point to obtain the grid trajectory, record the grid trajectory as its pattern, and then obtain the trajectory pattern dataset; assume that R is the spatial range of the trajectory dataset X, R is limited by the longitude range (left, right) and latitude range (bottom, top), left is the minimum longitude of R, right is the maximum longitude of R, bottom is the minimum latitude of R, and top is the maximum latitude of R; divide the longitude range of the spatial range R into u w The latitude range is divided into u h segments, divided into u w ×u h Space grids, the space grid set is recorded as Cell = {cell i |i=0,1,...,u h ×u w -1}, where cell i (cell i .row,cell i .column) is the i-th grid of the spatial range R, cell i .row, cell i .column represents cell i The row and column numbers of i The trajectory point The corresponding spatial grid is Respectively The row and column numbers of The calculation method is as follows: The trajectory x i The mode is represented by The trajectory pattern dataset is recorded as Pattern = {pattern i |i=0,1,...,|X|-1}; S3: Construct trajectory condition data set; calculate the trajectory condition information for each trajectory, and then construct the trajectory condition data set; the condition information of each trajectory includes the starting point, end point and standardized trajectory length of the trajectory; i The corresponding condition information is recorded as in For x i The starting point, For x i The end point, len i is the normalized trajectory length, len i The calculation method is as follows: Among them, l i is the trajectory x i The trajectory length (i.e. the number of trajectory points), μ length is the mean of the trajectory lengths of all trajectories in X, σ length is the standard deviation of the trajectory lengths of all trajectories in X; the conditional information dataset is recorded as Attr = {h i |i=0,1,...,|X|-1}.
3. The trajectory generation method based on the diffusion model according to claim 1, characterized in that: For each trajectory in the trajectory dataset, a time step t is randomly selected and noise is injected into it t times to obtain a noisy trajectory; the trajectory x i The initial state is recorded as (Right now ), injecting noise into it t times to obtain the noisy trajectory The calculation formula is: in, is a manually set hyperparameter, and ∈ represents random noise that follows a Gaussian distribution.
4. The trajectory generation method based on the diffusion model according to claim 1, characterized in that: The backward process of the diffusion model is the denoising process. By constructing a noise prediction network, the noisy trajectory is predicted and then the t-time noise is removed to obtain the generated trajectory. The noise prediction network is constructed using UNet as the backbone. The UNet network consists of three downsampling modules, one intermediate module and three upsampling modules. The input of the noise prediction network is the noisy trajectory. Condition Information i and time step t, the output is the predicted noise ∈ θ , x t The value and condition information after being processed by the input module h i The values obtained by adding the conditional embedding module and the time step embedding module after processing at time step t are used as the input of the UNet network, and then the output of the UNet network is obtained by the output module to obtain the noise ∈ added to the trajectory when the time step is t θ .
5. The trajectory generation method based on the diffusion model according to claim 1, characterized in that: The backward process of the diffusion model is the denoising process. By constructing a noise prediction network, the noisy trajectory is predicted and then t times the noise is removed to obtain the generated trajectory. The noise prediction network calculates the noise loss function and trajectory mode loss function Optimize its parameters, The calculation formula is as follows: Among them, p(x) represents the distribution of the original trajectory, represents Gaussian noise distribution, ∈ θ (·) is the noise prediction network, θ is the parameter of the network, Right now The noisy trajectory and time step t is input to the denoising network ∈ θ (·) The noise vector predicted after The actual noise ∈ added and the noise prediction network ∈ θ (·) Mean square error between the predicted and noise; The calculation method of is: in each training round, the noisy trajectory Time step t and condition information h i As input, use the current noise prediction network to predict the noise added at each time step, estimating Initial state And use the method in step (1) to calculate its trajectory pattern Combined with True Track Mode calculate The calculation formula is: Among them, q(x) represents the distribution of the original trajectory pattern; using the noise loss function With trajectory mode loss function Calculate the total loss function Right now: The training goal of the noise prediction network is to use the gradient descent method to update the noise prediction network ∈ θ The parameter θ of (·) makes the total loss function obtained by training The value of should be as small as possible.
6. The trajectory generation method based on the diffusion model according to claim 1, characterized in that: The backward process of the diffusion model is a denoising process. By constructing a noise prediction network, the noisy trajectory is predicted and then the t-time noise is removed to obtain the generated trajectory. The main component structure of the noise prediction network is as follows: the input module input is the noisy trajectory The module consists of a group normalization layer, SiLU, and a convolutional layer, and the output is a vector The input of the time step embedding module is the time step t. The module consists of a linear layer, a SiLU, and a linear layer, and the output is a vector t emb ; The input of the conditional embedding module is the conditional information h i The output vector is obtained by adding the vectors obtained after the starting point and the end point are processed by the embedding layer, the linear layer, the ReLU layer, and the linear layer and the vector obtained after the trajectory points are processed by the linear layer. The downsampling module consists of a residual block, a Transformer, and a downsampling layer; the input of the residual block is a vector Vector t emb With vector The sum of (remember this vector as ), in the residual block, the vector Output and vector after group normalization layer, SiLU and convolution layer After the outputs of the embedding layer, linear layer, and ReLU layer are added, the resulting vector is passed through the group normalization layer, SiLU layer, and convolution layer, and then added to the vector Add them together to get the output of the residual block, which is the input of the Transformer. The input of the intermediate module is the output of the last downsampling module. The intermediate module consists of a residual block, a Transformer, and a residual block. The output is the input of the upsampling module. The structure of the upsampling module is the same as that of the downsampling module. The structure of the output module is the same as that of the input module, and the output is the predicted noise ∈ θ .
7. The trajectory generation method based on the diffusion model according to claim 1, characterized in that: Using the noise prediction network trained in step (3), random noise, time step and condition information are used as input to generate a trajectory; the trajectory to be generated is recorded as x0, and its corresponding condition information is recorded as h. Assuming that after adding t times of noise to x0, the noisy trajectory x t ; As shown in Figure 4, the process of trajectory generation is from the noisy trajectory x t The process of removing t noises in the above example is as follows: the random noises satisfying the Gaussian distribution are regarded as the noisy trajectory x t , according to the time step t and the input condition information h, the noise prediction network predicts the noise ∈ θ ′, from x t Subtract ∈ θ ′Get x t-1 , repeat this process t times, and finally get the generated trajectory x0.
Citation Information
Patent Citations
Road network constraint trajectory generation method and system based on diffusion model
CN118070673A
Vehicle track generation method and device based on diffusion model and lightweight federated learning
CN118379876A
Trajectory processing method and device based on diffusion model
CN118760731B
Autonomous driving vehicle trajectory generation method and system based on adaptive segmentation and data evolution of diffusion model
CN118886303B
Method for generating GPS track based on distributed parallel reasoning diffusion model
CN119224804A
Cited By
A trajectory generation method and related device for arbitrary spatiotemporal point constraints
CN122507813A