Trajectory representation learning method based on road network-grid cross-attention fusion

CN123012586APending Publication Date: 2026-10-30ANHUI NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611350175.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-02
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0007]本发明的目的在于克服现有技术的不足,提供一种基于路网-网格交叉注意力融合的轨迹表示学习方法,旨在解决现有轨迹表示方法中道路拓扑信息与空间区域语义融合不足、不同轨迹之间弱相关关系刻画不充分的问题,从而提高轨迹表示的质量和鲁棒性

Benefits of technology

[0061]本发明的优点在于:1、本发明通过将道路网络拓扑信息、空间网格区域信息和区域语义信息共同引入轨迹表示学习过程,使轨迹表示不仅能够表达道路路段之间的连接关系和通行语义,还能够表达轨迹经过区域的空间位置和区域功能,从而提高轨迹表示的信息完整性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123012586A_ABST
    Figure CN123012586A_ABST
Patent Text Reader

Abstract

The application discloses a trajectory representation learning method based on road network-grid cross attention fusion, comprising the following steps: S1, acquiring GPS trajectory data of a mobile object to be processed, and performing trajectory preprocessing; S2, respectively constructing road perspective representation and grid perspective representation; S3, performing road network-grid interaction fusion on the road perspective representation and the grid perspective representation to obtain spatial fusion representation of the trajectory; S4, constructing a road-grid soft label matrix and forming a road-grid soft label self-supervision constraint; S5, using the road perspective representation, the grid perspective representation, the spatial fusion representation and the road-grid soft label self-supervision constraint, and combining a trajectory pre-training task to train a trajectory representation model, and obtaining trajectory vector representation used for a downstream trajectory analysis task. The method uses a multi-perspective cross attention fusion technology, significantly improves the quality of representation learning, improves the robustness of trajectory representation, and is suitable for the field of intelligent transportation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of trajectory representation learning technology, specifically relating to a trajectory representation learning method based on deep learning fusion, particularly a joint modeling method using road network topology information, spatial grid region information, regional semantic information, and self-supervised constraints of road-grid soft labels. It can be applied to the representation learning of trajectory data of mobile objects such as vehicle GPS trajectories, taxi trajectories, and ride-hailing vehicle trajectories, and can be used for downstream trajectory analysis tasks such as trajectory similarity query, trajectory classification, and travel time estimation. Background Technology

[0002] With the widespread application of GPS devices, in-vehicle terminals, ride-hailing platforms, and urban traffic management systems, large-scale trajectory data is continuously collected. Trajectory data records the continuous changes of moving objects in time and space, reflecting vehicle travel paths, urban road usage patterns, and regional traffic patterns. To enable trajectory data to be effectively processed by deep learning models, it is usually necessary to encode variable-length, sparse, and noisy trajectory sequences into low-dimensional dense vector representations.

[0003] Existing trajectory representation learning methods can be broadly categorized into road network-based methods and free space-based methods. Road network-based methods typically first perform map matching on GPS trajectories, converting the trajectories into sequences of road segments, and then modeling them using road topology or segment attributes. These methods can effectively represent road connectivity and fine-grained segment information, but they tend to overlook the spatial semantic information of the areas traversed by the trajectory. Free space-based methods typically divide urban areas into spatial grids, mapping GPS points or road segments to grid sequences, and then learning trajectory representations through neural networks. These methods can represent the spatial distribution of trajectories, but lack road topology constraints, making it difficult to accurately reflect the true connectivity between road segments.

[0004] Furthermore, existing methods often employ simple addition, splicing, or fixed-weight fusion when fusing road and grid perspectives. This approach lacks explicit modeling of the correspondence between road segments and spatial grids, easily leading to insufficient fusion between road topological semantics and regional spatial semantics.

[0005] On the other hand, during the trajectory pre-training stage, common contrastive learning methods typically treat the same trajectory or enhanced trajectory as positive samples and all other trajectories within the batch as negative samples. However, in real-world traffic scenarios, different trajectories may share some road segments or spatial grids, and these trajectories should not be entirely considered negative samples. Simply using hard-label contrastive learning may weaken the model's ability to represent spatially related trajectories.

[0006] Therefore, a new trajectory representation learning method is needed that can simultaneously utilize road network topology, spatial grid regions, and regional semantic information, and achieve cross-view fusion through a road-grid cross-attention mechanism. At the same time, soft label self-supervised constraints are constructed through road segment overlap and spatial grid overlap, enabling the model to learn a more reasonable alignment relationship between the road view and the grid view. Summary of the Invention

[0007] The purpose of this invention is to overcome the shortcomings of existing technologies and provide a trajectory representation learning method based on road network-grid cross-attention fusion. This aims to address the problems of insufficient fusion of road topology information and spatial region semantics in existing trajectory representation methods, as well as inadequate characterization of weak correlations between different trajectories, thereby improving the quality and robustness of trajectory representation.

[0008] To achieve the above objectives, the technical solution adopted by the present invention is as follows:

[0009] The trajectory representation learning method based on road network-grid cross-attention fusion includes the following steps:

[0010] S1. Obtain the GPS trajectory data of the moving object to be processed, and perform trajectory preprocessing to obtain the road segment identification sequence, spatial grid identification sequence, regional semantic sequence and multi-granularity time feature sequence corresponding to each trajectory and aligned with the position;

[0011] S2. Based on the road segment identification sequence, spatial grid identification sequence and their corresponding road network information and spatial region information, construct road perspective representation and grid perspective representation respectively;

[0012] S3. Perform road network-grid interactive fusion on the road view representation and the grid view representation to obtain the spatial fusion representation of the trajectory;

[0013] S4. Based on the overlap relationship between the road segment identification sequence and the spatial grid identification sequence, construct a road-grid soft label matrix and form a road-grid soft label self-supervised constraint;

[0014] S5. Using the road perspective representation, grid perspective representation, spatial fusion representation, and road-grid soft label self-supervised constraints, and combined with the trajectory pre-training task to train the trajectory representation model, a trajectory vector representation for downstream trajectory analysis tasks is obtained.

[0015] The preprocessing method for GPS trajectory data in step S1 includes:

[0016] S11. Represent each GPS track as a sequence of track points in chronological order. ,in, Includes longitude, latitude, and timestamp;

