Methods, systems, and media for journey trajectory reconstruction based on variable-length self-attention mechanisms

The travel trajectory reconstruction method based on variable length self-attention mechanism, utilizing a transformer pre-trained model and the DTW algorithm, solves the problem of dirty data in vehicle trajectory data, achieves high-precision trajectory reconstruction, reduces data annotation costs, and improves model convergence.

CN116091924BActive Publication Date: 2026-05-26北京宏瓴科技发展有限公司

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
北京宏瓴科技发展有限公司
Filing Date
2022-12-31
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing technologies suffer from dirty data problems when processing vehicle trajectory data, such as inaccurate positioning points, outliers, lost trajectory points, or transmission failures. This causes the travel trajectory to deviate from the actual situation and makes it impossible to accurately reconstruct real driving behavior.

Method used

A trajectory reconstruction method based on variable-length self-attention mechanism is adopted. By using a transformer pre-trained model and the DTW algorithm, combined with self-supervised learning and convolutional layer processing, abnormal data is removed and trajectory points are reconstructed.

Benefits of technology

While reducing the cost of data annotation, it improves the accuracy of trajectory reconstruction and the convergence of the model, and enhances the trajectory reconstruction capability under limited computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116091924B_ABST
    Figure CN116091924B_ABST
Patent Text Reader

Abstract

This invention relates to the field of artificial intelligence technology, specifically providing a method, apparatus, system, and medium for reconstructing travel trajectories based on a variable-length self-attention mechanism, aiming to solve the problem of how to reconstruct travel trajectories. To this end, the present invention provides a method for reconstructing travel trajectories based on a variable-length self-attention mechanism, comprising: acquiring raw travel data of a vehicle trajectory, each journey including several travel points; inputting the travel data into a transformer pre-trained model for training, wherein during training, the state output by the current travel point and the previous travel point is concatenated and then fed into a convolutional layer, and the difference in travel point reconstruction is evaluated using the DTW algorithm; until the transformer pre-trained model converges, the reconstructed travel trajectories are output.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to artificial intelligence technology, specifically providing a method, apparatus, system, and medium for reconstructing travel trajectories based on a variable-length self-attention mechanism. Background Technology

[0002] With the widespread installation of GPS satellite positioning devices on vehicles, it has become possible to study driving behavior patterns using trajectory data recorded during operation. During operation, GPS devices record spatial location (latitude and longitude), time, speed, and other data at a constant sampling rate. Compared to traditional small-scale, single-point data collection and analysis, massive GPS trajectory data offers several advantages in studying driving safety during vehicle operation. However, analyzing and processing such large-scale trajectory data in a spatiotemporal environment without additional information remains a significant challenge. In related technologies, vehicle trajectories often contain inaccurate positioning points, outliers, trajectory points outside the road area, lost trajectory points, or transmission failures—dirty or abnormal data—causing the trajectory to deviate from reality and hindering accurate driving behavior research. Reconstructing the true trajectory remains a difficult problem. Summary of the Invention

[0003] To overcome the above-mentioned shortcomings, the present invention is proposed to provide a method, apparatus, system and medium for reconstructing travel trajectories based on a variable-length self-attention mechanism, which solves or at least partially solves the technical problem of how to reconstruct travel trajectories.

[0004] In a first aspect, the present invention provides a method for reconstructing travel trajectories based on a variable-length self-attention mechanism, comprising:

[0005] Obtain the raw travel data of the vehicle trajectory, each travel segment including several travel points;

[0006] The travel data is input into the transformer pre-trained model for training. During the training process, the state output of the current travel point and the previous travel point is concatenated and then entered into the convolutional layer. The difference in travel point reconstruction is evaluated by the DTW algorithm.

[0007] The process continues until the transformer pre-trained model converges, at which point the restored trajectory is output.

[0008] In one technical solution of the above-mentioned travel trajectory reconstruction method,

