Transform-based online large-scale abnormal trajectory detection method and system, and medium

By using a Transformer-based method in trajectory anomaly detection, preprocessing and feature representation of trajectory data, and using Transformer encoder and decoder to capture exception patterns, the inefficiency and overfitting problems of existing methods in large-scale and high-dimensional data processing are solved, and efficient online detection and accurate exception recognition are achieved.

CN119862524AInactive Publication Date: 2025-04-22SICHUAN AEROSPACE POLYTECHNIC

Patent Information

Application Number
CN202510352696.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2025-04-22
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing trajectory anomaly detection methods are inefficient in processing large-scale and high-dimensional trajectory data, lack of feature extraction, and are prone to overfitting problems, making it difficult to detect and identify abnormal trajectories online.

Method used

The online large-scale anomaly trajectory detection method based on Transformer is adopted to perform data preprocessing, road network matching and feature representation of the trajectory data through the model training stage. The trajectory features are encoded and decoded using Transformer encoder and decoder to capture the exception mode, and optimize the model through comparative learning and self-supervising adjustment.

Benefits of technology

It realizes efficient online detection of large-scale trajectory data, integrates user and time information, improves the model's classification and identification ability of trajectory representation, avoids overfitting, and ensures the accuracy and efficiency of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119862524A_ABST
    Figure CN119862524A_ABST
Patent Text Reader

Abstract

The invention discloses an online large-scale abnormal trajectory detection method and system based on Transform and a medium, and belongs to the technical field of trajectory detection. The method comprises the following steps: a model training stage: inputting a training data set, and initializing weight parameters of an encoder and a decoder; performing data preprocessing and road network matching on the initial trajectory data to obtain first trajectory data; performing trajectory representation according to the first trajectory data to obtain trajectory features; encoding the trajectory features by using an encoder to obtain trajectory characterization; decoding the trajectory characterization by using a decoder, and capturing an abnormal mode in the trajectory data; calculating a loss function; updating the weights of the encoder and the decoder based on the loss function, and iteratively optimizing the model; and a track detection stage: inputting a detection data set into the trained model to carry out abnormal track detection. According to the method, the track is mapped in the real road network, and the road segment representation is defined based on the road segment connection condition, so that the actual driving condition of the track on the road and the road network information are reflected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of trajectory detection technology, and in particular to a Transformer-based online large-scale abnormal trajectory detection method, system and medium. Background Art

[0002] Anomaly detection refers to identifying or detecting abnormal or unusual observations in a data set. For example, noise, errors, failures, or other unusual conditions in the data. Anomaly detection technology has shown its wide application value in many fields such as industrial manufacturing and equipment monitoring, medical diagnosis, production process optimization, and environmental science research.

[0003] In recent years, with the development of positioning technologies such as GPS and wireless sensor networks, large-scale complex trajectory data, including pedestrian, vehicle, ship and flight trajectories, have gradually accumulated in various fields. However, in these large-scale trajectory data, there are also a large number of abnormal trajectories that deviate significantly from most cases, which has caused many problems. How to efficiently use spatiotemporal data to perform trajectory outlier detection in large-scale trajectory datasets can not only reveal potential traffic problems, but also help promote the development of smart city transportation systems.

[0004] Trajectory anomaly detection refers to monitoring the movement trajectory of moving objects (such as vehicles, people, etc.) in space and time to identify abnormal behaviors or abnormal trajectories. This type of anomaly detection is important in many application areas, including traffic management, security monitoring, logistics, and transportation. In trajectory anomaly detection, the location information of the object is usually collected and recorded to form trajectory data. Each trajectory can be represented by a series of spatiotemporal coordinate points, where the time and space coordinates describe the movement path of the object. The goal of trajectory anomaly detection is to identify those trajectories that are significantly different from normal behavior in these trajectory data.

[0005] In the vast field of data mining, anomaly detection, as an important branch, focuses on identifying abnormal points or patterns in a data set that are significantly different from the majority of data. Traditional anomaly detection methods cover multiple dimensions, mainly including statistical methods, distance or other similarity measurement methods, and clustering methods. However, these methods are highly dependent on data distribution or have a large amount of manual feature engineering, and are not suitable for large-scale and high-dimensional data.