[0017] S12. Based on the trajectory point sequence, obtain the road segment identification sequence, spatial grid identification sequence, regional semantic sequence, and multi-granularity time feature sequence respectively; wherein, the road segment identification sequence is obtained by map matching, the spatial grid identification sequence is obtained by spatial grid mapping, the regional semantic sequence is obtained by regional semantic association, and the multi-granularity time feature sequence is obtained by timestamp extraction.

[0018] S13. Align the road segment identification sequence, spatial grid identification sequence, regional semantic sequence, and multi-granularity time feature sequence according to the trajectory position.

[0019] The methods for constructing the road view and the grid view in step S2 include:

[0020] The road view representation is constructed from a road topology map and a sequence of road segment identifiers. The road topology map is constructed based on road segments and their connections. The road topology map is encoded from a graph neural network or graph attention network to obtain road node embeddings. The road node embeddings are indexed based on the sequence of road segment identifiers and combined with trajectory position representations to obtain the road view representation.

[0021] The grid perspective representation is constructed from a spatial grid identifier sequence and a regional semantic sequence. Specifically, a grid embedding sequence is obtained by querying a grid embedding table based on the spatial grid identifier sequence, and a regional semantic embedding sequence is obtained by querying a regional semantic embedding table based on the regional semantic sequence. The grid embedding sequence and the regional semantic embedding sequence are then fused to obtain the grid perspective representation.

[0022] The road network-mesh interaction fusion method in step S3 includes:

[0023] S31, Receive road view representation and grid perspective representation Wherein, the road perspective is used to express the road topology and road segment semantics corresponding to the trajectory, and the grid perspective is used to express the spatial region and region semantics corresponding to the trajectory;

[0024] S32. Based on the correspondence between road segments and spatial grids in trajectory positions, perform cross-view interactive modeling of the road view representation and the grid view representation;

[0025] S33. Using a cross-attention fusion approach, with the road view representation as the query input, regional contextual information related to road segments is extracted from the grid view representation to obtain a cross-view contextual representation. ;

[0026] S34. Represent the cross-perspective context. By fusing the road view representation and the grid view representation, a spatial fusion representation of the trajectory is obtained. .

[0027] Spatial fusion representation in step S34 for:

[0028]

[0029] in, Spatial fusion representation of trajectories, This indicates the road perspective. Representing the grid perspective, This represents a cross-perspective context representation. Represents the learnable fusion coefficient. This indicates a random deactivation operation. Presentation layer normalization operation.

[0030] In step S33, cross-perspective context representation The expression method is as follows:

[0031] ;

[0032] In the formula, This indicates cross-attention calculation. As input for the query As key input and value input.

[0033] The self-supervised constraint construction method for road-mesh soft labels in step S4 includes:

[0034] S41. Extract the set of valid road segments and effective spatial grid set ;

[0035] S42. Calculate the soft similarity between trajectories based on the overlap relationships of road sets and grid sets. ;

[0036] S43. Construct a road-grid soft label matrix Y based on the soft similarity;

[0037] S44. Use the road-mesh soft label matrix Y to constrain the self-supervised alignment training between the road view representation and the mesh view representation.

[0038] The method for constructing the road-mesh soft label matrix in step S43 includes:

[0039] Based on the soft similarity between any two trajectories within the training batch Construct a road-grid soft label matrix ,in, Indicates the first Road perspective representation of the trajectory and the first The soft label weights between the trajectories are represented from a grid perspective.

[0040] Assume the training batch contains For each trajectory, the road-grid soft label matrix... It can be represented as:

[0041]

[0042] In the formula, Represents the road-grid soft label matrix. Represents the number of trajectories in a training batch; matrix The The row corresponds to the first Road perspective representation of a trajectory, matrix The Column corresponding to the first A grid view representation of the trajectory, elements Indicates the first Road perspective representation of the trajectory and the first The soft label weights between the trajectories are represented from a grid perspective.

[0043] Before normalization, when hour, Set as strong positive sample weights to represent the correspondence between the road view representation and the grid view representation of the same trajectory; when hour, Based on soft similarity This is defined to represent the weak correlation between different trajectories based on road segment overlap and spatial grid overlap.

[0044] Let the road-grid soft label matrix before normalization be... ,in, Indicates the first before normalization Road perspective representation of the trajectory and the first The soft label weights between the trajectories are represented by a grid view. The expression is:

[0045]

[0046] In the formula, Indicates the first before normalization Road perspective representation of the trajectory and the first The soft label weights between the trajectories are represented from a grid perspective. Indicates the first Trajectory and the first Soft similarity between trajectories; Indicates the first Trajectory and the first The overlap of spatial grid sets between trajectories; The scaling factor representing the weight of off-diagonal soft labels; This represents the maximum limit value for the weight of off-diagonal soft labels; This indicates a preset similarity threshold;

[0047] Among them, when hour, These are set as strong positive sample weights to represent the correspondence between the road view representation and the grid view representation of the same trajectory; when When two trajectories have overlapping spatial grids and soft similarity... Not lower than the preset similarity threshold According to Determine the off-diagonal soft label weights, and through Limit its maximum value; if the two trajectories do not have spatial grid overlap, or soft similarity Below the preset similarity threshold If so, the corresponding off-diagonal soft label weight will be reset to zero.

[0048] Methods for calculating the soft similarity Sij used to determine the weights of off-diagonal soft labels include:

[0049] S61. Perform effective identifier filtering on the road segment identifier sequence corresponding to each trajectory in the training batch, removing filler identifiers, start identifiers, end identifiers, and mask identifiers, and retaining only the real road segment identifiers, to obtain the first... The set of valid road segments corresponding to each trajectory ;

[0050] S62. Perform effective identifier filtering on the spatial grid identifier sequence corresponding to each trajectory in the training batch, removing filled and invalid grid identifiers, and retaining only the valid spatial grid identifiers to obtain the first... Effective spatial grid set corresponding to each trajectory ;

[0051] S63. For any two trajectories within a training batch and According to the Set of valid road segments for each trajectory and the Set of valid road segments for each trajectory Calculate the set overlap of the two trajectories at the road segment level. Its expression is:

[0052]

[0053] In the formula, Indicates the first Trajectory and the first The degree of overlap of the set of trajectories at the road segment level. Indicates the first The set of valid road segments for each trajectory Indicates the first The set of valid road segments for each trajectory This indicates the number of road segments shared by the two trajectories. This represents the total number of different road segments contained in the two trajectories;

[0054] S64. For any two trajectories within a training batch and According to the Effective spatial grid set of trajectories and the Effective spatial grid set of trajectories Calculate the set overlap of the two trajectories at the spatial grid level. Its expression is:

[0055]

[0056] In the formula, Indicates the first Trajectory and the first The degree of overlap of the sets of trajectories at the spatial grid level. Indicates the first The effective spatial grid set of the trajectory Indicates the first The effective spatial grid set of the trajectory This indicates the number of spatial grids shared by two trajectories. This represents the total number of distinct spatial grids contained in the two trajectories;

[0057] S65, Set the overlap of the road segment layers. Overlap with spatial grid level The weighted fusion is performed according to preset weights to obtain the first... Trajectory and the first Soft similarity between trajectories Its expression is:

[0058]

[0059] In the formula, Indicates the first Trajectory and the first Soft similarity between trajectories This represents the preset weight corresponding to the overlap of road segment sets. This represents the preset weight corresponding to the overlap of the spatial grid set. This indicates the degree of overlap between two trajectories at the road segment level. This indicates the degree of overlap between two trajectories at the spatial grid level.

[0060] Among them, the soft similarity The soft similarity is used to characterize the comprehensive spatial correlation between two trajectories in a training batch at the road segment level and the spatial grid level. It is a continuous similarity value used to characterize the partial spatial correlation between different trajectories. Compared with the hard labeling method that only treats the same trajectory as a positive sample and all other trajectories as negative samples, the soft similarity calculation method can characterize different trajectories with partial spatial correlation in the training batch as weakly correlated samples based on the road segment overlap relationship and the spatial grid overlap relationship.

[0061] The advantages of this invention are as follows: 1. This invention introduces road network topology information, spatial grid area information and regional semantic information into the trajectory representation learning process, so that the trajectory representation can not only express the connection relationship and traffic semantics between road segments, but also express the spatial location and regional function of the area through which the trajectory passes, thereby improving the information integrity of the trajectory representation.

[0062] 2. This invention employs a road network-grid cross-attention fusion method, using the road perspective representation as the query input and the grid perspective representation as the key and value input. This allows the road perspective to extract regional context information related to the current road segment from the grid perspective. Compared to simple addition, splicing, or fixed-weight fusion methods, this method can model the correspondence between road segments and spatial grids at a finer granular level, improving the cross-perspective information fusion effect.

[0063] 3. This invention constructs soft similarity between trajectories based on the overlap of road segment sets and spatial grid sets, and further constructs a road-grid soft label matrix, enabling the training process to characterize the weak correlation between different trajectories within the same training batch. Compared to the hard labeling method that treats only the same trajectory as a positive sample and all other trajectories as negative samples, this method can reduce misjudgments of some spatially related trajectories.

[0064] 4. This invention utilizes a road-mesh soft label matrix for bidirectional self-supervised alignment training, ensuring that the road view representation and mesh view representation of the same trajectory remain consistent in the representation space. At the same time, it preserves the weak correlation information between different trajectories with overlapping road segments or spatial meshes, thereby improving the robustness and spatial consistency of trajectory representation.

[0065] 5. This invention performs joint pre-training of masked road segment prediction, trajectory triplet learning, and road-grid soft label self-supervised learning, enabling the model to simultaneously learn local road context information, trajectory-level similarity relationships, and cross-view consistency between road view and grid view, thereby enhancing the versatility of trajectory vector representation.

[0066] 6. The trajectory vector representation obtained by this invention can be used for downstream trajectory analysis tasks such as trajectory similarity query, trajectory classification, and travel time estimation, and can provide effective trajectory representation support in scenarios such as intelligent transportation, vehicle trajectory analysis, and travel pattern recognition. Attached Figure Description

[0067] The following is a brief explanation of the contents of each of the accompanying drawings and the markings in the drawings:

[0068] Figure 1 This is a flowchart of the trajectory representation learning method of the present invention;

[0069] Figure 2 This is a diagram of the overall model architecture corresponding to the method of the present invention;

[0070] Figure 3 This is the road network-grid intersection attention fusion map of the present invention;

[0071] Figure 4 This is the self-supervised constraint diagram for the road-grid soft label of the present invention. Detailed Implementation

[0072] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings and the description of the preferred embodiments.

[0073] This embodiment provides a trajectory representation learning method based on the fusion of graph neural networks and Transformers, applicable to representation learning of vehicle GPS trajectories and downstream task analysis. This method transforms the original GPS trajectory into a dense vector usable for downstream tasks, enabling analysis of multiple tasks. It employs multi-view cross-attention fusion technology, significantly improving the quality of representation learning and enhancing the robustness of trajectory representation, making it suitable for the field of intelligent transportation.

[0074] like Figure 1 As shown in the figure, a trajectory representation learning method based on road network-grid cross-attention fusion in this embodiment includes the following steps:

[0075] S1. Obtain GPS trajectory data of the moving object, and perform trajectory preprocessing on the GPS trajectory data to obtain a road segment identification sequence, a spatial grid identification sequence, a regional semantic sequence, and a multi-granularity time feature sequence that correspond to and are aligned with each trajectory.

[0076] S2. Based on the road segment identification sequence, spatial grid identification sequence and their corresponding road network information and spatial region information, construct road perspective representation and grid perspective representation respectively;

[0077] S3. Perform road network-grid interactive fusion on the road view representation and grid view representation to obtain a spatial fusion representation of the trajectory, wherein the road network-grid interactive fusion includes cross-attention fusion;

[0078] S4. Based on the overlap relationship between the road segment identification sequence and the spatial grid identification sequence, construct a road-grid soft label matrix and form a road-grid soft label self-supervised constraint;

[0079] S5. Using the road perspective representation, grid perspective representation, spatial fusion representation, and road-grid soft label self-supervised constraints, and combined with the trajectory pre-training task to train the trajectory representation model, a trajectory vector representation for downstream trajectory analysis tasks is obtained.

[0080] The trajectory preprocessing process in step S1 includes:

[0081] S11. Represent each GPS track as a sequence of track points in chronological order. ,in, Includes longitude, latitude, and timestamp;

[0082] S12. Based on the trajectory point sequence, obtain the road segment identification sequence, spatial grid identification sequence, regional semantic sequence, and multi-granularity time feature sequence respectively; wherein, the road segment identification sequence is obtained by map matching, the spatial grid identification sequence is obtained by spatial grid mapping, the regional semantic sequence is obtained by regional semantic association, and the multi-granularity time feature sequence is obtained by timestamp extraction.

[0083] S13. Align the road segment identification sequence, spatial grid identification sequence, regional semantic sequence, and multi-granularity time feature sequence according to the trajectory position.