[0009] The acquisition of the vehicle trajectory raw travel data includes:

[0010] Obtain the source data stream of the vehicle trajectory;

[0011] The source data stream is segmented into trip data to obtain several original trip data, wherein each trip includes multiple GPS points, and the multiple GPS points are sorted according to the acquisition time to form a GPS point sequence;

[0012] The GPS points within the trip are divided into several trip point segments.

[0013] In one technical solution of the above-mentioned travel trajectory reconstruction method,

[0014] The method further includes: performing trip segmentation on the source data stream and removing trips where the GPS points exceed a threshold.

[0015] In one technical solution of the above-mentioned travel trajectory reconstruction method,

[0016] The step of inputting the travel data into the transformer pre-trained model for training includes:

[0017] The input itinerary data is randomly labeled and replaced to obtain the processed itinerary data;

[0018] Randomly select travel data and arrange them from longest to shortest to divide them into several travel points;

[0019] The travel points are input into each layer of the pre-trained transformer model, and the output is obtained through forward propagation.

[0020] The output results are evaluated using the DTW algorithm to assess the differences in travel point reconstruction.

[0021] The travel point reconstruction difference and trajectory MSE are linearly combined to calculate the loss of the marked travel data, and then backpropagation is used for training.

[0022] In one technical solution of the above-mentioned travel trajectory reconstruction method,

[0023] The process of randomly labeling and replacing the input trip data to obtain processed trip data includes:

[0024] Randomly select and label a portion of the input travel data;

[0025] The data in the labeled data will be partially replaced with 0, another part of the data will be replaced with the mean of the trip, and the rest of the data will remain unchanged.

[0026] In one technical solution of the above-mentioned travel trajectory reconstruction method,

[0027] The travel points are input into each layer of the transformer pre-trained model, and the output results are obtained through forward propagation, including:

[0028] For each trip, take the nth trip point from the beginning and calculate the query for the self-attention of each trip;

[0029] For each process, the nth segment point is taken from the beginning and concatenated with the state output of the (n-1)th segment. Then, a one-dimensional convolution is performed. The convolution result is used to calculate the key and value of the self-attention.

[0030] The self-supervised network is computed using query, key, and value. The result of each layer of self-supervision is stored as state and passed to the next layer until the final layer of the model outputs the result.

[0031] In one technical solution of the above-mentioned travel trajectory reconstruction method,

[0032] The travel point reconstruction difference and trajectory MSE are linearly combined to calculate the loss of the labeled travel data, and backpropagation is used for training, including:

[0033] The trajectory MSE calculates the mean square error between the original travel data points and the output data points.

[0034] The DTW algorithm evaluates the differences in travel point reconstruction by calculating the similarity between the original travel and the reconstructed travel.

[0035] The mean squared error and the similarity are added together with fixed weights to form a loss function, and training is performed through backpropagation.

[0036] In a second aspect, the present invention provides a travel trajectory reconstruction apparatus based on a variable-length self-attention mechanism, comprising a memory, one or more processors, and one or more application programs, wherein the one or more application programs are stored in the memory and are configured to, when invoked by the one or more processors, cause the one or more processors to perform the method as described in any one aspect.

[0037] In a third aspect, the present invention provides a travel trajectory reconstruction system, the system comprising the apparatus described in the second aspect.

[0038] In a fourth aspect, the present invention provides a computer-readable storage medium including one or more application programs, wherein the one or more application programs are configured to, when invoked by one or more processors, cause the one or more processors to perform the method as described in any one of the first aspects.

[0039] The above-described technical solutions of the present invention have at least one or more of the following beneficial effects:

[0040] In implementing the technical solution of this invention, the invention uses a self-supervised learning method, which eliminates the need for a large amount of data annotation and greatly reduces data costs; during model training, the travel points are concatenated with the previous states and information is obtained through convolution, which expands the receptive field of neurons, enabling the model to accept longer sequences while saving computational resources as much as possible, thereby enhancing the model's reconstruction accuracy; at the same time, the DTW algorithm is used to evaluate the trajectory point sequence reconstruction effect, reducing the difficulty of model convergence. Attached Figure Description

