Track similarity measurement method based on comparative predictive coding, computer readable storage medium and computer program product

By comparing the combination of predictive encoding and Manhattan distance, the problems of high computational complexity of trajectory similarity measurement and difficulty in feature extraction in the existing technology are solved, and more efficient and accurate trajectory similarity measurement is achieved, suitable for large-scale and high-dimensional Data processing.

CN119046698AActive Publication Date: 2024-11-29SHANDONG COMP SCI CENTNAT SUPERCOMP CENT IN JINAN +2

Patent Information

Application Number
CN202411160238.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-22
Publication Date
2024-11-29
Estimated Expiration
2044-08-22

AI Technical Summary

Technical Problem

The existing trajectory similarity measurement methods have high computational complexity when processing large-scale and high-dimensional data, are difficult to extract features, and are difficult to fully capture trajectory shape and timing information, resulting in insufficient accuracy when processing complex modes.

Method used

Using a method based on contrast predictive coding (CPC), the high-dimensional features of the trajectory are extracted through shared encoder and enhanced autoregressive modules, combined with Manhattan distance and GPU acceleration technology, optimize feature extraction and computing efficiency, and improve the accuracy of similarity measurements. and efficiency.

Benefits of technology

It significantly improves the accuracy and efficiency of trajectory similarity measurement, can capture complex spatiotemporal relationships in trajectory data more comprehensively, is suitable for large-scale data processing, reduces computing resource consumption, and provides a more accurate and reliable analysis foundation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119046698A_ABST
    Figure CN119046698A_ABST
Patent Text Reader

Abstract

The invention belongs to the field of track similarity measurement, and particularly relates to a track similarity measurement method based on comparative predictive coding, a computer readable storage medium and a computer program product, and the method comprises the following steps: S1, carrying out the preprocessing and transposition operation of data, and obtaining track data meeting the input requirements of an improved neural network model; s2, using an improved neural network model, combining a shared encoder of the model and an enhanced autoregression module, training trajectory data, and extracting a high-dimensional feature vector of each trajectory; and S3, a distance matrix is generated by calculating Manhattan distances between the high-dimensional feature vectors, the distance matrix is converted into a ranking matrix, and each element in the ranking matrix represents a relative ranking position of a corresponding distance value in the distance matrix. According to the method, the complex time-space relationship in the trajectory data can be more comprehensively captured, and the accuracy and efficiency of similarity measurement are effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of trajectory similarity measurement, and in particular relates to a trajectory similarity measurement method based on contrast prediction coding, a computer-readable storage medium and a computer program product. Background Art

[0002] With the rapid development of data science and artificial intelligence technology, trajectory data research has become a hot topic in academia and industry. Trajectory data is widely used in transportation, logistics, mobile communications and other fields. Through in-depth analysis, valuable information and laws can be mined. As a basic technology, trajectory similarity measurement has important research and application value. It provides an effective method for evaluating and comparing different trajectories. In trajectory prediction tasks, trajectory similarity measurement plays a key role. By measuring the similarity of historical trajectories, the pattern of trajectories can be identified, so that future trajectories can be predicted more accurately, which is of great significance for applications that require foresight and planning, such as traffic management and logistics optimization. In addition, trajectory similarity measurement is also very important in trajectory classification tasks. By measuring the similarity between trajectories, trajectories with similar movement patterns can be classified into one category to achieve effective classification. This classification helps to understand different types of movement behaviors and patterns, and provides support for subsequent analysis and decision-making. Therefore, researching and developing efficient and accurate trajectory similarity measurement methods is of great significance to improving the analysis ability and decision-making level in related fields.

[0003] With the development and application of global positioning system (GPS) technology, the level of data collection and analysis in various fields has been significantly improved. GPS enables us to obtain accurate trajectory data through satellite signal positioning and time synchronization. This technological advancement has greatly promoted the development of trajectory data research, especially in the fields of traffic management, logistics optimization and mobile communications. The trajectory data obtained by GPS can more accurately evaluate and compare the similarity between different trajectories, thereby improving the practicality and reliability of trajectory similarity measurement methods. At present, the research on trajectory similarity measurement is mainly divided into two types: traditional machine learning methods and deep learning methods. Among traditional machine learning methods, dynamic time warping (DTW) is a common trajectory similarity measurement method. DTW measures similarity by calculating the time alignment distance of trajectories, which can effectively handle irregular and nonlinear time series. However, DTW has high computational complexity, especially in large-scale data sets, and the efficiency problem is prominent. In order to improve computational efficiency, Zheng et al. combined the geometric features of trajectories and the K nearest neighbor algorithm (KNN) to propose a fast measurement method. This method achieves a balance between efficiency and accuracy through feature vectorization and KNN evaluation, but it still faces challenges in high-dimensional feature space. Another traditional method is based on edit distance metrics, such as EDR (Edit Distance on Realsequence) and ERP (Edit Distance with Real Penalty). These methods measure similarity by calculating the minimum cost of insertion, deletion, and replacement operations between trajectory points. Although the edit distance method has advantages in dealing with trajectory deviations and missing points, its computational complexity is high and it is difficult to apply in large-scale datasets. Traditional machine learning methods have certain practicality in trajectory similarity measurement, but their main disadvantages are high computational complexity, complex feature selection, and performance degradation when dealing with large-scale and high-dimensional data.

[0004] Chinese patent document CN117034025A discloses a trajectory similarity measurement method based on multi-channel feature learning, which preprocesses trajectory data, transforms coordinates and enhances data to obtain trajectory positive and negative sample pairs, extracts trajectory point number features, trajectory segment length and time features, and trajectory direction angle features, and obtains multi-channel feature maps by feature splicing. A multi-channel convolutional neural network containing an attention mechanism is used to perform deep learning on the multi-channel feature maps of the trajectory, and finally outputs the similarity score of the trajectory. The present invention aims at the problems of insufficient trajectory feature representation, difficult feature extraction, and focusing on time series information while ignoring trajectory shape. It can effectively extract multi-channel features and time series information of trajectory data and capture trajectory shape, improve the accuracy of trajectory similarity measurement, and provide a new method and approach for trajectory similarity measurement. Although CN117034025A proposes an innovative trajectory similarity measurement method, the method still has some shortcomings. First, the complex feature extraction process increases the computational complexity and has a high dependence on the quality and format of trajectory data, which may affect the accuracy and extensiveness in practical applications. Secondly, too much emphasis on capturing temporal information may lead to insufficient expression of the overall shape of the trajectory, especially when dealing with complex trajectory patterns. In addition, although the use of a multi-channel convolutional neural network with an attention mechanism enhances the expressive power of the model, the computational cost is high and may not be suitable for real-time processing of large-scale trajectory data.