[0006] In recent years, with the rapid development of deep learning technology, new solutions have been introduced to the field of anomaly detection in large-scale trajectory data. With its powerful feature extraction and complex pattern recognition capabilities, deep learning provides a more efficient and accurate detection method for this challenging problem. For example, trajectory data can be represented and anomalies can be predicted based on recurrent neural networks (RNNs) and long short-term memory networks (LSTMs); or data can be generated based on variational autoencoders (VAEs) by learning the distribution of latent variables and detecting abnormal trajectories. These methods have achieved some remarkable results in trajectory anomaly detection, but there are still some shortcomings that need to be improved.

[0007] By analyzing and summarizing the existing trajectory anomaly detection methods, the existing methods have the following shortcomings: (1) The encoding method of the original trajectory information is too simple, making it difficult to utilize the original trajectory information and the spatiotemporal information of the road network, and only focusing on the trajectory data itself, ignoring other information of the trajectory data, such as the user and time information of the trajectory; (2) Most heuristic abnormal sub-trajectory detection methods are inefficient and difficult to achieve online detection; (3) Many existing models often have the problem of overfitting, making it difficult to accurately judge abnormal sub-trajectories. Summary of the invention

[0008] The purpose of the present invention is to overcome the deficiencies of the prior art and provide a Transformer-based online large-scale abnormal trajectory detection method, system and medium.

[0009] The objective of the present invention is achieved through the following technical solutions: The first aspect of the present invention provides: a Transformer-based online large-scale abnormal trajectory detection method, comprising the following steps: In the model training phase, the training data set is input to initialize the weight parameters of the encoder and decoder; the initial trajectory data is preprocessed and the road network is matched to obtain the first trajectory data; the trajectory is represented according to the first trajectory data to obtain the trajectory feature; the trajectory feature is encoded using the encoder to obtain the trajectory representation; the trajectory representation is decoded using the decoder to capture abnormal patterns in the trajectory data; the loss function is calculated; the weights of the encoder and decoder are updated based on the loss function to optimize the model; it is determined whether the maximum number of time steps has been reached. If not, return to the step of encoding with the encoder. If so, use random batch meta-learning to learn the weight parameters of the encoder and decoder and increase the number of iterations by one; it is determined whether the specified number of iterations has been reached. If so, the training ends. If not, return to the step of encoding with the encoder; In the trajectory detection stage, the detection dataset is input into the trained model to obtain the abnormal trajectory dataset and the normal trajectory dataset.

[0010] Preferably, the data preprocessing includes data cleaning, data conversion and data filtering; the trajectory data after data preprocessing is subjected to road network matching, and the road network matching includes integrating road network data, collecting GPS trajectory data, accurately matching trajectories and road sections, calibrating trajectory points with position offsets, removing abnormal points and smoothing trajectories.

[0011] Preferably, the trajectory representation includes trajectory data enhancement and multimodal representation fusion; The trajectory data enhancement includes missing enhancement, segmentation enhancement and multi-hop enhancement; the missing enhancement generates missing trajectories by hiding some position points in the trajectory using different mask matrices; the segmentation enhancement obtains multiple sub-trajectory segments by truncating the complete trajectory according to a given ratio; the multi-hop enhancement generates multi-hop sub-trajectories by sampling from the original trajectory according to a given number of hops; The multimodal representation fusion comprises the following steps: firstly, encoding the user, time and location information of the trajectory, and then fusing the user features, time features and location encoding based on road network matching mapping through a neural network to generate a location representation.

[0012] Preferably, converting the trajectory representation into a trajectory representation window for training and testing comprises the following steps: Given a trajectory dataset, a trajectory representation dataset is obtained after a representation fusion operation; the sub-trajectory representation is converted into a local context window of a preset length. If the window length is less than the preset length, it is filled by copying, and the representation sequence of the entire trajectory is converted into a sliding window sequence.