[0041] The disclosure of this invention will become more readily understood with reference to the accompanying drawings. It will be readily understood by those skilled in the art that these drawings are for illustrative purposes only and are not intended to limit the scope of protection of this invention. Furthermore, similar numbers in the drawings are used to denote similar components, wherein:

[0042] Figure 1 This is a schematic diagram of the main steps of a route trajectory reconstruction method based on a variable-length self-attention mechanism according to an embodiment of the present invention;

[0043] Figure 2 This is a schematic diagram of the main steps of the training process according to an embodiment of the present invention;

[0044] Figure 3 This is a schematic diagram of the main steps of the forward propagation training process according to an embodiment of the present invention. Detailed Implementation

[0045] Some embodiments of the present invention will now be described with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are merely illustrative of the technical principles of the present invention and are not intended to limit the scope of protection of the present invention.

[0046] In the description of this invention, "module" and "processor" can include hardware, software, or a combination of both. A module can include hardware circuitry, various suitable sensors, communication ports, memory, and may also include software components, such as program code, or a combination of software and hardware. A processor can be a central processing unit, microprocessor, image processor, digital signal processor, or any other suitable processor. The processor has data and / or signal processing capabilities. The processor can be implemented in software, in hardware, or a combination of both. Non-transitory computer-readable storage media includes any suitable medium capable of storing program code, such as magnetic disks, hard disks, optical disks, flash memory, read-only memory, random access memory, etc. The term "A and / or B" means all possible combinations of A and B, such as only A, only B, or A and B. The terms "at least one A or B" or "at least one of A and B" have a similar meaning to "A and / or B" and can include only A, only B, or A and B. The singular terms "a" or "this" can also include plural forms.

[0047] Currently, supervised learning is used to correct biases in data through traditional machine learning or deep learning. However, the cost of manually labeled supervised data is too high for traditional machine learning methods, while self-supervised learning requires a fixed length of input data, which limits the accuracy of data reconstruction. Therefore, if traditional methods are used directly to reconstruct vehicle trajectory data, the accuracy is limited and the reconstructed data is not accurate.

[0048] See appendix Figure 1 , Figure 1 This is a schematic flowchart illustrating the main steps of a path trajectory reconstruction method based on a variable-length self-attention mechanism according to an embodiment of the present invention. Figure 1 As shown, the travel trajectory reconstruction method based on variable length self-attention mechanism in this embodiment of the invention mainly includes the following steps S101-S103.

[0049] Step S101: Obtain the original travel data of the vehicle trajectory, each travel includes several travel points;

[0050] In this embodiment, the source data stream of the vehicle trajectory is first acquired, and the source data stream is segmented into several raw travel data. Each travel includes multiple GPS points, which are sorted according to the acquisition time to form a GPS point sequence. The GPS points within the travel are then divided into several travel point segments. A floating-point array (longitude, latitude, and some other dimensions such as altitude, vehicle speed, vehicle status, number of satellites, etc.) can be referred to as a GPS point.

[0051] In one implementation, trip segmentation of the source data stream can remove trips with more than a threshold of GPS points, such as trips with more than 5,000 GPS points.

[0052] Step S102: Input the travel data into the transformer pre-trained model for training;

[0053] In this embodiment, as Figure 2 As shown, the training process may include the following steps:

[0054] Step S201: Randomly label and replace the input travel data to obtain the processed travel data;

[0055] Specifically, a portion of the input trip data is randomly selected and labeled; some of the labeled data is replaced with 0, another portion is replaced with the trip mean, and the rest of the data remains unchanged.

[0056] For example, 60% of the data in the source data field (GPS point sequence) is randomly selected and labeled; 30% of the labeled data is replaced with 0 data, 30% of the data is replaced with the mean of the trip data, and 40% of the data remains unchanged.