[0005] In recent years, deep learning has been widely used in the study of trajectory similarity measurement due to its powerful feature extraction ability. Deep learning methods are mainly divided into supervised learning and unsupervised learning. Supervised learning requires a large amount of labeled data, which is difficult to achieve in trajectory data. Unsupervised learning methods show great potential. Generative learning and contrastive learning are the two main methods in unsupervised learning. In the generative learning method, the variational autoencoder (VAE) method proposed by Vaswani et al. generates new trajectory data similar to the original data by constructing a probabilistic model of trajectory data, thereby realizing trajectory similarity measurement, but the generation quality may be limited in high-dimensional data processing. In the contrastive learning method, the contrastive learning method proposed by He et al. constructs positive and negative sample pairs, minimizes the distance between positive sample pairs, and maximizes the distance between negative sample pairs to realize trajectory similarity measurement. In addition, ContrastivePredictive Coding (CPC) is an emerging contrastive learning method that has achieved remarkable results in audio, image, and natural language processing. CPC can efficiently learn the latent representation of data under unsupervised conditions by predicting future segments of data, thereby capturing complex temporal and spatial characteristics.

[0006] To solve the above problems, the present invention innovatively applies the Contrastive Predictive Coding (CPC) method to the field of trajectory similarity measurement. Summary of the invention

[0007] In view of the shortcomings of the prior art, the purpose of the present invention is to disclose a trajectory similarity measurement method based on contrastive predictive coding, which effectively evaluates and compares the similarities between different trajectories and improves the accuracy and efficiency of trajectory similarity measurement.

[0008] The invention also discloses a computer-readable storage medium for implementing the above method.

[0009] The invention also discloses a program product for realizing the method.

[0010] The technical solution adopted by the present invention to achieve the above-mentioned purpose is:

[0011] A trajectory similarity measurement method based on contrastive predictive coding, the method steps are as follows:

[0012] 1) Clean, flip and transpose the trajectory data to obtain GPS trajectory data that meets the input requirements of the CPC neural network model;

[0013] 2) Using the CPC neural network model, combined with the model's shared encoder and enhanced autoregressive module, the GPS trajectory data is trained to extract the high-dimensional feature vector of each trajectory;

[0014] 2-1) Feature extraction based on shared encoder

[0015] The shared encoder is used to process GPS trajectory data to extract its potential spatiotemporal features and generate a high-dimensional feature representation z t =g enc (x t );

[0016] 2-2) Temporal dependencies in trajectory data modeling based on dual GRU

[0017] After using the shared encoder to extract the latent spatiotemporal features of the trajectory and generate high-dimensional feature representations, these high-dimensional features will be input into two independent gated recurrent unit GRU modules, which are configured to process the sequence forward and backward respectively. The generated context of the current moment is represented as c t =g ar (z ≤t ), to model the temporal dependencies in GPS trajectory data;

[0018] 2-3) Prediction and model optimization

[0019] After getting the context representation c t Then, the feature representation z of the next k moments is predicted t+k , which is done by in the linear layer W k Let context be c t This is achieved by mapping back to the original 512-dimensional feature space through a series of linear transformations;

[0020] InfoNCE loss is used as the loss function of the model to optimize the model, that is, to maximize the mutual information between the context information representation and the target variable, thereby improving the feature extraction and representation capabilities of the model;

[0021] 3) After the model training is completed, the trained encoder module is used to extract high-dimensional features for each trajectory. After the high-dimensional features are extracted, the distance matrix is ​​generated by calculating the Manhattan distance between the high-dimensional feature vectors; then, each distance value in the distance matrix is ​​sorted from small to large and converted into a ranking matrix. Each element in the ranking matrix represents the position of the corresponding distance in the sorting. The similarity of the trajectories is evaluated by ranking. The higher the ranking, the higher the similarity between the trajectories and the target trajectory.

[0022] Preferably, the data cleaning means, first, extracting useful fields from the PLT file, removing useless fields, converting the fields into numerical data, and unifying the time format; then, smoothing noise points and processing drift points for each trajectory data, and then removing trajectories with less than a preset threshold, and finally, converting the processed data into HDF5 format;

[0023] After the above data cleaning, the trajectory data set is obtained, in which each trajectory meets the quality standard. The cleaned trajectory data set is T and is expressed as:

[0024]

[0025] In formula (1), T i represents each trajectory, |T i ∣ represents the trajectory T i The number of points, N min Indicates the minimum threshold of points;

[0026] Each trajectory T i It is further represented as a sequence containing trajectory points:

[0027] T i = {P ij |j=1,2,..,|T i |} (2)

[0028] In formula (2), p ij Represents the trajectory T iThe jth point in the trajectory point p ij Contains valid data fields such as latitude, longitude, altitude, and time, expressed as:

[0029] p ij =(Latitude ij , Longitude ij ,Altitude ij , Days ij ) (3)

[0030] In formula (3), Latitude ij Represents the trajectory T i The latitude of the jth point in ik Represents the trajectory T i The longitude of the jth point in ij Represents the trajectory T i The altitude of the j-th point in the latitude, Days ij Represents the trajectory T i The number of days of the jth point in ;

[0031] After integrating the above information, the trajectory data set T after data cleaning is expressed as:

[0032]

[0033] The smoothing of noise points refers to detecting noise points according to the spatiotemporal characteristics of trajectory points: first, by calculating the speed between adjacent trajectory points, and then detecting whether there are outliers:

[0034] If the adjacent trajectory point p i and p i+1 If the speed v between exceeds the preset maximum speed threshold vmax, then the point is a noise point;

[0035] For adjacent trajectory points p i and p i+1 , the speed v is calculated as follows:

[0036]

[0037] In formula (5), d(p i ,p i+1 ) represents the geographical distance between two points, t i and t i+1 They are the trajectory points p i and p i+1 timestamp;

[0038] For the detected noise points, the weighted average method is used to smooth the noise.i =(lat i ,lon i ) is detected as a noise point, its coordinates are replaced by the weighted average of the k non-noise points before and after it. The formula is as follows:

[0039]

[0040]

[0041] In formula (6) and (7), the weight w j Set based on time difference or distance to ensure that closer points have a greater impact on the smoothing result;

[0042] Processing drift points refers to detecting drift points by calculating the distance between adjacent trajectory points:

[0043] If the distance between adjacent points exceeds the preset threshold d max , then this point is a drift point, and the preset threshold d max Adjust according to the specific situation of the data set, and the detection formula is as follows:

[0044] dist(x i ,x i+1 )>d maX (8)

[0045] In formula (8), dist(x i ,x i+1 ) is the point x i and x i+1 The distance between

[0046] After the drift point is detected, its geographic coordinates are corrected using linear interpolation to calculate the new position. The new position calculation formula is as follows:

[0047]

[0048] In formula (9), represents the new position, x i represents the drift point, x i-1 and x i+1 Respectively represent the normal point before and after the drift point, the new position For the two normal points x before and after i-1 and x i+1 The midpoint of the sensor can effectively reduce the drift error.

[0049] The method of eliminating trajectories with less than a threshold number of trajectory points is as follows: first, the number of points of each trajectory is counted; then, a threshold N is set. threshold, mark the trajectories with less than the threshold value as the trajectories to be eliminated; finally, remove the trajectories to be eliminated, and retain the trajectories with no less than the threshold value, to ensure that the retained data has sufficient information.

[0050] Preferably, the transposition means that the shape of the trajectory data set after data cleaning is (trajectory_window, num_features), which is transposed to (num_features, trajectory_window), and the data of each feature in the trajectory point are arranged together, so that the CPC neural network model can correctly parse the various features of each trajectory point, where trajectory_window represents the number of trajectory points and num_features represents the number of features.

[0051] Preferably, the shared encoder comprises five one-dimensional convolutional layers, each of which is equipped with a batch normalization BatchNormalization and a ReLU activation function. In order to ensure the stability and convergence of network training, the weights of the convolutional layer and the linear layer are initialized using the He initialization method, and the He initialization method adjusts the weight distribution according to the number of input features of the network layer to enhance the learning ability of the network and prevent the gradient from disappearing;

[0052] The specific configuration of the five one-dimensional convolutional layers is as follows: the convolution kernel size of the first convolutional layer is 10, the stride is 5, the padding is 3, and the output is 512 feature channels; the convolution kernel size of the second convolutional layer is 8, the stride is 4, the padding is 2, and the output is maintained at 512 feature channels; the convolution kernel size of the third, fourth and fifth convolutional layers is 4, the stride is 2, and the padding is 1. Each layer maintains the output of 512 feature channels to extract deeper features respectively; through multiple layers of convolutional layers, different features of trajectory data are gradually captured. The initial layer uses a larger convolution kernel to capture features with a longer time span, and the subsequent layers use a smaller convolution kernel to capture finer-grained features, thereby more comprehensively describing the complexity of trajectory data. In addition, batch normalization and ReLU activation function after each layer accelerate model training and improve convergence speed, while reducing the risk of gradient vanishing and gradient explosion.

[0053] Preferably, the temporal dependency in the trajectory data based on the dual GRU modeling specifically refers to that the input of each GRU module is a high-dimensional feature extracted by the shared encoder, whose dimension is 512, and after GRU processing, a 128-dimensional temporal feature representation is output, the forward GRU and the reverse GRU have the same structure, both include a hidden layer, a step size of 1, and do not use a bidirectional setting, the forward GRU processes the forward part of the sequence, and the reverse GRU processes the reverse part of the sequence, and the generated context representation of the current moment is c t =g ar (z ≤t), the hidden state of each GRU module uses the He initialization method to initialize the network weights after each iteration to ensure that the sequence processed in each batch remains consistent to adapt to the nonlinear characteristics of the ReLU activation function.

[0054] Preferably, the prediction refers to obtaining the context representation c t Then, the feature representation z of the next k moments is predicted t+k , which is done by in the linear layer W k c t This is achieved by mapping back to the original 512-dimensional feature space through a series of linear transformations. Specifically, the outputs of the forward and reverse GRUs combine the contextual information in the time series to provide a more comprehensive temporal feature representation, which is a predictive feature representation generated by the linear transformation. Used to represent the real feature z t+k Make a match;

[0055] Since mutual information can be expressed by density ratio, the future observation value x can be indirectly measured by density ratio. t+k and the context representation c t The mutual information between them, the density ratio formula is:

[0056]

[0057] In formula (10), f k (x t+k ,c t ) is the density ratio; p(x t+k ∣c t ) is given under the condition c t In the case of x t+k The conditional probability density function, which means that under the condition c t Next, x t+k The distribution of p(x t+k ) is in the absence of any condition c t In the case of x t+k The marginal probability density function of x t+k Distribution of the overall data; density ratio f k (x t+k ,c t ) is used to measure the future observation value x t+k In the given context c t The relative probability under the condition is proportional to the ratio of the probability of future real data to random sampling data.

[0058] Since it is difficult to directly calculate the density ratio, a parameterized function is introduced. With the approximate density ratio, through the linear matrix W1,W2,…,Wk Multiply by the context representation c t As the predicted value W k c t ,and is the true value, and the vector inner product is used to measure the similarity;

[0059] The InfoNCE loss is used as the loss function of the model and is defined as follows:

[0060]

[0061] In formula (11), X={x1,x2,…,x N} is a set of samples; (x t+k ,c t ) represents a positive sample pair; (x j ,c t ) represents a negative sample pair, and optimizing the loss function is to maximize x t+k and c t The mutual information between, as shown in the InfoNCE loss formula, f k (x t+k ,c t ) is indeed It is proportional to and has nothing to do with the number of negative samples selected N-1.

[0062] Preferably, the Manhattan distance between the high-dimensional feature vectors is calculated using the formula:

[0063]

[0064] In formula (12), v and y are two high-dimensional feature vectors, v i and i They represent the eigenvalues ​​of the i-th dimension respectively.

[0065] Converting the distance matrix into a ranking matrix means sorting each row or column in the distance matrix in ascending order, recording the relative position of each distance value after sorting, and using the indexes of these relative positions as elements in the ranking matrix, thereby generating a ranking matrix representing the relative ranking position of each distance value.

[0066] A computer-readable storage medium stores computer instructions, which can implement the steps of the above method when executed by a processor.

[0067] A computer program product loaded with the above method comprises computer instructions, which can implement the steps of the above method when executed by a processor.

[0068] Compared with the prior art, the present invention has the following beneficial effects:

[0069] (1) Traditional trajectory similarity measurement methods usually rely on simple geometric distance calculations, such as Euclidean distance and dynamic time warping (DTW). Although these methods are widely used, they often cannot fully capture the deep features in the trajectory data when dealing with complex spatiotemporal relationships, thereby limiting the accuracy and effectiveness of similarity evaluation. The present invention innovatively applies the contrastive predictive coding (CPC) method to the field of trajectory similarity measurement, and significantly improves the accuracy of similarity evaluation by extracting richer spatiotemporal features from trajectory data. At the same time, the present invention combines Manhattan distance calculation and GPU acceleration technology, which significantly improves the computational efficiency and robustness when processing large-scale trajectory data.