[0084] The road view and mesh view construction conditions in step S2 include:

[0085] The road perspective representation is constructed from a road topology map and a sequence of road segment identifiers. The road topology map is constructed based on road segments and their connections. The road topology map is encoded from a graph neural network or graph attention network to obtain road node embeddings. The road node embeddings are indexed based on the sequence of road segment identifiers and combined with trajectory position representations to obtain the road perspective representation.

[0086] The grid perspective representation is constructed from a spatial grid identifier sequence and a regional semantic sequence. Specifically, a grid embedding sequence is obtained by querying a grid embedding table based on the spatial grid identifier sequence, and a regional semantic embedding sequence is obtained by querying a regional semantic embedding table based on the regional semantic sequence. The grid embedding sequence and the regional semantic embedding sequence are then fused to obtain the grid perspective representation.

[0087] The road network-grid interaction fusion process in step S3 includes:

[0088] S31, Receive road view representation and grid perspective representation Wherein, the road perspective is used to express the road topology and road segment semantics corresponding to the trajectory, and the grid perspective is used to express the spatial region and region semantics corresponding to the trajectory;

[0089] S32. Based on the correspondence between road segments and spatial grids in trajectory positions, perform cross-view interactive modeling of the road view representation and the grid view representation;

[0090] S33. Using a cross-attention fusion approach, with the road view representation as the query input, regional contextual information related to road segments is extracted from the grid view representation to obtain a cross-view contextual representation. ;

[0091] S34. Represent the cross-perspective context. By fusing the road view representation and the grid view representation, a spatial fusion representation of the trajectory is obtained. .

[0092] S34 Spatial Fusion Representation The expression is:

[0093]

[0094] in, Spatial fusion representation of trajectories, This indicates the road perspective. Representing the grid perspective, This represents a cross-perspective context representation. Represents the learnable fusion coefficient. This indicates a random deactivation operation. Presentation layer normalization operation;

[0095] In S33, cross-perspective context representation The expression is:

[0096]

[0097] In the formula, This indicates cross-attention calculation. As input for the query As key input and value input.

[0098] The road-mesh soft label self-supervised constraint construction process in step S4 includes:

[0099] S41. Extract the set of valid road segments and effective spatial grid set ;

[0100] S42. Calculate the soft similarity between trajectories based on the overlap relationships of road sets and grid sets. ;

[0101] S43. Construct a road-grid soft label matrix Y based on the soft similarity;

[0102] S44. Use the road-mesh soft label matrix to constrain the self-supervised alignment training between the road view representation and the mesh view representation.

[0103] The road-grid soft label matrix features in S43 are as follows:

[0104] S51. Based on the soft similarity between any two trajectories within the training batch. Construct a road-grid soft label matrix ,in, Indicates the first Road perspective representation of the trajectory and the first The soft label weights between the trajectories are represented from a grid perspective.

[0105] Assume the training batch contains For each trajectory, the road-grid soft label matrix... It can be represented as:

[0106]

[0107] In the formula, Represents the road-grid soft label matrix. Represents the number of trajectories in a training batch; matrix The The row corresponds to the first Road perspective representation of a trajectory, matrix The Column corresponding to the first A grid view representation of the trajectory, elements Indicates the first Road perspective representation of the trajectory and the first The soft label weights between the trajectories are represented from a grid perspective.

[0108] S52. Before normalization, when hour, Set as strong positive sample weights to represent the correspondence between the road view representation and the grid view representation of the same trajectory; when hour, Based on soft similarity This is defined to represent the weak correlation between different trajectories based on road segment overlap and spatial grid overlap.

[0109] Furthermore, let the road-grid soft label matrix before normalization be... ,in, Indicates the first before normalization Road perspective representation of the trajectory and the first The soft label weights between the trajectories are represented by a grid view. The expression is:

[0110]

[0111] In the formula, Indicates the first before normalization Road perspective representation of the trajectory and the first The soft label weights between the trajectories are represented from a grid perspective. Indicates the first Trajectory and the first Soft similarity between trajectories; Indicates the first Trajectory and the first The overlap of spatial grid sets between trajectories; The scaling factor representing the weight of off-diagonal soft labels; This represents the maximum limit value for the weight of off-diagonal soft labels; This indicates a preset similarity threshold;

[0112] Among them, when hour, These are set as strong positive sample weights to represent the correspondence between the road view representation and the grid view representation of the same trajectory; when When two trajectories have overlapping spatial grids and soft similarity... Not lower than the preset similarity threshold According to Determine the off-diagonal soft label weights, and through Limit its maximum value; if the two trajectories do not have spatial grid overlap, or soft similarity Below the preset similarity threshold If so, the corresponding off-diagonal soft label weight will be reset to zero.

[0113] The calculation method for soft similarity Sij, used to determine the weight of off-diagonal soft labels in S52, includes:

[0114] S61. Perform effective identifier filtering on the road segment identifier sequence corresponding to each trajectory in the training batch, removing filler identifiers, start identifiers, end identifiers, and mask identifiers, and retaining only the real road segment identifiers, to obtain the first... The set of valid road segments corresponding to each trajectory ;

[0115] S62. Perform effective identifier filtering on the spatial grid identifier sequence corresponding to each trajectory in the training batch, removing filled and invalid grid identifiers, and retaining only the valid spatial grid identifiers to obtain the first... Effective spatial grid set corresponding to each trajectory ;

[0116] S63. For any two trajectories within a training batch and According to the Set of valid road segments for each trajectory and the Set of valid road segments for each trajectory Calculate the set overlap of the two trajectories at the road segment level. Its expression is:

[0117]

[0118] In the formula, Indicates the first Trajectory and the first The degree of overlap of the set of trajectories at the road segment level. Indicates the first The set of valid road segments for each trajectory Indicates the first The set of valid road segments for each trajectory This indicates the number of road segments shared by the two trajectories. This represents the total number of different road segments contained in the two trajectories;

[0119] S64. For any two trajectories within a training batch and According to the Effective spatial grid set of trajectories and the Effective spatial grid set of trajectories Calculate the set overlap of the two trajectories at the spatial grid level. Its expression is:

[0120]

[0121] In the formula, Indicates the first Trajectory and the first The degree of overlap of the sets of trajectories at the spatial grid level. Indicates the first The effective spatial grid set of the trajectory Indicates the first The effective spatial grid set of the trajectory This indicates the number of spatial grids shared by two trajectories. This represents the total number of distinct spatial grids contained in the two trajectories;

