Architecture method of vehicle abnormal trajectory detection model in open environment
By introducing the encoding network, embedding network and inference network into the vehicle abnormal trajectory detection model, combined with the similarity measure loss and cross-entropy loss, the problem of unknown abnormal behavior recognition in the open environment is solved, and the effective identification and recognition of unknown trajectory patterns are achieved. Classification improves the robustness and accuracy of the model.
Patent Information
- Application Number
- CN202410670825.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-05-28
AI Technical Summary
Existing technologies cannot effectively identify and classify unknown abnormal vehicle trajectory behaviors in an open environment. They rely on closed-world assumptions and cannot cope with unknown behaviors in the environment.
An architectural method for vehicle abnormal trajectory detection model in an open environment is proposed, including a coding network, an embedding network and an inference network. Through similarity measurement loss and cross-entropy loss, the mutual relationships and probabilistic connections between trajectories are learned, pseudo labels are assigned and Optimize model parameters to ensure effective recognition and classification of models in the open world.
Effectively identify and classify unknown abnormal behaviors in the open world, enhance the robustness and accuracy of the model, be able to adapt to emerging trajectory patterns, and improve the accuracy and reliability of classification.
Smart Images

Figure CN118537645A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of trajectory recognition, and in particular to a construction method of a vehicle abnormal trajectory detection model in an open environment. Background Art
[0002] Due to the popularity of mobile devices and location-aware sensor systems, a large amount of location tracking data has been generated, making it possible to collect time-related trajectory datasets. Many researchers are committed to discovering valuable knowledge from these trajectories and applying them to specific applications. Identifying abnormal trajectories is one of the key tasks of trajectory mining because it is related to the accuracy of certain services, such as the charging accuracy of operating vehicles that are charged based on mileage.
[0003] Intuitively, the trajectories that are considered abnormal are those that deviate from the normal driving mode, such as detour anomalies, navigation anomalies, and route exchange anomalies. Among them, detour anomalies refer to the fact that in the normal trajectory of the vehicle, the shortest path is usually followed from the starting point to the destination, but in reality, the vehicle may take a long detour; navigation anomalies refer to the situation that due to network or system reasons, GPS positioning is inaccurate, causing the vehicle to be located in a place that deviates from the trajectory; route exchange anomalies refer to the fact that due to actual road conditions, the vehicle chooses to switch between several commonly used routes in order to allow passengers to reach the destination faster.
[0004] But in practice, solving this problem is not a simple task due to the differences in personal preferences as well as the uncertainty of traffic patterns. Most efforts mainly seek to detect anomalies that deviate from the normal trajectory of a specific travel demand, such as the trajectory from source S to destination D. To this end, most traditional studies identify anomalies through heuristic-based and learning-based paradigms, the former mainly relying on density or distance measurements to find outliers, while the latter aims to adopt machine learning methods to obtain promising discriminative models.
[0005] Heuristic-based methods, such as iBAT [Detecting anomalous taxi trajectories from GPS traces. In Proceedings of the 13th international conference on Ubiquitous computing, pages 99–108, 2011] and TRAOD [Trajectory outlier detection: A partition-and-detect framework. In 2008 IEEE 24th International Conference on Data Engineering, pages 140–149. IEEE, 2008], use multiple hand-crafted features and usually fail to discover the diverse patterns of normal trajectories, which in turn leads to the degradation of specifying anomalies. Learning-based methods, such as using recurrent neural networks (RNNs) to process the diverse sequence information of trajectories [Anomalous trajectory detection using recurrent neural network. In International Conference on Advanced Data Mining and Applications, pages 263–277. Springer, 2018] or designing an end-to-end framework with prior assumptions [Anomaly detection in time series with robust variational quasi-recurrent autoencoders. In 2022 IEEE 38th International Conference on Data Engineering (ICDE), pages 1342–1354. IEEE, 2022], although they have function approximation capabilities and can build a model that distinguishes patterns, they cannot reveal the rich spatiotemporal semantics behind a large number of trajectories, such as dynamic dependencies.
[0006] Existing learning-based methods mainly focus on developing recurrent neural networks (RNNs) and their variants to study complex spatiotemporal dependencies to enhance the versatility of trajectory representation. Although a large number of modern deep learning techniques have been invested in identifying abnormal trajectories, there are still the following defects:
[0007] Existing solutions, such as the generative models GM-VSAE (Gaussian Mixture Variational Sequence AutoEncoder) and DeepTEA (Deep Temporal Embedding Attention), are usually based on the closed world assumption, which assumes that all possible types of behavior patterns have been fully identified and reported. This assumption means that the learning system has a complete understanding of the world and can build discriminative or generative models based on simple distribution assumptions such as independent and identically distributed. However, this assumption is often impractical in real-world applications because real-world data usually only provides incomplete knowledge. Therefore, under the assumption of an open world, that is, an open environment, these models may not be able to effectively deal with unknown abnormal behaviors in the environment, and can only expose their existence without further classification or understanding. Summary of the invention
[0008] The technical problem to be solved by the present invention is to propose a construction method for a vehicle abnormal trajectory detection model in an open environment, wherein the constructed model can effectively identify and classify unknown abnormal behaviors in the environment under the assumption of an open world.
[0009] The technical solution adopted by the present invention to solve the above technical problems is:
[0010] A method for constructing a vehicle abnormal trajectory detection model in an open environment, wherein the vehicle abnormal trajectory detection model comprises an encoding network, an embedding network and an inference network, wherein the encoding network is an encoding network capable of capturing time-varying dependencies between trajectory points contained in a trajectory, and the training process of the vehicle abnormal trajectory detection model comprises the following steps:
[0011] A1. Data preparation
[0012] Obtain trajectory samples and construct a data set. The acquired trajectory samples are divided into normal trajectories, known abnormal trajectories, and unknown abnormal trajectories according to whether the behavior patterns of the recorded trajectories are known. The behavior patterns of normal trajectories and known abnormal trajectories are known and used as labels, while the behavior patterns of unknown abnormal trajectories are unknown.
[0013] A2. Trajectory Classification
[0014] Input the trajectory sample of this round of training, use the encoding network to perform feature encoding, and obtain the trajectory encoding of the input trajectory sample; based on the obtained trajectory encoding, use the embedding network to perform embedding encoding, and obtain the trajectory embedding of the input trajectory sample; based on the obtained trajectory embedding, use the inference network to infer the probability that each trajectory sample belongs to each type of behavior mode;
[0015] A3. Model Update
[0016] Calculate the total loss, and based on the total loss, use the gradient descent method to update the vehicle abnormal trajectory detection model;
[0017] The total loss includes similarity metric loss and cross entropy loss; wherein the calculation of the similarity metric loss includes:
[0018] The trajectory samples input in this round of training are randomly combined in pairs to form trajectory pairs; based on the trajectory embedding of each trajectory sample obtained in step A2, the trajectory similarity score between the two trajectory samples contained in each trajectory pair is calculated using the similarity learning network; based on the probability that each trajectory sample obtained in step A2 belongs to each type of behavior pattern, the pattern similarity score between the two trajectory samples contained in each trajectory pair is calculated using the similarity function; by aligning the pattern similarity score and trajectory similarity score of each trajectory pair, the similarity measurement loss of each trajectory pair is calculated;
[0019] A4, extracting trajectory samples from the data set as input, using the vehicle abnormal trajectory detection model updated in step A3 to obtain the probability that each trajectory sample input in this step belongs to each type of behavior mode; then, based on the probability that each trajectory sample input in this step belongs to each type of behavior mode, calculating the cross entropy loss, and using the gradient descent method to update the parameters of the similarity learning network;
[0020] A5. Execute steps A2 to A4 repeatedly until the training termination condition is reached, thereby obtaining a trained vehicle abnormal trajectory detection model.
[0021] The calculation of the cross entropy loss in step A3 and step A4 includes:
[0022] Based on the probability that each trajectory sample input in the corresponding step belongs to each type of behavior pattern, each trajectory sample is classified, and labels are assigned to trajectory samples belonging to known behavior patterns, and pseudo labels are assigned to trajectory samples belonging to unknown behavior patterns; then, based on the labels or pseudo labels of each trajectory sample, the cross entropy loss of each trajectory sample is calculated.
[0023] Furthermore, in step A1, the acquired trajectory samples include normal trajectories, detour anomalies, navigation anomalies, and route exchange anomalies; any one of the three anomalies is regarded as a known class abnormal trajectory, and the remaining two anomalies are regarded as unknown class abnormal trajectories.
[0024] Furthermore, an area of the road network completely covered by all trajectory samples of the data set is defined as an identification area, and the identification area is gridded; the encoding network adopts an encoding network based on relational distillation, including a pre-trained spatiotemporal semantic embedding matrix; in step A2, the trajectory sample of this round of training is input, and the pre-trained spatiotemporal semantic embedding matrix is used to obtain the spatiotemporal semantic coding of the grid contained in the trajectory sample based on the mapping relationship between the grid contained in the trajectory sample and the matrix, so as to form the trajectory coding of the trajectory sample;
[0025] The pre-training process of the spatiotemporal semantic embedding matrix includes:
[0026] B1. Data initialization
[0027] Constructing and initializing a spatiotemporal semantic embedding matrix, wherein the elements of the spatiotemporal semantic embedding matrix correspond one-to-one to the grids of the recognition area;
[0028] B2. Input the trajectory samples in the dataset constructed in step A1 one by one
[0029] Taking the input trajectory sample as the current trajectory, and the grids that the current trajectory passes through on the grid map, construct the positive sample grid set of the current trajectory tr; sampling grids from the grids contained in the trajectory samples whose starting grids and ending grids are different from the current trajectory tr in the dataset, constitute the negative sample grid set of the current trajectory tr; using the spatiotemporal semantic embedding matrix, based on the mapping relationship between the grid and the matrix, obtain the spatiotemporal semantic encoding of each grid in the positive sample grid set and the negative sample grid set;
[0030] B3. Update the spatiotemporal semantic embedding matrix
[0031] Using the spatiotemporal semantic encoding of each grid obtained in step B2, through comparative learning of positive sample grids and negative sample grids, relationship distillation is performed based on minimization expectation to update the spatiotemporal semantic embedding matrix;
[0032] B4. Loop through steps B2 to B3 until all trajectory samples in the dataset are traversed to obtain a spatiotemporal semantic embedding matrix that has completed training.
[0033] Furthermore, the identification area is gridded, and the side length of the divided grid should be greater than or equal to 100m and less than or equal to 500m; in step A1, each trajectory sample in the data set is traversed, and the grids it passes through on the grid map are obtained respectively, and the trajectory samples whose number of passed grids is less than a threshold are excluded, and the data set is updated to retain only the remaining trajectory samples; in step A1, the trajectory samples contained in the data set are sorted according to their starting grid and end grid.
[0034] Furthermore, the encoding network adopts an encoding network based on relational distillation, an encoding network based on RNN, or an encoding network constructed based on a variant of RNN.
[0035] Furthermore, in step B3, the spatiotemporal semantic encoding of each grid obtained in step B2 is used to update the spatiotemporal semantic embedding matrix by performing relation distillation based on minimizing expectation through comparative learning of positive sample grids and negative sample grids according to the following formula:
[0036]
[0037] in, represents the minimization expectation, r l is the lth positive sample grid, r l ∈tr\(S,D) indicates that the positive sample grid set includes the grids of the current trajectory tr except the starting grid S and the end grid D, and s(·) indicates the similarity calculation; Represents the spatiotemporal semantic encoding of the anchor point used as the comparison benchmark, and the grid corresponding to the anchor point belongs to the current trajectory tr; r j is the jth negative sample grid, J represents the number of grids sampled from the negative sample grid set; v(r l ) and v(r j ) represent the positive sample grid r l and negative sample grid r j spatiotemporal semantic encoding.
[0038] Further, the pre-trained spatiotemporal semantic embedding matrix includes a first spatiotemporal semantic embedding matrix V1 and a second spatiotemporal semantic embedding matrix V2;
[0039] In step A2, the trajectory sample of this round of training is input, and the first spatiotemporal semantic embedding matrix V1 and the second spatiotemporal semantic embedding matrix V2 of the pre-training are used respectively, based on the mapping relationship between the grid contained in the trajectory sample and the matrix, the first spatiotemporal semantic coding and the second spatiotemporal semantic coding of the grid contained in the trajectory sample are obtained to form the first trajectory coding and the second trajectory coding of the trajectory sample; then, aggregation is performed to obtain the trajectory coding of the trajectory sample;
[0040] In step B1, the first spatiotemporal semantic embedding matrix V1 and the second spatiotemporal semantic embedding matrix V2 are constructed and initialized respectively; in step B2, the first spatiotemporal semantic encoding and the second spatiotemporal semantic encoding of each grid in the positive sample grid set and the negative sample grid set are obtained respectively; in step B3, the definition Among them, r l1 With r l2 They represent the two grids that constitute the anchor point, and use the starting grid and the end grid of the current trajectory tr to form the anchor point for updating the first spatiotemporal semantic embedding matrix V1, and use the grid r that is the same as the current calculation positive samplel Two adjacent grids belonging to the current trajectory tr constitute anchor points for updating the second spatiotemporal semantic embedding matrix V2.
[0041] Furthermore, the encoding network includes an aggregation network and a pre-trained spatiotemporal semantic embedding matrix, and the aggregation network adopts a fully connected network; in step A2, the trajectory encoding of the trajectory sample is obtained by aggregation through the aggregation network according to the following formula:
[0042] v(r l )=[v1(r l );v2(r l )]W r +b r
[0043]
[0044] Among them, r l represents the lth grid of the trajectory sample, v(r l ) represents the grid r l The spatiotemporal semantic encoding of v1(r l ) and v2(r l ) represent the grid r l The first spatiotemporal semantic code and the second spatiotemporal semantic code, [;] represents the concatenation operation; W r and b r are the trainable parameters of the fully connected network that constitutes the aggregation network; L represents the number of grids contained in the trajectory sample.
[0045] Furthermore, the embedding network adopts a state space model, and the inference network adopts a fully connected network;
[0046] In step A2, based on the obtained trajectory encoding, embedding coding is performed using an embedding network to obtain a trajectory embedding of the input trajectory sample, including:
[0047] First, to obtain the trajectory encoding As input to the state-space model, through the state-space model:
[0048] x l =Ax l-1 +Bv(r l ), h l =Cx l +Dv(r l )
[0049] Calculate its state space output:
[0050]
[0051]
[0052]
[0053]
[0054]
[0055] Among them, x l is the state variable, h l is the output variable, v(r l ) is the input variable, A, B, C, and D are all parameters of the state space model; GELU represents the GELU activation function, represents the Fourier transform, represents the inverse Fourier transform, K L is the convolution kernel of the state space model obtained by dynamic modeling of the dynamic dependencies of each grid contained in the current calculation trajectory sample. A, B, and C are all parameters of the state space. (ΔA) -1 is the inverse matrix of ΔA matrix, Δ represents the sampling period, I is the unit matrix, W D Corresponding to the parameter D of the state space equation; r l represents the lth grid of the current calculation trajectory sample, v(r l ) represents the grid r l The spatiotemporal semantic encoding of L indicates the number of grids contained in the current calculation trajectory sample;
[0056] Then, based on the state space output of the current calculated trajectory sample h = [h1, h2, ..., h l ,…h L ], calculate the trajectory embedding of the current calculation trajectory sample:
[0057]
[0058] in, Represents the trajectory embedding of the current calculation trajectory sample;
[0059] In step A2, based on the obtained trajectory embedding, the probability of each trajectory sample belonging to each behavior mode is inferred using the inference network according to the following formula:
[0060]
[0061] Among them, MLP1 represents the fully connected network that constitutes the inference network, Softmax represents the Softmax function, represents the trajectory embedding of the current calculation trajectory sample, The probability distribution vector representing the current calculation trajectory sample belonging to each behavior mode.
[0062] Furthermore, in step A3, based on the trajectory embedding of each trajectory sample obtained in step A2, the trajectory similarity score between the two trajectory samples contained in each trajectory pair is calculated using the similarity learning network according to the following formula:
[0063]
[0064] Among them, MLP2 represents the fully connected network that constitutes the similarity learning network, Sigmod represents the Sigmod function, and They represent the trajectory embedding of the two trajectory samples contained in the trajectory sample pair respectively;
[0065] In step A3, based on the probability that each trajectory sample obtained in step A2 belongs to each behavior pattern, the pattern similarity score between the two trajectory samples contained in each trajectory pair is calculated using the similarity function according to the following formula:
[0066]
[0067] in, and They represent the probability distribution vectors of the two trajectory samples contained in the trajectory sample pair belonging to various behavior modes, and |·| represents the modulus length of the probability distribution vector;
[0068] In step A3, the similarity metric loss of each trajectory pair is calculated by aligning the pattern similarity score and trajectory similarity score of each trajectory pair according to the following formula:
[0069]
[0070] in, represents the pattern similarity score of the nth trajectory sample pair, represents the trajectory similarity score of the nth trajectory sample pair.
[0071] Furthermore, the calculation of the cross entropy loss in step A3 and step A4 includes:
[0072] First, based on the probability that each trajectory sample belongs to each type of behavior pattern in the corresponding step, each trajectory sample is classified, and labels are assigned to trajectory samples belonging to known behavior patterns and pseudo labels are assigned to trajectory samples belonging to unknown behavior patterns through one-hot encoding; each bit of the one-hot encoding corresponds to a type of behavior pattern, and the number of bits is U+K, where K represents the number of known behavior patterns and U represents the number of unknown behavior patterns;
[0073] For trajectory samples with known behavior patterns, the corresponding bit of the behavior pattern with the highest probability is 1, and the others are 0;
[0074] For trajectory samples of unknown behavior patterns, only when the probability of the current trajectory sample belonging to this type of behavior pattern obtained by reasoning is greater than the confidence threshold γ, the bit corresponding to this type of behavior pattern is 1, otherwise it is 0;
[0075] Then, the cross entropy loss of each trajectory sample is calculated based on the label or pseudo label of each trajectory sample according to the following formula:
[0076]
[0077] Where, M is the number of trajectories; represents the value of the cth position in the one-hot encoding of the label or pseudo-label of the mth track, Represents the probability that the mth trajectory obtained by inference network belongs to the cth behavior pattern.
[0078] Furthermore, in step A3, the total loss also includes entropy regularization loss The entropy regularization loss Calculated as follows:
[0079]
[0080] Where K represents the number of known behavior patterns, U represents the number of unknown behavior patterns, It represents the average value of the probability that each trajectory sample belongs to the cth type of behavior pattern.
[0081] Furthermore, in step A3, the total loss is calculated according to the following formula:
[0082]
[0083] in, represents the similarity metric loss of the nth trajectory sample pair, N is the number of trajectory sample pairs, represents the cross entropy loss, represents the entropy regularization loss.
[0084] The beneficial effects of the present invention are as follows: compared with the prior art, the architecture method of the vehicle abnormal trajectory detection model of the present invention first assigns labels to trajectory samples with known behavior patterns and assigns pseudo labels to trajectory samples with unknown behavior patterns during the training phase, making it possible to calculate the cross entropy loss; then, by aligning the similarity of embeddings between any two trajectories and the similarity of probability distributions between trajectories, a similarity metric loss of pairwise trajectory similarity is introduced, so that the model not only learns the classification of a single trajectory, but also understands the mutual relationship and probabilistic connection between different trajectories. Therefore, it can ensure that the probability distribution of the obtained model output can reflect the actual similarity and difference between trajectories, so that it can adapt to newly emerging trajectory patterns with unknown distributions, that is, it can effectively identify and classify unknown abnormal behaviors in the environment under the assumption of an open world.
[0085] Furthermore, through the similarity of the two trajectory embeddings, that is, the trajectory similarity score, the model can learn the relative relationship and structural features between the trajectories, rather than relying solely on specific labels seen during training; aligning it with the probability distribution similarity, that is, aligning the pattern similarity score with the trajectory similarity score, can enhance the robustness and accuracy of the model in processing unknown data and generalizing to new scenarios, while enhancing the model's ability to represent trajectory embeddings and the correlation between trajectory representation and predicted probability.
[0086] Therefore, the calculation of similarity metric loss prompts the model to learn deeper feature representations, so that similar trajectories are embedded close to each other in high-dimensional space, while different trajectories are relatively far away. This learning process emphasizes the richness and distinctiveness of information in the embedding vector, and enhances the model's ability to capture the intrinsic structure and pattern of trajectory data. Using similarity metric loss, through the optimization of pairwise similarity, the model is guided to form a meaningful clustering structure in the embedding space. This structure enables the model to better understand and distinguish various types of trajectories in the embedding space, providing a solid foundation for classification decisions.
[0087] When trajectory embeddings are optimized by similarity metric loss during training, their distribution in feature space becomes more suitable for classification tasks. Therefore, during inference, even if classification is performed only by the predicted probabilities of the inference network, the optimized embeddings can provide clearer and more distinguishable features, which directly improves the accuracy and reliability of classification. This strategy effectively encodes the intrinsic structure and similarity of trajectories into the embeddings, so that even simple probabilistic predictions can accurately reflect the category of the trajectory during the inference phase. BRIEF DESCRIPTION OF THE DRAWINGS
[0088] Figure 1 This is a diagram of the training process in an embodiment of the architecture method of a vehicle abnormal trajectory detection model in an open environment of the present invention. DETAILED DESCRIPTION
[0089] The present invention aims to propose a construction method for a vehicle abnormal trajectory detection model in an open environment. The constructed model can effectively identify and classify unknown abnormal behaviors in the environment under the assumption of an open world.
[0090] Specifically, the present invention provides a method for constructing a vehicle abnormal trajectory detection model in an open environment, wherein the vehicle abnormal trajectory detection model includes a coding network, an embedding network, and an inference network, wherein the coding network is a coding network that can capture the time-varying dependencies between trajectory points contained in the trajectory, and the training process of the vehicle abnormal trajectory detection model includes the following steps:
[0091] A1. Data preparation
[0092] Obtain trajectory samples and construct a data set. The acquired trajectory samples are divided into normal trajectories, known abnormal trajectories, and unknown abnormal trajectories according to whether the behavior patterns of the recorded trajectories are known. The behavior patterns of normal trajectories and known abnormal trajectories are known and used as labels, while the behavior patterns of unknown abnormal trajectories are unknown.
[0093] A2. Trajectory Classification
[0094] Input the trajectory sample of this round of training, use the encoding network to perform feature encoding, and obtain the trajectory encoding of the input trajectory sample; based on the obtained trajectory encoding, use the embedding network to perform embedding encoding, and obtain the trajectory embedding of the input trajectory sample; based on the obtained trajectory embedding, use the inference network to infer the probability that each trajectory sample belongs to each type of behavior mode;
[0095] A3. Model Update
[0096] Calculate the total loss, and based on the total loss, use the gradient descent method to update the vehicle abnormal trajectory detection model;
[0097] The total loss includes similarity metric loss and cross entropy loss; wherein the calculation of the similarity metric loss includes:
[0098] The trajectory samples input in this round of training are randomly combined in pairs to form trajectory pairs; based on the trajectory embedding of each trajectory sample obtained in step A2, the trajectory similarity score between the two trajectory samples contained in each trajectory pair is calculated using the similarity learning network; based on the probability that each trajectory sample obtained in step A2 belongs to each type of behavior pattern, the pattern similarity score between the two trajectory samples contained in each trajectory pair is calculated using the similarity function; by aligning the pattern similarity score and trajectory similarity score of each trajectory pair, the similarity measurement loss of each trajectory pair is calculated;
[0099] A4, extracting trajectory samples from the data set as input, using the vehicle abnormal trajectory detection model updated in step A3 to obtain the probability that each trajectory sample input in this step belongs to each type of behavior mode; then, based on the probability that each trajectory sample input in this step belongs to each type of behavior mode, calculating the cross entropy loss, and using the gradient descent method to update the parameters of the similarity learning network;
[0100] A5. Loop through steps A2 to A4 until the training termination condition is reached, thereby obtaining a trained vehicle abnormal trajectory detection model.
[0101] The calculation of the cross entropy loss in step A3 and step A4 includes:
[0102] Based on the probability that each trajectory sample input in the corresponding step belongs to each type of behavior pattern, each trajectory sample is classified, and labels are assigned to trajectory samples belonging to known behavior patterns, and pseudo labels are assigned to trajectory samples belonging to unknown behavior patterns; then, based on the labels or pseudo labels of each trajectory sample, the cross entropy loss of each trajectory sample is calculated.
[0103] Among them, the encoding network is used to perform feature encoding to obtain the trajectory encoding of the input trajectory sample; based on the obtained trajectory encoding, the embedding network is used to perform embedding encoding to obtain the trajectory embedding of the input trajectory sample to capture long sequence dependencies; based on the obtained trajectory embedding, the inference network is used to map the trajectory to the U+K dimensional space to obtain the predicted probability distribution, where K represents the number of known behavior patterns and U represents the number of unknown behavior patterns.
[0104] In an open environment, trajectory data may contain unknown or unseen patterns and behaviors. The unknown behavior pattern refers to a trajectory behavior pattern that has not appeared before and is different from the known class behavior pattern, and it can be clustered through the trajectory behavior features learned by the model. The basis for classifying unknown behavior patterns is the behavior pattern of the trajectory, and similar patterns are clustered into one category. Compared with existing methods, existing methods can only classify known classes from known classes and unknown classes, and separate unknown classes from known classes; while the present invention, on the basis of realizing the functions of existing methods, can also classify unknown classes.
[0105] In order to achieve clustering of behavior patterns, especially unknown classes, the construction method of the present invention introduces a similarity metric loss in the total loss during the training phase. It is based on the embedded representation of the trajectory and obtains the trajectory similarity score of the two trajectories through a similarity learning network; at the same time, in order to cluster trajectories with different behavior patterns, a formal alignment principle for similarity measurement is proposed, that is, using the output of the inference network and using a simple similarity measurement, such as cosine similarity, to estimate the pattern similarity of the two trajectories. Finally, the similarity metric loss of the two trajectories is calculated by aligning the pattern similarity score and trajectory similarity score of the trajectory.
[0106] By calculating the similarity of two trajectory embeddings through the similarity learning network, the model can learn the relative relationship and structural features between trajectories, rather than relying solely on specific labels seen during training. This helps the model effectively classify new or rare trajectory types through learned similarity patterns. The similarity of two trajectory embeddings enables the model to clearly distinguish between trajectories of different categories, optimize classification boundaries by comparing the embedding representations of different trajectories, and enhance the embedding ability of trajectories. This method is particularly important when the differences between categories are not very significant, and helps to improve the granularity of classification.
[0107] Aligning the embedding similarity with the predicted probability distribution means that the model must not only learn the classification of individual trajectories, but also understand the relationships and probabilistic connections between different trajectories. This alignment helps ensure that the model's output, the probability distribution, reflects the actual similarities and differences between trajectories, and can enhance the model's robustness and accuracy in processing unknown data and generalizing to new scenarios. It also enhances the model's ability to embed trajectory representations and the correlation between trajectory representations and predicted probabilities, making predictions more accurate and reliable.
[0108] However, it should be noted that in the early stage of training, the similarity signal provided by the similarity learning network is extremely noisy. Optimizing all parameters of the vehicle abnormal trajectory detection model and the similarity learning network at the same time will seriously affect the ability of the inference network to identify unknown patterns. Therefore, the construction method of the present invention constructs an interactive optimization strategy during training. Specifically, first, the parameters of the vehicle abnormal trajectory detection model are optimized using the total loss; then, based on the updated vehicle abnormal trajectory detection model, predictions are made again, and the cross entropy loss function is used to optimize the parameters of the similarity learning network.
[0109] Secondly, during the training process, using only trajectory labels of known class behavior patterns may lead to unacceptable bias. Therefore, when facing trajectories with unknown behavior patterns, pseudo labels are also assigned to them. In order to reduce the risk of unreliable pseudo labels, when performing one-hot encoding of pseudo labels, it is best to introduce a confidence threshold γ.
[0110] Third, there is a risk that the inference network will assign all trajectories with different unknown behavior patterns to the same category. That is, when dealing with trajectories with unknown behavior patterns, the model may be overconfident and prefer a specific behavior pattern. Therefore, in order to ensure a uniform distribution among various behavior patterns, it is best to introduce entropy regularization loss in the total loss to enhance the diversity of category predictions.
[0111] As described above, the improvement of the construction method of the present invention mainly lies in the training of the model during the construction process. Therefore, the vehicle abnormal trajectory detection model can be any existing model. However, it should be noted that the existing encoding network usually focuses on capturing the global dependencies of specific trajectories based on random initialization of regions, while ignoring the context-aware learning at the regional level, and thus cannot capture the correlation between the various regions of the trajectory; in the present invention, effectively and efficiently capturing the long-term dependencies between the trajectory points contained in the trajectory is particularly important for maintaining the consistency of individual behavioral intentions and identifying abnormal scale patterns. Therefore, the encoding network of the vehicle abnormal trajectory detection model of the present invention should be an encoding network that can capture the time-varying dependencies between the trajectory points contained in the trajectory, such as: LSTM, GRU, SGE-net, TLUTE (Trajectory Linking via UserEmbedding and Trajectory Embedding), etc., which is used to capture these time-varying dependencies by introducing a recurrent neural network (RNN).
[0112] However, the encoding networks based on RNN or RNN variants face challenges in processing long trajectory data with complex spatiotemporal dependencies, such as gradient vanishing or complex dependencies hidden behind the trajectory. Therefore, it is best to use relational distillation for encoding. The encoding network based on relational distillation uses contrastive learning between different dimensions and / or different regions to capture unique information from different dimensions and / or different regions. Specifically:
[0113] The area of the road network completely covered by all trajectory samples of the data set is defined as an identification area, and the identification area is gridded; the encoding network includes a pre-trained spatiotemporal semantic embedding matrix; in step A2, the trajectory samples of this round of training are input, and the pre-trained spatiotemporal semantic embedding matrix is used to obtain the spatiotemporal semantic coding of the grid contained in the trajectory sample based on the mapping relationship between the grid contained in the trajectory sample and the matrix, so as to constitute the trajectory coding of the trajectory sample.
[0114] The pre-training process of the spatiotemporal semantic embedding matrix includes:
[0115] B1. Data initialization
[0116] Constructing and initializing a spatiotemporal semantic embedding matrix, wherein the elements of the spatiotemporal semantic embedding matrix correspond one-to-one to the grids of the recognition area;
[0117] B2. Input the trajectory samples in the dataset constructed in step A1 one by one
[0118] Taking the input trajectory sample as the current trajectory, and the grids that the current trajectory passes through on the grid map, construct the positive sample grid set of the current trajectory tr; sampling grids from the grids contained in the trajectory samples whose starting grids and ending grids are different from the current trajectory tr in the dataset, constitute the negative sample grid set of the current trajectory tr; using the spatiotemporal semantic embedding matrix, based on the mapping relationship between the grid and the matrix, obtain the spatiotemporal semantic encoding of each grid in the positive sample grid set and the negative sample grid set;
[0119] B3. Update the spatiotemporal semantic embedding matrix
[0120] Using the spatiotemporal semantic encoding of each grid obtained in step B2, through comparative learning of positive sample grids and negative sample grids, relationship distillation is performed based on minimization expectation to update the spatiotemporal semantic embedding matrix;
[0121] B4. Loop through steps B2 to B3 until all trajectory samples in the dataset are traversed to obtain a spatiotemporal semantic embedding matrix that has completed training.
[0122] The encoding method, that is, the encoding based on relational distillation, can be the existing ReMVC (Region Embedding with Multi-View Contrastive Learning).
[0123] In the embodiment, in step B3, the spatiotemporal semantic encoding of each grid obtained in step B2 is used to update the spatiotemporal semantic embedding matrix by performing relation distillation based on minimization expectation through comparative learning of positive sample grids and negative sample grids according to the following formula:
[0124]
[0125] in, represents the minimization expectation, r l is the lth positive sample grid, r l ∈tr\(S,D) indicates that the positive sample grid set includes the grids of the current trajectory tr except the starting grid S and the end grid D, and s(·) indicates the similarity calculation; Represents the spatiotemporal semantic encoding of the anchor point used as the comparison benchmark, and the grid corresponding to the anchor point belongs to the current trajectory tr; r j is the jth negative sample grid, J represents the number of grids sampled from the negative sample grid set; v(r l ) and v(rj ) represent the positive sample grid r l and negative sample grid r j spatiotemporal semantic encoding.
[0126] The significance of the above encoding method lies in the following: first, there is a strong correlation between each region in a given trajectory and its corresponding start and end regions, so each region in the trajectory may play an important role to indicate whether it is normal or abnormal; second, the fact that each trajectory traverses multiple regions indicates that these regions may have significant interactions, reflecting behavioral patterns. Therefore, through comparative learning of positive sample grids and negative sample grids, relation distillation based on minimization of expectations, and extraction of interactive semantics between grids in the trajectory, the time-varying dependencies of the trajectory can be effectively and efficiently mined, thereby generating a dense but semantically rich representation for each grid.
[0127] In the above calculation, the anchor point can be every grid belonging to the current trajectory tr. However, in a given trajectory, the strong correlation between the trajectory grids is mainly reflected in: the strong correlation between the grid and the start and end grids, and the strong correlation between the grid and the adjacent path grids. Therefore, in order to simplify the calculation, the pre-trained spatiotemporal semantic embedding matrix includes the first spatiotemporal semantic embedding matrix V1 and the second spatiotemporal semantic embedding matrix V2; and define Among them, r l1 With r l2 They represent the two grids that constitute the anchor point, and use the starting grid and the end grid of the current trajectory tr to form the anchor point for updating the first spatiotemporal semantic embedding matrix V1, and use the grid r that is the same as the current calculation positive sample l Two adjacent grids belonging to the current trajectory tr constitute anchor points for updating the second spatiotemporal semantic embedding matrix V2.
[0128] The scheme of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0129] Example
[0130] This embodiment provides a method for constructing a vehicle abnormal trajectory detection model in an open environment. The vehicle abnormal trajectory detection model includes an encoding network, an embedding network, and an inference network. Figure 1 As shown, the training process of the vehicle abnormal trajectory detection model includes the following steps:
[0131] S1. Build a dataset:
[0132] First, trajectory samples are obtained and a dataset is constructed. The acquired trajectory samples are divided into normal trajectories, known abnormal trajectories, and unknown abnormal trajectories according to whether the behavior patterns of the recorded trajectories are known. The behavior patterns of normal trajectories and known abnormal trajectories are known and used as labels, while the behavior patterns of unknown abnormal trajectories are unknown.
[0133] In order to facilitate the acquisition of training data, in this embodiment, the acquired trajectory samples include normal trajectories, detour anomalies, navigation anomalies, and route exchange anomalies; any one of the three anomalies is used as a known abnormal trajectory, and the remaining two anomalies are used as unknown abnormal trajectories. That is, in this embodiment, U+K=4, the number of known behavior patterns K is 2, including normal trajectories and one type of abnormal trajectory; the number of unknown behavior patterns U is also 2, including the remaining two types of abnormal trajectories.
[0134] Then, the area of the road network completely covered by all trajectory samples of the data set is demarcated as the recognition area, and the recognition area is gridded. Grid division is usually performed according to the size of the recognition area. If the recognition area is relatively large, the trajectory will usually be longer and the granularity of the division will be larger. If the grid is too small, the trajectory length will be too long and the model will be difficult to learn. Therefore, it is best to grid the abnormal recognition area, and the side length of the divided grid should be greater than or equal to 100m and less than or equal to 500m. In this embodiment, the trajectory data is taxi trajectory data, the recognition area is the main urban area of the city, and a 100m×100m grid is used.
[0135] At the same time, it should be noted that a trajectory that is too short is random and not representative. Therefore, further, in this step, each trajectory sample in the data set is traversed to obtain the grids it passes through on the grid map, and the trajectory samples whose number of grids passed through is less than the threshold are excluded, and the data set is updated to retain only the remaining trajectory samples. In this embodiment, the trajectory samples whose number of grids passed through is less than 20 grids are excluded.
[0136] In addition, in order to facilitate subsequent calculations, especially the extraction of subsequent negative samples, in this step, the trajectory samples contained in the data set are sorted according to their starting grid and end grid.
[0137] S2. Pre-training of spatiotemporal semantic embedding matrix
[0138] S21. Data initialization
[0139] Construct and initialize a spatiotemporal semantic embedding matrix, the elements of which correspond one-to-one to the grids of the identification area to achieve mapping based on the grid ID; the spatiotemporal semantic embedding matrix includes a first spatiotemporal semantic embedding matrix V1 and a second spatiotemporal semantic embedding matrix V2.
[0140] S22, input the trajectory samples in the data set constructed in step S1 in sequence
[0141] Taking the input trajectory sample as the current trajectory and the grids that the current trajectory passes through on the grid map, a positive sample grid set of the current trajectory tr is constructed; grids are sampled from the grids contained in the trajectory samples whose starting grids and ending grids are different from the current trajectory tr in the data set to form a negative sample grid set of the current trajectory tr; using the spatiotemporal semantic embedding matrix, based on the mapping relationship between the grid and the matrix, the first spatiotemporal semantic code and the second spatiotemporal semantic code of each grid in the positive sample grid set and the negative sample grid set are obtained respectively;
[0142] S23. Update spatiotemporal semantic embedding matrix
[0143] Using the spatiotemporal semantic encoding of each grid obtained in step S22, through comparative learning of positive sample grids and negative sample grids, relation distillation is performed based on minimizing expectations to update the spatiotemporal semantic embedding matrix.
[0144] Among them, the first spatiotemporal semantic embedding matrix V1 is updated according to the following formula:
[0145]
[0146] Update the second spatiotemporal semantic embedding matrix V2 according to the following formula:
[0147]
[0148] in, represents the minimization expectation, r l is the lth positive sample grid, r l ∈tr\(S,D) indicates that the positive sample grid set includes the grids of the current trajectory tr except the starting grid S and the end grid D, s(·) indicates the cosine similarity calculation; r j is the jth negative sample grid, J represents the number of grids sampled from the negative sample grid set; v(r l ) and v(r j ) represent the positive sample grid r l and negative sample grid r j spatiotemporal semantic encoding.
[0149] Represents the spatiotemporal semantic encoding of the anchor point used as the comparison benchmark, and the grid corresponding to the anchor point belongs to the current trajectory tr, defined as:
[0150]
[0151] Among them, r l1 With rl2 They represent the two grids that constitute the anchor point, and use the starting grid and the end grid of the current trajectory tr to form the anchor point for updating the first spatiotemporal semantic embedding matrix V1, and use the grid r that is the same as the current calculation positive sample l Two adjacent grids belonging to the current trajectory tr constitute anchor points for updating the second spatiotemporal semantic embedding matrix V2.
[0152] S24, looping through steps S22 to S23 until all trajectory samples in the data set are traversed to obtain a spatiotemporal semantic embedding matrix that has completed training.
[0153] S3, trajectory encoding
[0154] First, the trajectory samples of this round of training are input, and the first spatiotemporal semantic embedding matrix V1 and the second spatiotemporal semantic embedding matrix V2 of the pre-training are used respectively. Based on the mapping relationship between the grids contained in the trajectory samples and the matrices, the first spatiotemporal semantic coding and the second spatiotemporal semantic coding of the grids contained in the trajectory samples are obtained to form the first trajectory coding and the second trajectory coding of the trajectory samples.
[0155] Then, aggregation is performed to obtain the trajectory encoding of the trajectory sample. The aggregation methods include: splicing, weight sum, neural network, etc. In order to achieve the adaptive adjustment of the aggregation weight during the aggregation process of the first spatiotemporal semantic region encoding and the second spatiotemporal semantic region encoding, in this embodiment, the encoding network includes an aggregation network and a pre-trained spatiotemporal semantic embedding matrix. The aggregation network adopts a fully connected network, and according to the following formula, aggregation is performed through the aggregation network to obtain the trajectory encoding of the trajectory sample
[0156] v(r l )=[v1(r l );v2(r l )]W r +b r
[0157]
[0158] Among them, r l represents the lth grid of the trajectory sample, v(r l ) represents the grid r l The spatiotemporal semantic encoding of v1(r l ) and v2(r l ) represent the grid r l The first spatiotemporal semantic code and the second spatiotemporal semantic code, [;] represents the concatenation operation; W r and b r are the trainable parameters of the fully connected network that constitutes the aggregation network; L represents the number of grids contained in the trajectory sample.
[0159] S4. Trajectory Embedding
[0160] The embedding network can adopt any existing network, such as RNN. In this embodiment, the embedding network adopts a state space model. Generally, the state space model can be expressed as:
[0161] x l =Ax l-1 +Bv(r l ), h l =Cx l +Dv(r l )
[0162] Among them, x l is the state variable, h l is the output variable, v(r l ) are input variables, and A, B, C, and D are parameters of the state-space model.
[0163] The above formula is the state space equation in the continuous time case, and in order to use this model in a discrete time system, the system needs to be discretized. In digital control, the input usually remains unchanged during the sampling period until the next sampling period begins. Therefore, based on the zero-order hold, it is assumed that the input remains constant in each sampling period during the continuous to discrete conversion process.
[0164] Therefore, if a sampling period Δ is given, then:
[0165]
[0166]
[0167] Where (ΔA) -1 is the inverse matrix of the ΔA matrix. Applying the formula to the continuous form, we can get:
[0168]
[0169] Where L is the number of grids in the trajectory.
[0170] therefore, Modeling dependency dynamics can be viewed as a convolutional process, performed in a non-autoregressive or parallel manner, where the total output h = [h1,h2,…,h l ,…h L ] will be calculated once.
[0171] Based on the above assumptions, the spatiotemporal semantic region encoding of the input trajectory sample
[0172]
[0173] Then, through the state space model under the discrete time system, the state space output of the input trajectory sample can be calculated:
[0174]
[0175]
[0176]
[0177]
[0178] Among them, GELU represents the GELU activation function, represents the Fourier transform, represents the inverse Fourier transform, K L is the convolution kernel of the state space model obtained by dynamic modeling of the dynamic dependencies of each grid contained in the current calculation trajectory sample. A, B, and C are all parameters of the state space. (ΔA) -1 is the inverse matrix of ΔA matrix, Δ represents the sampling period, I is the unit matrix, W D Corresponding to the parameter D of the state space equation; r l represents the lth grid of the current calculation trajectory sample, v(r l ) represents the grid r l The spatiotemporal semantic encoding of L represents the number of grids contained in the current calculation trajectory sample.
[0179] Then, based on the state space output of the current calculated trajectory sample h = [h1, h2, ..., h l ,…h L ], calculate the trajectory embedding of the current calculation trajectory sample:
[0180]
[0181] in, Represents the trajectory embedding of the current computation trajectory sample.
[0182] S5. Probabilistic Reasoning
[0183] The reasoning network can adopt any reasoning network, such as UNO (UNified Objective). UNO is a novel objective function that aims to solve the novel class discovery (NCD) problem by leveraging prior knowledge of labeled datasets to infer new object categories in unlabeled datasets. Specifically, UNO uses a multi-view self-labeling strategy to generate pseudo labels, which are processed in a unified way together with the true labels.
[0184] In this embodiment, the inference network adopts a fully connected network. Specifically, according to the following formula, based on the obtained trajectory embedding, the inference network is used to infer the probability that each trajectory sample belongs to each type of behavior mode:
[0185]
[0186] Among them, MLP1 represents the fully connected network that constitutes the inference network, Softmax represents the Softmax function, represents the trajectory embedding of the current calculation trajectory sample, The probability distribution vector representing the current calculation trajectory sample belonging to each behavior mode.
[0187] S6. Model update
[0188] In this step, the total loss is calculated, and based on the total loss, the vehicle abnormal trajectory detection model is updated using the gradient descent method. The model is also the vehicle abnormal trajectory detection model constructed by the present invention. Since the similarity learning network is only used in the training phase, the model does not include the similarity learning network. In this embodiment, the vehicle abnormal trajectory detection model includes a state space model, an inference network, and an aggregation network.
[0189] The total loss includes similarity metric loss, cross entropy loss and entropy regularization loss. The total loss is calculated according to the following formula:
[0190]
[0191] in, represents the similarity metric loss of the nth trajectory sample pair, N is the number of trajectory sample pairs, represents the cross entropy loss, represents the entropy regularization loss.
[0192] Among them, the similarity measurement loss The calculation includes:
[0193] Combine any two of the trajectory samples input in this round of training to form trajectory pairs;
[0194] Based on the trajectory embedding of each trajectory sample obtained in step S4, the trajectory similarity score between the two trajectory samples contained in each trajectory pair is calculated using the similarity learning network according to the following formula:
[0195]
[0196] Among them, MLP2 represents the fully connected network that constitutes the similarity learning network, Sigmod represents the Sigmod function, and They represent the trajectory embedding of the two trajectory samples contained in the trajectory sample pair respectively;
[0197] Based on the probability that each trajectory sample obtained in step S5 belongs to each behavior pattern, the pattern similarity score between the two trajectory samples contained in each trajectory pair is calculated using the similarity function according to the following formula:
[0198]
[0199] in, and They represent the probability distribution vectors of the two trajectory samples contained in the trajectory sample pair belonging to various behavior modes, and |·| represents the modulus length of the probability distribution vector;
[0200] The similarity metric loss for each trajectory pair is calculated by aligning the pattern similarity score and trajectory similarity score of each trajectory pair according to the following formula:
[0201]
[0202] in, represents the pattern similarity score of the nth trajectory sample pair, represents the trajectory similarity score of the nth trajectory sample pair.
[0203] Among them, the cross entropy loss The calculation includes:
[0204] First, based on the probability that each trajectory sample of this round of training input belongs to each type of behavior pattern obtained in step S5, each trajectory sample is classified, and through one-hot encoding, labels are assigned to trajectory samples belonging to known behavior patterns, and pseudo labels are assigned to trajectory samples belonging to unknown behavior patterns; each bit of the one-hot encoding corresponds to a type of behavior pattern, and the number of bits is U+K, K represents the number of known behavior patterns, and U represents the number of unknown behavior patterns.
[0205] For trajectory samples with known behavior patterns, the corresponding bit of the behavior pattern with the highest probability is 1, and the others are 0;
[0206] For trajectory samples of unknown behavior patterns, only when the probability of the current trajectory sample belonging to this type of behavior pattern obtained through inference is greater than the confidence threshold γ, the bit corresponding to this type of behavior pattern is 1, otherwise it is 0.
[0207] Then, the cross entropy loss of each trajectory sample is calculated based on the label or pseudo label of each trajectory sample according to the following formula:
[0208]
[0209] Where, M is the number of trajectories; represents the value of the cth position in the one-hot encoding of the label or pseudo-label of the mth track, Represents the probability that the mth trajectory obtained by inference network belongs to the cth behavior pattern.
[0210] Among them, the entropy regularization loss The calculation formula is:
[0211]
[0212] Where K represents the number of known behavior patterns, U represents the number of unknown behavior patterns, It represents the average value of the probability that each trajectory sample belongs to the cth type of behavior pattern.
[0213] S7. Similarity learning network update
[0214] In this step, the trajectory samples in the data set are extracted as input, and the abnormal vehicle trajectory detection model obtained by updating in step S6 is used to obtain the probability that each trajectory sample input in this step belongs to each type of behavior pattern; then, based on the probability that each trajectory sample input in this step belongs to each type of behavior pattern, the cross entropy loss of this step is calculated in the same way as in step S6, and the parameters of the similarity learning network are updated using the gradient descent method.
[0215] S8. Training iteration
[0216] In this step, it is determined whether the training termination condition is met. If so, a trained vehicle abnormal trajectory detection model is obtained; otherwise, steps S3 to S7 are executed in a loop.
[0217] After the training is completed, the construction of the vehicle abnormal trajectory detection model is completed, and the trained vehicle abnormal trajectory detection model can be used to perform the detection task. In actual use, the vehicle trajectory data to be detected is used as input, and the first spatiotemporal semantic embedding matrix and the second spatiotemporal semantic embedding matrix obtained by pre-training in step S2 are used to obtain its first trajectory encoding and the second trajectory encoding; then, according to the method of steps S3 to S5, the probability that the trajectory to be detected belongs to each type of behavior pattern is inferred; then, according to the probability that the trajectory to be detected belongs to each type of behavior pattern, the detection result is output, and the detection result is the label of the normal trajectory, the label of the known class abnormal trajectory, and the number of the unknown class abnormal trajectory. The number of the unknown class abnormal trajectory is a similar numbering form such as unknown class one, unknown class two, etc.
[0218] In order to verify the effect of the abnormal vehicle trajectory detection model constructed by the present invention, an experiment was conducted, and Table 1 shows the classification accuracy comparison between the abnormal vehicle trajectory detection model constructed by the embodiment and the existing model. In Table 1, k-means is an unlabeled clustering algorithm in the classic machine learning algorithm; ORCA (Open-woRld with unCertainty based Adaptive margin) and TRSSL (Towards Realistic Semi-Supervised Learning) are classification methods for unknown classes and known classes in the image field in recent years; the Known index is the accuracy of the known class, the Unknown index is the accuracy of the unknown class, the All index is the accuracy of all classes, and Porto and Chengdu are taxi trajectory data sets in two cities. From Table 1, it can be seen that the classification accuracy of the model constructed by the embodiment has been greatly improved.
[0219] Table 1 Comparison of classification accuracy between the model constructed in the embodiment and the existing model
[0220]
[0221] Table 2 Classification accuracy using different encoding networks
[0222]
[0223] Table 2 shows the classification results of trajectories of different lengths constructed based on the construction method of the present invention using different encoding networks. In Table 2, ACC is the classification accuracy of all classes, NMI (Normalized Mutual Information) and ARI (Adjusted Rand Index) are clustering indicators of unknown classes, the higher the better. Among them, NMI measures the similarity between the clustering result and the true label from the perspective of information theory; ARI is a Rand Index (RI) adjusted according to the decision pair method.
[0224] As can be seen from Table 2, models using different encoding methods can still achieve the classification of abnormal trajectories. However, due to the different encoding methods, the ability to capture the time-varying dependencies between trajectory points contained in the trajectory is different, which affects the final classification results. The embodiment is the best, followed by the model using LSTM in the encoding network. At the same time, due to the limitations of the encoding method itself, there are also differences in processing long and short trajectories. For example, the performance of LSTM and GRU encoding networks both decreases when processing trajectories with a length of >300, and the decrease of GRU is particularly obvious. Since trajectory anomalies are usually local features, and the Attention mechanism sometimes tends to capture global features, resulting in insufficient ability to capture local anomalies. For example, the various indicators of the Attention mechanism in Table 2 are lower than those of other encoding models.
[0225] Therefore, it should be recognized that the trajectory encoding network of the model constructed by the present invention has the core task of mining time-varying dependencies, which is crucial to improving the accuracy or quality of the task. It should select an encoding network that can capture the time-varying dependencies between the trajectory points contained in the trajectory, such as the encoding network based on relational distillation, the encoding network based on RNN, or the encoding network constructed by the variant of RNN described in the embodiment. Based on the above understanding, those skilled in the art should be able to select, adjust and optimize the architecture of the vehicle abnormal trajectory detection model according to its actual application scenario, so that the model can obtain performance that meets the requirements of its scenario.
[0226] Finally, it should be noted that the above embodiments are only preferred implementations and are not intended to limit the present invention. It should be pointed out that for those skilled in the art, several modifications, equivalent replacements, improvements, etc. can be made without departing from the scope of the present invention and the scope of protection of the claims, and all of these should be included in the protection scope of the present invention.
Claims
1. A method for constructing a vehicle abnormal trajectory detection model in an open environment, wherein the vehicle abnormal trajectory detection model includes an encoding network, an embedding network, and an inference network, and is characterized in that: The encoding network is an encoding network that can capture the time-varying dependencies between trajectory points contained in the trajectory. The training process of the vehicle abnormal trajectory detection model includes the following steps: A1. Data preparation Obtain trajectory samples and construct a data set. The acquired trajectory samples are divided into normal trajectories, known abnormal trajectories, and unknown abnormal trajectories according to whether the behavior patterns of the recorded trajectories are known. The behavior patterns of normal trajectories and known abnormal trajectories are known and used as labels, while the behavior patterns of unknown abnormal trajectories are unknown. A2. Trajectory Classification Input the trajectory sample of this round of training, use the encoding network to perform feature encoding, and obtain the trajectory encoding of the input trajectory sample; based on the obtained trajectory encoding, use the embedding network to perform embedding encoding, and obtain the trajectory embedding of the input trajectory sample; based on the obtained trajectory embedding, use the inference network to infer the probability that each trajectory sample belongs to each type of behavior mode; A3. Model Update Calculate the total loss, and based on the total loss, use the gradient descent method to update the vehicle abnormal trajectory detection model; The total loss includes similarity metric loss and cross entropy loss; wherein the calculation of the similarity metric loss includes: The trajectory samples input in this round of training are randomly combined in pairs to form trajectory pairs; based on the trajectory embedding of each trajectory sample obtained in step A2, the trajectory similarity score between the two trajectory samples contained in each trajectory pair is calculated using the similarity learning network; based on the probability that each trajectory sample obtained in step A2 belongs to each type of behavior pattern, the pattern similarity score between the two trajectory samples contained in each trajectory pair is calculated using the similarity function; by aligning the pattern similarity score and trajectory similarity score of each trajectory pair, the similarity measurement loss of each trajectory pair is calculated; A4, extracting trajectory samples from the data set as input, using the vehicle abnormal trajectory detection model updated in step A3 to obtain the probability that each trajectory sample input in this step belongs to each type of behavior mode; then, based on the probability that each trajectory sample input in this step belongs to each type of behavior mode, calculating the cross entropy loss, and using the gradient descent method to update the parameters of the similarity learning network; A5. Execute steps A2 to A4 in a loop until the training termination condition is reached, thereby obtaining a trained vehicle abnormal trajectory detection model; The calculation of the cross entropy loss in step A3 and step A4 includes: Based on the probability that each trajectory sample input in the corresponding step belongs to each type of behavior pattern, each trajectory sample is classified, and labels are assigned to trajectory samples belonging to known behavior patterns, and pseudo labels are assigned to trajectory samples belonging to unknown behavior patterns; then, based on the labels or pseudo labels of each trajectory sample, the cross entropy loss of each trajectory sample is calculated.
2. The method for constructing a vehicle abnormal trajectory detection model in an open environment as claimed in claim 1, characterized in that: In step A1, the acquired trajectory samples include normal trajectories, detour anomalies, navigation anomalies, and route exchange anomalies; any one of the three anomalies is regarded as a known abnormal trajectory, and the remaining two anomalies are regarded as unknown abnormal trajectories.
3. The method for constructing a vehicle abnormal trajectory detection model in an open environment as claimed in claim 1, characterized in that: The encoding network adopts an encoding network based on relational distillation, an encoding network based on RNN, or an encoding network constructed based on a variant of RNN.
4. The method for constructing a vehicle abnormal trajectory detection model in an open environment as claimed in claim 1, characterized in that: The area of the road network completely covered by all trajectory samples of the data set is defined as an identification area, and the identification area is gridded; the encoding network adopts an encoding network based on relational distillation, including a pre-trained spatiotemporal semantic embedding matrix; in step A2, the trajectory sample of this round of training is input, and the pre-trained spatiotemporal semantic embedding matrix is used to obtain the spatiotemporal semantic coding of the grid contained in the trajectory sample based on the mapping relationship between the grid contained in the trajectory sample and the matrix, so as to form the trajectory coding of the trajectory sample; The pre-training process of the spatiotemporal semantic embedding matrix includes: B1. Data initialization Constructing and initializing a spatiotemporal semantic embedding matrix, wherein the elements of the spatiotemporal semantic embedding matrix correspond one-to-one to the grids of the recognition area; B2. Input the trajectory samples in the dataset constructed in step A1 one by one Taking the input trajectory sample as the current trajectory, and the grids that the current trajectory passes through on the grid map, construct the positive sample grid set of the current trajectory tr; sampling grids from the grids contained in the trajectory samples whose starting grids and ending grids are different from the current trajectory tr in the dataset, constitute the negative sample grid set of the current trajectory tr; using the spatiotemporal semantic embedding matrix, based on the mapping relationship between the grid and the matrix, obtain the spatiotemporal semantic encoding of each grid in the positive sample grid set and the negative sample grid set; B3. Update the spatiotemporal semantic embedding matrix Using the spatiotemporal semantic encoding of each grid obtained in step B2, through comparative learning of positive sample grids and negative sample grids, relationship distillation is performed based on minimization expectation to update the spatiotemporal semantic embedding matrix; B4. Loop through steps B2 to B3 until all trajectory samples in the dataset are traversed to obtain a spatiotemporal semantic embedding matrix that has completed training.
5. The method for constructing a vehicle abnormal trajectory detection model in an open environment as claimed in claim 4, characterized in that: The identification area is gridded, and the side length of the divided grid should be greater than or equal to 100m and less than or equal to 500m; in step A1, each trajectory sample in the data set is traversed to obtain the grids it passes through on the grid map respectively, and the trajectory samples whose number of grids passed through is less than a threshold are excluded, and the data set is updated to retain only the remaining trajectory samples; in step A1, the trajectory samples contained in the data set are sorted according to their starting grid and end grid.
6. The method for constructing a vehicle abnormal trajectory detection model in an open environment as claimed in claim 4 or 5, characterized in that: In step B3, the spatiotemporal semantic encoding of each grid obtained in step B2 is used to update the spatiotemporal semantic embedding matrix by comparing the positive sample grid and the negative sample grid and performing relation distillation based on minimization expectation according to the following formula: in, represents the minimization expectation, r l is the lth positive sample grid, r l ∈tr\(S, D) means that the positive sample grid set includes the grids of the current trajectory tr except the starting grid S and the end grid D, and s(·) means the similarity calculation; Represents the spatiotemporal semantic encoding of the anchor point used as the comparison benchmark, and the grid corresponding to the anchor point belongs to the current trajectory tr; r j is the jth negative sample grid, J represents the number of grids sampled from the negative sample grid set; v(r l ) and v(r j ) represent the positive sample grid r l and negative sample grid r j spatiotemporal semantic encoding.
7. The method for constructing a vehicle abnormal trajectory detection model in an open environment as claimed in claim 6, characterized in that: The pre-trained spatiotemporal semantic embedding matrix includes a first spatiotemporal semantic embedding matrix V1 and a second spatiotemporal semantic embedding matrix V2; In step A2, the trajectory sample of this round of training is input, and the first spatiotemporal semantic embedding matrix V1 and the second spatiotemporal semantic embedding matrix V2 of the pre-training are used respectively, based on the mapping relationship between the grid contained in the trajectory sample and the matrix, the first spatiotemporal semantic coding and the second spatiotemporal semantic coding of the grid contained in the trajectory sample are obtained to form the first trajectory coding and the second trajectory coding of the trajectory sample; then, aggregation is performed to obtain the trajectory coding of the trajectory sample; In step B1, the first spatiotemporal semantic embedding matrix V1 and the second spatiotemporal semantic embedding matrix V2 are constructed and initialized respectively; in step B2, the first spatiotemporal semantic encoding and the second spatiotemporal semantic encoding of each grid in the positive sample grid set and the negative sample grid set are obtained respectively; in step B3, the definition Among them, r l1 With r l2 They represent the two grids that constitute the anchor point, and use the starting grid and the end grid of the current trajectory tr to form the anchor point for updating the first spatiotemporal semantic embedding matrix V1, and use the grid r that is the same as the current calculation positive sample l Two adjacent grids belonging to the current trajectory tr constitute anchor points for updating the second spatiotemporal semantic embedding matrix V2.
8. The method for constructing a vehicle abnormal trajectory detection model in an open environment as claimed in claim 7, characterized in that: The encoding network includes an aggregation network and a pre-trained spatiotemporal semantic embedding matrix. The aggregation network adopts a fully connected network. In step A2, the trajectory encoding of the trajectory sample is obtained by aggregation through the aggregation network according to the following formula: v(r l )=[v1(r l );v2(r l )]W r +b r Among them, r l represents the lth grid of the trajectory sample, v(r l ) represents the grid r l The spatiotemporal semantic encoding of v1(r l ) and v2(r l ) represent the grid r l The first spatiotemporal semantic code and the second spatiotemporal semantic code, [;] represents the concatenation operation; W r and b r are the trainable parameters of the fully connected network that constitutes the aggregation network; L represents the number of grids contained in the trajectory sample.
9. A method for constructing a vehicle abnormal trajectory detection model in an open environment as claimed in claim 1, 2, 3, 4 or 5, characterized in that: The embedding network adopts a state space model, and the inference network adopts a fully connected network; In step A2, based on the obtained trajectory encoding, embedding coding is performed using an embedding network to obtain a trajectory embedding of the input trajectory sample, including: First, to obtain the trajectory encoding As input to the state-space model, through the state-space model: x l =Ax l-1 +Bv(r l ),h l =Cx l +Dv(r l ) Calculate its state space output: Among them, x l is the state variable, h l is the output variable, v(r l ) is the input variable, A, B, C, and D are all parameters of the state space model; GELU represents the GELU activation function, represents the Fourier transform, represents the inverse Fourier transform, K L is the convolution kernel of the state space model obtained by dynamic modeling of the dynamic dependencies of each grid contained in the current calculation trajectory sample, (ΔA) -1 is the inverse matrix of ΔA matrix, Δ represents the sampling period, I is the unit matrix, W D Corresponding to the parameter D of the state space equation; r l represents the lth grid of the current calculation trajectory sample, v(r l ) represents the grid r l The spatiotemporal semantic encoding of L indicates the number of grids contained in the current calculation trajectory sample; Then, based on the state space output of the current calculated trajectory sample h = [h1, h2, ..., h l ,...h L ], calculate the trajectory embedding of the current calculation trajectory sample: in, Represents the trajectory embedding of the current calculation trajectory sample; In step A2, based on the obtained trajectory embedding, the probability of each trajectory sample belonging to each behavior mode is inferred using the inference network according to the following formula: Among them, MLP1 represents the fully connected network that constitutes the inference network, Softmax represents the Softmax function, represents the trajectory embedding of the current calculation trajectory sample, The probability distribution vector representing the current calculation trajectory sample belonging to each behavior mode.
10. A method for constructing a vehicle abnormal trajectory detection model in an open environment as claimed in claim 1, 2, 3, 4 or 5, characterized in that: In step A3, based on the trajectory embedding of each trajectory sample obtained in step A2, the trajectory similarity score between the two trajectory samples contained in each trajectory pair is calculated using the similarity learning network according to the following formula: Among them, MLP2 represents the fully connected network that constitutes the similarity learning network, Sigmod represents the Sigmod function, and They represent the trajectory embedding of the two trajectory samples contained in the trajectory sample pair respectively; In step A3, based on the probability that each trajectory sample obtained in step A2 belongs to each behavior pattern, the pattern similarity score between the two trajectory samples contained in each trajectory pair is calculated using the similarity function according to the following formula: in, and They represent the probability distribution vectors of the two trajectory samples contained in the trajectory sample pair belonging to various behavior modes, and |·| represents the modulus length of the probability distribution vector; In step A3, the similarity metric loss of each trajectory pair is calculated by aligning the pattern similarity score and trajectory similarity score of each trajectory pair according to the following formula: in, represents the pattern similarity score of the nth trajectory sample pair, represents the trajectory similarity score of the nth trajectory sample pair.
11. A method for constructing a vehicle abnormal trajectory detection model in an open environment as claimed in claim 1, 2, 3, 4 or 5, characterized in that: The calculation of the cross entropy loss in step A3 and step A4 includes: First, based on the probability that each trajectory sample belongs to each type of behavior pattern in the corresponding step, each trajectory sample is classified, and labels are assigned to trajectory samples belonging to known behavior patterns and pseudo labels are assigned to trajectory samples belonging to unknown behavior patterns through one-hot encoding; each bit of the one-hot encoding corresponds to a type of behavior pattern, and the number of bits is U+K, where K represents the number of known behavior patterns and U represents the number of unknown behavior patterns; For trajectory samples with known behavior patterns, the corresponding bit of the behavior pattern with the highest probability is 1, and the others are 0; For trajectory samples of unknown behavior patterns, only when the probability of the current trajectory sample belonging to this type of behavior pattern obtained by reasoning is greater than the confidence threshold γ, the bit corresponding to this type of behavior pattern is 1, otherwise it is 0; Then, the cross entropy loss of each trajectory sample is calculated based on the label or pseudo label of each trajectory sample according to the following formula: Where, M is the number of trajectories; represents the value of the cth position in the one-hot encoding of the label or pseudo-label of the mth track, Represents the probability that the mth trajectory obtained by inference network belongs to the cth behavior pattern.
12. A method for constructing a vehicle abnormal trajectory detection model in an open environment as claimed in claim 1, 2, 3, 4 or 5, characterized in that: In step A3, the total loss also includes entropy regularization loss The entropy regularization loss Calculated as follows: Where K represents the number of known behavior patterns, U represents the number of unknown behavior patterns, It represents the average value of the probability that each trajectory sample belongs to the cth type of behavior pattern.
13. The method for constructing a vehicle abnormal trajectory detection model in an open environment as claimed in claim 12, characterized in that: In step A3, the total loss is calculated according to the following formula: in, represents the similarity metric loss of the nth trajectory sample pair, N is the number of trajectory sample pairs, represents the cross entropy loss, represents the entropy regularization loss.
Citation Information
Patent Citations
Metric learning-based user trajectory similarity measurement method
CN107679558A
Trajectory similarity calculation method based on enhanced recurrent neural network
CN110990678A
Agent trajectory prediction using anchor trajectories
US20210001897A1
Massive high-dimensional AIS trajectory data clustering method
WO2023029461A1
Cited By
Vehicle trajectory similarity measurement method and system based on space-time consistency representation
CN118885824A
Forklift real-time map building and positioning method based on machine vision technology
CN119559325A