[0070] (2) Although the traditional CPC method has achieved remarkable results in feature extraction, there is still room for optimization in the design of its encoder and autoregressive module. The present invention achieves more refined feature extraction of trajectory data by introducing an improved encoder structure and an enhanced autoregressive module. These improvements enable the present invention to have higher accuracy and stability in extracting trajectory features, thereby improving the performance of the entire similarity measurement model. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] Figure 1 This is a diagram of the CPC neural network model architecture of the present invention;

[0072] Figure 2 This is the Loss / Accuracy effect diagram of the present invention;

[0073] Figure 3 This is a flow chart of trajectory similarity measurement of the present invention. DETAILED DESCRIPTION

[0074] Embodiment 1,

[0075] A trajectory similarity measurement method based on contrastive predictive coding, the method steps are as follows:

[0076] 1) Clean, flip and transpose the trajectory data to obtain GPS trajectory data that meets the input requirements of the CPC neural network model;

[0077] 2) Using the CPC neural network model, combined with the model’s shared encoder and enhanced autoregressive module, the GPS trajectory data is trained;

[0078] 2-1) Feature extraction based on shared encoder

[0079] The shared encoder is used to process GPS trajectory data to extract its potential spatiotemporal features and generate a high-dimensional feature representation z t =g enc (x t );

[0080] 2-2) Temporal dependencies in trajectory data modeling based on dual GRU

[0081] After using the shared encoder to extract the latent spatiotemporal features of the trajectory and generate high-dimensional feature representations, these high-dimensional features will be input into two independent gated recurrent unit GRU modules, which are configured to process the sequence forward and backward respectively. The generated context of the current moment is represented as c t =g ar (z ≤t ), to model the temporal dependencies in GPS trajectory data;

[0082] 2-3) Prediction and model optimization

[0083] After getting the context representation c t Then, the feature representation z of the next k moments is predicted t+k , which is done by in the linear layer W k Let context be c t This is achieved by mapping back to the original 512-dimensional feature space through a series of linear transformations;

[0084] InfoNCE loss is used as the loss function of the model to optimize the model, that is, to maximize the mutual information between the context information representation and the target variable, thereby improving the feature extraction and representation capabilities of the model;

[0085] 3) After the model training is completed, the trained encoder module is used to extract high-dimensional features for each trajectory. After the high-dimensional features are extracted, the distance matrix is ​​generated by calculating the Manhattan distance between the high-dimensional feature vectors; then, each distance value in the distance matrix is ​​sorted from small to large and converted into a ranking matrix. Each element in the ranking matrix represents the position of the corresponding distance in the sorting. The similarity of the trajectories is evaluated by ranking. The higher the ranking, the higher the similarity between the trajectories and the target trajectory.

[0086] Finally, by calculating the average ranking value under specific conditions, the similarity between trajectories can be accurately evaluated. Experimental results show that this method can more comprehensively capture the complex spatiotemporal relationships in trajectory data, effectively improving the accuracy and efficiency of similarity measurement. Compared with traditional methods, the present invention exhibits higher robustness and computational efficiency when processing large amounts of trajectory data, significantly reducing the consumption of computing resources. In addition, this method provides a more accurate and reliable basis for subsequent analysis and decision-making of trajectory data, and can be widely used in traffic planning, location recommendation and other fields. The specific processing scheme is as follows:

[0087] 1: Dataset and data preprocessing:

[0088] In order to verify the effectiveness of the present invention, the GeoLife dataset of Microsoft Research Asia was used. The dataset contains 17,621 GPS trajectory data collected by 182 users in five years, with a total distance of 1,292,951 kilometers and a total duration of 50,176 hours. The sampling rate of the trajectory data varies, and most trajectories are collected by recording one point every 15 seconds or every 510 meters. More details can be found in Table 1. The GPS tracks of the GeoLife dataset are stored in PLT format, and each folder contains a user's GPS log file. The first 6 lines of the PLT file are useless information and can be ignored. Each subsequent line describes a trajectory point and contains 7 fields: latitude, longitude, useless fields, altitude, date (number of days since December 30, 1899), date (string form) and time (string form). Field 5 and fields 6&7 represent the same date / time, and either one can be used.

[0089] Table 1 Statistics of GeoLife dataset

[0090]

[0091] Since there are several problems with PLT files, it is not practical to use these files directly for processing. First, PLT files contain useless fields, which have no practical significance for trajectory analysis. Secondly, the data quality of PLT files may be poor, containing noise points and drift points, and need to be cleaned to improve data quality. In addition, the data format and accuracy of PLT files are inconsistent, which increases the complexity of data preprocessing. The data processing flow of the present invention is as follows: First, extract useful fields from the PLT file, remove useless fields, convert the fields into numerical data, and unify the time format. Next, remove noise points and discrete points for each trajectory, and then eliminate trajectories with less than a threshold value (such as 2000 points) to improve the representativeness and reliability of the data. Finally, convert the processed data into HDF5 format. This process effectively solves the problem of PLT files and provides a high-quality data foundation for subsequent data analysis. The following steps are specific data cleaning operations:

[0092] 1.1: Smoothing noise points: Detect noise points based on the spatiotemporal characteristics of trajectory points. First, calculate the speed between adjacent trajectory points and then detect whether there are outliers. If the speed between adjacent trajectory points exceeds the preset maximum speed threshold vmax, the point is considered to be a noise point. i and p i+1 , the speed v is calculated as follows:

[0093]

[0094] Among them, d(pi ,p i+1 ) represents the geographical distance between two points, t i and t i+1 They are the trajectory points p i and p i+1 For the detected noise points, the weighted average method is used to smooth the noise. Assuming that the trajectory point p i =(lat i ,lon i ) is detected as a noise point, and its coordinates can be replaced by the weighted average of the k non-noise points before and after it. The formula is as follows:

[0095]

[0096]

[0097] Among them, the weight w j It can be set based on time difference or distance to ensure that closer points have a greater impact on the smoothing result.

[0098] 1.2: Handling drift points: In the process of trajectory similarity measurement, drift points refer to the phenomenon that the trajectory points deviate significantly from the actual trajectory due to GPS signal errors or poor reception conditions. First, the drift points are detected by calculating the distance between adjacent trajectory points. If the distance between adjacent points exceeds a certain threshold, the point is considered to be a drift point. The threshold d is set max It can be adjusted according to the specific situation of the data set. The formula is as follows:

[0099] dist(x i ,x i+1 )>d max (4)

[0100] where dist(x i ,x i+1 ) is the point x i and x i+1 Once a drift point is detected, its geographic coordinates are corrected using interpolation. The new position is calculated using linear interpolation. Assume that point x i is the drift point, and its front and back normal points are x i-1 and x i+1 , then the new position It can be calculated by the following formula:

[0101]

[0102] This formula represents the new position For the two normal points x before and after i-1 and x i+1The midpoint of the sensor can effectively reduce the drift error.

[0103] 1.3: Eliminate trajectories with fewer points than the threshold: After removing noise points and discrete points, further eliminate trajectories with fewer points than the specified threshold (such as 2000 points) to ensure data quality and representativeness. The specific process is as follows: First, count the number of points for each trajectory. Then, set a threshold N threshold = 2000, and mark the trajectories with less than the threshold as the ones to be removed. Finally, remove these short trajectories and only keep the trajectories with no less than the threshold. This step ensures that the retained data has enough information and provides a high-quality data foundation for subsequent analysis.

[0104] After the above series of data cleaning, the final trajectory data set is obtained, in which each trajectory meets certain quality standards. Assume that the cleaned trajectory data set is T, and each trajectory is T i , the point in the trajectory is p ij (i.e. trajectory T i The trajectory data set can be expressed as:

[0105]

[0106] Among them, |T i ∣ represents the trajectory T i The number of points, N min is the minimum threshold of the number of points. Each trajectory T i It can be further represented as a sequence of trajectory points:

[0107] T i ={p ij |j=1,2,..,|T i |} (7)

[0108] Trajectory point p ij Contains latitude and longitude coordinates and other valid data fields:

[0109] p ij =(Latitude ij , Longitude ij ,Altitudee ij , Days ij ) (8)

[0110] After integrating the above information, the trajectory data set T after data cleaning can be expressed as:

[0111]

[0112] 2: Data Transposition

[0113] After a series of data cleaning on the trajectory data, the data needs to be transposed to ensure that the dimensional order of the data matches the input requirements of the model. The shape of the original data is (trajectory_window, num_features), where trajectory_window represents the number of trajectory points and num_features represents the number of features. In order to adapt to the input requirements of the model, the data is transposed to (num_features, trajectory_window). Such a transposition operation is to arrange the data of each feature together so that the model can correctly parse the individual features of each trajectory point. For example, if the original data contains three features (such as latitude, longitude, and time), and each trajectory point has three values, then after transposition, these feature values ​​will be grouped by feature, allowing the model to process the entire sequence of each feature at once. This is especially important for time series models because they rely on the temporal relationship between features to make predictions. The transposed data can better adapt to the input requirements of the time series model, allowing the model to learn the spatiotemporal relationship and feature association of the trajectory from the time series. After completing the data transposition, the data is converted into a PyTorch tensor, which not only helps to simplify the subsequent model training and analysis process, but also makes full use of the efficient computing power and GPU acceleration function of the PyTorch framework to improve the training speed and effect of the model. The trajectory data processed in this way can ensure that the model obtains accurate and effective information during the training process, further improving the accuracy and efficiency of trajectory similarity measurement.

[0114] 3: Model design

[0115] This paper proposes an improved Contrastive Predictive Coding (CPC) neural network model to improve the ability of trajectory similarity measurement. Figure 1 As shown in the figure, the model combines an improved encoder and an autoregressive module, and enhances the feature extraction and comparison capabilities of trajectory data through a shared encoder architecture. Specifically, the model includes a shared encoder composed of multiple one-dimensional convolutional layers (1D-CNN) and non-linear activation functions to obtain high-dimensional features of the trajectory.

[0116] 3.1: Feature extraction based on shared encoder

[0117] The shared encoder is a strategy to improve model efficiency and performance by using the same encoder network in multiple tasks or data processing to reduce computational overhead and parameter redundancy. In trajectory feature extraction, the shared encoder not only simplifies the model structure, but also significantly improves the ability to capture the spatiotemporal features of trajectory data by sharing weights. The shared encoder g used in this experiment encIt is composed of multiple one-dimensional convolutional layers (1D-CNN) and nonlinear activation functions, which processes GPS trajectory data to extract its potential spatiotemporal features and generate high-dimensional feature representations z t =g enc (x t ).

[0118] In the present invention, a shared encoder containing five one-dimensional convolutional layers is used for trajectory feature extraction. The purpose of this design is to gradually extract the multi-level features of the trajectory data and ensure the training stability of the model. The use of a shared encoder can reduce the number of parameters, improve the training efficiency of the model, and ensure the consistency of feature extraction between different trajectories. Each convolutional layer is equipped with batch normalization and ReLU activation function, and the specific configuration is as follows: the first convolutional layer (convolution kernel size 10, step size 5, padding 3) outputs 512 feature channels; the second convolutional layer (convolution kernel size 8, step size 4, padding 2) keeps outputting 512 feature channels; the third, fourth and fifth convolutional layers (convolution kernel size 4, step size 2, padding 1) extract deeper features respectively, and each layer keeps outputting 512 feature channels. Through multiple layers of convolutional layers, different features of trajectory data are gradually captured. The initial layer uses a larger convolution kernel to capture features with a longer time span, and the subsequent layers use a smaller convolution kernel to capture finer-grained features, thereby more comprehensively describing the complexity of trajectory data. In addition, batch normalization and ReLU activation function after each layer accelerate model training and improve convergence speed while reducing the risk of gradient vanishing and gradient exploding.

[0119] In order to ensure the stability and convergence of network training, the present invention uses the He initialization method to initialize the weights of the convolutional layer and the linear layer. The He initialization method adjusts the weight distribution according to the number of input features of the network layer to enhance the learning ability of the network and prevent the gradient from disappearing. Through the design of this multi-layer convolution structure, the encoder can effectively extract important spatiotemporal features in the GPS trajectory data, significantly improving the model's understanding and processing capabilities of the trajectory data.

[0120] 3.2: Modeling temporal dependencies in trajectory data based on dual GRU

[0121] After the spatiotemporal features of the trajectory are extracted using the shared encoder, they are input into two independent GRU (Gated Recurrent Unit) modules to model the temporal dependencies in the GPS trajectory data. The GRU module is a common method for processing time series data. It effectively captures the long-term dependencies and dynamic changes in the time series through the gating mechanism. In this method, the GRU modules are configured to process the sequence in both forward and reverse directions to fully obtain the contextual information in the time series. Specifically, the input of each GRU module is the features extracted by the encoder with a dimension of 512, and the output is a 128-dimensional temporal feature representation after GRU processing. The forward GRU (self.gru1) and the reverse GRU (self.gru2) have the same structure, both including one hidden layer, with a step size of 1, and do not use a bidirectional setting. The hidden state of each GRU module is initialized after each iteration to ensure that the sequence processed in each batch is consistent. In the implementation of GRU, the He initialization method is used to initialize the network weights to adapt to the nonlinear characteristics of the ReLU activation function. In addition, a similar initialization strategy is also used for the linear layer to ensure good performance of the model in the early stage of training.

[0122] During the forward propagation process, the encoded feature z t and all previous moments in the latent space are input into an autoregressive model g ar The autoregressive model is composed of the two independent GRU (Gated Recurrent Unit) modules mentioned above, which process the forward and reverse sequences respectively. The forward GRU processes the forward part of the sequence, while the reverse GRU processes the reverse part of the sequence. The generated context at the current moment is represented as c t =g ar (z ≤t ).

[0123] 3.3: Prediction and model optimization

[0124] After getting the context representation c t Then, try to predict the feature representation z for the next k moments t+k This is done by placing c t After a series of linear transformations (consisting of linear layers W k The output of the forward and reverse GRUs is combined with the contextual information in the time series to provide a more comprehensive temporal feature representation. These temporal feature representations are then transformed into the predicted feature representations generated by the linear transformation. Used to represent the real feature z t+k to make a match.

[0125] The present invention does not use the generative model p(x t+k |c) to make predictions, but to maximize x t+kand c, which measures the dependency between two random variables, making the prediction With the real z t+k As similar as possible. Since mutual information can be expressed by density ratio, through density ratio, x can be indirectly measured t+k and c t The mutual information between them. The density ratio formula is given as Density ratio f k (x t+k ,c t ) is used to measure the future observation value x t+k In the given context c t The relative probability under the condition is proportional to the ratio of the probability of future real data to random sampling data. Since it is difficult to directly calculate the density ratio, a parameterized function is introduced. To approximate the density ratio, through the linear matrix W1,W2,…,W k Multiply by c t As the predicted value (i.e. W k c t ),and is the true value, and the vector inner product is used to measure the similarity.

[0126] In order to optimize the model, that is, to maximize the mutual information, InfoNCE loss is used as the loss function of the model, which is defined as follows:

[0127]

[0128] where X = {x1, x2, …, x N} is a set of samples, (x t+k ,c t ) represents a positive sample pair, (x j ,c t ) represents a negative sample pair. Optimizing this loss function is to maximize x t+k and c t The mutual information between, as shown in the InfoNCE loss formula, f k (x t+k ,c t ) is indeed It is proportional to and has nothing to do with the number of negative samples selected N-1.

[0129] Therefore, optimizing this loss function is equivalent to maximizing the mutual information between the context information representation and the target variable, thereby improving the feature extraction and representation capabilities of the model.

[0130] 4: Model training and validation

[0131] First, the Geolife dataset is segmented. 70% of the trajectory data is randomly extracted from the cleaned dataset for model training, 20% for model verification, and 10% for model testing. In the model training stage, a neural network model based on the CPC described above is constructed, and the dynamic Adam optimizer and InfoNCE loss function are used to optimize the model, and the loss is calculated by comparing the predicted features with the actual features. In the model evaluation stage, the present invention uses the test set to evaluate the performance of the trained model.

[0132] In order to measure the performance of the model, accuracy and loss are used to evaluate the quality of model training. Throughout the experiment, multiple hyperparameters are adjusted to optimize model performance, including trajectory window size, batch size, time step, and number of training rounds. These hyperparameters were experimented with many times and the best parameter combination was found. The results of one training are selected to draw the Loss / Accuracy graph, as shown in Figure 2 As shown in the figure below, the ordinate of the left figure represents the accuracy, the abscissa represents the rounds of training, the meaning of Training and Validation Accuracy is the accuracy of the model on the training set and the validation set, the meaning of trainaccuracy is the accuracy on the training set, and the meaning of validation accuracy is the accuracy on the validation set. The ordinate of the right figure represents the size of the loss value, the abscissa represents the rounds of training, the meaning of Training and Validation Loss is the size of the loss value of the model on the training set and the validation set, the meaning of train loss is the size of the loss value on the training set, and the meaning of validation loss is the size of the loss value on the validation set. It can be observed that the performance on the training set is very good, with the accuracy stable at around 0.99 and the loss value stable at around 0.04. The performance on the validation set is also satisfactory, with the accuracy stable at around 0.97 and the loss value stable at around 0.2. This performance of the model shows that it has high accuracy and stability on both training data and validation data.

[0133] 5: Use CPC encoder to extract features to evaluate trajectory similarity

[0134] In order to overcome the limitations of traditional methods in processing high-dimensional data, the present invention first uses contrastive predictive coding (CPC) to extract high-dimensional features, and then uses Manhattan distance to measure trajectory similarity. Manhattan distance measures the similarity between two points by calculating the sum of the absolute differences in each dimension. Compared with other distance measurement methods, Manhattan distance has the advantages of simple and effective calculation when processing high-dimensional data and feature vectors. Its formula is:

[0135]

[0136] Among them, x and y are two eigenvectors, x i and i Respectively represent the eigenvalues ​​of the i-th dimension. Compared with the Euclidean distance, the Manhattan distance is simpler to calculate in high-dimensional space and is not easily affected by outliers, because it does not involve square operations and avoids the problem of extreme values ​​in distance metrics. It is particularly suitable for real-time analysis of large-scale data and has high robustness to outliers and noise. The size of the Manhattan distance directly reflects the degree of difference between the two trajectories in the feature space. The smaller the distance, the more similar the two trajectories are. By calculating the Manhattan distance, the overall difference between the feature vectors can be effectively captured, and the similarity of the trajectory data can be reflected in the feature space. This method provides an efficient and stable measurement method when processing high-dimensional data, which helps to improve the accuracy of trajectory similarity measurement.

[0137] The present invention innovatively applies the contrastive predictive coding (CPC) method to the field of trajectory similarity measurement, and evaluates the similarity by extracting trajectory features using the CPC encoder and calculating the Manhattan distance. Specifically, a specified number of trajectories are first randomly selected from the trajectory dataset to evaluate the similarity of the trajectories. For comparison, each trajectory is divided into two subsets: one containing trajectory points at odd positions (subset_A) and the other containing trajectory points at even positions (subset_B). The original trajectory, odd trajectory points, and even trajectory points of each trajectory dataset will be used as input for subsequent CPC encoding and similarity calculation. After data preprocessing, the pre-trained CPC model is loaded and set to evaluation mode to ensure that the model does not update weights during inference. The trajectory data is converted into feature vectors through the pre-trained model encoder, and these feature vectors are merged into a large feature matrix. Then, the Manhattan distance between the feature vectors is calculated. As mentioned above, the Manhattan distance measures the sum of the absolute differences between feature vectors, and this distance measurement method can quantify the similarity of trajectories. In order to better analyze the similarity of trajectories, after obtaining the Manhattan distance matrix, it is converted into a ranking matrix. Each element in the ranking matrix represents the relative ranking position of the corresponding distance value in the distance matrix. This transformation enables the relative distance relationship of feature pairs to be displayed in an ordered form, which is convenient for comparison and analysis.

[0138] After obtaining the ranking matrix, the trajectory similarity is evaluated through the following steps to verify the effect of CPC feature extraction. First, the evaluation data set is constructed. As mentioned above, the trajectory data is divided into three categories: original trajectory, odd-point trajectory, and even-point trajectory. The similarity of these data is compared to evaluate the model's ability to measure similarity between different trajectories. Then the ideal ranking is set. Ideally, the distance ranking between the odd-point trajectory and the original trajectory should be 1, and the distance ranking between the odd-point trajectory and the even-point trajectory should be 2. This reflects the expected trajectory similarity: that is, the odd-point trajectory should have the highest similarity with the original trajectory and the second highest similarity with the even-point trajectory. Next, check whether the actual ranking in the ranking matrix meets these ideal situations. If the actual ranking of the odd-point trajectory and the original trajectory is 1, and the actual ranking of the odd-point trajectory and the even-point trajectory is 2, these situations are considered to meet the ideal standards. At this time, 1 is added to the ranking set to indicate that the evaluation effect is good. For situations that do not meet these conditions, the actual ranking values ​​of the odd-point trajectory and the even-point trajectory are added to the ranking set. Finally, by averaging all the values ​​in the ranking set, a comprehensive evaluation index is obtained to evaluate the performance of CPC feature extraction in trajectory similarity measurement. Ideally, the average ranking value should be close to 1, indicating that the feature extraction method can effectively capture the similarity between trajectories. If the average ranking value deviates from 1, it indicates that the model may need further optimization. The overall trajectory similarity measurement process is as follows Figure 3 shown.

[0139] 3000 trajectory data were used in the experiment, including the original trajectory, the trajectory points at odd positions and even positions. Features were extracted by the pre-trained CPC encoder, and their Manhattan distance and ranking matrix were calculated. Ideally, the distance ranking of the odd point to itself is 1, the distance ranking to the original trajectory should be 2, and the distance ranking to the even point is 3. If the distance ranking of the odd point to the original trajectory is 1 and the ranking to the even point is 2, 1 is added to the ranking set. If these conditions are not met, the actual distance ranking value is added to the ranking set. The final calculated average ranking value is about 1.27. The experimental results show that the CPC encoder can capture the characteristics of the trajectory well. The method has high accuracy in trajectory feature extraction and similarity measurement, proving its feasibility in trajectory similarity measurement.

Claims

1. A trajectory similarity measurement method based on contrastive predictive coding, characterized in that: The method steps are as follows: 1) Clean, flip and transpose the trajectory data to obtain GPS trajectory data that meets the input requirements of the CPC neural network model; 2) Using the CPC neural network model, combined with the model's shared encoder and enhanced autoregressive module, the GPS trajectory data is trained to extract the high-dimensional feature vector of each trajectory; 2-1) Feature extraction based on shared encoder The shared encoder is used to process GPS trajectory data to extract its potential spatiotemporal features and generate a high-dimensional feature representation z t =g enc (x t ); 2-2) Temporal dependencies in trajectory data modeling based on dual GRU After using the shared encoder to extract the latent spatiotemporal features of the trajectory and generate high-dimensional feature representations, these high-dimensional features will be input into two independent gated recurrent unit GRU modules, which are configured to process the sequence forward and backward respectively. The generated context of the current moment is represented as c t =g ar (z ≤t ), to model the temporal dependencies in GPS trajectory data; 2-3) Prediction and model optimization After getting the context representation c t Then, the feature representation z of the next k moments is predicted t+k , which is done by in the linear layer W k Let context be c t This is achieved by mapping back to the original 512-dimensional feature space through a series of linear transformations; Use InfoNCE loss as the loss function of the model to optimize the model, that is, maximize the mutual information between the context information representation and the target variable; 3) After the model training is completed, the trained encoder module is used to extract high-dimensional features for each trajectory. After the high-dimensional features are extracted, the distance matrix is ​​generated by calculating the Manhattan distance between the high-dimensional feature vectors; then, each distance value in the distance matrix is ​​sorted in ascending order and converted into a ranking matrix. Each element in the ranking matrix represents the position of the corresponding distance in the sorting. The similarity of the trajectories is evaluated by ranking. The higher the ranking of the trajectory, the higher its similarity to the target trajectory.

