An architecture method of a vehicle abnormal trajectory detection model in an open environment

By introducing encoding networks, embedding networks, and inference networks into the vehicle abnormal trajectory detection model, and combining similarity metric loss and cross-entropy loss, the problem of existing models being unable to identify unknown abnormal behaviors in open environments is solved. This enables effective classification and identification of unknown behaviors, improving the robustness and accuracy of the model.

CN118537645BActive Publication Date: 2026-03-27SOUTHWESTERN UNIV OF FINANCE & ECONOMICS
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-28
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing vehicle abnormal trajectory detection models cannot effectively identify and classify unknown abnormal behaviors in open environments, and cannot cope with incomplete knowledge in the real world.

Method used

We employ an architecture combining encoding, embedding, and inference networks. By combining similarity metric loss and cross-entropy loss, we train a model to capture the time-varying dependencies between trajectory points. Furthermore, we use a similarity learning network to calculate trajectory similarity scores and pattern similarity scores, thereby enabling the identification and classification of unknown abnormal behaviors.

Benefits of technology

In an open environment, the model can effectively identify and classify unknown abnormal behaviors, improve the robustness and accuracy of trajectory data, and enhance the model's ability to process unknown data and generalize to new scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118537645B_ABST
    Figure CN118537645B_ABST
Patent Text Reader

Abstract

The present application relates to the field of trajectory recognition, and particularly relates to a kind of open environment vehicle abnormal trajectory detection model architecture method, its model includes coding network, embedding network and inference network.In training phase, first, the total loss including similarity loss and cross-entropy loss is used to update model parameters, then, the updated model is used to update similarity learning network using cross-entropy loss until training is completed.The calculation of the similarity loss includes: based on trajectory embedding, the similarity between trajectories is calculated using similarity learning network, the cross-entropy loss is calculated based on the predicted probability distribution and the similarity between trajectories, then, the similarity loss is calculated by aligning the two types of similarity.The method of the present application introduces similarity loss, so that the model not only learns the classification of a single trajectory, but also understands the relationship and connection between different trajectories, which can effectively classify unknown abnormal behavior in the environment under the assumption of open world.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of trajectory recognition, and more specifically to an architecture method for a vehicle abnormal trajectory detection model in an open environment. Background Technology

[0002] The widespread adoption of mobile devices and location-aware sensing systems has generated a massive amount of location tracking data, making it possible to collect time-related trajectory datasets. Many researchers are dedicated to extracting valuable knowledge from these trajectories and applying it to specific applications. Identifying anomalous trajectories is one of the key tasks in trajectory mining, as it relates to the accuracy of certain services, such as the accuracy of mileage-based billing for commercial vehicles.

[0003] Intuitively, abnormal trajectories are those that deviate from the normal driving pattern, such as: abnormal detours, abnormal navigation, and abnormal route switching. Abnormal detours refer to situations where, in a vehicle's normal trajectory, the shortest path from the starting point to the destination is usually followed, but in reality, the vehicle takes a longer route. Abnormal navigation refers to inaccurate GPS positioning due to network or system issues, causing the vehicle to be located off-track. Abnormal route switching refers to situations where, due to real-world road conditions, the vehicle switches between several commonly used routes to allow passengers to reach their destination faster.

[0004] However, in practice, solving this problem is not a simple task due to differences in individual preferences and the uncertainty of traffic patterns. Most efforts primarily seek to detect anomalies in normal trajectories that deviate from specific travel demands, such as trajectories from source S to destination D. To this end, most traditional research identifies anomalies through heuristic-based and learning-based paradigms. The former mainly relies on density or distance measurements to find outliers, while the latter aims to use 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, which 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 (RNN) to process the diverse sequential 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 end-to-end frameworks 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 the function approximation ability to build a model that distinguishes patterns, cannot reveal the rich spatiotemporal semantics behind a large number of trajectories, such as dynamic dependencies.

[0006] Existing learning-based methods, the research mainly focuses on developing recurrent neural networks (RNNs) and their variants to study complex spatiotemporal dependencies to enhance the generality of trajectory representation. Despite the large number of modern deep learning techniques being invested in identifying anomalous trajectories, there are still the following defects:

[0007] Existing solutions such as Gaussian Mixture Variational Sequence AutoEncoder (GM-VSAE) and Deep Temporal Embedding Attention (DeepTEA) are usually built on the closed-world assumption, i.e., assuming that all possible behavior pattern types have been sufficiently 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, as real-world data usually only provides incomplete knowledge. Therefore, under the open-world assumption, i.e., in 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

[0008] The technical problem to be solved by the present application is to provide an architecture method of a vehicle abnormal trajectory detection model in an open environment, which can effectively identify and classify unknown abnormal behaviors in the environment under the open-world assumption.

[0009] The technical solution adopted by the present application to solve the above technical problem is:

[0010] An architecture method of a vehicle abnormal trajectory detection model in an open environment, the vehicle abnormal trajectory detection model comprising an encoding network, an embedding network and an inference network, the encoding network being 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 comprising the following steps:

[0011] A1, data preparation

[0012] Trajectory samples are obtained and a data set is constructed, the obtained trajectory samples being divided into normal trajectories, known class abnormal trajectories and unknown class abnormal trajectories according to whether the behavior patterns of the trajectories recorded thereby are known, wherein the behavior patterns of the normal trajectories and the known class abnormal trajectories are known and are used as labels, and the behavior patterns of the unknown class abnormal trajectories are unknown;

[0013] A2, trajectory classification

[0014] The trajectory samples of the current training are input, feature encoding is performed using the encoding network to obtain trajectory encoding of the input trajectory samples; based on the obtained trajectory encoding, embedding encoding is performed using the embedding network to obtain trajectory embedding of the input trajectory samples; based on the obtained trajectory embedding, the inference network is used to infer the probabilities of each trajectory sample belonging to each behavior pattern;

[0015] A3, model updating

[0016] The total loss is calculated, and based on the total loss, the vehicle abnormal trajectory detection model is updated by using the gradient descent method;

[0017] The total loss includes a similarity measure loss and a cross-entropy loss; wherein the calculation of the similarity measure loss includes:

[0018] The trajectory samples input in this round of training are combined in any two, to form trajectory pairs; based on the trajectory embedding of each trajectory sample obtained in step A2, the similarity learning network is used to calculate the trajectory similarity score between the two trajectory samples contained in each trajectory pair; based on the probability that each trajectory sample belongs to each behavior pattern obtained in step A2, the similarity function is used to calculate the pattern similarity score between the two trajectory samples contained in each trajectory pair; by aligning the pattern similarity score and the trajectory similarity score of each trajectory pair, the similarity measure loss of each trajectory pair is calculated;

[0019] A4, extract the trajectory samples in the data set as input, use 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 behavior pattern; then, based on the probability that each trajectory sample input in this step belongs to each behavior pattern, the cross-entropy loss is calculated, and the parameters of the similarity learning network are updated by using the gradient descent method;

[0020] A5, steps A2-A4 are executed in a loop until the training termination condition is reached, and the trained vehicle abnormal trajectory detection model is obtained;

[0021] The calculation of the cross-entropy loss in steps A3 and A4 includes:

[0022] Based on the probability that each trajectory sample input in this step belongs to each behavior pattern, classify each trajectory sample, and assign a label to the trajectory sample belonging to the known behavior pattern and a pseudo-label to the trajectory sample belonging to the unknown behavior pattern; then, based on the label or pseudo-label of each trajectory sample, the cross-entropy loss of each trajectory sample is calculated.

