MoCo-AIS: Contrastive Learning for Vessel Trajectories
- The paper presents MoCo-AIS, which replaces computationally expensive geometric comparisons with learned trajectory embeddings for efficient similarity retrieval.
- It standardizes AIS data preprocessing, augmentation, and evaluation protocols, allowing for fair benchmarking across various deep sequence encoders.
- Empirical results show that MoCo-AIS outperforms classical methods and prior self-supervised baselines, especially in same-region scenarios.
MoCo-AIS is a self-supervised contrastive learning framework for computing similarity between vessel trajectories from AIS data by learning trajectory embeddings rather than directly comparing raw coordinate sequences with computationally expensive geometric distances such as Hausdorff or DTW. Introduced in "MoCo-AIS: A Contrastive Learning Framework for Similarity Computation of Vessel Trajectories" (Song et al., 16 Jun 2026), it adapts the Momentum Contrast paradigm to maritime trajectory analysis and simultaneously serves as a model-agnostic benchmark: preprocessing, augmentations, contrastive training, and evaluation are standardized so that alternative deep sequence encoders can be assessed under the same retrieval setting.
1. Problem definition and conceptual scope
MoCo-AIS is formulated around a vessel trajectory as an ordered sequence of AIS observations,
where each point
contains longitude, latitude, speed over ground, course over ground, and timestamp. In the actual similarity model, the representation is restricted to the spatial sequence while preserving temporal order:
This restriction is central: the framework deliberately excludes speed and course from the final representation because they were found to be highly variable under local noise and irregular sampling (Song et al., 16 Jun 2026).
The paper distinguishes non-learned and learned similarity functions. For traditional methods,
where is a trajectory distance. For learned methods, an encoder maps each trajectory to a latent vector and similarity is computed in embedding space:
MoCo-AIS is designed for the second regime. Its premise is that semantically similar vessel paths should be close in latent space and dissimilar ones far apart, without requiring labels generated from a predefined metric.
The framework is motivated by three claims. First, traditional distance-based trajectory similarity methods such as Hausdorff and DTW are computationally heavy and often sensitive to outliers, noise, and sampling density. Second, supervised similarity models typically require labels derived from those same handcrafted distances and therefore learn to reproduce the supervisory metric “by construction,” which limits generalization. Third, AIS datasets are usually unlabeled, and “ground-truth” global similarity labels are intrinsically ambiguous. MoCo-AIS therefore positions self-supervised contrastive learning as a way to learn transferable representations directly from raw vessel movement patterns.
2. Data model, preprocessing, and trajectory augmentations
The framework operates on large-scale real-world AIS data from Marine Cadastre for 2024 across three maritime regions: East Coast, Chesapeake Bay, and Strait of Georgia (Song et al., 16 Jun 2026). The reported dataset statistics are 3,066 vessels, 8,658 trajectories, and 4,310,435 points for East Coast; 7,053 vessels, 15,824 trajectories, and 14,054,482 points for Chesapeake Bay; and 5,140 vessels, 12,977 trajectories, and 15,208,276 points for Strait of Georgia. These regions are chosen to capture diverse navigation behaviors and operating conditions.
Before contrastive training, the AIS streams undergo a maritime-specific preprocessing pipeline. Points appearing on land are removed using coastal and inland water boundaries. Vessels with very low speed, specifically below 0.5 knots, are removed as typically stationary or loitering behavior, and points with speeds exceeding 40 knots are removed as likely errors. The remaining records are grouped by MMSI and segmented into trips whenever the temporal gap between consecutive messages exceeds 1 hour or the spatial gap exceeds 100,000 meters. Each segmented trajectory is then resampled to 2-minute intervals by linear interpolation of latitude and longitude, and only trajectories with between 50 and 3,000 points after interpolation are retained.
Within a mini-batch, trajectories are padded to the maximum sequence length in that batch, producing padded tensors
with true lengths stored separately and a binary mask indicating valid versus padded positions. This permits a single framework to accommodate variable-length trajectories while preserving temporal order.
Self-supervision is created through trajectory-specific augmentations. For each original trajectory , MoCo-AIS generates two augmented views, a query view and a key view , which form a positive pair. The paper uses three augmentation strategies: sub-trajectory extraction, which trims a subset of points; shape distortion, which perturbs point positions to alter the path; and simplification using the Ramer–Douglas–Peucker algorithm, which reduces trajectory complexity while preserving overall shape. These augmentations are intended to preserve semantic route identity while introducing enough variation for contrastive learning.
3. Framework architecture and contrastive learning mechanism
MoCo-AIS follows the standard Momentum Contrast design: a query encoder, a key encoder, a projection or embedding pathway, a momentum update from query to key, a FIFO memory queue of negative embeddings, and an InfoNCE loss (Song et al., 16 Jun 2026). The positive pair is formed by two augmented views of the same trajectory, while negatives are taken from the queue rather than only from the current mini-batch. This is the mechanism that allows many negatives without requiring extremely large batch sizes.
Formally, for a trajectory 0 and its augmentation 1,
2
The queue at iteration 3 is
4
and the contrastive loss is
5
where 6 is the query embedding, 7 the positive key embedding, 8 negatives from the queue, 9 cosine similarity, and 0 the temperature. The key encoder is updated by exponential moving average:
1
A distinctive aspect of MoCo-AIS is its model-agnostic backbone interface. The paper evaluates BiLSTM, BiGRU, TCN, and Transformer encoders under the same training protocol. For GRU, LSTM, and TCN variants, each input point is linearly projected into a 2-dimensional space, the sequence is packed according to true lengths, passed through the stacked recurrent or convolutional network, and pooled by masked mean pooling. For the Transformer, each 2D point 3 is linearly projected, scaled by 4, and combined with sinusoidal positional encodings
5
so that
6
For all backbones, hidden states are reduced to a fixed-length embedding by masked mean pooling,
7
ensuring padded positions do not contribute.
The reported hyperparameters are deliberately standardized. MoCo-AIS uses hidden dimension 8 and dropout 9 for all encoders; the Transformer uses 4 attention heads and 2 encoder layers; GRU and LSTM use 2 bidirectional layers; and the TCN uses depth 4, kernel size 3, and base dilation 1. Training runs for up to 600 epochs with batch size between 32 and 128, Adam optimizer, learning rate between 0.0001 and 0.001, ReduceLROnPlateau, and early stopping patience between 10 and 25 epochs. MoCo-specific settings are momentum coefficient 0 in the range 0.99–0.9999, queue size 256–1024, and temperature 1 in the range 0.01–0.07.
4. Benchmark design and evaluation methodology
A major contribution of MoCo-AIS is not only the representation model but also the benchmarking protocol (Song et al., 16 Jun 2026). The paper explicitly standardizes AIS preprocessing, trip segmentation, interpolation interval, trajectory filtering, contrastive objective, positive-pair generation, evaluation protocol, and retrieval metric. Only the encoder backbone changes. This converts the framework into a controlled experimental platform for maritime trajectory representation learning.
Two evaluation metrics are central. Mean Rank measures how highly each trajectory’s augmented variants are retrieved in embedding space:
2
where 3 is the average rank of the three augmented versions of trajectory 4. Lower is better, and values close to 1 indicate that positives are retrieved at or near the top.
Hitting Ratio compares nearest neighbors in embedding space with nearest neighbors under a classical distance metric:
5
and
6
This metric does not define the training objective; rather, it quantifies the degree to which learned similarity neighborhoods align with neighborhoods induced by geometric distances.
The benchmark includes both same-region and cross-region scenarios. Same-region experiments vary training size and evaluation size, while cross-region experiments train on East Coast 6K and evaluate on Chesapeake Bay 6K, Strait of Georgia 3K, and Strait of Georgia 9K. Baselines include classical Hausdorff and DTW, and learning-based methods t2vec and TrajCL, with t2vec modified to remove its word2vec module for consistency with raw coordinate input and TrajCL adapted to maritime conditions with changed preprocessing and a 10 km grid size.
5. Empirical findings
MoCo-AIS yields a highly structured embedding space in which original trajectories and their augmented variants cluster tightly together while different trajectory groups remain separated (Song et al., 16 Jun 2026). The paper visualizes this with t-SNE and PCA and interprets it as evidence that the learned representation is stable under sub-trajectory extraction, distortion, and simplification while remaining discriminative across distinct route patterns.
In same-region retrieval, all MoCo-AIS variants perform strongly, especially Transformer and BiLSTM. With 6K training samples, the Transformer achieves Mean Rank 1.000 on 1K evaluation, 1.002 on 3K, 1.001 on 6K, and 1.007 on 9K; with 9K training samples, it reports 1.000, 1.000, 1.001, and 1.001 across 1K, 3K, 6K, and 9K evaluation sizes. BiLSTM is also strong, with 1.005, 1.007, 1.009, and 1.010 for 6K training, and 1.002, 1.006, 1.010, and 1.017 for 9K training. BiGRU is slightly worse but still strong, while TCN is the weakest among the MoCo-AIS backbones and degrades more at scale. Classical baselines are materially worse: Hausdorff lies around 1.025 to 1.141 depending on evaluation size, whereas DTW is around 1.001 to 1.004 where reported.
Against learning-based baselines on Strait of Georgia with 6K training and 1K evaluation, the gap is much larger. t2vec* reports Mean Rank 551.730 and rank percentage 55.173%; TrajCL reports 186.189 and 18.619%; MoCo-AIS Transformer reports 1.000 and 0.100%; BiLSTM 1.087 and 0.109%; TCN 1.297 and 0.130%; and BiGRU 2.647 and 0.265%. The paper highlights this as one of its strongest empirical results: all MoCo-AIS variants substantially outperform the prior self-supervised baselines.
Cross-regional retrieval is notably harder. Training on East Coast 6K and testing on Chesapeake Bay 6K yields Mean Rank 3.133 for Transformer, 16.102 for BiGRU, 5.375 for BiLSTM, and 9.208 for TCN. On Strait of Georgia, the drop is much sharper for Transformer and TCN: Transformer reaches 87.715 on 3K and 258.015 on 9K, while TCN reaches 80.924 and 239.009. By contrast, RNN-based models are more robust under regional shift: BiGRU gives 3.832 on Strait of Georgia 3K and 9.440 on 9K, and BiLSTM gives 7.619 and 21.902. The paper attributes this degradation to region-specific mobility structure: same-region retrieval exploits recurring navigation regularities, whereas broad transfer is limited by local geography, traffic patterns, and operating conditions.
Computational efficiency is another central result. Pairwise Hausdorff computation requires 1.04, 8.77, 34.39, and 77.66 hours for 1K, 3K, 6K, and 9K trajectories, respectively. DTW requires 5.49, 49.44, and 190.85 hours for 1K, 3K, and 6K, with 9K omitted and estimated to exceed one month. By contrast, MoCo-AIS runtime is measured in seconds and includes both embedding inference and cosine distance matrix computation. The Transformer requires 0.66 s inference plus 0.01 s distance for 1K, 1.34 s plus 0.01 s for 3K, 2.08 s plus 0.02 s for 6K, and 2.94 s plus 0.05 s for 9K. The paper states that this corresponds to a speedup on the order of 7.
6. Interpretation, limitations, and research directions
MoCo-AIS is best understood as both a similarity-learning method and a unifying experimental protocol for maritime trajectory representation learning (Song et al., 16 Jun 2026). Its substantive contribution is not merely the use of contrastive learning, but the systematic adaptation of query-key momentum encoding, queue-based negative sampling, maritime-specific preprocessing, and trajectory-specific augmentations to AIS trajectory retrieval, all under a framework in which encoder backbones can be compared fairly.
Several clarifications are important. MoCo-AIS is not a supervised approximation to Hausdorff or DTW, and its objective does not force it to reproduce classical geometric rankings. The paper explicitly notes that learned embeddings do not necessarily match Hausdorff or DTW neighbor orderings because InfoNCE optimizes relative structure in latent space rather than approximation of a specific distance. This is presented both as a limitation and as a design choice: the model is intended to learn a richer notion of similarity than one fixed handcrafted metric.
The framework also has clear limitations. Performance depends on augmentation design, and some backbones—especially Transformer and TCN—are less robust under regional distribution shift. The empirical scope is centered on retrieval rather than downstream tasks such as anomaly detection or vessel behavior classification. Cross-region degradation indicates that learned representations are partly region-specific, which limits universal transfer even when same-region retrieval is nearly perfect. The paper therefore treats transferability, negative-sampling strategy, queue design, and augmentation diversity as open research problems.
Future directions are stated explicitly. The authors suggest improving the balance of positive and negative learning, refining queue structure and negative sampling, increasing augmentation diversity, testing more advanced contrastive variants such as MoCo-v2 and MoCo-v3, exploring alternative self-supervised paradigms such as SwAV and BYOL, and evaluating the learned embeddings on downstream maritime tasks. In that sense, MoCo-AIS defines not a closed solution but a reusable foundation for scalable, label-free vessel trajectory similarity learning.