[0057] Step S202: Randomly extract travel data and arrange it from longest to shortest to divide it into several travel points;

[0058] Specifically, a small batch of data is arranged from longest to shortest, and each segment consists of 50 points. If there are fewer than 50 points, 0 to 50 points are added. The small batch of data refers to the batch data, which is randomly selected from the entire dataset.

[0059] Step S203: Input the travel points into each layer of the transformer pre-trained model and perform forward propagation to obtain the output results;

[0060] Specifically, such as Figure 3 As shown, the forward propagation process may include the following steps:

[0061] Step S2031: For each trip, take the nth trip point from front to back, and calculate the query for the self-attention of each trip;

[0062] Step S2032: For each journey, take the nth segment point from front to back, concatenate it with the state output of the (n-1)th segment, and then perform a one-dimensional convolution (output directly when n=1). Calculate the key and value of the self-attention using the convolution result. Steps S2031-S2032 solve the accuracy problem with a larger model, which greatly increases the model cost.

[0063] Step S2033: Calculate the self-supervised network using query, key, and value, store the result of each layer of self-supervision as state, and pass the result to the next layer until the last layer of the model outputs the result.

[0064] Step S204: The output results are evaluated using the DTW algorithm to assess the differences in travel point reconstruction;

[0065] Specifically, after forward propagation is completed, the DTW algorithm is used to evaluate the differences in the restored trajectory, reducing the difficulty of model convergence.

[0066] Step S205: The travel point reconstruction difference and trajectory MSE are calculated by linear combination, the loss of the marked travel data is calculated, and backpropagation is used for training.

[0067] Specifically, the trajectory difference and trajectory MSE are linearly combined to calculate the loss of the labeled data in step S201, followed by backpropagation. The MSE calculates the mean squared error between the original data points and the actual data points as a component of the loss function; DTW can calculate a value for the two trajectories, which can be regarded as distance or similarity. This distance / similarity is directly used as another component of the loss function. The MSE value and the DTW value are added with fixed weights to calculate the loss of the labeled travel data, and backpropagation is used for training.

[0068] Step S103: Until the transformer pre-trained model converges, output the restored travel distance.

[0069] In one implementation, steps S201-S205 are repeated until the transformer pre-trained model converges and outputs the reconstructed travel trajectory. When new data requires trajectory reconstruction, all points are input, and steps S201-S203 are performed to output the model's prediction result. That is, inputting a travel route (a series of GPS points), entering the aforementioned transformer network, entering the convolutional layer, and the output GPS points are the reconstructed travel route.

[0070] Based on the above steps S101-S103, this embodiment of the invention uses a self-supervised learning method, which eliminates the need for a large amount of data annotation and greatly reduces data costs. During model training, the travel points are concatenated with the previous states and information is obtained through convolution, which expands the receptive field of neurons, enabling the model to accept longer sequences while saving computational resources as much as possible, thereby enhancing the model's reconstruction accuracy. At the same time, the DTW algorithm is used to evaluate the trajectory point sequence reconstruction effect, reducing the difficulty of model convergence.

[0071] It should be noted that although the steps in the above embodiments are described in a specific order, those skilled in the art will understand that in order to achieve the effects of the present invention, different steps do not necessarily have to be executed in such an order. They can be executed simultaneously (in parallel) or in other orders, and these variations are all within the scope of protection of the present invention.

[0072] Furthermore, the present invention also provides a travel trajectory reconstruction device based on a variable-length self-attention mechanism, including a memory, one or more processors, and one or more application programs, wherein the one or more application programs are stored in the memory, and the one or more application programs are configured to cause the one or more processors to execute the method described in the above steps S101-S103 when invoked by the one or more processors.