[0013] Preferably, the encoder is a Transformer encoder, and the step of encoding the trajectory features using the encoder to obtain the trajectory representation comprises the following steps: The first encoder is used to process the input trajectory features, and a new data sample is generated by data augmentation. The trajectory is embedded into a fixed-length representation vector using a position representation and encoding method to obtain a preliminary trajectory representation. After the first encoder completes the encoding, contrastive learning is introduced to adjust the similarity. The preliminary trajectory representation is used as the key and value of the second encoder, which applies position encoding to the input window and generates a feature vector through a masked multi-head self-attention operation, a layer normalization operation, and a second multi-head self-attention operation.

[0014] Preferably, the step of decoding the trajectory representation using a decoder to capture abnormal patterns in the trajectory data comprises the following steps: generating a first reconstruction and a second reconstruction of the input window by a first decoder and a second decoder, capturing basic features and context information of the trajectory data; The first reconstruction output by the first decoder is input to the second decoder to generate a third reconstruction.

[0015] Preferably, the calculation of the loss function comprises the following steps: The contrastive loss function is obtained by summing the contrastive learning losses of all batch trajectories when encoding by the encoder. ; Define the reconstruction loss and adversarial loss functions of the decoder: ; Where 𝑛 is the training cycle; 𝜖 is a training parameter close to 1; L 1 is the reconstruction loss of the first decoder; L 2 is the reconstruction loss of the second decoder; R 1 is the first reconstruction; R 2 is the second reconstruction; W is the windowed sub-trajectory input; R R1 It is the third reconstruction; Finally, three different hyperparameters 𝛼, 𝛽, and 𝛾 are used to transform L 1. L 2 、 Integrated into the loss function for abnormal trajectory detection: ;in represents the regularization hyperparameter; represents the model parameters; is a regularization term used to prevent overfitting.

[0016] Preferably, the trajectory detection stage specifically includes the following steps: Input detection dataset; Generate trajectory features; Encode using the trained encoder; Decode using the trained decoder; Calculate the anomaly score of each sub-track in the track. , the anomaly score s is defined as the weighted sum of two reconstruction errors: ; Calculate the average anomaly score for the entire trajectory; Determine whether the anomaly score exceeds the threshold. If so, the trajectory is an abnormal trajectory; if not, it is a normal trajectory.

[0017] The second aspect of the present invention provides: a Transformer-based online large-scale abnormal trajectory detection system, which is used to implement any of the above-mentioned Transformer-based online large-scale abnormal trajectory detection methods, comprising: In the model training phase, the training data set is input to initialize the weight parameters of the encoder and decoder; the initial trajectory data is preprocessed and the road network is matched to obtain the first trajectory data; the trajectory is represented according to the first trajectory data to obtain the trajectory feature; the trajectory feature is encoded using the encoder to obtain the trajectory representation; the trajectory representation is decoded using the decoder to capture abnormal patterns in the trajectory data; the loss function is calculated; the weights of the encoder and decoder are updated based on the loss function to optimize the model; it is determined whether the maximum number of time steps has been reached. If not, return to the step of encoding with the encoder. If so, use random batch meta-learning to learn the weight parameters of the encoder and decoder and increase the number of iterations by one; it is determined whether the specified number of iterations has been reached. If so, the training ends. If not, return to the step of encoding with the encoder; In the trajectory detection stage, the detection dataset is input into the trained model to obtain the abnormal trajectory dataset and the normal trajectory dataset.

[0018] The third aspect of the present invention provides: a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by a processor, any of the above-mentioned Transformer-based online large-scale abnormal trajectory detection methods is implemented.

[0019] The beneficial effects of the present invention are: 1) The present invention maps the trajectory into the real road network and defines the segment representation based on the segment connection, thereby reflecting the actual driving conditions of the trajectory on the road and the road network information.

[0020] 2) The present invention uses a Transformer-based trajectory encoder to obtain a trajectory representation that integrates user and time information.

[0021] 3) The present invention uses contrastive learning pre-training technology to improve the model's ability to classify and identify trajectory representations.

