<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Vessel Trajectory Prediction Using Robust AIS Preprocessing and Dual-Self-Attention GRU</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Marilena Sinni</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Dimitris M. Kyriazanos</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>National Centre for Scientific Research "Demokritos", Institute of Informatics and Telecommunications (IIT), Patr. Gregoriou E &amp; 27 Neapoleos</institution>
          ,
          <addr-line>Athens</addr-line>
          ,
          <country country="GR">Greece</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2025</year>
      </pub-date>
      <abstract>
        <p>Precise forecasting of vessel movements is crucial for efective maritime trafic monitoring and management. Automatic Identification System (AIS) data ofer rich information for trajectory prediction but sufer from irregular sampling, missing values, noise, and transmission errors that complicate modeling. To address these challenges, we propose a two-stage forecasting framework: first, a comprehensive preprocessing pipeline performs data cleaning, feature extraction, anomaly correction, and interpolation to produce consistent trajectories; second, an enhanced GRU network augmented with a dual-head self-attention layer jointly predicts future vessel positions, speed, and course up to 7 hours ahead. We evaluate our method on real AIS data from the port of Brest, France, and demonstrate that it outperforms LSTM, standard GRU, and single-head attention baselines in both loss and error metrics. These results highlight the efectiveness of combining rigorous data denoising with a tailored deep-learning architecture for accurate multi-step vessel trajectory forecasting.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;AIS data preprocessing</kwd>
        <kwd>Future trajectory forecasting</kwd>
        <kwd>Gated Recurrent Units</kwd>
        <kwd>Self-attention</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>Accurate forecasting of vessel trajectories is fundamental to safe and eficient maritime trafic
management. With global shipping carrying over 80% of world trade by volume, port authorities and coastal
surveillance systems depend on reliable predictions of vessel movements to prevent collisions, optimize
trafic flow, and ensure environmental compliance.</p>
      <p>
        The AIS provides the primary data source for these forecasts. The International Maritime Organization