[0073] The apparatus in this embodiment of the invention mainly includes a memory and a processor. The memory can be configured to store a program for executing the travel trajectory reconstruction method based on the variable-length self-attention mechanism described in the above-described method embodiments. The processor can be configured to execute the program in the memory, which includes, but is not limited to, the program for executing the travel trajectory reconstruction method based on the variable-length self-attention mechanism described in the above-described method embodiments. For ease of explanation, only the parts related to the embodiments of the present invention are shown. For specific technical details not disclosed, please refer to the method section of the embodiments of the present invention.

[0074] In embodiments of the present invention, the travel trajectory reconstruction device may be a control device comprising various electronic devices. In some possible implementations, the device may include multiple storage devices and multiple processors. The program executing the travel trajectory reconstruction method based on the variable-length self-attention mechanism described in the above method embodiments may be divided into multiple subroutines, each of which may be loaded and run by a processor to execute different steps of the travel trajectory reconstruction method based on the variable-length self-attention mechanism described in the above method embodiments. Specifically, each subroutine may be stored in a different memory, and each processor may be configured to execute programs in one or more memories to jointly implement the travel trajectory reconstruction method based on the variable-length self-attention mechanism described in the above method embodiments. That is, each processor executes different steps of the travel trajectory reconstruction method based on the variable-length self-attention mechanism described in the above method embodiments to jointly implement the travel trajectory reconstruction method based on the variable-length self-attention mechanism described in the above method embodiments.

[0075] The aforementioned multiple processors can be processors deployed on the same device. For example, the aforementioned computer device can be a high-performance device composed of multiple processors, and the aforementioned multiple processors can be processors configured on that high-performance device. Alternatively, the aforementioned multiple processors can also be processors deployed on different devices. For example, the aforementioned computer device can be a server cluster, and the aforementioned multiple processors can be processors on different servers within the server cluster.

[0076] The aforementioned travel trajectory restoration device is used for execution Figure 1The illustrated embodiments of the trajectory reconstruction method based on the variable-length self-attention mechanism are similar in technical principle, the technical problems solved, and the technical effects produced. Those skilled in the art can clearly understand that, for the sake of convenience and brevity, the specific working process of the control device and related descriptions can be found in the embodiments of the trajectory reconstruction method based on the variable-length self-attention mechanism, which will not be repeated here.

[0077] Furthermore, the present invention also provides a travel trajectory reconstruction system, including the travel trajectory reconstruction device of the above embodiments. For ease of explanation, only the parts related to the embodiments of the present invention are shown; for specific technical details not disclosed, please refer to the method section of the embodiments of the present invention.

[0078] Those skilled in the art will understand that all or part of the processes in the method of the above-described embodiment of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable storage medium can include any entity or device capable of carrying the computer program code, a medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory, a random access memory, an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc. It should be noted that the computer-readable storage medium does not include electrical carrier signals and telecommunication signals.

[0079] Furthermore, the present invention also provides a computer-readable storage medium. In one embodiment of the computer-readable storage medium according to the present invention, the computer-readable storage medium can be configured to store a program that executes the travel trajectory reconstruction method based on the variable-length self-attention mechanism described in the above-described method embodiments. This program can be loaded and run by a processor to implement the above-described travel trajectory reconstruction method based on the variable-length self-attention mechanism. For ease of explanation, only the parts related to the embodiments of the present invention are shown; for specific technical details not disclosed, please refer to the method section of the embodiments of the present invention. The computer-readable storage medium can be a storage device comprising various electronic devices. Optionally, in the embodiments of the present invention, the computer-readable storage medium is a non-transitory computer-readable storage medium.

[0080] Furthermore, it should be understood that since the various modules are only provided to illustrate the functional units of the device of the present invention, the physical devices corresponding to these modules may be the processor itself, or a part of the processor's software, hardware, or a combination of software and hardware. Therefore, the number of modules shown in the figures is merely illustrative.

[0081] Those skilled in the art will understand that the various modules in the device can be adaptively split or combined. Such splitting or combining of specific modules will not cause the technical solution to deviate from the principles of the present invention; therefore, the technical solutions after splitting or combining will fall within the protection scope of the present invention.