[0022] 4) The present invention uses a training method based on the idea of ​​self-supervised regulation and a pre-trained Transformer encoder model to achieve efficient online abnormal trajectory detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 This is a flow chart of the online large-scale abnormal trajectory detection method based on Transformer; Figure 2 Flowchart for model training; Figure 3 This is the flow chart of trajectory detection. DETAILED DESCRIPTION

[0024] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0025] See also Figure 1-Figure 3 The first aspect of the present invention provides: a Transformer-based online large-scale abnormal trajectory detection method, comprising the following steps: In the model training phase, the training data set is input to initialize the weight parameters of the encoder and decoder; the initial trajectory data is preprocessed and the road network is matched to obtain the first trajectory data; the trajectory is represented according to the first trajectory data to obtain the trajectory feature; the trajectory feature is encoded using the encoder to obtain the trajectory representation; the trajectory representation is decoded using the decoder to capture abnormal patterns in the trajectory data; the loss function is calculated; the weights of the encoder and decoder are updated based on the loss function to optimize the model; it is determined whether the maximum number of time steps has been reached. If not, return to the step of encoding with the encoder. If so, use random batch meta-learning to learn the weight parameters of the encoder and decoder and increase the number of iterations by one; it is determined whether the specified number of iterations has been reached. If so, the training ends. If not, return to the step of encoding with the encoder; In the trajectory detection stage, the detection dataset is input into the trained model to obtain the abnormal trajectory dataset and the normal trajectory dataset.

[0026] In this embodiment, random batch meta-learning encoder and decoder weight parameters are used to improve the generalization ability of the model. The present invention cleverly maps the trajectory data to the real road network, and uses the road segment connection to construct a road segment representation, accurately reflecting the actual driving path of the trajectory and the complex information of the road network. The core of the present invention adopts the Transformer trajectory encoder, which deeply integrates user behavior patterns and time dimension features to construct a comprehensive and rich trajectory representation. In addition, in order to further enhance the model's ability to classify and identify trajectory features, the present invention innovatively introduces comparative learning pre-training technology, and continuously optimizes model parameters through a self-supervised adjustment training strategy to ensure that both high efficiency and accurate identification of abnormal trajectories can be maintained during the online detection process, providing powerful data insights and security guarantees for various application scenarios.

[0027] In some embodiments, the data preprocessing includes data cleaning, data conversion and data filtering; the trajectory data after data preprocessing is subjected to road network matching, and the road network matching includes integrating road network data, collecting GPS trajectory data, accurately matching trajectories and road sections, calibrating trajectory points with position offsets, removing abnormal points and smoothing trajectories.

[0028] In this embodiment, before processing and analyzing large-scale trajectory data, the original data needs to be preprocessed to remove noise, outliers and redundant information, thereby improving data quality and operability, which is helpful for subsequent model training. Specific preprocessing operations include data cleaning, data conversion and data filtering, thereby enhancing data availability and interpretability, making the analysis more efficient and accurate. After trajectory data preprocessing, road network matching is required, that is, pairing the original trajectory with the road network. The process includes integrating road network data, collecting GPS trajectory data, accurately pairing trajectories with road sections, calibrating trajectory points with position offsets, removing abnormal points and smoothing trajectories. Through these steps, more accurate and reliable trajectory data can be obtained, which is convenient for subsequent anomaly detection.

[0029] In some embodiments, the trajectory representation includes trajectory data enhancement and multimodal representation fusion; The trajectory data enhancement includes missing enhancement, segmentation enhancement and multi-hop enhancement; the missing enhancement generates missing trajectories by hiding some position points in the trajectory using different mask matrices; the segmentation enhancement obtains multiple sub-trajectory segments by truncating the complete trajectory according to a given ratio; the multi-hop enhancement generates multi-hop sub-trajectories by sampling from the original trajectory according to a given number of hops; The multimodal representation fusion comprises the following steps: firstly, encoding the user, time and location information of the trajectory, and then fusing the user features, time features and location encoding based on road network matching mapping through a neural network to generate a location representation.