[0122] S65, Set the overlap of the road segment layers. Overlap with spatial grid level The weighted fusion is performed according to preset weights to obtain the first... Trajectory and the first Soft similarity between trajectories Its expression is:

[0123]

[0124] In the formula, Indicates the first Trajectory and the first Soft similarity between trajectories This represents the preset weight corresponding to the overlap of road segment sets. This represents the preset weight corresponding to the overlap of the spatial grid set. This indicates the degree of overlap between two trajectories at the road segment level. This indicates the degree of overlap between two trajectories at the spatial grid level.

[0125] Among them, the soft similarity The soft similarity is used to characterize the comprehensive spatial correlation between two trajectories in a training batch at the road segment level and the spatial grid level. It is a continuous similarity value used to characterize the partial spatial correlation between different trajectories. Compared with the hard labeling method that only treats the same trajectory as a positive sample and all other trajectories as negative samples, the soft similarity calculation method can characterize different trajectories with partial spatial correlation in the training batch as weakly correlated samples based on the road segment overlap relationship and the spatial grid overlap relationship.

[0126] Furthermore, in step S5, after completing the joint pre-training of the road-grid soft label self-supervised constraint, masked road segment prediction task and trajectory triplet learning task, the position alignment feature sequence corresponding to the trajectory to be represented is input into the trained trajectory representation model to obtain the trajectory vector representation for downstream trajectory analysis tasks.

[0127] Specifically, the location alignment feature sequence includes a road segment identification sequence, a spatial grid identification sequence, a regional semantic sequence, and a multi-granularity temporal feature sequence. The trajectory representation model first obtains road node embeddings based on the road segment identification sequence and combines them with trajectory location embeddings to obtain a road perspective representation; it then obtains grid embeddings based on the spatial grid identification sequence, obtains regional semantic embeddings based on the regional semantic sequence, and fuses the grid embeddings and regional semantic embeddings to obtain a grid perspective representation; finally, it obtains temporal feature representations based on the multi-granularity temporal feature sequence.

[0128] Furthermore, using the road-view representation as the query input and the grid-view representation as the key and value input, a road-grid cross-attention fusion module extracts regional context information related to road segments from the grid-view representation. This regional context information is then residually fused and normalized with both the road-view and grid-view representations to obtain a spatially fused representation. This spatially fused representation, along with the temporal feature representation, is then input into the trajectory encoder to obtain the hidden state representation sequence corresponding to each location in the trajectory. .

[0129] set up For the effective location mask, where Indicates the first Is each trajectory position a valid trajectory position? When, it indicates the first One position is a valid position; when When, it indicates the first Each position is either a filled position or an invalid position. Masked average pooling is performed on the hidden state representation sequence to obtain the trajectory vector representation. The calculation method is as follows:

[0130]

[0131] in, This represents the final trajectory vector representation. Indicates the first The hidden state representation corresponding to each trajectory position. Indicates the first The effective location mask corresponds to each location. Therefore, the trajectory representation model can encode road topology information, spatial grid information, regional semantic information, and temporal state information into a unified trajectory vector representation. This trajectory vector representation can be used for downstream trajectory analysis tasks such as trajectory similarity query, trajectory classification, and travel time estimation.

[0132] like Figure 2 As shown, after trajectory preprocessing, the original GPS trajectory is converted into a trajectory feature sequence aligned to four types of locations: road, grid, regional semantics, and time. Specifically, in step S1, a multi-view sequence is constructed from the original GPS trajectory. The original GPS trajectory is first arranged into a sequence of trajectory points in chronological order:

[0133]

[0134] in, Indicates the first Each trajectory point contains longitude, latitude, and timestamp information.

[0135] By using map matching methods, trajectory points or trajectory segments are mapped to road segments in the road network, resulting in a sequence of road segment identifiers:

[0136] ;

[0137] By using a spatial grid mapping method, trajectory points or road segments are mapped to a preset spatial grid, resulting in a spatial grid identifier sequence:

[0138]

[0139] By using regional semantic association methods, interest point categories, regional function categories, or spatial statistical information are associated with trajectory points or spatial grids to obtain regional semantic sequences:

[0140]

[0141] By extracting intraday, intraweek, or date-related information from timestamps, multi-granularity time feature sequences can be obtained:

[0142]

[0143] The above road segment identification sequence Spatial grid identification sequence Region semantic sequence and multi-granularity time feature sequences Align according to the trajectory position.

[0144] in, Indicates the first The road segment identifier corresponding to each trajectory location Indicates the first Spatial grid identifiers corresponding to each trajectory position Indicates the first The semantic identifier of the region corresponding to each trajectory location. Indicates the first The multi-granularity time features corresponding to each trajectory location include at least one of intraday time, intraweek time, and date-related information.

[0145] After alignment, the same trajectory position Simultaneously possesses road status spatial regions Regional semantics and time status This forms a multi-view trajectory feature unit that can be used to represent the trajectory. .

[0146] Furthermore, such as Figure 2 As shown in the road perspective branch, grid perspective branch, and time feature branch, in step S2, road perspective representation, grid perspective representation, and time feature representation are constructed respectively. Specifically, the road perspective branch generates the road perspective representation using the road network topology and road segment identification sequence; the grid perspective branch generates the grid perspective representation using the spatial grid identification sequence and the regional semantic sequence; and the time branch generates the time feature representation using a multi-granularity time feature sequence.

[0147] The road perspective representation is used to express the topological relationships and semantics of the road segments traversed by the trajectory. A road topology map is constructed based on the road segments and their connections within the road network.

[0148]

[0149] in, Represents the set of road segment nodes. This represents the set of connections between road segments. The road topology graph is encoded using a graph neural network or graph attention network to obtain the road node embedding matrix:

[0150]

[0151] For each trajectory, based on its road segment identifier sequence Embedded matrix from road nodes The road node embedding corresponding to the index is combined with the trajectory location embedding. The road perspective representation is obtained as follows:

[0152]

[0153] in, This indicates the road perspective. This represents the road node embedding sequence obtained based on the road segment identifier sequence index. This indicates the embedding of the trajectory position.

[0154] The grid perspective is used to represent the location features and regional semantics of the spatial region traversed by the trajectory. This is based on the spatial grid identifier sequence. Query the grid embedding table to obtain the grid embedding sequence. According to the region semantic sequence Query the region semantic embedding table to obtain the region semantic embedding sequence. By combining the two, we obtain a grid-view representation:

[0155]

[0156] in, Representing the grid perspective, Represents a grid embedding sequence. This represents a region semantic embedding sequence.

[0157] Furthermore, based on multi-granularity time feature sequences Query the time feature embedding table to obtain the time feature representation:

[0158]

[0159] in, Indicates time characteristics. This represents the time embedding sequence obtained based on the multi-granularity time feature sequence index.

[0160] like Figure 3 As shown, in step S3, road network-grid cross-attention fusion is performed on the road view representation and the grid view representation to obtain the spatial fusion representation of the trajectory. Figure 2 The left side shows the correspondence between road networks, spatial grids, and trajectory points in urban space, while the middle shows the road perspective representation. and grid perspective representation The right side illustrates the process of cross-attention computation using the road view representation as the query and the grid view representation as the key and value. Specifically, the road view representation... As query input, the grid perspective is represented Using key and value inputs, a cross-attention mechanism is employed to extract regional contextual information related to road segments from the grid-view representation, resulting in a cross-view contextual representation. .

[0161] In one specific implementation, the cross-attention calculation process is represented as follows:

[0162]

[0163]

[0164]

[0165] in, Represents the query matrix. Represents the key matrix, Represents a value matrix, , , Let represent the learnable linear transformation parameter matrices, respectively.

[0166] Cross-perspective context representation Represented as:

[0167]

[0168] Substitution , , After that, it can be written as:

[0169]

[0170] In the formula, Represents the dimension of the key vector. This indicates the calculation of normalized attention weights. This represents the cross-view context representation obtained after querying grid view information from the road view perspective.

[0171] Furthermore, such as Figure 2 As shown on the right, the road view is represented. Grid perspective representation and cross-perspective context representation By performing residual fusion and normalization, a spatial fusion representation of the trajectory is obtained:

[0172]

[0173] In the formula, Spatial fusion representation of trajectories, Represents the learnable fusion coefficient. This indicates a random deactivation operation. Presentation layer normalization operation.

[0174] Furthermore, such as Figure 1 As shown, spatial fusion representation Representation of time features The common input is used to the subsequent trajectory encoder to learn a trajectory representation that simultaneously incorporates road topology, spatial region semantics, and temporal state.

[0175] like Figure 3 As shown in the upper part, in step S4, a road-grid soft label matrix is ​​constructed based on the overlap relationship between the road segment identification sequence and the spatial grid identification sequence, and a road-grid soft label self-supervised constraint is formed. Figure 3 The soft label matrix construction process is shown in the figure: first, the road overlap and grid overlap are calculated based on the road sequence and grid sequence respectively, then the soft similarity is obtained by fusion, and finally the road-grid soft label matrix is ​​generated. .

[0176] Specifically, for each trajectory within a training batch, a set of valid road segments is extracted from its road segment identifier sequence, and a set of valid spatial grids is extracted from its spatial grid identifier sequence. For any two trajectories within a training batch... and The overlap of road segment sets is calculated based on the effective road segment sets and effective spatial grid sets of both. Overlap with spatial grid set .

[0177] Furthermore, the overlap degree of the road segment set and the overlap degree of the spatial grid set are weighted and fused according to preset weights to obtain the first... Trajectory and the first Soft similarity between trajectories Its expression is:

[0178]

[0179] In the formula, This represents the preset weight corresponding to the overlap of road segment sets. This represents the preset weight corresponding to the overlap of the spatial grid set.

[0180] Furthermore, based on soft similarity Constructing a road-grid soft label matrix Suppose that the training batch contains For each trajectory, the road-grid soft label matrix is... It can be represented as:

[0181]

[0182] Among them, matrix The The row corresponds to the first The road perspective of the trajectory is represented by the first... Column corresponding to the first A grid view representation of the trajectory, elements Indicates the first Road perspective representation of the trajectory and the first The soft label weights between the grid views of the trajectories are represented.

[0183] like Figure 4 China Soft Tag Matrix As shown in the construction process, soft similarity is obtained. Then, threshold filtering, scaling truncation, and row normalization are performed on it. Let the road-grid soft label matrix before normalization be... Its elements The expression is:

[0184]

[0185] In the formula, This represents the scaling factor for off-diagonal soft label weights. This represents the maximum limit value for the weight of off-diagonal soft labels. This indicates the preset similarity threshold.

[0186] Then, the unnormalized road-grid soft label matrix Normalize by row to obtain the final road-grid soft label matrix. Its expression is:

[0187]

[0188] In the formula, This represents a minimal constant used to prevent the denominator from being zero. After normalization, the matrix... Each row forms a soft label distribution. Diagonal elements are used to represent strong positive sample relationships between the road view representation and the grid view representation of the same trajectory, while off-diagonal elements are used to represent weak correlations between different trajectories based on road segment overlap and spatial grid overlap.

[0189] With this soft label matrix, the model not only focuses on the alignment between the road view representation and the grid view representation of the same trajectory during self-supervised training, but also retains the weak correlation between some spatially related trajectories within the training batch, avoiding simply treating all different trajectories as negative samples.

[0190] Furthermore, such as Figure 4 As shown in the lower part, in step S5, the road-grid soft label matrix is ​​used. Self-supervised alignment training is performed on the road view representation and the grid view representation. Figure 4The self-supervised alignment training process in the example illustrates the following: first, the road view representation and the grid view representation are pooled into trajectory-level vectors, respectively; then, the similarity matrix between the road trajectory vector and the grid trajectory vector is calculated. Finally, a soft tag matrix is ​​used. The similarity matrix is ​​supervised.

[0191] Specifically, the road view representation and the grid view representation are pooled separately to obtain the road trajectory vector. and grid trajectory vector Then, the road trajectory vector and the grid trajectory vector are normalized, and the similarity matrix between them is calculated:

[0192]

[0193] In the formula, Represents the road trajectory vector. Represents the grid trajectory vector. Indicates the temperature coefficient. This represents the similarity matrix between the road view trajectory vector and the grid view trajectory vector within the training batch.

[0194] Furthermore, based on the similarity matrix and road-grid soft label matrix Calculate the self-supervised alignment loss in the road-to-mesh direction and the self-supervised alignment loss in the mesh-to-road direction, respectively:

[0195]

[0196]

[0197] In the formula, This represents the soft label alignment loss in the direction from the road view to the grid view. This represents the soft label alignment loss in the direction from the grid view to the road view. This represents the cross-entropy loss based on the soft-label distribution.