[0082] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after such changes or substitutions will all fall within the scope of protection of the present invention.

Claims

1. A method for reconstructing travel trajectories based on a variable-length self-attention mechanism, characterized in that, include: Obtain the raw travel data of the vehicle trajectory, each travel segment including several travel points; The travel data is input into the transformer pre-trained model for training. During the training process, the state output of the current travel point and the previous travel point is concatenated and then entered into the convolutional layer. The difference in travel point reconstruction is evaluated by the DTW algorithm. The process continues until the transformer pre-trained model converges, at which point the restored trajectory is output. The step of inputting the travel data into the transformer pre-trained model for training includes: The input itinerary data is randomly labeled and replaced to obtain the processed itinerary data; Randomly select travel data and arrange them from longest to shortest to divide them into several travel points; The travel points are input into each layer of the pre-trained transformer model, and the output is obtained through forward propagation. The output results are evaluated using the DTW algorithm to assess the differences in travel point reconstruction. The travel point reconstruction difference and trajectory MSE are linearly combined to calculate the loss of the marked travel data, and backpropagation is used for training. The travel points are input into each layer of the transformer pre-trained model, and the output results are obtained through forward propagation, including: For each trip, take the nth trip point from the beginning and calculate the query for the self-attention of each trip; For each process, the nth segment point is taken from the beginning and concatenated with the state output of the (n-1)th segment. Then, a one-dimensional convolution is performed. The convolution result is used to calculate the key and value of the self-attention. The self-supervised network is computed using query, key, and value. The result of each layer of self-supervision is stored as state and passed to the next layer until the final layer of the model outputs the result.

2. The method for reconstructing travel trajectories based on a variable-length self-attention mechanism according to claim 1, characterized in that, The acquisition of the vehicle trajectory raw travel data includes: Obtain the source data stream of the vehicle trajectory; The source data stream is segmented into trip data to obtain several original trip data, wherein each trip includes multiple GPS points, and the multiple GPS points are sorted according to the acquisition time to form a GPS point sequence; The GPS points within the trip are divided into several trip point segments.

3. The method for reconstructing travel trajectories based on a variable-length self-attention mechanism according to claim 2, characterized in that, The method further includes: performing trip segmentation on the source data stream and removing trips where the GPS points exceed a threshold.

4. The method for reconstructing travel trajectories based on a variable-length self-attention mechanism according to claim 1, characterized in that, The process of randomly labeling and replacing the input trip data to obtain processed trip data includes: Randomly select and label a portion of the input travel data; The data in the labeled data will be partially replaced with 0, another part of the data will be replaced with the mean of the trip, and the rest of the data will remain unchanged.

5. The method for reconstructing travel trajectories based on a variable-length self-attention mechanism according to claim 1, characterized in that, The travel point reconstruction difference and trajectory MSE are linearly combined to calculate the loss of the labeled travel data, and backpropagation is used for training, including: The trajectory MSE calculates the mean square error between the original travel data points and the output data points. The DTW algorithm evaluates the differences in travel point reconstruction by calculating the similarity between the original travel and the reconstructed travel. The mean squared error and the similarity are added together with fixed weights to form a loss function, which is then used for backpropagation training.

6. A trajectory reconstruction device based on a variable-length self-attention mechanism, characterized in that, It includes a memory, one or more processors, and one or more applications, wherein the one or more applications are stored in the memory and are configured to, when invoked by the one or more processors, cause the one or more processors to perform the method as described in any one of claims 1-5.

7. A travel trajectory reconstruction system, characterized in that, The system includes the apparatus as described in claim 6.

8. A computer-readable storage medium, characterized in that, It includes one or more applications, wherein when the one or more applications are invoked by one or more processors, the one or more processors cause the one or more processors to perform the method as described in any one of claims 1-5.