2. The trajectory similarity measurement method based on contrastive predictive coding according to claim 1, characterized in that: The data cleaning is to first extract useful fields from the PLT file, remove useless fields, convert the fields into numerical data, and unify the time format; then, smooth the noise points and process the drift points of each trajectory data, and then remove the trajectory with less than a preset threshold, and finally, convert the processed data into HDF5 format; After the data cleaning, a trajectory data set is obtained, in which each trajectory meets the quality standard. The cleaned trajectory data set is T and is expressed as: In formula (1), T i represents each trajectory, |T i ∣ represents the trajectory T i The number of points, N min Indicates the minimum threshold of points; Each trajectory T i It is further represented as a sequence containing trajectory points: T i ={p ij |j=1,2,…,|T i ∣} (2) In formula (2), p ij Represents the trajectory T i The jth point in the trajectory point p ij Contains valid data fields such as latitude, longitude, altitude, and time, expressed as: p ij =( Latitude ij , Longitude ij , Altitude ij , Days ij ) (3) In formula (3), Latitude ij Represents the trajectory T i The latitude of the jth point in ij Represents the trajectory T i The longitude of the jth point in ij Represents the trajectory T i The altitude of the j-th point in the latitude, Days ij Represents the trajectory T i The number of days of the jth point in ; After integrating the above information, the trajectory data set T after data cleaning is expressed as:

3. The trajectory similarity measurement method based on contrastive predictive coding according to claim 2 is characterized in that: The smoothing of noise points refers to detecting noise points according to the spatiotemporal characteristics of trajectory points: first, by calculating the speed between adjacent trajectory points, and then detecting whether there are outliers: If the adjacent trajectory point p i and p i+1 If the speed v between exceeds the preset maximum speed threshold vmax, then the point is a noise point; For adjacent trajectory points p i and p i+1 , the speed v is calculated as follows: In formula (5), d(p i ,p i+1 ) represents the geographical distance between two points, t i and t i+1 They are the trajectory points p i and p i+1 timestamp; For the detected noise points, the weighted average method is used to smooth the noise. i =(lat i ,lon i ) is detected as a noise point, its coordinates are replaced by the weighted average of the k non-noise points before and after it. The formula is as follows: In formula (6) and (7), the weight w j Set based on time difference or distance to ensure that closer points have a greater impact on the smoothing result; Processing drift points refers to detecting drift points by calculating the distance between adjacent trajectory points: If the distance between adjacent points exceeds the preset threshold d max , then this point is a drift point, and the preset threshold d max Adjust according to the specific situation of the data set, and the detection formula is as follows: dist (x i ,x i+1 )>d max (8) In formula (8), dist(x i ,x i+1 ) is the point x i and x i+1 The distance between After the drift point is detected, its geographic coordinates are corrected using linear interpolation to calculate the new position. The new position calculation formula is as follows: In formula (9), represents the new position, x i represents the drift point, x i-1 and x i+1 Respectively represent the normal point before and after the drift point, the new position For the two normal points x before and after i-1 and x i+1 The midpoint of , thereby effectively reducing the drift error; The method of eliminating trajectories with less than a threshold number of trajectory points is as follows: first, the number of points of each trajectory is counted; then, a threshold N is set. threshold , mark the trajectories with less than the threshold value as the trajectories to be eliminated; finally, remove the trajectories to be eliminated, and retain the trajectories with no less than the threshold value, to ensure that the retained data has sufficient information.