[0198] Finally, the road-mesh soft label self-supervised loss is expressed as:

[0199]

[0200] This loss is used to ensure that the road view representation and the grid view representation of the same trajectory remain consistent, while preserving the weak correlation between different trajectories with overlapping road segments or spatial grids.

[0201] Furthermore, such as Figure 2As shown in the self-supervised learning task and joint training loss module, during the pre-training phase, the road-mesh soft label self-supervised loss is weighted and fused with the masked road segment prediction loss and trajectory triplet loss to obtain the total training loss:

[0202]

[0203] In the formula, This represents the prediction loss for the masked road segment, used to learn local road context information of the trajectory; This represents the trajectory triplet loss, used to learn trajectory-level similarity relationships; This represents the road-mesh soft label self-supervised loss, used to learn the cross-view consistency relationship between the road view and the mesh view; , and These represent the weighting coefficients of the corresponding loss terms.

[0204] Using the above scheme for trajectory representation learning has the following technical advantages and beneficial effects:

[0205] 1. This invention incorporates road network topology information, spatial grid region information, and regional semantic information into the trajectory representation learning process, enabling the trajectory representation to not only express the connection relationships and traffic semantics between road segments, but also the spatial location and regional function of the area traversed by the trajectory, thereby improving the information completeness of the trajectory representation.

[0206] 2. This invention employs a road network-grid cross-attention fusion method, using the road perspective representation as the query input and the grid perspective representation as the key and value input. This allows the road perspective to extract regional context information related to the current road segment from the grid perspective. Compared to simple addition, splicing, or fixed-weight fusion methods, this method can model the correspondence between road segments and spatial grids at a finer granular level, improving the cross-perspective information fusion effect.

[0207] 3. This invention constructs soft similarity between trajectories based on the overlap of road segment sets and spatial grid sets, and further constructs a road-grid soft label matrix, enabling the training process to characterize the weak correlation between different trajectories within the same training batch. Compared to the hard labeling method that treats only the same trajectory as a positive sample and all other trajectories as negative samples, this method can reduce misjudgments of some spatially related trajectories.

[0208] 4. This invention utilizes a road-mesh soft label matrix for bidirectional self-supervised alignment training, ensuring that the road view representation and mesh view representation of the same trajectory remain consistent in the representation space. At the same time, it preserves the weak correlation information between different trajectories with overlapping road segments or spatial meshes, thereby improving the robustness and spatial consistency of trajectory representation.

[0209] 5. This invention performs joint pre-training of masked road segment prediction, trajectory triplet learning, and road-grid soft label self-supervised learning, enabling the model to simultaneously learn local road context information, trajectory-level similarity relationships, and cross-view consistency between road view and grid view, thereby enhancing the versatility of trajectory vector representation.

[0210] 6. The trajectory vector representation obtained by this invention can be used for downstream trajectory analysis tasks such as trajectory similarity query, trajectory classification, and travel time estimation, and can provide effective trajectory representation support in scenarios such as intelligent transportation, vehicle trajectory analysis, and travel pattern recognition.

[0211] Obviously, the specific implementation of this invention is not limited to the above-described methods. Any non-substantial improvements made using the inventive concept and technical solution of this invention are within the protection scope of this invention.

Claims

1. A trajectory representation learning method based on road network-grid cross-attention fusion, characterized by: Includes the following steps: S1. Obtain the GPS trajectory data of the moving object to be processed, and perform trajectory preprocessing to obtain the road segment identification sequence, spatial grid identification sequence, regional semantic sequence and multi-granularity time feature sequence corresponding to each trajectory and aligned with the position; S2. Based on the road segment identification sequence, spatial grid identification sequence and their corresponding road network information and spatial region information, construct road perspective representation and grid perspective representation respectively; S3. Perform road network-grid interactive fusion on the road view representation and the grid view representation to obtain the spatial fusion representation of the trajectory; S4. Based on the overlap relationship between the road segment identification sequence and the spatial grid identification sequence, construct a road-grid soft label matrix and form a road-grid soft label self-supervised constraint; S5. Using the road perspective representation, grid perspective representation, spatial fusion representation, and road-grid soft label self-supervised constraints, and combined with the trajectory pre-training task to train the trajectory representation model, a trajectory vector representation for downstream trajectory analysis tasks is obtained.

2. The trajectory representation learning method based on road network-grid cross-attention fusion as described in claim 1, characterized in that: The preprocessing method for GPS trajectory data in step S1 includes: S11. Represent each GPS track as a sequence of track points in chronological order. ,in, Includes longitude, latitude, and timestamp; S12. Based on the trajectory point sequence, obtain the road segment identification sequence, spatial grid identification sequence, regional semantic sequence, and multi-granularity time feature sequence respectively; wherein, the road segment identification sequence is obtained by map matching, the spatial grid identification sequence is obtained by spatial grid mapping, the regional semantic sequence is obtained by regional semantic association, and the multi-granularity time feature sequence is obtained by timestamp extraction. S13. Align the road segment identification sequence, spatial grid identification sequence, regional semantic sequence, and multi-granularity time feature sequence according to the trajectory position.

3. The trajectory representation learning method based on road network-grid cross-attention fusion as described in claim 1, characterized in that: The methods for constructing the road view and the grid view in step S2 include: The road view representation is constructed from a road topology map and a sequence of road segment identifiers. The road topology map is constructed based on road segments and their connections. The road topology map is encoded from a graph neural network or graph attention network to obtain road node embeddings. The road node embeddings are indexed based on the sequence of road segment identifiers and combined with trajectory position representations to obtain the road view representation. The grid perspective representation is constructed from a spatial grid identifier sequence and a regional semantic sequence. Specifically, a grid embedding sequence is obtained by querying a grid embedding table based on the spatial grid identifier sequence, and a regional semantic embedding sequence is obtained by querying a regional semantic embedding table based on the regional semantic sequence. The grid embedding sequence and the regional semantic embedding sequence are then fused to obtain the grid perspective representation.

4. The trajectory representation learning method based on road network-grid cross-attention fusion as described in claim 1, characterized in that: The road network-mesh interaction fusion method in step S3 includes: S31, Receive road view representation and grid perspective representation Wherein, the road perspective is used to express the road topology and road segment semantics corresponding to the trajectory, and the grid perspective is used to express the spatial region and region semantics corresponding to the trajectory; S32. Based on the correspondence between road segments and spatial grids in trajectory positions, perform cross-view interactive modeling of the road view representation and the grid view representation; S33. Using a cross-attention fusion approach, with the road view representation as the query input, regional contextual information related to road segments is extracted from the grid view representation to obtain a cross-view contextual representation. ; S34. Represent the cross-perspective context. By fusing the road view representation and the grid view representation, a spatial fusion representation of the trajectory is obtained. .