[0030] In this embodiment, the goal of trajectory data enhancement is to obtain more diverse trajectory samples and improve the pre-training effect. The trajectory enhancement strategies are as follows: Missing enhancement, a method of generating missing trajectories by using different mask matrices to hide some position points in the trajectory. Segmentation enhancement: The complete trajectory is truncated according to a given ratio to obtain multiple sub-trajectory segments, which is helpful for detecting anomalies in sub-trajectories during trajectory anomaly detection. Multi-hop enhancement: A data enhancement method for generating multi-hop sub-trajectories by sampling from the original trajectory according to a given number of hops. Multimodal representation fusion: First, the user, time and location information of the trajectory is encoded, and then the user features, time features and location encoding based on road network matching mapping are fused through a neural network to generate the final location representation.

[0031] In some embodiments, converting the trajectory representation into a trajectory representation window for training and testing includes the following steps: Given a trajectory dataset, a trajectory representation dataset is obtained after a representation fusion operation; the sub-trajectory representation is converted into a local context window of a preset length. If the window length is less than the preset length, it is filled by copying, and the representation sequence of the entire trajectory is converted into a sliding window sequence.

[0032] In this embodiment, in order to improve the robustness of the model, the trajectory representation needs to be converted into a trajectory representation window for training and testing.

[0033] In some embodiments, the encoder is a Transformer encoder, and encoding the trajectory features using the encoder to obtain the trajectory representation comprises the following steps: The first encoder is used to process the input trajectory features, and a new data sample is generated by data augmentation. The trajectory is embedded into a fixed-length representation vector using a position representation and encoding method to obtain a preliminary trajectory representation. After the first encoder completes the encoding, contrastive learning is introduced to adjust the similarity. The preliminary trajectory representation is used as the key and value of the second encoder, which applies position encoding to the input window and generates a feature vector through a masked multi-head self-attention operation, a layer normalization operation, and a second multi-head self-attention operation.

[0034] In this embodiment, the Transformer-based trajectory encoder module processes trajectory features and includes two encoders: the first encoder: processes the input trajectory features and generates a preliminary trajectory representation. It uses data augmentation to generate new data samples and uses position representation and encoding methods to embed the trajectory into a fixed-length representation vector. This output is used as the key and value of the second encoder. In addition, in order to more accurately extract trajectory features, enhance anomaly detection capabilities and model generalization. Contrastive learning is introduced after the first encoder is encoded, and its goal is to enable the model to accurately distinguish similar and dissimilar samples by adjusting similarity. The second encoder: applies position encoding to the input window and adjusts the self-attention mechanism to mask the data at subsequent positions. By masking the multi-head self-attention operation, layer normalization operation and the second multi-head self-attention operation, a feature vector is generated for subsequent decoder processing. This encoder ensures that future data is not exposed during training and encapsulates and utilizes larger contextual relationships.

[0035] In some embodiments, the decoding of the trajectory representation using a decoder to capture abnormal patterns in the trajectory data comprises the following steps: generating a first reconstruction and a second reconstruction of the input window by a first decoder and a second decoder, capturing basic features and context information of the trajectory data; The first reconstruction output by the first decoder is input to the second decoder to generate a third reconstruction.

[0036] In this embodiment, two decoders are included to further process the output of the second encoder, specifically including two stages. In the first stage, two approximate reconstructions of the input window are generated by two decoders. The goal of this stage is to capture the basic features and contextual information of the trajectory data, and provide a basis for subsequent reconstruction and anomaly detection. In the second stage, the output of the first decoder in the first stage is used as input, and a reconstruction similar to the output of the first decoder in the first stage is generated by the second decoder. This process achieves the goal of self-supervised learning, that is, the model optimizes the understanding and reconstruction of the trajectory data by comparing and adjusting its own output. This design enables the model to focus more on subsequences with large reconstruction deviations, thereby more accurately capturing abnormal patterns in the trajectory data.