[0023] Further, in step A1, the obtained trajectory samples include normal trajectories, detour abnormalities, navigation abnormalities, and route exchange abnormalities; any one of the three abnormalities is taken as a known class abnormal trajectory, and the remaining two abnormalities are taken as unknown class abnormal trajectories.

[0024] Further, an area completely covered by all trajectory samples of the data set on the road network of the area is delimited as a recognition area, and the recognition 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, input the trajectory sample of the current round of training, and obtain the spatiotemporal semantic encoding of the grid contained in the trajectory sample based on the mapping relationship between the grid and the matrix by using the pre-trained spatiotemporal semantic embedding matrix, to constitute the trajectory encoding of the trajectory sample.

[0025] The pre-training process of the spatiotemporal semantic embedding matrix includes:

[0026] B1, data initialization

[0027] The spatiotemporal semantic embedding matrix is constructed and initialized, and the elements of the spatiotemporal semantic embedding matrix correspond to the grids of the recognition area one by one.

[0028] B2, input the trajectory sample in the data set constructed in step A1 in turn

[0029] The input trajectory sample is taken as a current trajectory, and the grids passed by the current trajectory on the gridded map are used to construct a positive sample grid set of the current trajectory tr; the grids contained in the trajectory samples whose start grid and end grid are different from the current trajectory tr are sampled to constitute a negative sample grid set of the current trajectory tr; the spatiotemporal semantic encoding of each grid in the positive sample grid set and the negative sample grid set is obtained based on the mapping relationship between the grid and the matrix by using the spatiotemporal semantic embedding matrix.

[0030] B3, update the spatiotemporal semantic embedding matrix

[0031] The spatiotemporal semantic encoding of each grid obtained in step B2 is used to learn by comparison between the positive sample grid and the negative sample grid, and the spatiotemporal semantic embedding matrix is updated based on relational distillation by minimizing expectation.

[0032] B4, steps B2-B3 are executed in a loop until all trajectory samples in the data set are traversed, and the trained spatiotemporal semantic embedding matrix is obtained.

[0033] Further, the recognition area is gridded, and the 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 grid passed by each trajectory sample on the gridded map, the trajectory sample whose number of passed grids is less than the threshold value is excluded, and the data set is updated to only keep the remaining trajectory samples; in step A1, the trajectory samples contained in the data set are sorted according to their start grid and end grid.

[0034] Further, the encoding network adopts an encoding network based on relational distillation, an encoding network based on RNN, or an encoding network based on a variant of RNN.

[0035] Further, in step B3, the spatiotemporal semantic encoding of each grid obtained in step B2 is used to update the spatiotemporal semantic embedding matrix based on relational distillation by minimum expectation through comparison learning of positive sample grids and negative sample grids according to the following formula:

[0036]

[0037] wherein, represents the minimum expectation, r l is the lth positive sample grid, r l tr\(S,D) represents that the positive sample grid set includes grids other than the start grid S and the end grid D of the current trajectory tr, and s(·) represents similarity calculation; represents the spatiotemporal semantic encoding of the anchor point as a comparison reference, and the grid corresponding to the anchor point belongs to the current trajectory tr; r j is the jth negative sample grid, and J represents the number of grids sampled from the negative sample grid set; v(r l ) and v(r j ) respectively represent the spatiotemporal semantic encoding of the positive sample grid r l and the negative sample grid r j .

[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 the current round of training is input, and the first spatiotemporal semantic embedding matrix V1 and the second spatiotemporal semantic embedding matrix V2 are respectively used to obtain the first spatiotemporal semantic encoding and the second spatiotemporal semantic encoding of the grids contained in the trajectory sample based on the mapping relationship between the grids and the matrices, thereby constructing the first trajectory encoding and the second trajectory encoding of the trajectory sample; then, aggregation is performed to obtain the trajectory encoding of the trajectory sample.

[0040] In step B1, the first spatiotemporal semantic embedding matrix V1 and the second spatiotemporal semantic embedding matrix V2 are respectively constructed and initialized; 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 respectively obtained; and in step B3, the following definitions are made: wherein, r l1 and r l2 respectively represent the two grids constituting the anchor point, and the start grid and the end grid of the current trajectory tr are used to constitute the anchor point for updating the first spatiotemporal semantic embedding matrix V1, and the start grid and the end grid of the current trajectory tr are used to constitute the anchor point for updating the second spatiotemporal semantic embedding matrix V2.l The two grids adjacent to each other and belonging to the current trajectory tr constitute an anchor point for updating the second spatio-temporal semantic embedding matrix V2.

[0041] Further, the encoding network comprises an aggregation network and a pre-trained spatio-temporal semantic embedding matrix, the aggregation network adopts a full connection 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] Wherein, r l represents the lth grid of the trajectory sample, v(r l ) represents the spatio-temporal semantic encoding of the grid r l , v1(r l ) and v2(r l ) represent the first spatio-temporal semantic encoding and the second spatio-temporal semantic encoding of the grid r l respectively, [;] represents the splicing operation; W r and b r are trainable parameters of the full connection network constituting the aggregation network; L represents the number of grids contained in the trajectory sample.

[0045] Further, the embedding network adopts a state space model, and the inference network adopts a full connection network;

[0046] In step A2, based on the obtained trajectory encoding, the embedding network is used for embedding coding to obtain the trajectory embedding of the input trajectory sample, comprising:

[0047] First, taking the obtained trajectory encoding as the input of the state space model, the state space model is used to obtain the state space output of the trajectory sample:

[0048] x l =Ax l-1 +Bv(r l ), h l =Cx l +Dv(r l )

[0049]

[0050]

[0051]

[0052]

[0053]

[0054]

[0055] wherein x l is a state variable, h l is an output variable, v(r l ) is an input variable, A, B, C, D are all parameters of the state space model; GELU represents a GELU activation function, represents a Fourier transform, represents an inverse Fourier transform, K L is a convolution kernel of the state space model obtained based on dynamic modeling of dynamic dependence of each grid contained in the current trajectory sample, A, B, C are all parameters of the state space, (ΔA) -1 is an inverse matrix of the ΔA matrix, Δ represents a sampling period, I is an identity matrix, W D corresponds to the parameter D of the state space equation; r l represents the lth grid of the current trajectory sample, v(r l ) represents the spatiotemporal semantic encoding of the grid r l ; L represents the number of grids contained in the current trajectory sample;

[0056] Then, based on the state space output h = [h1, h2, …, h l , …, h L ] of the current trajectory sample, the trajectory embedding of the current trajectory sample is calculated:

[0057]

[0058] wherein, represents the trajectory embedding of the current trajectory sample;

[0059] In step A2, based on the obtained trajectory embedding, the probability that each trajectory sample respectively belongs to each behavior pattern is inferred using an inference network according to the following formula:

[0060]

[0061] wherein, MLP1 represents a fully connected network constituting the inference network, Softmax represents a Softmax function, represents the trajectory embedding of the current trajectory sample, represents a probability distribution vector that the current trajectory sample belongs to each behavior pattern.

[0062] Further, 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 by using the similarity learning network according to the following formula

[0063]

[0064] wherein, MLP2 represents the fully connected network constituting the similarity learning network, Sigmod represents the Sigmod function, and respectively represent the trajectory embedding of the two trajectory samples contained in the trajectory sample pair;