5. The trajectory representation learning method based on road network-grid cross-attention fusion as described in claim 4, characterized in that: Spatial fusion representation in step S34 for: ; in, Spatial fusion representation of trajectories, This indicates the road perspective. Representing the grid perspective, This represents a cross-perspective context representation. Represents the learnable fusion coefficient. This indicates a random deactivation operation. Presentation layer normalization operation.

6. The trajectory representation learning method based on road network-grid cross-attention fusion as described in claim 4, characterized in that: In step S33, cross-perspective context representation The expression method is as follows: ; In the formula, This indicates cross-attention calculation. As input for the query As key input and value input.

7. The trajectory representation learning method based on road network-grid cross-attention fusion as described in claim 1, characterized in that: The self-supervised constraint construction method for road-mesh soft labels in step S4 includes: S41. Extract the set of valid road segments and effective spatial grid set ; S42. Calculate the soft similarity between trajectories based on the overlap relationships of road sets and grid sets. ; S43. Construct a road-grid soft label matrix Y based on the soft similarity; S44. Use the road-mesh soft label matrix Y to constrain the self-supervised alignment training between the road view representation and the mesh view representation.

8. The trajectory representation learning method based on road network-grid cross-attention fusion as described in claim 7, characterized in that: The method for constructing the road-mesh soft label matrix in step S43 includes: Based on the soft similarity between any two trajectories within the training batch Construct a road-mesh soft label matrix ,in, Indicates the first Road perspective representation of the trajectory and the first The soft label weights between the trajectories are represented from a grid perspective. Assume the training batch contains For each trajectory, the road-grid soft label matrix... It can be represented as: ; In the formula, Represents the road-grid soft label matrix. Represents the number of trajectories in a training batch; matrix The The row corresponds to the first Road perspective representation of a trajectory, matrix The Column corresponding to the first A grid view representation of the trajectory, elements Indicates the first Road perspective representation of the trajectory and the first The soft label weights between the trajectories are represented from a grid perspective. Before normalization, when hour, Set as strong positive sample weights to represent the correspondence between the road view representation and the grid view representation of the same trajectory; when hour, Based on soft similarity This is defined to represent the weak correlation between different trajectories based on road segment overlap and spatial grid overlap. Let the road-grid soft label matrix before normalization be... ,in, Indicates the first digit before normalization Road perspective representation of the trajectory and the first The soft label weights between the trajectories are represented by a grid view. The expression is: ; In the formula, Indicates the first digit before normalization Road perspective representation of the trajectory and the first The soft label weights between the trajectories are represented from a grid perspective. Indicates the first Trajectory and the first Soft similarity between trajectories; Indicates the first Trajectory and the first The overlap of spatial grid sets between trajectories; The scaling factor representing the weight of off-diagonal soft labels; This represents the maximum limit value for the weight of off-diagonal soft labels; This indicates a preset similarity threshold; Among them, when hour, These are set as strong positive sample weights to represent the correspondence between the road view representation and the grid view representation of the same trajectory; when When two trajectories have overlapping spatial grids and soft similarity... Not lower than the preset similarity threshold According to Determine the off-diagonal soft label weights, and through Limit its maximum value; if the two trajectories do not have a spatial grid overlap, or the similarity is soft. Below the preset similarity threshold If so, the corresponding off-diagonal soft label weight will be reset to zero.

9. The trajectory representation learning method based on road network-grid cross-attention fusion as described in claim 8, characterized in that: Methods for calculating the soft similarity Sij used to determine the weights of off-diagonal soft labels include: S61. Perform effective identifier filtering on the road segment identifier sequence corresponding to each trajectory in the training batch, removing filler identifiers, start identifiers, end identifiers, and mask identifiers, and retaining only the real road segment identifiers, to obtain the first... The set of valid road segments corresponding to each trajectory ; S62. Perform effective identifier filtering on the spatial grid identifier sequence corresponding to each trajectory in the training batch, removing filled and invalid grid identifiers, and retaining only the valid spatial grid identifiers to obtain the first... The effective spatial grid set corresponding to each trajectory ; S63. For any two trajectories within a training batch and According to the Set of valid road segments for each trajectory and the Set of valid road segments for each trajectory Calculate the set overlap of the two trajectories at the road segment level. Its expression is: ; In the formula, Indicates the first Trajectory and the first The degree of overlap of the set of trajectories at the road segment level. Indicates the first The set of valid road segments for each trajectory Indicates the first The set of valid road segments for each trajectory This indicates the number of road segments shared by the two trajectories. This represents the total number of different road segments contained in the two trajectories; S64. For any two trajectories within a training batch and According to the Effective spatial grid set of trajectories and the Effective spatial grid set of trajectories Calculate the set overlap of the two trajectories at the spatial grid level. Its expression is: ; In the formula, Indicates the first Trajectory and the first The degree of overlap of the sets of trajectories at the spatial grid level. Indicates the first The effective spatial grid set of the trajectory Indicates the first The effective spatial grid set of the trajectory This indicates the number of spatial grids shared by two trajectories. This represents the total number of distinct spatial grids contained in the two trajectories; S65, Set the overlap of the road segment layers. Overlap with spatial grid level The weighted fusion is performed according to preset weights to obtain the first... Trajectory and the first Soft similarity between trajectories Its expression is: ; In the formula, Indicates the first Trajectory and the first Soft similarity between trajectories This represents the preset weight corresponding to the overlap of road segment sets. This represents the preset weight corresponding to the overlap of the spatial grid set. This indicates the degree of overlap between two trajectories at the road segment level. This indicates the degree of overlap between two trajectories at the spatial grid level. Among them, the soft similarity The soft similarity is used to characterize the comprehensive spatial correlation between two trajectories in a training batch at the road segment level and the spatial grid level. It is a continuous similarity value used to characterize the partial spatial correlation between different trajectories. Compared with the hard labeling method that only treats the same trajectory as a positive sample and all other trajectories as negative samples, the soft similarity calculation method can characterize different trajectories with partial spatial correlation in the training batch as weakly correlated samples based on the road segment overlap relationship and the spatial grid overlap relationship.