(IMO) mandates AIS, which uses VHF transmissions to relay dynamic data (e.g., position, speed, course)
and static data (e.g., MMSI, vessel type, voyage info) [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. Despite its richness, AIS sufers from irregular
sampling intervals (from seconds to hours), missing or corrupted records (e.g., spurious land-based
“jumps” or implausible speeds), and heterogeneous vessel behaviors (cargo ships, tankers, fishing boats,
etc.), all of which pose significant challenges for machine learning models. Many works have analyzed
the AIS data errors and proposed preprocessing methods, such as correcting AIS errors [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], simplifying
[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] and compressing the vessel trajectory data [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
      </p>
      <p>
        Future trajectory forecasting is an active research domain, with a variety of techniques explored
for vessel trajectory prediction [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. Existing methods utilize Recurrent Neural Networks (RNN) [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ],
bidirectional Long Short-Term Memory (LSTM) and Gated Recurrent Unit (GRU) [
        <xref ref-type="bibr" rid="ref7 ref8">7, 8</xref>
        ], Transformer [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ],
and Attention-based architectures [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] for AIS-based future location forecasting, as well as
intervalbased future location prediction [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ], each employing its own preprocessing strategy.
      </p>
      <p>The key challenge is to bridge the gap between the complexities of AIS data preprocessing and the
need for accurate future trajectory forecasting. To address this, we propose a rigorous data analysis
pipeline alongside a prediction model that estimates both vessel position and kinematic variables
speed and course - using a GRU architecture enhanced with a dual-head self-attention layer. The main
contributions of this paper are summarized as follows:
• A comprehensive preprocessing pipeline for AIS trajectories, incorporating noise filtering,
interpolation of missing values, and normalization ensuring high-quality, analysis-ready sequences.
• A robust sequence forecasting model, combining a single-layer GRU with a dual-head
selfattention mechanism that enhances prediction accuracy.
• A multi-task output design to jointly predict future vessel position, Speed Over Ground (SOG),
and Course Over Ground (COG) up to 7 hours ahead, significantly outperforming LSTM and
standard GRU baselines.</p>
      <sec id="sec-1-1">
        <title>1.1. Overview</title>
        <p>The remainder of this paper is organized as follows. Section 2 discusses the related work. In section 3
the GRU+self-attention forecasting architecture is described. Experimental setup, evaluation metrics,
and results are presented in Section 4. Finally, Section 5 concludes the study and discusses directions
for future research.</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>2. Related work</title>
      <sec id="sec-2-1">
        <title>2.1. AIS data preprocessing</title>
        <p>
          Several works exist in AIS data preprocessing addressing the aforementioned errors. In [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ], the authors
propose a preprocessing model consisting of data cleaning, trajectory extraction, and compression
stages, where the Douglas–Peucker (DP) algorithm is used to reduce data size while preserving key
trajectory information. This work keeps the sparse sampling of the dataset that is created after the
compression and prepares the dataset for trajectory clustering.
        </p>
        <p>
          Building on the identification and categorization of AIS data errors, Zhao et al. [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ] develop a
systematic framework that addresses inaccuracies in three dimensions: physical integrity, spatial logical
integrity and time accuracy. For physical integrity, they filter out implausible values, such as latitudes
beyond ±90°, unrealistically high speeds over ground, and tracks with too few points or missing static
information and correct or discard those records. To improve spatial logical integrity, they detect and
eliminate sudden, illogical jumps in vessel position as well as conflicts in MMSI assignment that lead
to overlapping tracks or land-crossing anomalies. In the time domain, they address timestamp delays
and random resets using kernel density estimation and apply a time-gap threshold (e.g., 10 minutes) to
reconstruct consistent trajectories. Through this combination of threshold-based partitioning, statistical
correction and association filtering, their method retains over 97% of the original AIS records while
markedly improving the quality and usability of trajectory data for maritime trafic monitoring and
navigation applications.
        </p>
        <p>
          Concerning that our goal is to prepare the AIS dataset for tasks such as trajectory prediction or
anomaly detection, we reviewed several studies that address both tasks. These approaches typically
follow a pipeline that begins with AIS data preprocessing to remove outliers and prepare clean inputs,
followed by trajectory prediction of the vessel’s next expected position, speed and course, and finally
anomaly detection based on deviations from the predicted trajectory. Studies consistently emphasize
sanitizing raw inputs by removing invalid records like positions on land, impossible speeds (e.g., &lt;0
knots or &gt;30 knots), incorrect MMSI formats, and null values [
          <xref ref-type="bibr" rid="ref12 ref13 ref14">12, 13, 14</xref>
          ]. Following this core validation,
trajectory structuring is applied to define coherent voyages; this involves segmenting data streams
using maximum time-gap thresholds (typically 2-4 hours) and discarding tracks deemed too short for
meaningful analysis (e.g., &lt;4 hours or fewer than 36 points) [
          <xref ref-type="bibr" rid="ref13 ref14">13, 14</xref>
          ]. To handle irregular reporting
intervals and missing data, temporal regularization is then performed through resampling at fixed
intervals (ranging from 1 to 10 minutes) using interpolation methods like inverse distance weighting [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ]
or linear interpolation [
          <xref ref-type="bibr" rid="ref15">15</xref>
          ]. Beyond these foundational steps, some approaches incorporate advanced
ifltering, such as excluding stationary points (SOG &lt;1 knot), removing statistical outliers based on
trajectory variance [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ], or repairing implausible kinematic sequences (e.g., unrealistic accelerations
or sudden position jumps) [
          <xref ref-type="bibr" rid="ref14">14</xref>
          ]. The studies that perform the most analytical preprocessing [
          <xref ref-type="bibr" rid="ref12 ref14">12, 14</xref>
          ],
correcting the most inherent errors of the data, are the works that achieve better results in the prediction
step.
        </p>
      </sec>
      <sec id="sec-2-2">
        <title>2.2. Future location prediction</title>
        <p>
          In recent years, several advancements have been made in the trajectory forecasting problem using
NNbased prediction techniques. The authors in [
          <xref ref-type="bibr" rid="ref16">16</xref>
          ] propose an extended sequence-to-sequence model based
on GRU networks for short-term vessel trajectory prediction using AIS data, demonstrating improved
stability over LSTM and standard GRU baselines when forecasting future positions on Yangzi River routes,
especially in multi-step scenarios where traditional models tend to lose accuracy. Similarly, Capobianco
et al. [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ] leverage sequence-to-sequence deep learning models with encoder–decoder RNNs and attention
mechanisms to predict vessel trajectories from historical AIS data. Further innovations include Bi-LSTM
approaches that combine trajectory denoising with standardized time-series formatting, achieving
notable improvements in prediction accuracy [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ], and transformer-based models like TrAISformer,
which enable long-term forecasting with errors under 10 nautical miles over 10-hour horizons through
high-dimensional AIS representations [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ]. Another study explores trajectory prediction of sea surface
targets using LSTM enhancing prediction accuracy by integrating attention mechanisms to better
capture temporal dependencies [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]. In congested port waters, Wang et al. [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ] propose a Bi-GRU-based
model specifically designed for predicting vessel berthing trajectories. Trained on AIS data from Tianjin
Port, their approach demonstrates higher accuracy and lower prediction error compared to traditional
RNN models such as LSTM and GRU, highlighting the efectiveness of Bi-GRU in dense and complex
maritime environments. Although these works focus solely on position (latitude/longitude) prediction,
our interest in this work also includes predicting SOG and COG. Qi et al. in [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ] developed a CNN-LSTM
model that specifically predicts the vessel’s next position, SOG and COG, as a precursor to anomaly
detection task, demonstrating the value of multi-feature prediction in maritime applications. Similarly,
Zhang et al. [
          <xref ref-type="bibr" rid="ref14">14</xref>
          ] proposed a bi-GRU model that predicts position, SOG and COG to support anomaly
detection tasks.
        </p>
        <p>
          Unlike threshold-based filtering and simple moving average (MA) correction, [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ], our preprocessing
pipeline enforces kinematic constraints (e.g., acceleration limits) and iteratively refines trajectories
through physics-aware outlier correction (Section 3.1.3), preserving realistic vessel behavior. While there
are recent works that predict SOG/COG along with position, [
          <xref ref-type="bibr" rid="ref12 ref14">12, 14</xref>
          ], our unified output design forecasts
longer horizons (7 hours) and handles COG’s circular nature via cosine similarity loss. Additionally,
several studies have addressed the trajectory prediction problem using GRU [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ], biGRU [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ], and attention
mechanisms [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]. However, to the best of our knowledge, no prior work has leveraged a GRU equipped
with two self-attention heads.
        </p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3. Methodology</title>
      <p>This study follows a step-by-step methodology to create a solid dataset, clean of outliers and irregularly
sampled vessel trajectories and perform eficient next-point trajectory prediction. Our forecasting
model is a GRU encoder augmented with a dual-head self-attention layer, trained to predict vessel’s next
geographic position (latitude and longitude), SOG and COG. This section details both the preprocessing
steps applied to the raw AIS data and the architecture of the prediction framework.</p>
      <sec id="sec-3-1">
        <title>3.1. Data preprocessing</title>
        <p>Data preprocessing addresses AIS flaws, mentioned in 2, in terms of physical errors, spatial
inconsistencies, and temporal inaccuracies.</p>
        <sec id="sec-3-1-1">
          <title>3.1.1. Data cleaning</title>
          <p>
            Specifically, for each vessel, this work leverages some standard data cleansing operations including:
removing duplicate records (i.e., entries with identical timestamps or timestamps less than one second
apart), elimination of rows with column data for SOG with a value of 0. Additionally, all points with
SOG greater than 30 (outside of normal speed values) and COG outside 0-360 were removed. Also, in
order to exploit the static information of the dataset, vessels with ship type out of the oficial boundaries
(20-90), according to [
            <xref ref-type="bibr" rid="ref17">17</xref>
            ], were filtered out.
          </p>
        </sec>
        <sec id="sec-3-1-2">
          <title>3.1.2. Trajectory extraction</title>
          <p>
            Trajectory extraction groups AIS data by MMSI to form vessel-specific trajectories [
            <xref ref-type="bibr" rid="ref4">4</xref>
            ]. Since a single
vessel can make multiple passes, it is essential to segment its trajectory accordingly. First, each vessel’s
points are chronologically sorted, then the time diference between successive records is computed and
new trajectory is started whenever this gap exceeds 10 minutes. We also split tracks exceeding 24 hours
or containing more than our 24-point minimum, discarding shorter ones as uninformative. Finally, we
iflter out trajectories with an average SOG below 1 knot to remove stationary vessels, retaining only
actively moving tracks.
          </p>
        </sec>
        <sec id="sec-3-1-3">
          <title>3.1.3. Speed and position anomaly correction</title>
          <p>To ensure the quality of the extracted trajectories, we implement two anomaly correction methods:</p>
          <p>Speed outlier correction method prevents unrealistic jumps in SOG. Physically implausible
accelerations or decelerations in vessel speed were detected and corrected. Given a maximum allowed
acceleration (max) and deceleration (max), we enforce the following constraints in each trajectory:
∆ SOG = |SOG − SOG− 1|
∆ SOG ≤
{︃max · ∆  if accelerating</p>
          <p>max · ∆  if decelerating
where (max) and (max) were fixed in 0.15 knots/s (this value is approximately the average of
acceleration for all ships) and ∆  =  − − 1 is the time diference in seconds. So, if a violation is
detected, the erroneous SOG value is replaced by time-weighted average of its neighbors:
SOGcorrected = ∆  · SOG− 1 + ∆ − 1 · SOG+1</p>
          <p>∆ − 1 + ∆</p>
          <p>Position outlier correction detects unrealistic displacements using kinematic constraints (maximum
allowed movement per timestep). The maximum allowed displacement ∆  from point i-1 to i is
derived from:
where − 1 = SOG− 1 · 0.514 (knots → m/s), and max = 0.15 knots/s · 0.514 (→ m/s²).
The actual displacement ∆  is computed in UTM coordinates (meters):</p>
          <p>∆  = √︀( − − 1)2 + ( − − 1)2
If ∆  &gt; ∆  , we further check the next segment  →  + 1 to avoid overcorrection. If both
segments violate constraints, the point is flagged for correction. Once an outlier is identified, an
interpolation-based method is applied to perform the correction.</p>
          <p>corrected = − 1 + ︂(  − − 1 )︂
+1 − − 1
(+1 − − 1)
(1)
(2)
(3)
(4)
(5)
corrected = − 1 + ︂(  − − 1 )︂</p>
          <p>(+1 − − 1)
+1 − − 1</p>
          <p>The algorithm operates iteratively to progressively refine data corrections, as single-pass approaches
often introduce new anomalies while resolving existing ones. Based on empirical evaluation on the
selected dataset, we determined that three iterations provide a balanced trade-of between correction
accuracy and computational eficiency.
(6)</p>
        </sec>
        <sec id="sec-3-1-4">
          <title>3.1.4. Resampling</title>
          <p>The final preprocessing step involves resampling trajectory points to uniform 1-minute intervals. This
converts irregularly sampled data into temporally consistent sequences, helping models learn clearer
time-based patterns and reducing noise from variable sampling rates. After segmentation (Section
3.1.2), which limits gaps between points to under 10 minutes, we chose a 1-minute interval, close to
the mean sampling rate, to balance data smoothing with movement fidelity. Missing SOG values are
recalculated using distance over time between interpolated positions. For COG, angular unwrapping is
used to handle 0°/360° discontinuities, allowing smooth linear interpolation before rewrapping to the
[0°, 360°) range.</p>
        </sec>
      </sec>
      <sec id="sec-3-2">
        <title>3.2. Trajectory Prediction Framework</title>
        <sec id="sec-3-2-1">
          <title>Architecture and hyperparameters</title>
          <p>This work employs a GRU-based neural network with multi-head attention to predict subsequent
trajectory points. The architecture features an input layer, a recurrent layer (GRU) and a dual-head
attention block. During training, the model processes normalized sliding windows of vessel trajectories,
with inputs containing five temporal features (normalized position, SOG, and COG represented as
sine-cosine components) and outputs predicting the subsequent position, speed, and course. The model
structure is illustrated in Figure 1.</p>
        </sec>
        <sec id="sec-3-2-2">
          <title>Input Layer</title>
          <p>The input layer ingests fixed-length sequences of normalized trajectory points. Each raw trajectory
point  = (, , ,  ) where ,  are longitude/latitude,  is SOG, and  is COG, is transformed into
a feature vector ′ = (︀ , , , cos  , sin  ︀) , where position coordinates (, ) are converted to
UTM (meters), and along with speed are z-score normalized. Course  is converted to radians  = 180 
and then mapped to sine-cosine components to avoid discontinuities at 0∘ /360∘ .</p>
          <p>Sequential patterns are extracted via overlapping sliding windows of length  = 5 over each vessel’s
trajectory:</p>
          <p>= {˜, ˜+1, ˜+2, ˜+3, ˜+4},  = ˜+5,
with  = 0, . . . ,  − 6, where M is the length of the trajectory. Each window shares four points with
the previous one, ensuring smooth transitions and maximal use of the trajectory data for predicting the
immediate next point.</p>
        </sec>
        <sec id="sec-3-2-3">
          <title>GRU Layer</title>
          <p>The recurrent base consists of a single-layer GRU with hidden size ℎ = 256. At each time step , the
GRU updates its hidden state ℎ by combining the current input ˜ with the previous state ℎ− 1:
ℎ = GRU(︀ ˜, ℎ− 1)︀</p>
          <p>
            It generates full sequences of hidden states  = {ℎ1, ℎ2, ..., ℎ } ∈  × 256, where  = window
length. The GRU [
            <xref ref-type="bibr" rid="ref18">18</xref>
            ] uses gating mechanisms (update/reset gates) to control information flow,
addressing vanishing gradients in standard RNNs. This enables efective modeling of temporal dependencies in
vessel trajectories.
          </p>
        </sec>
        <sec id="sec-3-2-4">
          <title>Self-Attention Layer</title>
          <p>
            Following the GRU encoder, a dual-head self-attention mechanism [
            <xref ref-type="bibr" rid="ref19">19</xref>
            ] refines the sequence
representation through contextual aggregation. It operates on the entire GRU output sequence  ∈ R × 256,
enabling each timestep to dynamically attend to all others. The mechanism first projects  into
combined query, key, and value representations  = ,  = ,  = , 
These projections are split into  = 2 heads by reshaping the 256-dimensional features into pairs of
128-dimensional heads, producing (), (),  ()
attention is computed as head() = softmax ︁( ()(())⊤ )︁
∈
 × 128 for each head . Scaled dot-product
          </p>
          <p>() with  = 128 for the two heads. The
√
head outputs are then concatenated [head(1); head(2)] ∈ R × 256 and projected with  ∈ R256× 256.
This output combines with the original GRU states through residual connection and layer normalization:
out = LayerNorm (︁  + [head(1); head(2)]⊤ +  ,
︁)
where  ∈ R256 is a bias term, preserving temporal features while enhancing contextual awareness.</p>
        </sec>
        <sec id="sec-3-2-5">
          <title>Output Heads</title>
          <p>The two head outputs are concatenated to restore dimension ℎ = 256. The fused representation is fed
into three specialized output heads predicting: (1) Position, two-dimensional coordinates in normalized
space, (2) Speed (SOG) which is a scalar value, (3) Course (COG) a sine-cosine pair.</p>
          <p>Input Layer</p>
          <p>GRU Layer
Multi-Head Self-Attention</p>
          <p>Concatenate
First Head</p>
          <p>Second Head
Position FFN</p>
          <p>Speed FFN</p>
          <p>Course FFN
latitude, longitude
speed</p>
          <p>cos(course), sin(course)
predictions of directional angles. The final loss is given by:
( − ˆ)2 + ( − ˆ)2 + ( − ˆ)2 + ︁( 1
− (cos   cos ˆ + sin   sin ˆ)
︁)]︁
(7)</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. Experimental evaluation</title>
      <sec id="sec-4-1">
        <title>4.1. Dataset</title>
        <p>
          For the evaluation of our method, we chose the Brest dataset [
          <xref ref-type="bibr" rid="ref17">17</xref>
          ] because it is a publicly available
dataset and is the most rich in terms of complexity. The dataset includes both static and dynamic
information for various types of vessels, collected by an AIS receiver located in Brest, France, between
October 1, 2015, and March 31, 2016 (a six-month period) and are illustrated in Fig. 2a. It comprises
18,657,858 AIS records from 5,041 vessels. The number of signals recorded per vessel ranges from 1
to 1,065,741. The sampling rate varies from less than one second to several days, with an average of
approximately 15 minutes and a median of 10 seconds. The Brest dataset contains all types of ships like
cargo, tanker, passenger, fishing boats, pleasure crafts, towing and tug, military, and other. The special
thing about this dataset is that it contains rare vessel types, such as military and ’other’ categories,
which are often absent from other AIS datasets and also has extreme sampling irregularity that makes
it particularly challenging for comprehensive data preprocessing and evaluating model robustness.
        </p>
      </sec>
      <sec id="sec-4-2">
        <title>4.2. AIS data preprocessing</title>
        <p>In Section 3.1, we outlined our end-to-end preprocessing pipeline covering data cleaning, trajectory
segmentation, and temporal resampling. As shown in Figure 2, spatial integrity issues, such as land
crossings and illogical position jumps, have been efectively corrected. Table 1 summarizes the results of
speed and position anomaly corrections aimed at reinforcing kinematic consistency, while Table 2 details
the impact of each cleaning stage on dataset size, trajectory count, and vessel coverage. Trajectory
extraction enhances the dataset by partitioning continuous AIS tracks into consistent sub-sequences,
thereby increasing the diversity of vessel behavior patterns.</p>
        <p>(a) Raw BREST dataset
(b) Preprocessed dataset</p>
        <p>The key insights from the table highlight two major stages where a significant number of points were
removed. The first stage is during the speed filtering step, which eliminates vessels with either zero
SOG or unrealistic values above 30 knots. Most of the removed points had SOG = 0, indicating many
stationary vessels or erroneous readings that could have negatively impacted the prediction model.
In the second stationary trajectory filtering applied after segmentation, the rest of route segments
where vessels remain static were also removed. These steps ensure that the final dataset primarily
contains meaningful kinematic information suitable for trajectory prediction. The second stage is at
the temporal resampling which uniformly down-samples the data to fixed intervals, smoothing out
irregular sampling and improving the stability of downstream prediction models. Another observation
from the table is that the extraction procedure resulted in a significant reduction in the number of
vessels, while the total number of trajectory points decreased far less proportionally. This suggests that
the 10-minute time-gap threshold led to the creation of many short trajectories either single point or
fewer than 24 points which were subsequently discarded. As a result, many vessels with dense but
uneven sampling were removed from the dataset.</p>
      </sec>
      <sec id="sec-4-3">
        <title>4.3. Evaluation Setup - Parameter Selection</title>
        <p>This work implements and trains the model using the PyTorch framework over 200 training epochs,
with early stopping (patience=20 epochs) to prevent overfitting. The model optimization employs the
Adam optimizer with a learning rate of 0.001 and a step decay scheduler (gamma=0.1 at every 10 epochs).
This configuration promotes stable convergence during training while mitigating gradient-related issues
such as explosion or vanishing gradients. We employed a batch size of 128 and the dataset was split
into 70% for training, 10% for validation, and 20% for testing and finally, k-fold cross-validation was
used to ensure the robustness and generalizability of the model across diferent subsets of the data.</p>
        <p>To evaluate our model’s predictive performance, we apply it to the test set, which is preprocessed in
the same way as the training data. For each trajectory, we slide a window of length  over the sequence:
at each step  (where  =  + 1, . . . , ), the model observes the previous  points and predicts the -th
point. We then compare this prediction to the true value at time  to obtain an instantaneous loss . By
sliding the window across all  points, we accumulate these losses and compute the average prediction
error as follows:
 =</p>
        <p>1 ∑︁ 
 −  =+1
where  is the total number of points in the trajectory and  is the window size.</p>
        <p>To evaluate the selection of GRU with dual-head self-attention layer as the best model, we
experimented with other methods that are usually used to solve such time-series forecasting tasks. The
models tested are LSTM, GRU without attention layer and also GRU with a single-head attention layer
to justify the usefulness of the second head.</p>
      </sec>
      <sec id="sec-4-4">
        <title>4.4. Results</title>
        <p>In this section, we present the results of the prediction framework. Table 3 shows a detailed comparison
of diferent models to identify the best-performing one, and on Table 4 the rest of the performance
measurements of the best performing model are presented. While the enhanced MSE loss was used
during training, it proved insuficient on its own for evaluating model performance. Therefore, we also
report additional metrics, including the mean, median, and maximum distance errors across the entire
dataset, to provide a more comprehensive evaluation.</p>
        <sec id="sec-4-4-1">
          <title>Model</title>
          <p>LSTM
GRU
GRU+Single-head Attention Layer
GRU+Dual-head Attention Layer</p>
          <p>Self-attention layer allows the model to dynamically re-weight past time steps, enabling it to capture
long range dependencies and abrupt maneuvering behaviors that purely recurrent layers may overlook.
By computing pairwise afinities across the entire sequence, self-attention can emphasize critical
context—such as an earlier course change or speed adjustment when predicting the next point. In our
ablation (Table 3), adding a single attention head already yields a substantial drop in median error (from
86.3 m to 63.1 m) by focusing on the most informative time steps. Splitting into two parallel heads further
boosts performance reducing interference between these distinct modalities. This dual-head design
leads to the lowest overall loss and best error statistics (median 58.5 m, average 90.4 m), demonstrating
that two parallel attention heads significantly improve trajectory prediction accuracy.</p>
          <p>For further evaluation, we select two vessels with diferent total prediction errors as examples. Figure
3 shows the experimental results for one vessel with an average distance error of 25.9 m. Specifically,
Figure 3a shows the ground truth represented by a blue line and the predicted points marked as red
crosses, and the other two figures 3b, 3c illustrate the SOG and COG predictions, compared with the
ground truth. Also, Figure 4 shows the comparison charts for another vessel with an average error of
26.2 m. This vessel is particularly interesting because, from the position and SOG plots, we observe that
it remains stationary for 155 minutes; despite this, the prediction accuracy remains strong for up to 208
minutes, with the longest successful prediction extending to 7 hours. An analytical error distribution
for the two vessels is shown in Figures 5 and 6, respectively.</p>
          <p>(a) Latitude and longitude position prediction</p>
          <p>(a) Latitude and longitude position prediction</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>5. Conclusion and Future Work</title>
      <p>In this study, we presented a vessel trajectory prediction framework that combines robust preprocessing
of AIS data with a GRU-based model augmented by a dual-head self-attention layer. Using historical
AIS records from the port of Brest, France, our experiments demonstrate that:
• The proposed preprocessing pipeline successfully handles a heterogeneous dataset containing
diverse vessel types. By filtering spurious points, interpolating gaps, and normalizing features,
we reduce noise and produce smooth, analysis-ready trajectories.
• The GRU + dual-head self-attention architecture reliably forecasts future positions up to more
than 7 hours ahead. In addition to spatial coordinates, it jointly predicts SOG and COG with
strong accuracy, as evidenced by consistently low median and average error metrics.
• Incorporating two parallel attention heads, yields the best overall performance, reducing
interference between modalities and improving both loss and error statistics relative to single-head and
purely recurrent baselines.</p>
      <p>In future work, our goal is to validate the generality of our approach on additional AIS datasets
from diferent regions and trafic conditions to prove its robustness. Another goal is to compare our
forecasting performance against state-of-the-art methods in trajectory prediction benchmarks, and
specifically bidirectional RNNs and transformers, to quantify relative gains. Furthermore, we intend to
use this model as a foundation to extend to anomaly detection: by comparing live AIS streams against
our predicted trajectories, speeds, and headings, we aim to identify unusual vessel behavior in real time.</p>
    </sec>
    <sec id="sec-6">
      <title>Acknowledgments</title>
      <p>This work has received funding from the European Defence Fund programme under grant agreement
No 101103386, FaRADAI project. The views and opinions expressed are, however, those of the author(s)
only and do not necessarily reflect those of the European Union or the European Commission. Neither
the European Union nor the granting authority can be held responsible for them.</p>
      <p>Special thanks to the IIT group MagCIL and in particular research associates Christos Nikou and
Christos Sgouropoulos for their scientific support and comments.</p>
    </sec>
    <sec id="sec-7">
      <title>Declaration on Generative AI</title>
      <p>During the preparation of this work, the authors used ChatGPT, Grammarly in order to: Grammar and
spelling check. After using these tools, the authors reviewed and edited the content as needed and take
full responsibility for the publication’s content.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>Z.</given-names>
            <surname>Yan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Xiao</surname>
          </string-name>
          , L. Cheng,
          <string-name>
            <given-names>R.</given-names>
            <surname>He</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Ruan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Zhou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Bin</surname>
          </string-name>
          ,
          <article-title>Exploring ais data for intelligent maritime routes extraction</article-title>
          ,
          <source>Applied Ocean Research</source>
          <volume>101</volume>
          (
          <year>2020</year>
          )
          <fpage>102271</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>L.</given-names>
            <surname>Zhao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Shi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Yang</surname>
          </string-name>
          ,
          <article-title>Ship trajectories pre-processing based on ais data</article-title>
          ,
          <source>The Journal of Navigation</source>
          <volume>71</volume>
          (
          <year>2018</year>
          )
          <fpage>1210</fpage>
          -
          <lpage>1230</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>Z.</given-names>
            <surname>Wei</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Xie</surname>
          </string-name>
          ,
          <string-name>
            <surname>X. Zhang,</surname>
          </string-name>
          <article-title>Ais trajectory simplification algorithm considering ship behaviours</article-title>
          ,
          <source>Ocean Engineering</source>
          <volume>216</volume>
          (
          <year>2020</year>
          )
          <fpage>108086</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>I. P. N.</given-names>
            <surname>Hartawan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>I. M. O.</given-names>
            <surname>Widyantara</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Karyawati</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N. I.</given-names>
            <surname>Er</surname>
          </string-name>
          ,
          <string-name>
            <surname>K. B. Artana</surname>
            ,
            <given-names>N. P.</given-names>
          </string-name>
          <string-name>
            <surname>Sastra</surname>
          </string-name>
          ,
          <article-title>Ais data pre-processing for trajectory clustering data preparation</article-title>
          ,
          <source>in: 2021 IEEE International Conference on Aerospace Electronics and Remote Sensing Technology (ICARES)</source>
          , IEEE,
          <year>2021</year>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>5</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>X.</given-names>
            <surname>Zhang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Fu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Xiao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Xu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Qin</surname>
          </string-name>
          ,
          <article-title>Vessel trajectory prediction in maritime transportation: Current approaches and beyond</article-title>
          ,
          <source>IEEE Transactions on Intelligent Transportation Systems</source>
          <volume>23</volume>
          (
          <year>2022</year>
          )
          <fpage>19980</fpage>
          -
          <lpage>19998</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>S.</given-names>
            <surname>Capobianco</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L. M.</given-names>
            <surname>Millefiori</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Forti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Braca</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Willett</surname>
          </string-name>
          ,
          <article-title>Deep learning methods for vessel trajectory prediction based on recurrent neural networks</article-title>
          ,
          <source>IEEE Transactions on Aerospace and Electronic Systems</source>
          <volume>57</volume>
          (
          <year>2021</year>
          )
          <fpage>4329</fpage>
          -
          <lpage>4346</lpage>
          . doi:
          <volume>10</volume>
          .1109/TAES.
          <year>2021</year>
          .
          <volume>3096873</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <surname>C.-H. Yang</surname>
          </string-name>
          ,
          <string-name>
            <surname>C.-H. Wu</surname>
            ,
            <given-names>J.-C.</given-names>
          </string-name>
          <string-name>
            <surname>Shao</surname>
            ,
            <given-names>Y.-C.</given-names>
          </string-name>
          <string-name>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <surname>C.-M. Hsieh</surname>
          </string-name>
          ,
          <article-title>Ais-based intelligent vessel trajectory prediction using bi-lstm</article-title>
          ,
          <source>IEEE Access 10</source>
          (
          <year>2022</year>
          )
          <fpage>24302</fpage>
          -
          <lpage>24315</lpage>
          . doi:
          <volume>10</volume>
          .1109/ACCESS.
          <year>2022</year>
          .
          <volume>3154812</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>C.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Ren</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <article-title>Vessel trajectory prediction based on ais data and bidirectional gru</article-title>
          , in: 2020 International conference
          <article-title>on computer vision, image and deep learning (CVIDL)</article-title>
          , IEEE,
          <year>2020</year>
          , pp.
          <fpage>260</fpage>
          -
          <lpage>264</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>D.</given-names>
            <surname>Nguyen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Fablet</surname>
          </string-name>
          ,
          <article-title>A transformer network with sparse augmented data representation and cross entropy loss for ais-based vessel trajectory prediction</article-title>
          ,
          <source>IEEE Access 12</source>
          (
          <year>2024</year>
          )
          <fpage>21596</fpage>
          -
          <lpage>21609</lpage>
          . doi:
          <volume>10</volume>
          .1109/ACCESS.
          <year>2024</year>
          .
          <volume>3349957</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>T.</given-names>
            <surname>Yu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Zhang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Zhao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Yang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W.</given-names>
            <surname>Guo</surname>
          </string-name>
          ,
          <article-title>Vessel trajectory prediction based on modified lstm with attention mechanism</article-title>
          ,
          <source>in: 2024 4th International Conference on Neural Networks, Information and Communication</source>
          Engineering (NNICE), IEEE,
          <year>2024</year>
          , pp.
          <fpage>912</fpage>
          -
          <lpage>918</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>E.</given-names>
            <surname>Chondrodima</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Pelekis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Pikrakis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Theodoridis</surname>
          </string-name>
          ,
          <article-title>An eficient lstm neural network-based framework for vessel location forecasting</article-title>
          ,
          <source>IEEE transactions on intelligent transportation systems 24</source>
          (
          <year>2023</year>
          )
          <fpage>4872</fpage>
          -
          <lpage>4888</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Qi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Yang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Bai</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Liu</surname>
          </string-name>
          ,
          <article-title>A method for real-time detection of vessel abnormal behavior based on cnn-lstm, Expert Systems with Applications (</article-title>
          <year>2025</year>
          )
          <fpage>128303</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>Z.</given-names>
            <surname>Xie</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Bai</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Xu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Xiao</surname>
          </string-name>
          ,
          <article-title>An anomaly detection method based on ship behavior trajectory</article-title>
          ,
          <source>Ocean Engineering</source>
          <volume>293</volume>
          (
          <year>2024</year>
          )
          <fpage>116640</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>B.</given-names>
            <surname>Zhang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Hirayama</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Ren</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <article-title>Ship anomalous behavior detection using clustering and deep recurrent neural network</article-title>
          ,
          <source>Journal of Marine Science and Engineering</source>
          <volume>11</volume>
          (
          <year>2023</year>
          )
          <fpage>763</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>D.</given-names>
            <surname>Nguyen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Vadaine</surname>
          </string-name>
          , G. Hajduch,
          <string-name>
            <given-names>R.</given-names>
            <surname>Garello</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Fablet</surname>
          </string-name>
          ,
          <article-title>Geotracknet-a maritime anomaly detector using probabilistic neural network representation of ais tracks and a contrario detection</article-title>
          ,
          <source>IEEE Transactions on Intelligent Transportation Systems</source>
          <volume>23</volume>
          (
          <year>2021</year>
          )
          <fpage>5655</fpage>
          -
          <lpage>5667</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [16]
          <string-name>
            <given-names>L.</given-names>
            <surname>You</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Xiao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Q.</given-names>
            <surname>Peng</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Claramunt</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Han</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Guan</surname>
          </string-name>
          ,
          <string-name>
            <surname>J. Zhang</surname>
          </string-name>
          , St-seq2seq:
          <article-title>A spatio-temporal feature-optimized seq2seq model for short-term vessel trajectory prediction</article-title>
          ,
          <source>IEEE Access 8</source>
          (
          <year>2020</year>
          )
          <fpage>218565</fpage>
          -
          <lpage>218574</lpage>
          . doi:
          <volume>10</volume>
          .1109/ACCESS.
          <year>2020</year>
          .
          <volume>3041762</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          [17]
          <string-name>
            <given-names>C.</given-names>
            <surname>Ray</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Dréo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Camossi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.-L.</given-names>
            <surname>Jousselme</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Iphar</surname>
          </string-name>
          ,
          <article-title>Heterogeneous integrated dataset for maritime intelligence, surveillance, and reconnaissance</article-title>
          ,
          <source>Data in brief 25</source>
          (
          <year>2019</year>
          )
          <fpage>104141</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          [18]
          <string-name>
            <given-names>J.</given-names>
            <surname>Chung</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Gulcehre</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Cho</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Bengio</surname>
          </string-name>
          ,
          <article-title>Empirical evaluation of gated recurrent neural networks on sequence modeling</article-title>
          ,
          <source>arXiv preprint arXiv:1412.3555</source>
          (
          <year>2014</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          [19]
          <string-name>
            <given-names>A.</given-names>
            <surname>Vaswani</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Shazeer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Parmar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Uszkoreit</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Jones</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. N.</given-names>
            <surname>Gomez</surname>
          </string-name>
          , Ł. Kaiser,
          <string-name>
            <surname>I. Polosukhin</surname>
          </string-name>
          ,
          <article-title>Attention is all you need</article-title>
          ,
          <source>Advances in neural information processing systems</source>
          <volume>30</volume>
          (
          <year>2017</year>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>