[0037] In some embodiments, the calculation of the loss function comprises the following steps: The contrastive loss function is obtained by summing the contrastive learning losses of all batch trajectories when encoding by the encoder. ; Define the reconstruction loss and adversarial loss functions of the decoder: ; Where 𝑛 is the training cycle; 𝜖 is a training parameter close to 1; L 1 is the reconstruction loss of the first decoder; L 2 is the reconstruction loss of the second decoder; R 1 is the first reconstruction; R 2 is the second reconstruction; W is the windowed sub-trajectory input; R R1 It is the third reconstruction; Finally, three different hyperparameters 𝛼, 𝛽, and 𝛾 are used to transform L 1. L 2 、 Integrated into the loss function for abnormal trajectory detection: ;in represents the regularization hyperparameter; represents the model parameters; is a regularization term used to prevent overfitting.

[0038] In this embodiment, the first encoder introduces a contrastive learning method in order to learn the invariance of trajectory data under different transformations and enhance the model's discrimination ability. Specifically, two data augmentation methods are used to obtain the position representation of each trajectory, which are regarded as queries and positive samples, respectively. In addition, the expanded position representations of other trajectories in the same batch are used as negative samples. In order to maximize the similarity between the query and the positive sample and minimize the difference between the query and the negative sample, the present invention introduces the normalized temperature scaled cross entropy loss to define the contrastive learning loss. Finally, by accumulating the contrastive learning losses in all batches, the overall contrastive learning loss function is obtained. This process helps to understand and distinguish trajectory data more accurately, thereby improving its performance in anomaly detection.

[0039] The main task of the two decoders is to reconstruct the input trajectory sequence window. In order to quantify the performance of this reconstruction process, the Euclidean norm is introduced to define the reconstruction loss of each decoder, so as to accurately evaluate the reconstruction ability of the decoder. The reconstruction loss not only reflects the degree of fit of the decoder to the input trajectory, but also may reveal potential abnormal patterns, providing important clues for subsequent anomaly detection tasks. At the same time, in order to maintain the stability of training, an adversarial training process is also designed. Specifically, the goal of the first decoder is to make the reconstruction error of the self-adjusted output as small as possible, while the goal of the second decoder is to make the reconstruction error of the self-adjusted output as large as possible. In order to ensure the optimization of the model performance, the reconstruction loss and adversarial loss function of the two stages of the decoder are further combined to obtain L 1 and L 2.

[0040] In some embodiments, the trajectory detection stage specifically includes the following steps: Input detection dataset; Generate trajectory features; Encode using the trained encoder; Decode using the trained decoder; Calculate the anomaly score of each sub-track in the track. , the anomaly score s is defined as the weighted sum of two reconstruction errors: ; Calculate the average anomaly score for the entire trajectory; Determine whether the anomaly score exceeds the threshold. If so, the trajectory is an abnormal trajectory; if not, it is a normal trajectory.

[0041] In this embodiment, the two reconstruction errors ( R 1, R R1) respectively measure the difference between the original data and the first reconstruction result, and the difference between the first reconstruction result and the second reconstruction result. In this way, the anomaly score comprehensively considers the reconstruction stability and consistency of the data in the model. Anomaly score threshold setting method: A dynamic threshold setting method based on extreme value theory can automatically adjust the threshold according to the data distribution, so as to adapt to the anomaly detection needs in different scenarios. Since the model only considers the data before the current position, it means that the model processes the data sequentially in an online manner, evaluating the degree of anomaly of each data point or sub-trajectory one by one.

[0042] The second aspect of the present invention provides: a Transformer-based online large-scale abnormal trajectory detection system, which is used to implement any of the above-mentioned Transformer-based online large-scale abnormal trajectory detection methods, comprising: In the model training phase, the training data set is input to initialize the weight parameters of the encoder and decoder; the initial trajectory data is preprocessed and the road network is matched to obtain the first trajectory data; the trajectory is represented according to the first trajectory data to obtain the trajectory feature; the trajectory feature is encoded using the encoder to obtain the trajectory representation; the trajectory representation is decoded using the decoder to capture abnormal patterns in the trajectory data; the loss function is calculated; the weights of the encoder and decoder are updated based on the loss function to optimize the model; it is determined whether the maximum number of time steps has been reached. If not, return to the step of encoding with the encoder. If so, use random batch meta-learning to learn the weight parameters of the encoder and decoder and increase the number of iterations by one; it is determined whether the specified number of iterations has been reached. If so, the training ends. If not, return to the step of encoding with the encoder; In the trajectory detection stage, the detection dataset is input into the trained model to obtain the abnormal trajectory dataset and the normal trajectory dataset.

