A self-supervised trajectory classification method and system based on multi-level feature extraction
By adopting multi-level feature extraction and self-supervised learning methods in trajectory classification, combined with graph neural network and time series analysis, the problem of insufficient classification accuracy and adaptability in traditional methods is solved, and more efficient and accurate trajectory classification is achieved.
Patent Information
- Application Number
- CN202411895845.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2044-12-23
AI Technical Summary
The traditional trajectory classification method has shortcomings in accuracy and efficiency, mainly due to the ignorance of dynamic changes and complex relationships, resulting in poor classification accuracy and adaptability.
A self-supervised trajectory classification method based on multi-level feature extraction is adopted, and a graph attention network and graph convolution network are constructed through road network matching and data enhancement technology, and a long-term memory network and self-attention mechanism are combined to pre-train the trajectory classification model.
It improves the accuracy and adaptability of trajectory classification, enhances the model's ability to capture complex road networks and time dependence, reduces the dependence on a large amount of labeled data, and improves the learning efficiency of the model.
Smart Images

Figure CN119357751B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of trajectory classification, and in particular to a self-supervised trajectory classification method and system based on multi-level feature extraction. Background Art
[0002] In recent years, the vigorous development of mobile Internet and smart devices has made it extremely convenient to obtain user trajectory data with the help of GPS, WiFi and sensor technology, providing massive data for trajectory classification systems. This trend not only meets the needs of user behavior analysis and personalized services, but also strongly promotes the application and innovation of related technologies in multiple fields. Trajectory data provides important solutions for smart cities, traffic planning, and reasonable travel arrangements. The analysis and utilization of trajectory data has been the focus of commercial discussions in recent years. For example, for smartphones with positioning functions, trajectory data reflects the behavior of mobile phone holders in a certain period of time. The mobile Internet network can locate the location of the mobile phone through wireless signals, and then sample and record it. By connecting the sampling points, the movement trajectory data of the mobile phone holder is formed. For example, using GPS positioning terminals, the latitude and longitude information of the terminal location is recorded at a fixed sampling frequency, and the data is collected to the server through wireless networks to form the movement trajectory of the object. In terms of trajectory classification, user trajectory data carries important information about their daily activities, travel habits and preferences. These data provide opportunities for mining user interests and behavior patterns, thereby achieving efficient and intelligent trajectory classification. However, there are many problems with traditional trajectory classification methods. They mostly rely on historical trajectory data and rules, clustering or statistical model technology, focusing mainly on static trajectory features, ignoring dynamic changes and complex associations, resulting in poor classification accuracy and adaptability. For example, when modeling user travel behavior, it is not accurate enough, and the classification results have large errors; when processing dynamic trajectory data, the model updates slowly and it is difficult to keep up with changes in user behavior; there is insufficient mining of trajectory features, such as time, location type, and traffic conditions, and the same problem of insufficient mining of user attributes, such as geographic location and travel purpose, fails to fully utilize this information to improve classification efficiency.
[0003] In view of the increasing demand for user behavior analysis and the increasing requirements for intelligence, trajectory classification technology has attracted much attention. Researchers are actively exploring new classification methods, which has brought new opportunities for the development of this technology, but also faces many challenges such as data integration, dynamic model construction and deep data mining. Summary of the invention
[0004] In order to solve the above-mentioned shortcomings of the trajectory classification method in terms of accuracy and efficiency, the present invention provides a self-supervised trajectory classification method and system based on multi-level feature extraction.
[0005] In a first aspect, the present invention provides a self-supervised trajectory classification method based on multi-level feature extraction, which adopts the following technical solution:
[0006] A self-supervised trajectory classification method based on multi-level feature extraction, comprising:
[0007] Access road networks and GPS-based trajectories;
[0008] Match the road network and GPS-based trajectories, generate trajectories constrained by the road network, and enhance the trajectories constrained by the road network;
[0009] Construct a trajectory classification model, embed the graph attention network and the graph convolutional network into the trajectory classification model, obtain the position sequence embedding through the trajectory enhanced view, embed the long short-term memory network into the trajectory classification model, and obtain the time series embedding through the time series of the view;
[0010] The trajectory classification model is pre-trained using position sequence embedding and time series embedding, and the pre-trained model is optimized and trajectory classification is performed.
[0011] Further, the obtaining of the road network and the GPS-based trajectory includes:
[0012] Get the characteristics of the road and represent the road network as a directed graph ,in, A set of nodes representing roads, Represents the total number of nodes, Indicates a road, Indicates the characteristics of the road. is a directed graph of road network The binary value adjacency matrix indicates whether there is a directed link between the roads, and E is the set of edges, indicating the connection relationship between the roads;
[0013] Use GPS equipment to obtain space-time sampling points, thereby obtaining GPS-based trajectories. The space-time sampling points are:
[0014] ,
[0015] in Indicates longitude, Represents the dimension, Indicates the access timestamp.
[0016] Furthermore, the road characteristics include road type characteristics, road length characteristics, lane number characteristics, maximum driving speed characteristics, road network degree characteristics and road network out-degree characteristics.
[0017] Furthermore, the trajectory matching between the road network and the GPS-based trajectory includes utilizing a map matching algorithm based on a hidden Markov model, and the trajectory constrained by the road network is represented as:
[0018] ,
[0019] in, represents the time-ordered sequence of m adjacent roads generated by the user, Indicates a road, yes The access timestamp.
[0020] Furthermore, the performing trajectory enhancement on the trajectory constrained by the road network includes:
[0021] Setting a fixed time window and retaining the internal road data of the time window;
[0022] Generating subsequences of different lengths by randomly removing a portion of the tracks of the internal road data, thereby obtaining a first position data view;
[0023] A time stamp sequence is generated by performing a time and position shift on the internal road data, thereby obtaining a second position data view.
[0024] Furthermore, embedding the graph attention network and the graph convolutional network into the trajectory classification model includes:
[0025] Using graph attention network as embedding model, the road representation is initialized according to the functional characteristics of the road and the attention weights between roads are calculated;
[0026] The road output features are obtained by combining neighborhood features with attention weights and averaged over the final layer of the graph attention network;
[0027] Use K-means algorithm to cluster the nodes of the road and construct subgraphs;
[0028] The subgraphs are embedded using a graph convolutional network, and the subgraph embeddings are aggregated and normalized.
[0029] Further, the initializing the road representation according to the functional characteristics of the road and calculating the attention weights between the roads includes:
[0030] The graph attention network has a total of Layer, taking the characteristics of the road as the input of the first layer;
[0031] The initial road representation of the road is created by connecting the features of the road and calculating the attention weights between the roads, which can be expressed as:
[0032] ,
[0033] in, For the road and The attention weights between is the activation function, It's the road Neighborhood of Indicates the road and The intersection between Indicates the road and The intersection between ,in, Indicates splicing, yes and The road indicates that is the learned parameter matrix, is the initialization road representation of the road, represents a vector space, is the dimension of the vector.
[0034] Furthermore, the road output characteristics are:
[0035] ,
[0036] in, represents the product, is the attention score calculated by the kth attention head, It's the road Neighborhood of It is a layer The weight matrix of the corresponding linear transformation in is, is a non-linear activation function.
[0037] Furthermore, the final layer of the graph attention network is averaged as:
[0038] ,
[0039] in, is a nonlinear activation function, It is a layer The weight matrix of the corresponding linear transformation in .
[0040] Furthermore, the method of clustering the nodes of the road and constructing a subgraph by using the K-means algorithm includes:
[0041] Select k initial centroids ;
[0042] Calculate the distance between the road node and the centroid, assign the road node to the nearest centroid, and update the centroid to the mean of all road nodes in the current cluster, which can be expressed as: ,in, is the set of nodes in cluster k, is the number of nodes in cluster k, Representation Node Features;
[0043] Repeat the assignment and update until the centroid reaches the maximum number of iterations, and build multiple subgraphs according to cluster k.
[0044] Furthermore, embedding the subgraphs using a graph convolutional network, aggregating the subgraph embeddings and normalizing them includes:
[0045] The subgraph is embedded using a graph convolutional network, which can be expressed as:
[0046] ,
[0047] in, Indicates The node feature matrix of the layer, each row of the node feature matrix represents the feature of a node, in the initial layer In the example, the road features are input data , , is the adjacency matrix of the graph, is the identity matrix, is the normalized form of the adjacency matrix of the graph, It corresponds to The degree matrix of is a learnable weight matrix, Indicates The node feature matrix of the layer, Relu is a nonlinear activation function;
[0048] The embeddings of all subgraphs are aggregated together by road number and normalized.
[0049] Furthermore, embedding the long short-term memory network into the trajectory classification model to obtain a time series embedding through the time series of the view includes:
[0050] Get the time points in the time series of the trajectory constrained by the road network;
[0051] Performing time embedding on the time series;
[0052] Input the time points in the time series into the LSTM network and establish time dependencies;
[0053] The self-attention mechanism is used to calculate the attention scores between time points on the same trajectory.
[0054] Furthermore, the time series is time-embedded, which is expressed by the formula:
[0055] ,
[0056] in, is a time point in the time series, Indicates the time series The result after time embedding of time points is: and is a learnable parameter, is the index of a time point in the time series;
[0057] The time points in the time series are input into the long short-term memory network and the time dependency is established, which is expressed by the formula:
[0058] ,
[0059] in, They represent input gate, forget gate, output gate and storage unit respectively. LSTM is long short-term memory network. Indicates the first The vector representation of each time point after time embedding is: Indicated in The output of the LSTM unit at time steps is Indicates that the LSTM unit is The hidden state at time step.
[0060] The self-attention mechanism is used to calculate the attention score between time points on the same trajectory, which is expressed as:
[0061] ,
[0062] in, represents the improved state representation, which is the attention function,
[0063] ,
[0064] ,
[0065] in, is the parameter vector to be learned, is the matrix to be learned, and Respectively represent the trajectory and The hidden state at each time point is represented by Indicates The time point and The attention weight between time points.
[0066] Furthermore, the pre-training of the trajectory classification model by using position sequence embedding and time series embedding includes:
[0067] Get aggregated spatial embeddings, temporal embeddings, and position encodings of roads in the trajectory;
[0068] Construct contrastive learning training tasks and train the model using InfoNCE loss;
[0069] Construct a span mask training task and use span masks for training;
[0070] The trajectory classification model is pre-trained using the contrastive learning training task and the span mask training task.
[0071] Furthermore, the aggregated spatial embedding, aggregated temporal embedding and position encoding are expressed as follows:
[0072] ,
[0073] in, Representation trajectory Positional encoding, represents the aggregation spatial embedding, Represents time embedding.
[0074] Further, the constructing of the contrastive learning training task, by using the InfoNCE loss to perform model training, includes: constituting a positive pair with two different views of the same track, constituting a negative pair with any view pair of different tracks, calculating the contrastive training loss of the positive pair, and calculating the average loss of the first position data view and the second position data view of all tracks;
[0075] The calculation is for the contrastive training loss, which is expressed as:
[0076] ,
[0077] in, is the contrastive training loss, , indicating the trajectory and trajectory is the similarity between the feature representations of , τ is the temperature hyperparameter, and N is the batch size of samples used in one training.
[0078] Furthermore, the constructing of the span mask training task and the use of the span mask for training include:
[0079] Select multiple trajectories with lengths of The continuous subsequence is masked, including replacing each road in the subsequence with a label [MASK] , and set the time series embedding of the masked roads to the label [MASK];
[0080] The trajectory constrained by the masked road network Expressed as , predict the predicted value of the masked road:
[0081] ,
[0082] in, represents a linear layer with parameters, represents a bias vector whose dimension is the same as the number of nodes in the road network same, Representation trajectory The number of Represents parameters related to feature dimensions;
[0083] Compute and optimize the loss between the trajectory constrained by the masked road network and the predicted value of the masked road .
[0084] Furthermore, the pre-training using contrastive learning training tasks and span mask training tasks includes constructing a pre-training loss function , where λ is a hyperparameter to balance the two tasks, To compare the training loss, the pre-training loss function is optimized to complete the pre-training of the trajectory classification model.
[0085] Furthermore, the optimizing the pre-trained model and performing trajectory classification includes:
[0086] The softmax function is used to activate the predicted value of the trajectory belonging to each category. The softmax function is:
[0087] ,
[0088] in, is the input of the fully connected layer, is the number of categories,
[0089] The model is optimized using the cross entropy loss function, which is:
[0090] ,
[0091] in, is the ground truth class label, is the total number of trajectories in the test dataset, is the number of categories.
[0092] In the second aspect, a self-supervised trajectory classification system based on multi-level feature extraction includes:
[0093] A data acquisition module configured to acquire a road network and a GPS-based trajectory;
[0094] A road network constrained trajectory module is configured to perform trajectory matching between the road network and the GPS-based trajectory to generate a road network constrained trajectory;
[0095] A trajectory enhancement module is configured to perform trajectory enhancement on a trajectory constrained by a road network;
[0096] The multi-level road network constrained trajectory embedding module is configured to build a trajectory classification model, embed the graph attention network and the graph convolutional network into the trajectory classification model, and obtain the position sequence embedding through the trajectory enhanced view;
[0097] A time series embedding module is configured to embed a long short-term memory network into a trajectory classification model to obtain a time series embedding through a time series of the view;
[0098] A model pre-training module, configured to pre-train a trajectory classification model using position sequence embedding and time series embedding;
[0099] The trajectory classification module is configured to optimize the pre-trained model and perform trajectory classification.
[0100] In a third aspect, the present invention provides a computer-readable storage medium storing a plurality of instructions, wherein the instructions are suitable for being loaded and executed by a processor of a terminal device for a self-supervised trajectory classification method based on multi-level feature extraction.
[0101] In a fourth aspect, the present invention provides a terminal device comprising a processor and a computer-readable storage medium, the processor being used to implement various instructions; the computer-readable storage medium being used to store multiple instructions, the instructions being suitable for being loaded by the processor and executing the self-supervised trajectory classification method based on multi-level feature extraction.
[0102] In summary, the present invention has the following beneficial technical effects:
[0103] 1. The present invention proposes a self-supervised trajectory classification method and system based on multi-level feature extraction. The trajectory accuracy is improved. The road network matching technology is used to map the GPS trajectory to the actual road network to form a trajectory constrained by the road network. This operation greatly improves the accuracy of the GPS trajectory and effectively reduces the interference of trajectory noise on the analysis results. Data enhancement technology can simulate diverse user behaviors, so that the model has better adaptability and generalization ability under different time periods and traffic conditions. The graph attention network effectively aggregates neighborhood information, enhances the ability to express road section features, and enables the model to capture complex road network relationships. At the same time, the combination of LSTM and self-attention mechanism enables the important information in the time series to be fully utilized, and enhances the model's ability to capture time dependence. Finally, contrastive learning and masking technology are used for pre-training to make full use of unlabeled data, reduce dependence on a large amount of labeled data, and improve the learning efficiency of the model.
[0104] 2. The present invention proposes a self-supervised trajectory classification method and system based on multi-level feature extraction, with enhanced model adaptability. The data enhancement technology simulates diverse user behaviors by setting a fixed time window, randomly removing trajectories that are too long or too short, and performing operations such as trajectories translation and timestamp offset. This enables the model to learn a wider range of feature representations under different time periods and traffic conditions, thereby significantly improving the adaptability and generalization ability of the model. For example, when analyzing trajectory patterns under different time conditions such as different seasons, weekdays and weekends, the model can better adapt and accurately classify.
[0105] 3. The self-supervised trajectory classification method and system based on multi-level feature extraction proposed in the present invention combines multiple advanced technologies such as graph neural network, time series analysis and self-supervised learning, and can comprehensively analyze road network and trajectory data. It can be widely used in the fields of intelligent transportation, itinerary prediction, path planning, etc., and has high practical application value. Through data enhancement and self-supervised learning, the model's utilization efficiency of existing data is improved and the data annotation cost is reduced. The technical solution is easy to expand, and the feature input and model structure can be adjusted according to different needs to adapt to various application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0106] Figure 1 is a flow chart of the method of embodiment 1 of the present invention;
[0107] Figure 2 is a road network constraint trajectory definition framework diagram of Example 1 of the present invention;
[0108] Figure 3 is a road network constraint trajectory enhancement framework diagram of Example 1 of the present invention;
[0109] Figure 4 This is a framework diagram of a multi-level road network constraint trajectory embedding module according to Embodiment 1 of the present invention;
[0110] Figure 5 This is a time series embedding model framework diagram of Example 1 of the present invention;
[0111] Figure 6 is a flowchart of a multi-level feature extraction self-supervised trajectory recommendation method and system according to Embodiment 1 of the present invention;
[0112] Figure 7 It is the overall framework diagram of Example 2 of the present invention. DETAILED DESCRIPTION
[0113] The present invention is further described in detail below in conjunction with the accompanying drawings.
[0114] Example 1
[0115] Reference Figure 1 , a self-supervised trajectory classification method based on multi-level feature extraction in this embodiment includes:
[0116] S1. Obtain road network and GPS-based trajectory,
[0117] In this embodiment, the GPS trajectory is trajectory data pre-stored in a designated storage medium, or trajectory data collected in real time, which is reasonable. In practical applications, the target trajectory data can be a sequence of GPS location points formed by GPS location points periodically reported by the user's terminal device; in this case, the GPS location point is the trajectory point. The terminal device can be a mobile phone, a wearable electronic device, a vehicle-mounted terminal of the vehicle being driven or taken, and so on. It should be noted that the disclosed embodiment does not limit the method for obtaining the trajectory data of the target GPS. This embodiment describes the trajectory of 442 taxis throughout the year through an accurate data set provided by Alibaba Cloud. These taxis are operated by the taxi dispatch center using mobile data terminals installed in the vehicle.
[0118] S11. Obtain road features and represent the road network as a directed graph ,in, A set of nodes representing roads, Represents the total number of nodes, Indicates a road, Indicates the characteristics of the road. is a directed graph of road network The binary value adjacency matrix indicates whether there is a directed link between the roads, and E is the set of edges, indicating the connection relationship between the roads;
[0119] S12. Use the GPS device to obtain space-time sampling points, thereby obtaining a GPS-based trajectory, the space-time sampling points are:
[0120] ,
[0121] in Indicates longitude, Represents the dimension, Indicates the access timestamp.
[0122] The road characteristics include road type characteristics, road length characteristics, lane number characteristics, maximum driving speed characteristics, road network degree characteristics and road network out-degree characteristics.
[0123] Reference Figure 2 ,
[0124] S2. performing trajectory matching between the road network and the GPS-based trajectory, generating a trajectory constrained by the road network, and performing trajectory enhancement on the trajectory constrained by the road network;
[0125] S21. The trajectory matching between the road network and the GPS-based trajectory includes using a map matching algorithm based on a hidden Markov model, wherein the trajectory constrained by the road network is represented as:
[0126] ,
[0127] in, represents the time-ordered sequence of m adjacent roads generated by the user, Indicates a road, yes The access timestamp.
[0128] S22. The step of enhancing the trajectory of the road network constraint comprises:
[0129] S221. Setting a fixed time window and retaining the internal road data of the time window can effectively simulate the user's behavior in different time periods;
[0130] Reference Figure 3 ,
[0131] S222. Generating subsequences of different lengths by randomly removing part of the tracks of the internal road data, thereby obtaining a first position data view;
[0132] This data augmentation strategy not only enriches the training samples, but also helps the model learn its performance in different time periods and traffic conditions, thereby improving the generalization ability of the model;
[0133] S223. Generate a timestamp sequence by translating the internal road data in time and position, thereby obtaining a second position data view.
[0134] A translation amount is set. After the position is translated, the new road segment sequence is obtained through modulo operation to ensure that it returns to the starting point when the sequence length is exceeded, thus realizing cyclic translation.
[0135] S3. construct a trajectory classification model, embed the graph attention network and the graph convolutional network into the trajectory classification model, obtain the position sequence embedding through the trajectory enhanced view, embed the long short-term memory network into the trajectory classification model, and obtain the time series embedding through the time series of the view;
[0136] Reference Figure 4 , GAT is the graph attention network, GCN is the graph convolutional network;
[0137] S31. The embedding of the graph attention network and the graph convolutional network into the trajectory classification model comprises:
[0138] S311. Using the graph attention network as an embedding model, initializing the road representation according to the functional characteristics of the road and calculating the attention weights between the roads, including:
[0139] S3111. The graph attention network has a total of Layer, taking the characteristics of the road as the input of the first layer;
[0140] S3112. Create an initial road representation of the road by connecting the features of the road, and calculate the attention weights between the roads, which is expressed by the formula:
[0141] ,
[0142] in, For the road and The attention weights between is the activation function, It's the road Neighborhood of Indicates the road and The intersection between Indicates the road and The intersection between ,in, Indicates splicing, yes and The road indicates that is the learned parameter matrix, is the initialization road representation of the road, represents a vector space, is the dimension of the vector.
[0143] S312 uses the attention weight to combine the neighborhood features to obtain the road output features. In this embodiment, the road output features are obtained by combining the features of its neighbors using multi-head attention weights, and the average value is taken for the final layer of the graph attention network;
[0144] S3121. The road output characteristics are:
[0145] ,
[0146] in, represents the product, is the attention score calculated by the kth attention head, It's the road Neighborhood of It is a layer The weight matrix of the corresponding linear transformation in is, is a non-linear activation function.
[0147] S3122. The average value of the final layer of the graph attention network is:
[0148] ,
[0149] in, is a nonlinear activation function, It is a layer The weight matrix of the corresponding linear transformation in .
[0150] S313 uses the K-means algorithm to cluster the nodes of the road and construct a subgraph, including:
[0151] S3131. Randomly select k initial centroids ;
[0152] S3132. Calculate the distance between the road node and the centroid, assign the road node to the nearest centroid, and update the centroid to the mean of all road nodes in the current cluster, expressed as: ,in, is the set of nodes in cluster k, is the number of nodes in cluster k, Representation Node Features;
[0153] S3133. Repeat the allocation and updating until the centroid reaches the maximum number of iterations, and construct multiple subgraphs based on cluster k.
[0154] S314. Embed the subgraph using a graph convolutional network, aggregate the subgraph embeddings and normalize them, including:
[0155] S3141. Use graph convolutional network to embed subgraphs, expressed as:
[0156] ,
[0157] in, Indicates The node feature matrix of the layer, each row of the node feature matrix represents the feature of a node, in the initial layer In the example, the road features are input data , , is the adjacency matrix of the graph, is the identity matrix, is the normalized form of the adjacency matrix of the graph, It corresponds to The degree matrix of is a learnable weight matrix, Indicates The node feature matrix of the layer, Relu is a nonlinear activation function;
[0158] S3142. Aggregate the embeddings of all subgraphs together by road number and normalize them.
[0159] S32. The embedding of the long short-term memory network into the trajectory classification model, and obtaining the time series embedding through the time series of the view, comprises:
[0160] S321. Obtaining time points in the time series of the trajectory constrained by the road network;
[0161] Reference Figure 5 , LSTM is a long short-term memory network;
[0162] S322. Time embedding is performed on the time series; the formula is expressed as:
[0163] ,
[0164] in, is a time point in the time series, Indicates the time series The result after time embedding of time points is: and is a learnable parameter, is the index of a time point in the time series;
[0165] S323. Input the time points in the time series into the long short-term memory network and establish time dependency; expressed as:
[0166] ,
[0167] in, They represent input gate, forget gate, output gate and storage unit respectively. LSTM is long short-term memory network. Indicates the first The vector representation of each time point after time embedding is: Indicated in The output of the LSTM unit at time steps is Indicates that the LSTM unit is The hidden state at time step.
[0168] The LSTM unit uses the time embedding, hidden state, and cell state from the previous step to calculate the new hidden state and update the cell state. Finally, this embodiment converts the last hidden state As a representation of a time series, since it contains information about all time points of the trajectory.
[0169] S324. Different time points on the trajectory should have different weights in the calculation. This embodiment uses the attention mechanism to capture the correlation between trajectory points to improve the effectiveness of the model. The attention score between time points on the same trajectory is calculated using the self-attention mechanism, which is expressed as:
[0170] ,
[0171] in, represents the improved state representation, which is the attention function,
[0172] ,
[0173] ,
[0174] in, is the parameter vector to be learned, is the matrix to be learned, and Respectively represent the trajectory and The hidden state at each time point is represented by Indicates The time point and The attention weight between time points.
[0175] By incorporating the attention mechanism into time series embedding, this embodiment can discover more important time points, thereby improving model performance. It should be noted that this embodiment still uses the hidden representation of the last step to encode the entire time trajectory.
[0176] Reference Figure 6 ,
[0177] S4. Pre-train the trajectory classification model using position sequence embedding and time series embedding, including:
[0178] S41. Obtain aggregated spatial embedding, temporal embedding and position encoding of roads in the trajectory;
[0179] The aggregated spatial embedding, aggregated temporal embedding and position encoding are expressed as follows: ,in, Representation trajectory Positional encoding, represents the aggregation spatial embedding, Represents time embedding.
[0180] S42. Construct a contrastive learning training task and train the model using InfoNCE loss, including:
[0181] Two different views of the same track constitute a positive pair, and any view pair of different tracks constitutes a negative pair, calculate the contrastive training loss of the positive pair, and calculate the average loss of the first position data view and the second position data view of all tracks;
[0182] The calculation is for the contrastive training loss, which is expressed as:
[0183] ,
[0184] in, is the contrastive training loss, , indicating the trajectory and trajectory is the similarity between the feature representations of , τ is the temperature hyperparameter, and N is the batch size of samples used in one training.
[0185] S43. Construct a span mask training task and use the span mask for training, including:
[0186] S431. Select multiple trajectories with lengths of The continuous subsequence is masked, including replacing each road in the subsequence with a label [MASK] , and set the time series embedding of the masked roads to the label [MASK];
[0187] S432. Trajectory of the masked road network constraints Expressed as , predict the predicted value of the masked road:
[0188] ,
[0189] in, represents a linear layer with parameters, represents a bias vector whose dimension is the same as the number of nodes in the road network same, Representation trajectory The number of Represents parameters related to feature dimensions;
[0190] S433. Calculate and optimize the loss between the trajectory of the masked road network constraint and the predicted value of the masked road .
[0191] S44. Use contrastive learning training tasks and span mask training tasks to pre-train the trajectory classification model, perform average pooling, and finally obtain trajectory representation, including:
[0192] Constructing a pre-training loss function , where λ is a hyperparameter to balance the two tasks, To compare the training loss, the pre-training loss function is optimized to complete the pre-training of the trajectory classification model.
[0193] S5. Optimize the pre-trained model and perform trajectory classification, including:
[0194] S51. Activate the softmax function to obtain the predicted value of the trajectory belonging to each category, and the softmax function is:
[0195] ,
[0196] in, is the input of the fully connected layer, is the number of categories;
[0197] S52. Optimize the model using a cross entropy loss function, where the cross entropy loss function is:
[0198] ,
[0199] in, is the ground truth class label, is the total number of trajectories in the test dataset, is the number of categories.
[0200] Example 2
[0201] Reference Figure 7 ,
[0202] This embodiment provides a self-supervised trajectory classification system based on multi-level feature extraction, including:
[0203] A data acquisition module configured to acquire a road network and a GPS-based trajectory;
[0204] A road network constrained trajectory module is configured to perform trajectory matching between the road network and the GPS-based trajectory to generate a road network constrained trajectory;
[0205] A trajectory enhancement module is configured to perform trajectory enhancement on a trajectory constrained by a road network;
[0206] The multi-level road network constrained trajectory embedding module is configured to build a trajectory classification model, embed the graph attention network and the graph convolutional network into the trajectory classification model, and obtain the position sequence embedding through the trajectory enhanced view;
[0207] A time series embedding module is configured to embed a long short-term memory network into a trajectory classification model to obtain a time series embedding through a time series of the view;
[0208] A model pre-training module, configured to pre-train a trajectory classification model using position sequence embedding and time series embedding;
[0209] The trajectory classification module is configured to optimize the pre-trained model and perform trajectory classification.
[0210] A computer-readable storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded and executed by a processor of a terminal device, for a self-supervised trajectory classification method based on multi-level feature extraction.
[0211] A terminal device includes a processor and a computer-readable storage medium, wherein the processor is used to implement various instructions; and the computer-readable storage medium is used to store multiple instructions, wherein the instructions are suitable for being loaded by the processor and executing the self-supervised trajectory classification method based on multi-level feature extraction.
[0212] The above are all preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A self-supervised trajectory classification method based on multi-level feature extraction, characterized in that: include: Access road networks and GPS-based trajectories; Match the road network and GPS-based trajectories, generate trajectories constrained by the road network, and enhance the trajectories constrained by the road network; Construct a trajectory classification model, embed the graph attention network and the graph convolutional network into the trajectory classification model, obtain the position sequence embedding through the trajectory enhanced view, embed the long short-term memory network into the trajectory classification model, and obtain the time series embedding through the time series of the view; Pre-train the trajectory classification model using position sequence embedding and time series embedding; Optimize the pre-trained model and perform trajectory classification; The embedding of the graph attention network and the graph convolutional network into the trajectory classification model includes: Using graph attention network as embedding model, the road representation is initialized according to the functional characteristics of the road and the attention weights between roads are calculated; The road output features are obtained by combining neighborhood features with attention weights and averaged over the final layer of the graph attention network; Use K-means algorithm to cluster the nodes of the road and construct subgraphs; Use graph convolutional networks to embed subgraphs, aggregate subgraph embeddings and normalize them; The embedding of the long short-term memory network into the trajectory classification model and obtaining the time series embedding through the time series of the view include: Get the time points in the time series of the trajectory constrained by the road network; Performing time embedding on the time series; Input the time points in the time series into the LSTM network and establish time dependencies; The self-attention mechanism is used to calculate the attention scores between time points on the same trajectory.
2. The self-supervised trajectory classification method based on multi-level feature extraction according to claim 1 is characterized in that: The trajectory matching between the road network and the GPS-based trajectory includes using a map matching algorithm based on a hidden Markov model. The trajectory constrained by the road network is represented as ,in, represents the time-ordered sequence of m adjacent roads generated by the user, Indicates a road, yes The access timestamp.
3. The self-supervised trajectory classification method based on multi-level feature extraction according to claim 1 is characterized in that: The step of performing trajectory enhancement on the trajectory constrained by the road network includes: Setting a fixed time window and retaining the internal road data of the time window; Generating subsequences of different lengths by randomly removing a portion of the tracks of the internal road data, thereby obtaining a first position data view; A time stamp sequence is generated by performing a time and position shift on the internal road data, thereby obtaining a second position data view.
4. The self-supervised trajectory classification method based on multi-level feature extraction according to claim 1 is characterized in that: The method of pre-training the trajectory classification model by using position sequence embedding and time series embedding includes: Obtain aggregated spatial embeddings, temporal embeddings, and position encodings of roads in a trajectory; Construct a contrastive learning training task and train the model using InfoNCE loss; Construct span mask training tasks and use span masks for training; The trajectory classification model is pre-trained using the contrastive learning training task and the span mask training task.
5. The self-supervised trajectory classification method based on multi-level feature extraction according to claim 1 is characterized in that: The optimizing the pre-trained model and performing trajectory classification includes: The softmax function is used to activate the predicted value of the trajectory belonging to each category. The softmax function is: , in, is the input of the fully connected layer, is the number of categories, The model is optimized using the cross entropy loss function, which is: , in, is the ground truth class label, is the total number of trajectories in the test dataset, is the number of categories.
6. A self-supervised trajectory classification system based on multi-level feature extraction, executing the self-supervised trajectory classification method based on multi-level feature extraction as claimed in claim 1, characterized in that: include: A data acquisition module configured to acquire a road network and a GPS-based trajectory; A road network constrained trajectory module is configured to perform trajectory matching between the road network and the GPS-based trajectory to generate a road network constrained trajectory; A trajectory enhancement module is configured to perform trajectory enhancement on a trajectory constrained by a road network; The multi-level road network constrained trajectory embedding module is configured to build a trajectory classification model, embed the graph attention network and the graph convolutional network into the trajectory classification model, and obtain the position sequence embedding through the trajectory enhanced view; A time series embedding module is configured to embed a long short-term memory network into a trajectory classification model to obtain a time series embedding through a time series of the view; A model pre-training module, configured to pre-train a trajectory classification model using position sequence embedding and time series embedding; The trajectory classification module is configured to optimize the pre-trained model and perform trajectory classification.
7. A computer-readable storage medium storing a plurality of instructions, characterized in that: The instructions are suitable for being loaded by a processor of a terminal device and executing the self-supervised trajectory classification method based on multi-level feature extraction as described in claim 1.
8. A terminal device, comprising a processor and a computer-readable storage medium, wherein the processor is used to implement each instruction; and the computer-readable storage medium is used to store multiple instructions, characterized in that: The instructions are suitable for being loaded by a processor and executing the self-supervised trajectory classification method based on multi-level feature extraction as described in claim 1.
Citation Information
Patent Citations
Carbon footprint-user classification method based on hierarchical graph convolutional network
CN114266316A
Vehicle trajectory data complementing method based on space-time diagram embedding
CN118779595A