4. The trajectory similarity measurement method based on contrastive predictive coding according to claim 1, characterized in that: The transposition means that the shape of the trajectory data set after data cleaning is (trajectory_window, num_features), which is transposed to (num_features, trajectory_window), where trajectory_window represents the number of trajectory points and num_features represents the number of features.

5. The trajectory similarity measurement method based on contrastive predictive coding according to claim 1, characterized in that: The shared encoder includes five one-dimensional convolutional layers, each of which is equipped with batch normalization and ReLU activation function. In order to ensure the stability and convergence of network training, the weights of the convolutional layer and the linear layer are initialized using the He initialization method. The He initialization method adjusts the weight distribution according to the number of input features of the network layer to enhance the learning ability of the network and prevent the gradient from disappearing. The specific configurations of the five one-dimensional convolutional layers are as follows: the convolution kernel size of the first convolutional layer is 10, the step size is 5, the padding is 3, and the output is 512 feature channels; The convolution kernel size of the second convolutional layer is 8, the stride is 4, the padding is 2, and the output is 512 feature channels; The convolution kernel size of the third, fourth and fifth convolutional layers is 4, the stride is 2, and the padding is 1. Each layer maintains the output of 512 feature channels to extract deeper features.

6. The trajectory similarity measurement method based on contrastive predictive coding according to claim 1, characterized in that: The temporal dependency relationship in the trajectory data modeled based on the dual GRU specifically refers to that the input of each GRU module is the high-dimensional feature extracted by the shared encoder, whose dimension is 512, and after GRU processing, a 128-dimensional temporal feature representation is output. The forward GRU and the reverse GRU have the same structure, both including a hidden layer, a step size of 1, and no bidirectional setting is used. The forward GRU processes the forward part of the sequence, and the reverse GRU processes the reverse part of the sequence. The generated context representation of the current moment is c t =g ar (z ≤t ), the hidden state of each GRU module is initialized with the He initialization method after each iteration to ensure that the sequence processed in each batch remains consistent.

7. The trajectory similarity measurement method based on contrastive predictive coding according to claim 1, characterized in that: The prediction refers to obtaining the context representation c t Then, the feature representation z of the next k moments is predicted t+k , which is done by in the linear layer W k c t This is achieved by mapping back to the original 512-dimensional feature space through a series of linear transformations. Specifically, the outputs of the forward and reverse GRUs combine the contextual information in the time series to provide a more comprehensive temporal feature representation, which is a predictive feature representation generated by the linear transformation. Used to represent the real feature z t+k Make a match; Indirect measurement of future observations x through density ratio t+k and the context representation c t The mutual information between them, the density ratio formula is: In formula (10), f k (x t+k ,c t ) is the density ratio; p(x t+k ∣c t ) is given under the condition c t In the case of x t+k The conditional probability density function, which means that under the condition c t Next, x t+k The distribution of p(x t+k ) is in the absence of any condition c t In the case of x t+k The marginal probability density function of x t+k Distribution of the overall data; density ratio f k (x t+k ,c t ) is used to measure the future observation value x t+k In the given context c t The relative probability under the condition is proportional to the ratio of the probability of future real data to random sampling data. Since it is difficult to directly calculate the density ratio, a parameterized function is introduced. With the approximate density ratio, through the linear matrix W1,W2,…,W k Multiply by the context representation c t As the predicted value W k c t ,and is the true value, and the vector inner product is used to measure the similarity; The InfoNCE loss is used as the loss function of the model and is defined as follows: In formula (11), X={x1,x2,…,x N } is a set of samples; (x t+k ,c t ) represents a positive sample pair; (x j ,c t ) represents a negative sample pair.

8. The trajectory similarity measurement method based on contrastive predictive coding according to claim 1, characterized in that: The formula for calculating the Manhattan distance between the high-dimensional feature vectors is: In formula (12), v and y are two high-dimensional feature vectors, v i and i Respectively represent the eigenvalues ​​of the i-th dimension; Converting the distance matrix into a ranking matrix means sorting each row or column in the distance matrix in ascending order, recording the relative position of each distance value after sorting, and using the indexes of these relative positions as elements in the ranking matrix, thereby generating a ranking matrix representing the relative ranking position of each distance value.

9. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, they are used to implement the steps of the method as described in any one of claims 1 to 8.

10. A computer program product comprising computer instructions, characterized in that: When the computer instruction is executed by a processor, it is used to implement the steps of the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Social network user trajectory analysis method based on self-supervised learning

    CN113378074A

  • Massive high-dimensional AIS trajectory data clustering method

    CN113780395A

  • Track generation method and device, equipment and storage medium

    CN116822635A

  • Autoregression Image Abnormity Detection Method of Enhancing Latent Space Based on Memory

    US20230154177A1

Cited By

  • Track traffic mode classification method and device, electronic equipment and storage medium

    CN119740101A