[0043] The third aspect of the present invention provides: a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by a processor, any of the above-mentioned Transformer-based online large-scale abnormal trajectory detection methods is implemented.

[0044] The above is only a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the form disclosed herein, and should not be regarded as excluding other embodiments, but can be used in various other combinations, modifications and environments, and can be modified within the scope of the concept described herein through the above teachings or the technology or knowledge of the relevant field. The changes and modifications made by those skilled in the art shall not deviate from the spirit and scope of the present invention, and shall be within the scope of protection of the claims attached to the present invention.

Claims

1. A Transformer-based online large-scale abnormal trajectory detection method, characterized by: The following steps are involved: In the model training phase, the training data set is input to initialize the weight parameters of the encoder and decoder; the initial trajectory data is preprocessed and road network matched to obtain the first trajectory data; Performing trajectory representation according to the first trajectory data to obtain trajectory features; Use the encoder to encode the trajectory features to obtain the trajectory representation; use the decoder to decode the trajectory representation and capture abnormal patterns in the trajectory data; calculate the loss function; update the weights of the encoder and decoder based on the loss function to optimize the model; determine whether the maximum number of time steps has been reached. If not, return to the step of encoding with the encoder. If so, use random batch meta-learning to learn the weight parameters of the encoder and decoder and increase the number of iterations by one; determine whether the specified number of iterations has been reached. If so, the training ends. If not, return to the step of encoding with the encoder; In the trajectory detection stage, the detection dataset is input into the trained model to obtain the abnormal trajectory dataset and the normal trajectory dataset.

2. The Transformer-based online large-scale abnormal trajectory detection method according to claim 1, characterized in that: The data preprocessing includes data cleaning, data conversion and data filtering; the trajectory data after data preprocessing is matched with a road network, and the road network matching includes integrating road network data, collecting GPS trajectory data, accurately matching trajectories and road sections, calibrating trajectory points with position offsets, removing abnormal points and smoothing trajectories.

3. The Transformer-based online large-scale abnormal trajectory detection method according to claim 1, characterized in that: The trajectory representation includes trajectory data enhancement and multimodal representation fusion; The trajectory data enhancement includes missing enhancement, segmentation enhancement and multi-hop enhancement; The missing enhancement generates missing trajectories by hiding some position points in the trajectories using different mask matrices; The segmentation enhancement obtains a plurality of sub-trajectory segments by truncating the complete trajectory according to a given ratio; The multi-hop enhancement samples from the original trajectory according to a given number of hops, thereby generating a multi-hop sub-trajectory; The multimodal representation fusion comprises the following steps: firstly, encoding the user, time and location information of the trajectory, and then fusing the user features, time features and location encoding based on road network matching mapping through a neural network to generate a location representation.

4. The Transformer-based online large-scale abnormal trajectory detection method according to claim 1, characterized in that: Converting trajectory representations into trajectory representation windows for training and testing includes the following steps: Given a trajectory dataset, a trajectory representation dataset is obtained after a representation fusion operation; the sub-trajectory representation is converted into a local context window of a preset length. If the window length is less than the preset length, it is filled by copying, and the representation sequence of the entire trajectory is converted into a sliding window sequence.

5. The Transformer-based online large-scale abnormal trajectory detection method according to claim 1, characterized in that: The encoder is a Transformer encoder, and the encoding of the trajectory features using the encoder to obtain the trajectory representation comprises the following steps: The first encoder is used to process the input trajectory features, and a new data sample is generated by data augmentation. The trajectory is embedded into a fixed-length representation vector using a position representation and encoding method to obtain a preliminary trajectory representation. After the first encoder completes the encoding, contrastive learning is introduced to adjust the similarity. The preliminary trajectory representation is used as the key and value of the second encoder, which applies position encoding to the input window and generates a feature vector through a masked multi-head self-attention operation, a layer normalization operation, and a second multi-head self-attention operation.