[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 by using the similarity function according to the following formula

[0066]

[0067] wherein, and respectively represent the probability distribution vector of the two trajectory samples contained in the trajectory sample pair belonging to each behavior pattern, |·| represents the length of the probability distribution vector;

[0068] In step A3, the similarity measurement loss of each trajectory pair is calculated by aligning the pattern similarity score and the trajectory similarity score of each trajectory pair according to the following formula

[0069]

[0070] wherein, represents the pattern similarity score of the nth trajectory sample pair, represents the trajectory similarity score of the nth trajectory sample pair.

[0071] Further, the calculation of the cross-entropy loss in steps A3 and A4 includes:

[0072] First, based on the probability that each trajectory sample in the corresponding step belongs to each behavior pattern, the trajectory samples are classified, and by one-hot encoding, the trajectory samples belonging to the known behavior patterns are assigned labels, and the trajectory samples belonging to the unknown behavior patterns are assigned pseudo-labels; each bit of the one-hot encoding corresponds to a 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;

[0073] For the trajectory samples of known behavior patterns, the corresponding bit of the behavior pattern with the maximum probability is 1, and the others are 0;

[0074] For the trajectory samples of unknown behavior patterns, only when the probability of the current trajectory sample obtained by inference belongs to the behavior pattern is greater than the confidence threshold γ, the bit corresponding to the behavior pattern is 1, otherwise it is 0;

[0075] Then, based on the labels or pseudo-labels of each trajectory sample, the cross-entropy loss of each trajectory sample is calculated as follows

[0076]

[0077] Where M is the number of trajectories; represents the value of the cth bit in the one-hot encoding of the label or pseudo-label of the mth trajectory, represents the probability of the mth trajectory belonging to the cth behavior pattern obtained by inference of the inference network.

[0078] Further, in step A3, the total loss further includes an entropy regularization loss The entropy regularization loss is calculated as follows:

[0079]

[0080] Where K represents the number of known behavior patterns, and U represents the number of unknown behavior patterns, represents the average value of the probability of each trajectory sample belonging to the cth behavior pattern.

[0081] Further, in step A3, the total loss is calculated as follows:

[0082]

[0083] Where, represents the similarity measure loss of the nth trajectory sample pair, and 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 application are: the architecture method of the vehicle abnormal trajectory detection model of the present application, relative to the prior art, in the training stage, first, the trajectory samples of the known behavior mode are assigned labels, and the trajectory samples of the unknown behavior mode are assigned pseudo labels, so that the cross entropy loss calculation is possible; then, by aligning the similarity between the embeddings of any two trajectories and the similarity of the probability distribution between the trajectories, the similarity measurement loss of the pair trajectory similarity is introduced, so that the model not only learns the classification of a single trajectory, but also understands the mutual relationship and probability connection between different trajectories. Therefore, the probability distribution obtained by the model output can reflect the actual similarity and difference between trajectories, so that it can adapt to newly emerging, unknown distribution trajectory patterns, that is, it can effectively identify and classify unknown abnormal behaviors in the open world assumption.

[0085] Further, 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 trajectories, rather than relying only on specific labels seen during training; aligning the probability distribution similarity, that is, aligning the pattern similarity score and the trajectory similarity score, can enhance the robustness and accuracy of the model when processing unknown data and generalizing to new scenarios, while enhancing the model's ability to represent trajectory embeddings and the correlation between trajectory representations and predicted probabilities.

[0086] Therefore, the calculation of the similarity measurement loss prompts the model to learn deeper feature representations, so that similar trajectory embeddings are close to each other in high-dimensional space, while different trajectories are relatively far apart. Such a learning process emphasizes the richness and discriminability of information in the embedding vectors, enhancing the model's ability to capture the intrinsic structure and patterns of trajectory data. Using the similarity measurement loss, through the optimization of pairwise similarity, the model is guided to form meaningful clustering structures in the embedding space, which enables the model to better understand and distinguish various trajectories in the embedding space, providing a solid foundation for classification decisions.

[0087] When the trajectory embeddings are optimized through the similarity measurement loss in the training process, their distribution in the feature space will be more suitable for the classification task. Therefore, in the inference process, even if only the prediction probability of the inference network is used for classification, the optimized embeddings can provide clearer and more discriminative features, thereby directly improving the accuracy and reliability of classification. This strategy effectively encodes the intrinsic structure and similarity of trajectories into the embedding, so that even in the inference stage, simple probability prediction can accurately reflect the class of the trajectory. BRIEF DESCRIPTION OF DRAWINGS

[0088] Figure 1 The figure is a training process diagram in the embodiment of the architecture method of the vehicle abnormal trajectory detection model in an open environment of the present application. DETAILED DESCRIPTION

[0089] The present application aims to provide a method for constructing a vehicle abnormal trajectory detection model in an open environment, which can effectively identify and classify unknown abnormal behaviors in an open world.

[0090] Specifically, the method for constructing a vehicle abnormal trajectory detection model in an open environment comprises an encoding network, an embedding network and an inference network. The encoding network is an encoding network capable of capturing time-varying dependencies between trajectory points contained in a trajectory. The training process of the vehicle abnormal trajectory detection model comprises the following steps:

[0091] A1, data preparation

[0092] Trajectory samples are obtained and a data set is constructed. The trajectory samples are divided into normal trajectories, known abnormal trajectories and unknown abnormal trajectories according to whether the behavior patterns of the trajectories recorded are known. The behavior patterns of normal trajectories and known abnormal trajectories are known and are used as labels. The behavior patterns of unknown abnormal trajectories are unknown.

[0093] A2, trajectory classification

[0094] The trajectory samples of the current training are input, and the encoding network is used for feature encoding to obtain trajectory encoding of the input trajectory samples. Based on the obtained trajectory encoding, the embedding network is used for embedding encoding to obtain trajectory embedding of the input trajectory samples. Based on the obtained trajectory embedding, the inference network is used to infer the probability that each trajectory sample belongs to each behavior pattern.

[0095] A3, model updating

[0096] The total loss is calculated, and based on the total loss, the gradient descent method is used to update the vehicle abnormal trajectory detection model.

[0097] The total loss comprises a similarity measure loss and a cross-entropy loss. The calculation of the similarity measure loss comprises:

[0098] The trajectory samples input in the current training are combined in any two ways to form trajectory pairs. Based on the trajectory embedding of each trajectory sample obtained in step A2, the similarity learning network is used to calculate the trajectory similarity score between the two trajectory samples contained in each trajectory pair. Based on the probability that each trajectory sample belongs to each behavior pattern obtained in step A2, the similarity function is used to calculate the pattern similarity score between the two trajectory samples contained in each trajectory pair. By aligning the pattern similarity score and the trajectory similarity score of each trajectory pair, the similarity measure loss of each trajectory pair is calculated.

[0099] A4, extracting trajectory samples in the data set as input, updating the vehicle abnormal trajectory detection model obtained in step A3 to obtain the probability that each trajectory sample in the input of this step belongs to each behavior pattern; then, based on the probability that each trajectory sample in the input of this step belongs to each behavior pattern, the cross-entropy loss is calculated, and the gradient descent method is used to update the parameters of the similarity learning network;

[0100] A5, steps A2-A4 are repeatedly executed until the training termination condition is reached, and a trained vehicle abnormal trajectory detection model is obtained.

[0101] The calculation of the cross-entropy loss in steps A3 and A4 includes:

[0102] Based on the probability that each trajectory sample in the corresponding step input belongs to each behavior pattern, each trajectory sample is classified, and the trajectory samples belonging to known behavior patterns are assigned labels and the trajectory samples belonging to unknown behavior patterns are assigned pseudo-labels; then, based on the labels or pseudo-labels of each trajectory sample, the cross-entropy loss of each trajectory sample is calculated.

[0103] Wherein, the feature encoding is performed by using the encoding network to obtain the trajectory encoding of the input trajectory sample; based on the obtained trajectory encoding, the embedding encoding is performed by using the embedding network to obtain the trajectory embedding of the input trajectory sample, so as to capture the long sequence dependence relationship; based on the obtained trajectory embedding, the trajectory is mapped to a U+K-dimensional space by using the inference network, that is, the predicted probability distribution can be obtained, wherein 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 by 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 class. Compared with existing methods, the existing method can only classify known classes from known and unknown classes, and separate unknown classes from known classes; and the present application can classify unknown classes on the basis of realizing the function of the existing method.

[0105] To achieve clustering of behavioral patterns, especially unknown classes, the construction method of this invention introduces a similarity metric loss into the total loss during the training phase. Based on the embedded representation of trajectories, it obtains the trajectory similarity score between two trajectories through a similarity learning network. Simultaneously, to cluster trajectories with different behavioral patterns, a formal alignment principle for similarity measurement is proposed. That is, using the output of the inference network, a simple similarity measure, such as cosine similarity, is used to estimate the pattern similarity between two trajectories. Finally, the similarity metric loss between the two trajectories is calculated by aligning the pattern similarity score and the trajectory similarity score.

[0106] By using a similarity learning network to calculate the similarity between the embeddings of two trajectories, the model can learn the relative relationships and structural features between trajectories, rather than relying solely on specific labels seen during training. This helps the model effectively classify new or less common trajectory types using learned similarity patterns. The similarity between the embeddings of two trajectories enables the model to clearly distinguish between different categories of trajectories. By comparing the embedding representations of different trajectories, the model optimizes the classification boundary and enhances the embedding capability of trajectories. This method is particularly important when the differences between categories are not very significant, helping to improve the fine-grainedness 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 interrelationships and probabilistic connections between different trajectories. This alignment helps ensure that the model's output, i.e., the probability distribution, reflects the actual similarity and differences between trajectories. It enhances the model's robustness and accuracy when handling unknown data and generalizing to new scenarios, while also strengthening the model's ability to represent trajectory embeddings and increasing the correlation between trajectory representations and predicted probabilities, thereby making predictions more accurate and reliable.

[0108] However, it should be noted that in the early stages of training, the similarity signals provided by the similarity learning network are extremely noisy. Simultaneously optimizing all parameters of both the vehicle anomaly trajectory detection model and the similarity learning network will severely affect the inference network's ability to identify unknown patterns. Therefore, the construction method of this invention employs an interactive optimization strategy during training. Specifically, firstly, the parameters of the vehicle anomaly trajectory detection model are optimized using the total loss; then, based on the updated vehicle anomaly trajectory detection model, predictions are performed again, and the parameters of the similarity learning network are optimized using the cross-entropy loss function.

[0109] Secondly, using only trajectory labels with known behavior patterns during training can lead to unacceptable bias. Therefore, pseudo-labels are assigned to trajectories with unknown behavior patterns. To mitigate the risk of unreliable pseudo-labels, a confidence threshold γ is ideally introduced during one-hot encoding of pseudo-labels.

[0110] Thirdly, there is a risk that all trajectories with different unknown behavior patterns are assigned to the same category by the reasoning network. That is, the model may be overly confident in favoring a certain behavior pattern when processing trajectories with unknown behavior patterns. Therefore, in order to ensure a uniform distribution between various behavior patterns, the best is to introduce an entropy regularization loss in the total loss to enhance the diversity of category prediction.

[0111] As described above, the improvement of the construction method of the present application is mainly in the training of the model during the construction process, therefore, the vehicle abnormal trajectory detection model can be any existing model. It should be noted that existing encoding networks usually focus on random initialization based on regions to capture global dependencies of specific trajectories, while ignoring context-aware learning at the region level, thus failing to capture the correlation between regions of a trajectory. In the present application, long-term dependencies between trajectory points contained in the trajectory are effectively and efficiently captured, which is particularly important for maintaining the coherence of individual behavior intentions and identifying abnormal patterns. Therefore, the encoding network of the vehicle abnormal trajectory detection model of the present application should be an encoding network that can capture time-varying dependencies between trajectory points contained in the trajectory, such as LSTM, GRU, SGE-net, TLUTE (Trajectory Linking via User Embedding and Trajectory Embedding), etc., which introduce recurrent neural networks (RNN) to capture these time-varying dependencies.

[0112] However, the above-mentioned encoding network based on RNN or the encoding network constructed by the variant based on RNN faces challenges in processing long trajectory data with complex spatio-temporal dependencies, such as gradient vanishing or complex dependencies implied behind the trajectory. Therefore, the best is to use relational distillation for encoding. The encoding network based on relational distillation captures unique information from different dimensions and / or different regions using contrastive learning between different dimensions and / or different regions. Specifically:

[0113] The area completely covered by all trajectory samples of the data set on the road network is designated as the identification area, and the identification area is gridded; the encoding network includes a pre-trained spatio-temporal semantic embedding matrix; in step A2, the trajectory sample of the current training is input, and the pre-trained spatio-temporal semantic embedding matrix is used to obtain the spatio-temporal semantic encoding of the grid contained in the trajectory sample based on the mapping relationship between the grid and the matrix, to form the trajectory encoding of the trajectory sample.

[0114] The pre-training process of the spatio-temporal semantic embedding matrix includes:

[0115] B1, data initialization

[0116] constructing and initializing a spatio-temporal semantic embedding matrix, elements of the spatio-temporal semantic embedding matrix corresponding to grids of the identified region one by one;

[0117] B2, inputting trajectory samples in the constructed dataset of step A1 in turn

[0118] taking the input trajectory sample as a current trajectory, constructing a positive sample grid set of the current trajectory tr from grids passed by the current trajectory on the grid-based map, sampling grids from grids contained in trajectory samples different from the current trajectory tr in the start grid and the end grid of the dataset to form a negative sample grid set of the current trajectory tr, and obtaining spatio-temporal semantic codes of grids in the positive sample grid set and the negative sample grid set based on a mapping relationship between the grids and the spatio-temporal semantic embedding matrix;

[0119] B3, updating the spatio-temporal semantic embedding matrix

[0120] updating the spatio-temporal semantic embedding matrix by contrastive learning of the positive sample grids and the negative sample grids based on minimizing expectation using the spatio-temporal semantic codes of the grids obtained in step B2;

[0121] B4, performing steps B2-B3 in a loop until all trajectory samples in the dataset are traversed to obtain the trained spatio-temporal semantic embedding matrix.

[0122] The encoding mode, i.e., the encoding based on relationship distillation, can be an existing ReMVC (Region Embedding with Multi-View Contrastive Learning).

[0123] In an embodiment, in step B3, the spatio-temporal semantic embedding matrix is updated by contrastive learning of the positive sample grids and the negative sample grids based on minimizing expectation using the spatio-temporal semantic codes of the grids obtained in step B2 according to the following formula:

[0124]

[0125] wherein, represents the minimizing expectation, r l is the lth positive sample grid, r l ∈tr\(S,D) represents that the positive sample grid set includes grids other than the start grid S and the end grid D of the current trajectory tr, and s(·) represents similarity calculation; represents the spatio-temporal semantic code of an anchor point as a contrastive reference, and the grid corresponding to the anchor point belongs to the current trajectory tr; r j is the jth negative sample grid, and J represents the number of grids sampled from the negative sample grid set; v(r l ) and v(rj respectively represent the spatio-temporal semantic encoding of the positive sample grid r l and the negative sample grid r j .

[0126] The significance of the above encoding method lies in: first, there is a strong correlation between each region in a given trajectory and its corresponding start and end region, 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 interaction, reflecting the behavior pattern. Therefore, by contrast learning of the positive sample grid and the negative sample grid, based on relationship distillation by minimization expectation, the interaction semantics between the grids in the trajectory are extracted, which can effectively and efficiently mine the time-varying dependency of the trajectory, thereby generating a dense but semantically rich representation for each grid.

[0127] In the above calculation, the anchor point can be each 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 grid, and the strong correlation between the grid and the adjacent path grid. Therefore, in order to simplify the calculation, further, the pre-trained spatio-temporal semantic embedding matrix includes a first spatio-temporal semantic embedding matrix V1 and a second spatio-temporal semantic embedding matrix V2; and define wherein r l1 and r l2 respectively represent the two grids constituting the anchor point, and the start grid and the end grid of the current trajectory tr are used to constitute the anchor point for updating the first spatio-temporal semantic embedding matrix V1, and the two grids adjacent to the current calculation positive sample grid r l and belonging to the current trajectory tr constitute the anchor point for updating the second spatio-temporal semantic embedding matrix V2.

[0128] The scheme of the present application will be further described below in combination with the drawings and embodiments.

[0129] Embodiment

[0130] The present embodiment provides a method for constructing a vehicle abnormal trajectory detection model in an open environment, which includes an encoding network, an embedding network and an inference network, as shown in Figure 1 The training process of the vehicle abnormal trajectory detection model includes the following steps:

[0131] S1, constructing a data set:

[0132] Firstly, trajectory samples are obtained and a dataset is constructed. The obtained trajectory samples are divided into normal trajectories, known-class abnormal trajectories and unknown-class abnormal trajectories according to whether the behavior patterns of the trajectories recorded are known. The behavior patterns of the normal trajectories and the known-class abnormal trajectories are known and are used as labels, and the behavior patterns of the unknown-class abnormal trajectories are unknown.

[0133] In order to facilitate the obtaining of training data, in the embodiment, the obtained trajectory samples include normal trajectories, detour abnormalities, navigation abnormalities and route exchange abnormalities; any one of the three types of abnormalities is taken as a known-class abnormal trajectory, and the remaining two types of abnormalities are taken as unknown-class abnormal trajectories. That is, in the embodiment, U+K=4, the number K of known behavior patterns includes normal trajectories and one type of abnormal trajectories; the number U of unknown behavior patterns also includes the remaining two types of abnormal trajectories.

[0134] Then, an area covered by all trajectory samples in the dataset on the road network is delimited as a recognition area, and the recognition area is gridded. The grid division is usually performed according to the size of the recognition area. If the recognition area is relatively large, the trajectory is usually longer, and the granularity of the division is larger. If the grid is too small, the length of the trajectory is too long, and the model is difficult to learn. Therefore, the recognition area is gridded, and the length of the divided grid should be greater than or equal to 100 m and less than or equal to 500 m. In the embodiment, the trajectory data is taxi trajectory data, the recognition area is the main urban area of a city, and a 100 m x 100 m 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 dataset is traversed to obtain the grid passed on the gridded map, the trajectory sample whose number of passed grids is less than a threshold value is excluded, and the dataset is updated to only keep the remaining trajectory samples. In the embodiment, the trajectory sample whose number of passed grids is less than 20 grids is excluded.

[0136] In addition, in order to facilitate subsequent calculation, especially the extraction of negative samples, in this step, the trajectory samples contained in the dataset are sorted according to their start grid and end grid.

[0137] S2, pre-training of the spatio-temporal semantic embedding matrix

[0138] S21, data initialization

[0139] A spatio-temporal semantic embedding matrix is constructed and initialized. The elements of the spatio-temporal semantic embedding matrix correspond one-to-one to the grids of the recognition area to realize mapping based on grid ID; the spatio-temporal semantic embedding matrix includes a first spatio-temporal semantic embedding matrix V1 and a second spatio-temporal semantic embedding matrix V2.

[0140] S22, inputting the trajectory samples in the data set constructed in step S1 in sequence

[0141] Taking the input trajectory sample as a current trajectory, a positive sample grid set of the current trajectory tr is constructed from the grids passed through by the current trajectory on the grid map; a negative sample grid set of the current trajectory tr is constructed from the grids contained in the trajectory samples whose start grid and end grid are different from those of the current trajectory tr in the data set; first and second spatiotemporal semantic encodings of each grid in the positive and negative sample grid sets are obtained respectively based on the mapping relationship between the grids and the matrix using the spatiotemporal semantic embedding matrix;

[0142] S23, updating the spatiotemporal semantic embedding matrix

[0143] The spatiotemporal semantic encodings of each grid obtained in step S22 are used to update the spatiotemporal semantic embedding matrix through contrastive learning of the positive and negative sample grids based on relationship distillation of the minimum expectation.

[0144] The first spatiotemporal semantic embedding matrix V1 is updated according to the following formula:

[0145]

[0146] The second spatiotemporal semantic embedding matrix V2 is updated according to the following formula:

[0147]

[0148] wherein, represents the minimum expectation, r l is the lth positive sample grid, r l tr\(S,D) represents that the positive sample grid set includes the grids of the current trajectory tr except the start grid S and the end grid D, and s(·) represents the cosine similarity calculation; r j is the jth negative sample grid, and J represents the number of grids sampled from the negative sample grid set; v(r l ) and v(r j ) represent the spatiotemporal semantic encodings of the positive sample grid r l and the negative sample grid r j .

[0149] represents the spatiotemporal semantic encoding of the anchor point serving as the contrastive reference, and the grid corresponding to the anchor point belongs to the current trajectory tr, and is defined as:

[0150]

[0151] wherein, r l1 and rl2 respectively represent two grids constituting an anchor point, and the start grid and the end grid of the current trajectory tr are adopted to constitute an anchor point for updating the first spatio-temporal semantic embedding matrix V1, and the two grids adjacent to the current trajectory tr are adopted to constitute an anchor point for updating the second spatio-temporal semantic embedding matrix V2. l respectively represent two grids constituting an anchor point, and the start grid and the end grid of the current trajectory tr are adopted to constitute an anchor point for updating the first spatio-temporal semantic embedding matrix V1, and the two grids adjacent to the current trajectory tr are adopted to constitute an anchor point for updating the second spatio-temporal semantic embedding matrix V2.

[0152] S24, steps S22-S23 are cyclically executed until all trajectory samples of the data set are traversed, and the spatio-temporal semantic embedding matrix trained is obtained.

[0153] S3, trajectory encoding

[0154] First, the trajectory sample of the current round of training is input, and the first spatio-temporal semantic embedding matrix V1 and the second spatio-temporal semantic embedding matrix V2 are respectively used to obtain the first spatio-temporal semantic encoding and the second spatio-temporal semantic encoding of the grid contained in the trajectory sample based on the mapping relationship between the grid and the matrix, and to constitute the first trajectory encoding and the second trajectory encoding of the trajectory sample.

[0155] Then, aggregation is performed to obtain the trajectory encoding of the trajectory sample. The aggregation mode includes splicing, weight addition, neural network, etc. In order to adaptively adjust the aggregation weight in the aggregation process of the first spatio-temporal semantic region encoding and the second spatio-temporal semantic region encoding, in the embodiment, the encoding network includes an aggregation network and a pre-trained spatio-temporal semantic embedding matrix, the aggregation network adopts a fully connected network, and the trajectory encoding of the trajectory sample is obtained by aggregating the aggregation network according to the following formula

[0156] v(r l )=[v1(r l );v2(r l )]W r +b r

[0157]

[0158] Wherein, r l represents the lth grid of the trajectory sample, v(r l ) represents the spatio-temporal semantic encoding of the grid r l , v1(r l ) and v2(r l ) respectively represent the first spatio-temporal semantic encoding and the second spatio-temporal semantic encoding of the grid r l , [;] represents the splicing operation; W r and b r are trainable parameters of the fully connected network constituting the aggregation network; L represents the number of grids contained in the trajectory sample.

[0159] S4, trajectory embedding

[0160] The embedding network can employ any existing network, such as RNN. In the present embodiment, the embedding network employs a state space model. Generally, a state space model can be represented as:

[0161] x l = Ax l-1 + Bv(r l ), h l = Cx l + Dv(r l )

[0162] where x l is the state variable, h l is the output variable, v(r l ) is the input variable, and A, B, C, D are all parameters of the state space model.

[0163] The above formula is a state space equation in continuous time, 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 constant within a sampling period until the next sampling period begins, so based on zero-order hold, it is assumed that the input remains constant within each sampling period during the continuous-to-discrete conversion.

[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 have:

[0168]

[0169] where L is the number of grids of the trajectory.

[0170] Therefore, Modeling the dependency dynamics can be regarded as a convolution process, which is performed in a non-autoregressive or parallel manner, in which the total output h = [h1, h2, …, h l , …, h L ] is obtained at once.

[0171] Based on the above assumptions, the spatiotemporal semantic region encoding of the input trajectory sample

[0172]

[0173] Then, the state space output of the input trajectory sample can be calculated by the state space model under the discrete time system:

[0174]

[0175]

[0176]

[0177]

[0178] wherein GELU represents a GELU activation function, denotes a Fourier transform, denotes an inverse Fourier transform, K L is a convolution kernel of the state space model obtained based on dynamic modeling of dynamic dependence of each grid included in the current calculation trajectory sample, A, B, C are all parameters of the state space, (ΔA) -1 is an inverse matrix of the ΔA matrix, Δ represents a sampling period, I is a unit matrix, W D corresponds to the parameter D of the state space equation; r l denotes the lth grid of the current calculation trajectory sample, v(r l ) represents the spatiotemporal semantic encoding of the grid r l , and L represents the number of grids included in the current calculation trajectory sample.

[0179] Then, based on the state space output h = [h1, h2, …, h l ,…h L ] of the current calculation trajectory sample, the trajectory embedding of the current calculation trajectory sample is calculated:

[0180]

[0181] wherein, denotes the trajectory embedding of the current calculation trajectory sample.

[0182] S5, probability inference

[0183] The inference network can adopt any inference network, such as UNO (UNified Objective). UNO is a novel objective function aiming to infer new object classes in an unlabeled set by exploiting prior knowledge of the labeled dataset, thereby solving the novel class discovery (NCD) problem. Specifically, UNO generates pseudo-labels using a multi-view self-labeling strategy, and these pseudo-labels are processed together with the real labels in a unified manner.

[0184] In the embodiment, the inference network adopts a fully connected network. Specifically, based on the obtained trajectory embedding, the inference network is used to infer the probability that each trajectory sample belongs to each behavior pattern according to the following formula:

[0185]

[0186] wherein, MLP1 represents a fully connected network constituting the inference network, Softmax represents a Softmax function, represents the trajectory embedding of the trajectory sample currently calculated, represents a probability distribution vector of the trajectory sample currently calculated belonging to each behavior pattern.

[0187] S6, model updating

[0188] In this step, the total loss is calculated, and based on the total loss, the gradient descent method is used to update the vehicle abnormal trajectory detection model. The model is the vehicle abnormal trajectory detection model constructed by the present application. Since the similarity learning network is only used in the training stage, the model does not include the similarity learning network. In the embodiment, the vehicle abnormal trajectory detection model includes a state space model, an inference network and an aggregation network.

[0189] The total loss includes a similarity measure loss, a cross-entropy loss and an entropy regularization loss. The total loss is calculated according to the following formula:

[0190]

[0191] wherein, represents the similarity measure loss of the nth trajectory sample pair, and N is the number of trajectory sample pairs, represents the cross-entropy loss, represents the entropy regularization loss.

[0192] The calculation of the similarity measure loss includes:

[0193] The trajectory samples input in the current training are combined in any two groups to form trajectory pairs;

[0194] Based on the trajectory embedding of each trajectory sample obtained in step S4, the similarity learning network is used to calculate the trajectory similarity score between the two trajectory samples contained in each trajectory pair according to the following formula

[0195]

[0196] wherein, MLP2 represents a fully connected network constituting the similarity learning network, and Sigmod represents a Sigmod function, and respectively represent the trajectory embedding of the two trajectory samples contained in the trajectory sample pair;

[0197] Based on the probability that each trajectory sample belongs to each behavior pattern obtained in step S5, the pattern similarity score between the two trajectory samples contained in each trajectory pair is calculated using a similarity function according to the following formula

[0198]

[0199] wherein, and respectively represent the probability distribution vector of the two trajectory samples contained in the trajectory sample pair belonging to each behavior pattern, |·| represents the length of the probability distribution vector;

[0200] The similarity measure loss of each trajectory pair is calculated by aligning the pattern similarity score and the trajectory similarity score of each trajectory pair according to the following formula

[0201]

[0202] wherein, represents the pattern similarity score of the nth trajectory sample pair, represents the trajectory similarity score of the nth trajectory sample pair.

[0203] wherein, the calculation of the cross-entropy loss includes:

[0204] Firstly, based on the probability that each trajectory sample belongs to each behavior pattern obtained in step S5, each trajectory sample is classified, and a label is assigned to the trajectory sample belonging to the known behavior pattern and a pseudo label is assigned to the trajectory sample belonging to the unknown behavior pattern through one-hot encoding; each bit of the one-hot encoding corresponds to a 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 the trajectory sample of the known behavior pattern, the corresponding bit of the corresponding behavior pattern with the maximum probability is 1, and the others are 0;

[0206] For the trajectory sample of the unknown behavior pattern, only when the probability that the current trajectory sample belongs to the behavior pattern obtained through inference is greater than the confidence threshold γ, the bit corresponding to the behavior pattern is 1, otherwise it is 0.

[0207] Then, based on the label or pseudo label of each trajectory sample, the cross-entropy loss of each trajectory sample is calculated according to the following formula

[0208]

[0209] wherein M is the number of trajectories; represents the value of the cth bit in the one-hot encoding of the label or pseudo-label of the mth trajectory, represents the probability that the mth trajectory obtained by inference of the inference network belongs to the cth behavior pattern.

[0210] wherein the entropy regularization loss is calculated according to the following formula:

[0211]

[0212] wherein K represents the number of known behavior patterns, and U represents the number of unknown behavior patterns, represents the average value of the probability that each trajectory sample belongs to the cth behavior pattern.

[0213] S7, similarity learning network updating

[0214] In this step, the trajectory samples in the data set are extracted as input, and the vehicle abnormal 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 behavior pattern. Then, based on the probability that each trajectory sample input in this step belongs to each behavior pattern, the cross-entropy loss of this step is calculated using the same calculation method as in step S6, and the gradient descent method is used to update the parameters of the similarity learning network.

[0215] S8, training iteration

[0216] In this step, it is determined whether the training termination condition is reached. If yes, the vehicle abnormal trajectory detection model trained is obtained. Otherwise, steps S3-S7 are executed cyclically.

[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 trajectory encoding and the second trajectory encoding are obtained by using the first spatio-temporal semantic embedding matrix and the second spatio-temporal semantic embedding matrix obtained by pre-training in step S2. Then, according to the method of steps S3-S5, the probabilities that the trajectory to be detected belongs to each behavior pattern are inferred. Then, according to the probabilities that the trajectory to be detected belongs to each behavior pattern, the detection result is output. 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 also known as the number of the unknown class, such as unknown class one, unknown class two, etc.

[0218] In order to verify the effect of the vehicle abnormal trajectory detection model constructed by the present application, experiments are carried out, and Table 1 shows the classification accuracy comparison of the vehicle abnormal 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 basedAdaptive 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 indicator is the accuracy of the known class, the Unknown indicator is the accuracy of the unknown class, the All indicator is the accuracy of all classes, Porto and Chengdu are two city taxi trajectory data sets. From Table 1, it can be seen that the classification accuracy of the model constructed by the embodiment is greatly improved.

[0219] Table 1 Comparison of classification accuracy of the model constructed by 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 using different encoding networks based on the construction method of the present application. In Table 2, ACC is the classification accuracy of all classes, NMI (Normalized Mutual Information) and ARI (Adjusted Rand Index) are clustering indicators for unknown classes, and the higher the better. Among them, NMI is a measure of the similarity between the clustering results and the true labels from the perspective of information theory; ARI is a Rand Index (RI) adjusted according to the decision pair.

[0224] As can be seen from Table 2, the models using different encoding methods can still achieve the classification of abnormal trajectories, but due to the different capturing capabilities of the time-varying dependencies between the trajectory points contained in the trajectories by different encoding methods, the final classification results are affected, and the method of the embodiment is optimal, 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, such as: the performance of LSTM and GRU encoding networks in processing trajectories with a length > 300 decreases, and the decrease of GRU is extremely obvious. Since trajectory anomalies are usually characterized by local features, and the attention mechanism sometimes tends to capture global features, resulting in insufficient ability to capture local anomalies, such as in Table 2, the indicators of the attention mechanism 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 application is to mine time-varying dependencies, which is the core task, and it is crucial to improve the accuracy or quality of the task, and 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 constructed based on the relationship distillation, the RNN-based encoding network or the RNN-based variant described in the embodiment. Based on the above understanding, those skilled in the art can select, adjust and optimize the architecture of the vehicle abnormal trajectory detection model according to its actual application scenario, so that the model obtains the performance that meets the needs of its scene.

[0226] Finally, it should be noted that the above embodiments are only preferred embodiments and do not limit the present application. It should be noted that for those skilled in the art, without departing from the scope of the present application and the scope of protection of the claims, several modifications, equivalent replacements, improvements, etc. can be made, which should be included in the protection scope of the present application.

Claims

1. An architecture method of a vehicle abnormal trajectory detection model in an open environment, the vehicle abnormal trajectory detection model comprising an encoding network, an embedding network, and an inference network, characterized in that, 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: A1, data preparation Obtain trajectory samples and construct a data set, the obtained trajectory samples are divided into normal trajectories, known class abnormal trajectories and unknown class abnormal trajectories according to whether the behavior mode of the trajectory recorded thereby is known, wherein the behavior mode of the normal trajectory and the known class abnormal trajectory is known and the behavior mode thereof is taken as a label, and the behavior mode of the unknown class abnormal trajectory is unknown; A2, trajectory classification Input the trajectory samples of the current training, encode the features by using the encoding network to obtain the trajectory encoding of the input trajectory samples; based on the obtained trajectory encoding, embed the encoding by using the embedding network to obtain the trajectory embedding of the input trajectory samples; based on the obtained trajectory embedding, infer the probability that each trajectory sample belongs to each behavior mode by using the inference network; A3, model updating Calculate the total loss, and update the vehicle abnormal trajectory detection model by using the gradient descent method based on the total loss; The total loss includes a similarity measure loss and a cross-entropy loss; wherein the calculation of the similarity measure loss comprises: Combine the trajectory samples input in the current training in any two-by-two manner to form trajectory pairs; based on the trajectory embedding of each trajectory sample obtained in step A2, calculate the trajectory similarity score between the two trajectory samples contained in each trajectory pair by using a similarity learning network; based on the probability that each trajectory sample belongs to each behavior mode obtained in step A2, calculate the mode similarity score between the two trajectory samples contained in each trajectory pair by using a similarity function; calculate the similarity measure loss of each trajectory pair by aligning the mode similarity score and the trajectory similarity score of each trajectory pair; A4, extract the trajectory samples in the data set as input, and use 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 behavior mode; then, calculate the cross-entropy loss based on the probability that each trajectory sample input in this step belongs to each behavior mode, and update the parameters of the similarity learning network by using the gradient descent method; A5, execute steps A2-A4 cyclically until the training termination condition is reached, and obtain the trained vehicle abnormal trajectory detection model; The calculation of the cross-entropy loss in steps A3 and A4 comprises: Classify each trajectory sample based on the probability that each trajectory sample input in the corresponding step belongs to each behavior mode, and assign a label to the trajectory sample belonging to the known behavior mode and a pseudo-label to the trajectory sample belonging to the unknown behavior mode; then, calculate the cross-entropy loss of each trajectory sample based on the label or pseudo-label of each trajectory sample; The area completely covered by all trajectory samples of the data set on the road network of the area is identified as an identification area, and the identification area is gridded; the encoding network adopts an encoding network based on relationship distillation, including a pre-trained spatiotemporal semantic embedding matrix; in step A2, input the trajectory sample of the current round of training, and obtain the spatiotemporal semantic encoding of the grid contained in the trajectory sample based on the mapping relationship between the grid and the matrix by using the pre-trained spatiotemporal semantic embedding matrix, to form the trajectory encoding of the trajectory sample; The pre-training process of the spatiotemporal semantic embedding matrix includes: B1, data initialization The spatiotemporal semantic embedding matrix is constructed and initialized, and the elements of the spatiotemporal semantic embedding matrix correspond to the grids of the identification area one by one; B2, input the trajectory sample in the data set constructed in step A1 in turn Using the input trajectory sample as the current trajectory, and the grids traversed by the current trajectory on the gridded map, construct the current trajectory. A set of positive sample grids; the starting and ending grids from the dataset are the same as the current trajectory. The current trajectory is formed by sampling grids from the grids contained in the distinct trajectory samples. The negative sample grid set; using the spatiotemporal semantic embedding matrix, based on the mapping relationship between the grid and the matrix, the spatiotemporal semantic encoding of each grid in the positive sample grid set and the negative sample grid set is obtained; B3, update the spatiotemporal semantic embedding matrix The spatiotemporal semantic encoding of each grid obtained in step B2 is used to learn by comparison between positive sample grids and negative sample grids, and the spatiotemporal semantic embedding matrix is updated based on relationship distillation by minimizing expectation; B4, steps B2-B3 are executed in a loop until all trajectory samples in the data set are traversed, and a trained spatiotemporal semantic embedding matrix is obtained; In step B3, the spatiotemporal semantic encoding of each grid obtained in step B2 is used to learn by comparison between positive sample grids and negative sample grids based on the following formula, and the spatiotemporal semantic embedding matrix is updated based on relationship distillation by minimizing expectation: wherein, denotes the minimization of the expectation, is the th positive sample grid, denotes that the positive sample grid set includes the current trajectory except for the start grid and the end grid , denotes the similarity calculation; denotes the spatiotemporal semantic encoding of the anchor point as a contrastive reference, and the grid corresponding to the anchor point belongs to the current trajectory ; is the th negative sample grid, denotes the number of grids sampled from the negative sample grid set; and denote the spatiotemporal semantic encoding of the positive sample grid and the negative sample grid , respectively; 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 a similarity learning network according to the following formula : wherein, represents a fully connected network constituting the similarity learning network, represents a function, and respectively represent trajectory embeddings of two trajectory samples contained in the trajectory sample pair. In step A3, based on the probabilities 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 a similarity function as follows : wherein, and respectively represent a probability distribution vector of the two trajectory samples belonging to each class of behavior pattern, denotes the length of the probability distribution vector. In step A3, the similarity measure loss for each pair of trajectories is computed by aligning the pattern similarity scores and the trajectory similarity scores for each pair of trajectories according to the following equation : wherein, denotes a mode similarity score for a pair of denotes a trajectory similarity score for a pair of trajectory samples.​ 2. The architecture method of a vehicle abnormal trajectory detection model in an open environment according to claim 1, wherein, In step A1, the obtained trajectory samples include normal trajectories, detour anomalies, navigation anomalies, and route exchange anomalies; any one of the three anomalies is taken as a known class abnormal trajectory, and the remaining two anomalies are taken as unknown class abnormal trajectories.

3. The method of claim 1, wherein the model is configured to detect abnormal trajectories of a vehicle in an open environment. The encoding network adopts an encoding network based on relationship distillation, an encoding network based on RNN, or an encoding network constructed based on a variant of RNN.

4. The method of claim 1, wherein the method further comprises: determining a plurality of abnormal trajectory detection models for a plurality of vehicle types; and determining a plurality of abnormal trajectory detection models for a plurality of vehicle types based on the plurality of abnormal trajectory detection models. The identification area is gridded, and the 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 grid passed on the gridded map, the trajectory sample whose number of passed grids is less than a threshold value is excluded, and the data set is updated to only keep the remaining trajectory samples; in step A1, the trajectory samples contained in the data set are sorted according to their start grid and end grid.

5. The architecture method of the vehicle abnormal trajectory detection model in an open environment according to claim 1, characterized in that: The pre-trained spatio-temporal semantic embedding matrix comprises a first spatio-temporal semantic embedding matrix and a second spatio-temporal semantic embedding matrix ; In step A2, input the trajectory sample of this round of training, respectively use the pre-trained first spatio-temporal semantic embedding matrix and the second spatio-temporal semantic embedding matrix , based on the mapping relationship between the grid contained in the trajectory sample and the matrix, obtain the first spatio-temporal semantic encoding and the second spatio-temporal semantic encoding of the grid contained in the trajectory sample, and constitute the first trajectory encoding and the second trajectory encoding of the trajectory sample; then, aggregate to obtain the trajectory encoding of the trajectory sample; In step B1, the first spatiotemporal semantic embedding matrix is ​​constructed and initialized respectively. Second spatiotemporal semantic embedding matrix In step B2, the first and second spatiotemporal semantic codes of each grid in the positive sample grid set and the negative sample grid set are obtained respectively; in step B3, the definition is... ,in, and These represent the two grids that make up the anchor point, and the current trajectory is used. The starting and ending grids constitute the starting and ending grids used to update the first spatiotemporal semantic embedding matrix. The anchor points are based on the current calculation of the positive sample grid. Adjacent and belonging to the current trajectory The two grids form the basis for updating the second spatiotemporal semantic embedding matrix. Anchor point.

6. The architecture method of the vehicle abnormal trajectory detection model in an open environment according to claim 5, characterized in that: The encoding network comprises an aggregation network and a pre-trained spatiotemporal semantic embedding matrix, the aggregation network adopts a full connection network; in step A2, the trajectory encoding of the trajectory sample is obtained by aggregation through the aggregation network according to the following formula : wherein, represents the i-th grid of the trajectory sample, represents the spatio-temporal semantic encoding of the grid and represent a first and a second spatio-temporal semantic encoding of the grid represents a concatenation operation; and are trainable parameters of fully connected networks constituting the aggregation network; represents the number of grids comprised in the trajectory sample.​​​ 7. The architecture method of a vehicle abnormal trajectory detection model in an open environment according to claim 1, 2, 3 or 4, characterized in that: The embedding network adopts a state space model, and the inference network adopts a fully connected network; In step A2, the trajectory embedding of the input trajectory sample is obtained by using the embedding network to perform embedding coding based on the obtained trajectory encoding, including: First, the obtained trajectory is encoded As input to the state space model, by the state space model: , The state space output is calculated and obtained: wherein, is a state variable, is an output variable, is an input variable, are parameters of the state space model; GELU denotes a GELU activation function, denotes a Fourier transform, denotes an inverse Fourier transform, is a convolution kernel of the state space model obtained based on dynamic modeling of dynamic dependencies of each grid contained in the currently computed trajectory sample, is is an inverse matrix of the matrix, denotes a sampling period, is an identity matrix, correspond to parameters of the state space equation ; denotes the grid of the currently computed trajectory sample, denotes a spatio-temporal semantic encoding of the grid , denotes a number of grids contained in the currently computed trajectory sample; Then, based on the state space output of the current computed trajectory sample , a trajectory embedding of the current computed trajectory sample is computed: wherein, represents the trajectory embedding of the current computed trajectory sample; In step A2, the probability that each trajectory sample belongs to each behavior mode is inferred by using the inference network based on the obtained trajectory embedding according to the following formula: wherein, denotes a fully connected network constituting the reasoning network, denotes a function, denotes a trajectory embedding of the current computed trajectory sample, denotes a probability distribution vector of the current computed trajectory sample belonging to each class of behavior pattern.

8. The architecture method of a vehicle abnormal trajectory detection model in an open environment according to claim 1, 2, 3 or 4, characterized in that: The calculation of the cross-entropy loss in steps A3 and A4 includes: First, based on the probabilities that each trajectory sample in the corresponding step belongs to each type of behavior pattern, classify each trajectory sample, and through one-hot encoding, assign a label to the trajectory sample belonging to a known behavior pattern and a pseudo-label to the trajectory sample belonging to an unknown behavior pattern; each bit of the one-hot encoding corresponds to a type of behavior pattern, and the number of bits is , denotes the number of known behavior patterns, denotes the number of unknown behavior patterns; For the trajectory sample of the known behavior mode, the corresponding bit of the behavior mode corresponding to the maximum probability is 1, and others are 0; For the trajectory sample of the unknown behavior mode, only the current trajectory sample is inferred to obtain the probability belonging to the behavior mode greater than the confidence threshold The bit corresponding to the behavior mode is 1, otherwise 0. Then, based on the label or pseudo-label of each trajectory sample, the cross-entropy loss of each trajectory sample is calculated according to the following formula : in, The number of trajectories; Indicates the first The first one-hot encoding of the label or pseudo-label of the trajectory The value of the bit. The first one obtained through reasoning network is represented as the first one. The trajectory belongs to the first The probability of a class's behavioral pattern.

9. The architecture method of a vehicle abnormal trajectory detection model in an open environment according to claim 1, 2, 3 or 4, characterized in that: In step A3, the total loss also includes an entropy regularization loss , the entropy regularization loss is calculated as follows: wherein, denotes the number of known behavior patterns, denotes the number of unknown behavior patterns, denotes the average of the probabilities that each trajectory sample belongs to the class behavior pattern.

10. The method of claim 9, wherein the method further comprises: determining a plurality of abnormal trajectory detection models for a plurality of vehicle types; and determining a plurality of abnormal trajectory detection models for a plurality of vehicle types based on the plurality of abnormal trajectory detection models. In step A3, the total loss is calculated according to the following formula: + wherein, represents a similarity measure loss for a pair of trajectory samples, is the number of pairs of trajectory samples, represents a cross-entropy loss, represents an 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