6. The Transformer-based online large-scale abnormal trajectory detection method according to claim 1, characterized in that: The method of decoding the trajectory representation using a decoder to capture abnormal patterns in the trajectory data includes the following steps: generating a first reconstruction and a second reconstruction of the input window by a first decoder and a second decoder, capturing basic features and context information of the trajectory data; The first reconstruction output by the first decoder is input to the second decoder to generate a third reconstruction.

7. The Transformer-based online large-scale abnormal trajectory detection method according to claim 6, characterized in that: The calculation loss function comprises the following steps: The contrastive loss function is obtained by summing the contrastive learning losses of all batch trajectories when encoding by the encoder. ; Define the reconstruction loss and adversarial loss functions of the decoder: ; Where 𝑛 is the training cycle; 𝜖 is a training parameter close to 1; L 1 is the reconstruction loss of the first decoder; L 2 is the reconstruction loss of the second decoder; R 1 is the first reconstruction; R 2 is the second reconstruction; W is the windowed sub-trajectory input; R R1 It is the third reconstruction; Finally, through three different hyperparameters 𝛼, 𝛽, 𝛾 L 1. L 2 、 Integrated into the loss function for abnormal trajectory detection: ;in represents the regularization hyperparameter; represents the model parameters; is a regularization term used to prevent overfitting.

8. The Transformer-based online large-scale abnormal trajectory detection method according to any one of claims 1 to 7, characterized in that: The trajectory detection stage specifically includes the following steps: Input detection dataset; Generate trajectory features; Encode using the trained encoder; Decode using the trained decoder; Calculate the anomaly score of each sub-track in the track. , the anomaly score s is defined as the weighted sum of two reconstruction errors: ; Calculate the average anomaly score for the entire trajectory; Determine whether the anomaly score exceeds the threshold. If so, the trajectory is an abnormal trajectory; if not, it is a normal trajectory.

9. A Transformer-based online large-scale abnormal trajectory detection system, characterized by: The method for realizing the online large-scale abnormal trajectory detection based on Transformer according to any one of claims 1 to 8 comprises: In the model training phase, the training data set is input to initialize the weight parameters of the encoder and decoder; the initial trajectory data is preprocessed and the road network is matched to obtain the first trajectory data; the trajectory is represented according to the first trajectory data to obtain the trajectory feature; the trajectory feature is encoded using the encoder to obtain the trajectory representation; the trajectory representation is decoded using the decoder to capture abnormal patterns in the trajectory data; the loss function is calculated; the weights of the encoder and decoder are updated based on the loss function to optimize the model; it is determined whether the maximum number of time steps has been reached. If not, return to the step of encoding with the encoder. If so, use random batch meta-learning to learn the weight parameters of the encoder and decoder and increase the number of iterations by one; it is determined whether the specified number of iterations has been reached. If so, the training ends. If not, return to the step of encoding with the encoder; In the trajectory detection stage, the detection dataset is input into the trained model to obtain the abnormal trajectory dataset and the normal trajectory dataset.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by the processor, the online large-scale abnormal trajectory detection method based on Transformer according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Traffic state detecting method based on multi-data fusion

    CN109410586A

  • Comparative learning-based multivariate time series anomaly detection method

    CN117407816A

  • Vehicle trajectory similarity measurement method and system based on space-time consistency representation

    CN118885824A

Cited By

  • Intelligent ultra-wideband positioning data correction method

    CN120224367A

  • An intelligent ultra-wideband positioning data correction method

    CN120224367B

  • Trajectory abnormal route detection method and system based on self-supervised trajectory representation learning

    CN120724351A

  • Pre-training and online updating method for multi-view dynamic trajectory representation learning

    CN121050751A