Manuscript Offprint
arXiv:2610.13557Probabilistic Ship Trajectory Forecasting using Transformer Models on AIS Data
Abstract
Anticipation of vessel trajectories is an essential task when navigating at sea. This applies to both human navigators and autonomous surface vessels. Trajectory forecasting enables sub-routines such as collision avoidance to assess the situation and react accordingly in time. This paper investigates Transformer and Performer models for trajectory prediction of surface vessels in confined waters. Using widely available position data from the Automatic Identification System (AIS), candidate models are trained and evaluated. Historical information on how other vessels have moved in the local area surrounding each agent is conveyed using positional heat maps. The heat maps are generated using Kernel Density Estimation (KDE) and encoded with a Convolutional Neural Network (CNN) before entering the Transformer models. The models are trained with quantile loss to efficiently obtain a model-aware prediction interval, as this is crucial for timely collision avoidance. The proposed model architectures are shown to greatly outperform previous work while the inclusion of local heat maps enables the prediction of vessel movement that is not otherwise indicated from the previous positions.
Keywords: Trajectory Prediction, Autonomous Marine Vessels, Machine Learning, Autonomous Navigation, AIS Data
1 Introduction
Recently, autonomous surface vessels have gained notable research interest. Services such as decision support or full autonomy are envisaged to be a crucial part of the future of shipping. This, however, requires excellent situational awareness .
Situational awareness is obtained through three main steps: perception, understanding of the environment, and anticipation of how the situation develops [3]. While nearby vessels can be detected on both radar and cameras [4], estimation of future trajectories is needed if a short term path should be planned. A human navigator will use information about surrounding waters from the Electronic Chart Display and Information System (ECDIS) together with the past motion of vessels to assess the current situation. The past motion of nearby ships can be obtained e.g. by detection and tracking using radar [5, 6] or tracking camera detections [7, 8]. Commercial vessels and some large leisure crafts use Automatic Identification System (AIS) to broadcast current position, speed and heading among others.
Trajectory forecasting is a widely researched area, especially for pedestrian motion prediction. Many methods use Long short-term memory (LSTM) networks for motion prediction such
This work was carried out while the author was with the Automation and Control Group, Department of Electrical Engineering, Technical University of Denmark, Kgs. Lyngby, Denmark. The author is now an independent researcher.
as [9–11]. While Recurrent neural networks (RNN) are commonly used for tasks such as time series forecasting and Natural Language Processing (NLP), Transformer networks, first described in [12], have recently had immense success, especially for NLP, where models such as Bidirectional Encoder Representations from Transformers (BERT) [13], BART [14] and GPT-3 [15] outperformed previous LSTM models. Transformer networks have also shown their strengths in pedestrian trajectory forecasting [16], where they were shown to outperform the previous LSTM state of the art. One drawback of Transformers is that the computational burden increases quadratically with input sequence length. Multiple recent studies have investigated methods to introduce Transformer models with linear complexity [17, 18], though these often do not match the performance of the original Transformer. One study introduced the Performer [19] that incorporates Fast Attention Via Positive Orthogonal Random Features (FAVOR+) and obtains linear complexity. Their Performer-ReLU model showed to outperform a similar Transformer configuration with quadratic complexity while being more efficient.
If a trajectory forecast is to be used for risk assessment in the area of short term path planning for autonomous vessels, it is crucial not to obtain a single prediction, but to produce a prediction interval in which the observed vessel could go. A prediction interval can be obtained in numerous ways. For example by using Monte Carlo dropout [20], using Bayesian neural networks with probabilistic layer weights [21] or training the model as a conditional generative adversarial network (GAN) [22]. Common for these methods is that a prediction interval is not obtained directly from the network, but by running the network multiple times to approximate a prediction interval. This might result in a misleading prediction interval, as the network is trained to output a prediction close to the mean prediction and the prediction interval is approximated by drawing from a distribution. To circumvent these problems, this work utilizes quantile loss [23] to estimate prediction quantiles during training, which generates a model that is both aware of its prediction interval and can supply this in a single forward pass.
Maneuver-based methods use the information contained within the COLREGs or available historical data, such as AIS. Hexeberg et al. [25] described a single-point neighbor search method for long-term trajectory prediction using AIS data. Here, data points within a set distance to the target vessel were used to estimate the course and speed for the next timestep if the used points had a similar heading. The method could therefore model the mean trajectory for a vessel. A drawback to such an approach is the difficulty of predicting a trajectory that differs from the usual fairways. Rong et al. [26] fitted a Gaussian process on AIS data for a southbound shipping route. The Gaussian process was used to predict the lateral movement at discrete time steps while historical acceleration data was used for longitudinal movement estimation. Murray et al. [27] used clustered AIS data to predict the future trajectory of a target vessel based on cluster points near that of the target. An autoencoder approach was utilized for the generation of future movement by exploring the latent space, thereby generating a prediction interval. By using unsupervised learning [28] developed a method for AIS data that proposes potential routes and endpoints for the target vessel. The proposed routes are given a probability that is updated iteratively during run time. Tang et al. [29] used a LSTM to forecast the future position of a marine vessel using AIS data. The LSTM was trained to output the parameters of a bivariate gaussian distribution, describing the potential position of a vessel at a chosen point in the future.
relative to the amount of input data used. Schöller et al. [30] used an LSTM-GAN to forecast marine vessel trajectories using AIS data. The network had an auxiliary input consisting of CNN features from an AIS heat map of the area surrounding the vessels. It was found that including information about how previous vessels had moved in a given area would increase performance significantly enabling the method to predict movement which would not otherwise be indicated in the previous positions.
In the domain of pedestrian trajectory prediction, [11] proposed a method for encoding interaction between agents called social pooling by including other agents within a grid. The pooling method was used in training an LSTM-GAN and enabled the generation of socially aware trajectories. Sadeghian et al. [10] extended this idea by modeling social interactions using attention. Furthermore, a CNN was included to model the physical features of the environment. The most recent addition to the social GANs, [9], used a graph attention network [31] for social interaction which had the advantage of being invariant to the number of agents in the scene. Even though the methods with social interaction obtained better results than similar methods without social encoding, [16] argued that using the original Transformer network ([12]) for time series forecasting yielded better results, even without social modeling, obtaining state of the art results on common pedestrian trajectory data sets. Giuliari et al. [16], obtained prediction intervals by using a quantized version of the Transformer that performed step classification instead of regression, thereby enabling probabilistic modeling from the softmax output.
The bottlenecks of current AIS-based vessel trajectory prediction schemes are several: Some current methods only take characteristics of the investigated vessel into account, environmental factors such as water depth, land and navigational fairways are thus unknown and not modeled. Situations can therefore occur where a trajectory is predicted to go through land, which is infeasible. Other methods have the opposite problem. Clustering methods solely rely on the past movements of other vessels in the local area. The predicted trajectory will thus be some average of the trajectories of other similar vessels without directly taking the past movement of the investigated vessel into account. Finally, existing models use sampling-based approaches to obtain probabilistic predictions, which drastically increase inference time.
This paper, therefore, proposes a hybrid approach using Transformer models that uses the movement characteristics of the individual investigated vessel while considering the positional probability distribution of the local area. Most time-series-based approaches to ship trajectory prediction rely on recurrent neural networks such as LSTM [32] and Gated Recurrent Unit (GRU) [33]. Even though Transformer models have gained immense popularity in recent years, they have, to the best of the author's knowledge, not been investigated in the context of trajectory prediction for marine vessels. To forecast future trajectories, the proposed method uses a vessel's past movements together with a novel approach to including spatial probability distributions in form of positional heat maps in Transformer model. A probabilistic output is supplied without the need for Monte Carlo sampling by using quantile loss. The model therefore directly outputs a prediction interval useful for risk assessment.
The rest of this paper is structured as follows: Section 2 discusses the related work done in the area of trajectory forecasting. Section 3 introduces the data used in this research. Section 4 describes the model architectures investigated in this work and explains the difference between the Transformer and the Performer. Section 5 lists the training parameters used and introduces the loss function. Section 6 introduces the performance metrics used for evaluation and discusses the results. Finally, Section 7 presents the conclusions.
3 Data
The data processed in this work comes from AIS messages. AIS is an automatic tracking system in which ships send out relevant information about themselves. AIS messages include information such as unique identification (MMSI), position, course over ground, speed, and destination.
harbor. Vessels of more than 300 gross tonnage, passenger ships, and fishing vessels with a length above 15 meters are obligated to have an AIS transceiver installed, while recreational crafts can choose whether or not to install AIS. The frequency of dynamic messages varies from once every 2 seconds to once every 3 minutes depending on vessel speed and activity. Static information is broadcast once every 6 minutes. The AIS messages used in this work are recorded in Danish waters and are publicly available.
For the application of trajectory forecasting, the AIS messages are filtered to include only the position of the given vessel in GPS coordinates. While other attributes such as speed over ground, heading, course over ground, length, width, and draft affect the future movements of a vessel, it was chosen to solely rely on positional data to obtain a more general approach that can be transferred to using other sensors during deployment such as radar and visual tracking. Furthermore, information such as speed and heading is easily derived from the positional data by the model.
The raw AIS data is processed by first removing tracks with an average velocity below 0.5 knots to reject stationary objects such as buoys. As mentioned, the frequency of AIS messages varies depending on vessel activity. The methods discussed in this paper expect temporally equidistant data, which is why the positional data is resampled using linear interpolation, such that each data point is 20 seconds apart. Using the timestamp of each point, samples are resampled to the nearest 20-second mark, weighted by temporal distance to said mark. Temporal gaps are linearly filled from the nearest resampled data points as seen in Figure 1. For deployment, the method suggested in this paper will run only when a new AIS message arrives such that a trajectory is not predicted using extrapolated data.
Data processing

Figure 1: Example of linear interpolation of positional AIS data.
When two vessels approach each other, the smallest distance between them during the encounter is called Closest point of approach (CPA). For a given situation, the time left before CPA is called time to CPA (TCPA). Given that a navigator would like to be able to react to a potentially hazardous situation within a TCPA of 10 minutes, the models assessed in this paper will produce an output of 30 predicted timesteps, corresponding to 10 minutes.
Specifically, given a set of vessels within an area, for a vessel , the most recent positions are provided as , in Cartesian coordinates . It is desired to forecast the future positions of the vessel for predicted time-steps, where and . To make the prediction invariant to global position of the vessels, the latitude and longitude position at each time step in is converted to relative coordinates in meters relative to . The conversion from GPS coordinates to relative coordinates is done using the haversine formula.
The AIS messages used in this paper are sampled in the areas near various heavily trafficked trade routes in Danish waters. The areas are
• The Great Belt: between the two islands of Zealand and Funen.
-
Hven: The area around the Swedish island Hven, where traffic goes between Denmark and Sweden.
-
Falsterborev: The area south of Sweden where traffic from the Baltic Sea passes through.
The areas from which the data is collected have been selected due to a large amount of traffic, and due to the fairways of the areas having sudden turns. The data is collected over the span of one month. Figure 2 shows heat maps generated using AIS messages from the areas. Here, the shipping routes and fairways from the sea charts are clearly seen as the white lines. The sudden turns seen in the heat map come from the deep-water routes described in the sea charts. The black space between the fairways is the separation zone of the particular route. The heat map shows that there is a clear tendency of vessels with AIS following the fairways. A model with awareness of how previous vessels have moved in the local area is therefore preferable.
Table 1 shows an overview of the training data used in this paper.
Table 1: Overview of the training data.
| Area | Bounding rectangle | # Trajectories | Period |
|---|---|---|---|
| The Great Belt | 55°4.2259'N, 10°0.1282'E55°26.8333'N, 11°19.216'E | 574 171 | September 2018 |
| Hven | 55°47.9365'N, 12°23.3764'E56°8.0261'N, 13°3.6935'E | 653 979 | May 2018 |
| Falsterborev | 55°12.6989'N, 12°27.1789'E55°26.144'N, 12°50.4963'E | 408 070 | September 2018 |

(a) The Great Belt
(b) Hven
(c) Falsterborev
Figure 2: Heat maps of AIS data from the areas around The Great Belt, Oresund, and Falsterborev. The heat maps are generated using kernel density estimation.
4 Transformer type networks
The Transformer architecture is used to predict the future motion of an agent based on its past movement together with a positional probability distribution from the area. This section describes the inputs and outputs of the model, the general encoder-decoder Transformer structure, the difference between the Transformer and the Performer, and how historical AIS data is included in the models.
4.1 Input & Output
Transformer models were originally developed for NLP, where each input word is embedded into a floating-point value of a higher dimensional space using a learned lookup table with a known dictionary size. As this paper operates on positional data, a dictionary size is not defined. The inputs are therefore embedded to a -dimensional space using a linear transformation , where is a learnable weight matrix. The output of the model is the probabilistic prediction quantiles for the future trajectory of the -th agent , where is the output embedding of the model decoder.
4.2 Model Architecture
The model has three main components, an encoder, a convolutional neural network (CNN) for spatial feature extraction and a decoder which are described below. An illustration of the model architecture is shown in Figure 3.
Encoder. The encoder is tasked with encoding the temporal features of a vessel's movement into a vector representation. The input of the encoder stack is the past positions of the observed vessels projected into -dimensional space using a linear projection. The encoder consists of a stack of N layers. Each layer has a Multi-Head Attention step followed by a feed-forward neural network (FFNN) with ReLU activation as suggested by Vaswani et al. [12]. Each step is followed by layer normalization with a residual connection, denoted by the “Add & Norm” block in Figure 3. All sub-layers in the model have an output dimension of .
Spatial feature extractor. It is desired to include information about the marine fairways in the local area around each vessel, as these can indicate an upcoming trajectory change that past movement may not convey. In this work, such information is included in the form of an image which is passed to a CNN. One way of generating an image of the underlying fairways is by looking at the heat map of vessel locations, as large vessels are bound to primarily follow the fairways. Kernel density estimation (KDE) is suitable for generating such an image as it is a non-parametric way to estimate the probability density function of the data, thereby generating a heat map. The heat map is generated by a 2D KDE using the fastKDE algorithm [34]. A heat map is generated for the entire area of the data and is cropped to the local area around a given vessel, as only the local area influences short term future movement. The cropped heat map of the local area is used as input to a CNN which encodes the spatial features into a vector representation. The output of the spatial feature extractor is concatenated with the encoded temporal features from the encoder stack and projected to dimensional space using a linear projection.
Decoder. The decoder takes the merged spatial and temporal information from the spatial feature extractor and encoder and uses it to predict a future trajectory with a 95% prediction interval. The decoder consists of a stack of N layers. The merged features from the encoder stack are passed through two multi-head attention layers followed by a FFNN. The second multi-head attention step works in a recurrent fashion by being fed the output of the previous decoder layer. A linear transformation converts the output of the decoder from model dimension to the three prediction quantiles, each in cartesian coordinates, , where is the output embeddings produced by the decoder stack and is a learnable weight matrix.
Multi-head attention. Attention is essentially a map between a query and a set of key and value pairs that produce an output. The output consists of a weighted sum of the values, weighted based on a compatibility function between the query and the corresponding key. By

Spatial Feature Extractor
Encoder stack
Decoder stack
Figure 3: Model illustration of the implemented Transformer architecture.
weighting the inputs, the attention module enables the model to focus on the parts of the input that are most important to the task. In order to be true to the original Transformer paper [12], the attention type used in this particular case is Scaled Dot-Product Attention which is defined in Equation 1.
where Q contains the queries, K the keys, V the values and d is the dimension of the aforementioned. Here, the weighting is computed using the softmax function
where K is the number of entries in z. Instead of having a single attention layer, the Transformer model uses multi-head attention. Here, the queries, keys and values are first linearly projected h times to , and dimensionality respectively. The attention mapping is then run on each of the h heads in parallel and the outputs concatenated, as described in Equation 3.
Performer models. Performer models differ from the traditional Transformer by using Fast Attention Via positive Orthogonal Random features (FAVOR+) attention instead of the regular Scaled Dot-Product Attention. While the Scaled Dot-Product Attention is quadratic in complexity due to the QK expression in equation 1, [19] introduced the linear FAVOR+ attention method, in which the attention matrix is computed by decomposition using kernel functions. Normal decomposition is not possible due to the exponential in the numerator in Equation 2. Scaled Dot-Product Attention can be rewritten to the form:
where is the attention matrix and is the all-ones vector of length . In Equation 4, the softmax function is implicitly calculated during the operation. In order to decompose , FAVOR+ use attention matrices on the form , where and is the query and key vector in and respectively. The kernel, is defined for the randomly sampled mapping :
With and having rows and respectively, an approximation of the attention mechanism with linear complexity is given by
By choosing on the form presented in Equation 7, it is possible to model most kernels and not only the before-mentioned softmax function. [19] exploits this by introducing a Transformer model with ReLU activation instead of softmax by setting in Equation 7. They call this the Performer-ReLU model and find it to outperform the traditional Transformer presented in [12].
(7)
where and are a set of chosen functions, and are random feature vectors sampled independently from a distribution (typically isotropic Gaussian, optionally orthogonalized).
5 Training Specifications
The models were trained on 1636 220 trajectories, collected over the span of a month. The trajectories were collected from the different areas presented in Table 1. The AdamW optimizer [35] was used together with a warm restart learning rate scheduler [36] with a base learning rate of , weight decay of and , as parameters for the scheduler as recommended in [35] and [36] respectively.
Both the Transformer and the Performer models have internal dimension , attentional heads with query and value of dimension , . Internal dimension was chosen conservatively as the problem at hand is computationally simple compared to the translation task that the original Transformer was built for. , and are chosen with respect to as described in [12]. The spatial feature extractor is a small CNN, with the structure presented in Table 2. The input size of was found to be sufficient to convey the positional probability density of the local area. A local heat map is generated by cropping the larger heat maps shown in Figure 2. Given the past positions of a vessel, the crop is carried out such that the latest vessel
Table 2: Structure of the spatial feature extractor. Each Conv2d block is followed by batch normalization and LeakyReLU activation.
| Operation | # Filters | Kernel | Stride | Padding | Output size |
|---|---|---|---|---|---|
| Input | - | - | - | - | |
| Conv2d | 8 | 3 | 1 | 1 | |
| Conv2d | 8 | 3 | 1 | 1 | |
| Conv2d | 8 | 3 | 2 | 1 | |
| Conv2d | 16 | 3 | 1 | 1 | |
| Conv2d | 16 | 3 | 1 | 1 | |
| Conv2d | 16 | 3 | 2 | 1 | |
| Conv2d | 32 | 3 | 1 | 1 | |
| Conv2d | 32 | 3 | 1 | 1 | |
| Conv2d | 32 | 3 | 2 | 1 | |
| Flatten | - | - | - | - | 2048 |
| Linear | - | - | - | - | 256 |
position is centered in the local heat map. The local heat map covers an area of meters.
As trajectory forecasting is meant to be used for decision support or in an autonomous system, it is desired to obtain a probabilistic prediction interval to gain insight into the uncertainty of the model and for risk assessment. In this paper, such an interval is obtained by training the models with quantile loss as described in Equation 8.
where is the number of quantiles in . Using quantile loss, the models will have three outputs, one for each quantile. Each of the three outputs will consist of the predicted trajectory for the given quantile. The training data is split such that is set aside and used for validation. Training is stopped when the validation loss has converged.
6 Results
This section discusses the performance of the different methods for trajectory prediction. Currently, the automatic radar plotting aid (ARPA) installed in most large vessels use the assumption that other vessels keep current speed and heading. Two baselines are therefore used for comparison against the proposed methods: One is a Gaussian process, the other is linear regression using the three most recent positions. The linear regression was fitted using quantile regression. Both were chosen as they represent what is currently implemented on large vessels while bringing probability to the predictions. Another comparison was done against the model architecture proposed in [30], where an LSTM-GAN was used to forecast the trajectories of marine vessels. Similarly to this paper, the LSTM-GAN used local AIS information in the form of a KDE-generated heat map to aid in the predictions. Finally, comparison is also done using Transformer models without access to the local heat maps. These models are denoted as Transformer and Performer. All tested methods have been trained on the data presented in Section 3. Evaluation is carried out on three test sets which are presented in Table 3. Two sets are from The Great Belt and Falsterborev areas, though collected during a different time period than in the training set, namely in May 2018. The other test set is gathered from an area not included in the training data. This area, Oresund, is the area around The Oresund Bridge, connecting Denmark and Sweden. The heat map of the Oresund area can be seen in Figure 4. For testing, the heat maps used for forecasting are generated using data collected during a different time period than that of the test data as to emulate how the methods would perform in a real-world scenario.
Table 3: Overview of the test data.
| Area | Bounding rectangle | Count | Period |
|---|---|---|---|
| The Great Belt | May 2018 | ||
| Falsterborev | May 2018 | ||
| Oresund | May 2018 |

Figure 4: Heat map of the Ore-sund test area, which is not part of the training data.
Each method is evaluated using three metrics: average displacement error (ADE), final displacement error (FDE) and interval accuracy (IAcc).
ADE is the average distance in kilometers between the ground truth and the mean predicted trajectory, , across all time steps.
where is the total number of vessels, is the number of timesteps predicted and is the predicted position of vessel for quantile 2 at timestep . FDE is the distance in kilometers between and at the final time step, given by
where similarly, is the total number of observed vessels. Finally, IAcc indicates the fraction of ground truth steps that lie within the quantiles of the predicted trajectory.
where is defined as
where indicates the predicted position for vessel at time for prediction quantile .
Table 4 shows the evaluation results. Both the Transformer and the Performer models achieve an average ADE of around 0.18 km, which is far better than any of the baseline methods. The average final displacement error lies at around 0.4 km, which is around half of that of the baselines. The proposed method also has superior IAcc of which indicates that the ground truth trajectory falls within the prediction interval in of the predictions.
The inference speed of the Transformer type models is also significantly faster than the baselines. The LSTM-GAN, for example, has to run multiple forward passes, in order to approximate the model prediction interval. Though, it does seem like the Performer model is slightly slower than the Transformer even though the attention module of the Performer is linear
Table 4: Evaluation results on the three test areas. ADE and FDE are given in kilometres. Inference time is the average time per prediction measured over 1000 batches with a batch size of 1 on an NVIDIA RTX 3090 GPU. The best result in each group is shown in bold.
| Method | ADE ↓ | FDE ↓ | IAcc ↑ | Inference time (ms) |
|---|---|---|---|---|
| The Great Belt | ||||
| Linear | 0.415 | 1.054 | 7.0% | 14.5 |
| GP | 0.534 | 1.303 | 59.5% | 14.5 |
| LSTM-GAN | 0.363 | 0.767 | 78.0% | 157 |
| Transformer | 0.137 | 0.289 | 94.6% | 6.0 |
| Performer | 0.137 | 0.291 | 94.7% | 7.1 |
| Transformer | 0.392 | 1.024 | 84.0% | 4.9 |
| Performer | 0.416 | 1.069 | 79.9% | 6.0 |
| Falsterborev | ||||
| Linear | 0.282 | 0.691 | 4.0% | |
| GP | 0.326 | 0.808 | 66.6% | |
| LSTM-GAN | 0.313 | 0.642 | 76.6% | |
| Transformer | 0.119 | 0.257 | 95.2% | |
| Performer | 0.117 | 0.252 | 95.7% | |
| Transformer | 0.239 | 0.637 | 92.2% | |
| Performer | 0.251 | 0.650 | 89.5% | |
| Oresund (unseen area) | ||||
| Linear | 0.279 | 0.657 | 3.0% | |
| GP | 0.322 | 0.736 | 62.0% | |
| LSTM-GAN | 0.458 | 0.944 | 76.7% | |
| Transformer | 0.291 | 0.724 | 82.3% | |
| Performer | 0.302 | 0.755 | 83.1% | |
| Transformer | 0.264 | 0.648 | 88.4% | |
| Performer | 0.273 | 0.664 | 83.7% | |
| Average | ||||
| Linear | 0.325 | 0.801 | 4.7% | |
| GP | 0.394 | 0.949 | 62.7% | |
| LSTM-GAN | 0.378 | 0.784 | 77.1% | |
| Transformer | 0.182 | 0.423 | 90.7% | |
| Performer | 0.185 | 0.432 | 91.2% | |
| Transformer | 0.298 | 0.770 | 88.2% | |
| Performer | 0.313 | 0.794 | 84.4% | |
in complexity compared to the quadratic complexity of the Transformer. The slow-down of the Performer might be a result of the relatively small input length of 15 steps, at which the computational requirement of the kernel estimation in the FAVOR+ attention exceeds that of the Scaled Dot-Product Attention.
From Table 4 it is clearly seen that including heat map data significantly improves performance in The Great Belt area and Falsterborev areas, where the two Transformer models outperform all other methods. Though it is also noted that in the case of the Oresund area, the Transformer models without access to heat map data perform slightly better than their heat map counterparts. This could indicate overfitting of the spatial feature extraction subnetwork to the training areas, as while the training set includes a vast amount of trajectories, cropping each KDE leads to few unique heatmap images for the spatial feature extractor. To test this hypothesis, the Transformer networks are trained on data from the Oresund area collected during September 2018 and tested on data collected during May 2018. The results are presented in Table 5. Table 5 shows the performance of the Transformer models on the Oresund area if trained on data from the same area collected during a different time period. It is noted that in this case, including local heat
Table 5: Evaluation results on the Oresund area using models trained on data from the same area gathered during a different month. ADE and FDE are given in kilometres.
| Method | ADE ↓ | FDE ↓ | IAcc ↑ |
|---|---|---|---|
| Transformer | 0.222 | 0.483 | 71.1% |
| Performer | 0.206 | 0.461 | 75.0% |
| TransformerNo Heat | 0.247 | 0.585 | 86.6% |
| PerformerNo Heat | 0.257 | 0.608 | 85.3% |
map information leads to considerably lower displacement errors, although at the cost of a lower interval accuracy. Based on this result, if the proposed method was to be implemented in an onboard system, it would preferably be pretrained on data from the planned route. This would not be unrealistic as for example ferries have a predetermined route that is seldom changed.
To visually show the superiority of the proposed method, forecasted trajectories are plotted against each other in Figure 5. The input trajectory is sampled from The Great Belt test set.
Figure 5 shows the trajectory predictions by the different methods. The trajectories are plotted on top of the local heat map generated using data collected during a different time period. The pink coordinates are the input to the models while the blue coordinates are the ground truth trajectory of the vessel. The yellow coordinates indicate the anticipated trajectory with the prediction interval for each time step being the orange ellipsoids. The ellipsoids are generated as follows: let describe the point at the i-th latitudinal quantile and j-th longitudinal quantile. The sides of the ellipsoid describing the confidence interval have the lengths and . The resulting ellipsoid is rotated by the angle between the line from to and the x-axis. From Figures 5b and 5c it is clearly evident that the proposed method yields superior predictions. The inclusion of local heat maps enables predictions to follow navigational fairways, correctly predicting the sudden turn. It is furthermore noted that the ground truth trajectory lies well within the prediction interval of the proposed method with little distance to the mean prediction. The LSTM-GAN seems to be trying to model the upcoming turn, but with little success. This might be a result of LSTMs processing data sequentially compared to the parallel processing of the Transformer. The methods without a spatial feature extractor are unable to anticipate the upcoming turn and thus wrongly predict the vessel to keep going straight. Interestingly, the Transformer models without heat map inputs have quite a wide prediction interval for the later steps, which might point to the data set having many sudden turns which cannot be modelled by past positions alone.
7 Conclusion
This paper investigated Transformer and Performer models trained with quantile loss for probabilistic trajectory forecasting of marine vessels. A network architecture was proposed that adds a spatial feature extractor to the Transformer, giving the model information on how vessels have previously moved in the local area through KDE-generated heat maps. Training with quantile loss provides a prediction interval in a single forward pass, which makes inference considerably faster than sampling-based GAN-type models (6–7 ms compared to 157 ms per prediction).
The Transformer and the Performer performed similarly. Averaged over the three test areas, the Transformer obtained a slightly lower displacement error (ADE of 0.182 km compared to 0.185 km), while the Performer obtained a slightly higher interval accuracy (91.2% compared to 90.7%). Both models significantly outperformed the previously proposed LSTM-GAN, which had an average ADE of 0.378 km, as well as the linear and Gaussian process baselines. Despite its linear-complexity attention, the Performer was not faster than the Transformer for the short input sequences of 15 time steps used in this work.

(a) Linear Model

(b) Transformer

(c) Performer

(d) Gaussian Process

(e) Transformer Heat

(f) Performer Heat

(g) LSTM-GAN
Figure 5: Trajectory forecasting of a vessel using the different methods. Here, the background shows the local heat map, the pink coordinates indicate the input data, the blue coordinates the true trajectory, the yellow coordinates show the predicted trajectory, and the orange ellipsoids indicate the 95% prediction interval for each time step. It is clearly seen that including the heat map yields a far better prediction. The scale of the sub-figures is shown by the scale bar at the top of Figure 5a.
The heat maps were most beneficial in the areas covered by the training data. In the unseen Oresund area, the models without heat maps performed slightly better, indicating that the spatial feature extractor overfits to the training areas. When trained on data from the Oresund area, including heat maps again gave the lowest displacement errors, although at a lower interval accuracy. In practice, the method should therefore preferably be trained on data from the area or route in which it is deployed.
Further work includes improving the generalization of the spatial feature extractor to unseen areas, adding sea chart information to the model, and using positional data from smaller vessels without AIS, such as sailboats.
Acknowledgements
This work was sponsored by the Danish Innovation Fund, The Danish Maritime Fund, Orients Fund and the Lauritzen Foundation through the ShippingLab project (grant 8090-00063B).
References
[1] M. Blanke, S. Hansen, J. D. Stets, T. Koester, J. E. Brøsted, A. Llopart Maurin, N. Nykvist, and J. Bang. Outlook for navigation – comparing human performance with a robotic solution. In Proc. of ICMASS'2018. SINTEF Academic Press, May 2019. ISBN 978-82-536-1628-5. URL http://hdl.handle.net/11250/2599009.
[2] T. Porathe, J. Prison, and Y. Man. Situation awareness in remote control centres for unmanned ships. In Proceedings of Human Factors in Ship Design & Operation, pages 93–101, London, UK, 2014.
[3] Mica R Endsley. Toward a theory of situation awareness in dynamic systems. Human Factors, 37(1):32–64, 1995.
[4] Jonathan D. Stets, Frederik E. T. Schöller, Martin K. Plenge-Feidenhans'l, Rasmus H. Andersen, Søren Hansen, and Mogens Blanke. Comparing spectral bands for object detection at sea using convolutional neural networks. Journal of Physics: Conference Series, 1357: 012036, October 2019. doi: 10.1088/1742-6596/1357/1/012036.
[5] Lokukaluge P Perera, Paulo Oliveira, and C Guedes Soares. Maritime traffic monitoring based on vessel detection, tracking, state estimation, and trajectory prediction. IEEE Transactions on Intelligent Transportation Systems, 13(3):1188–1200, 2012.
[6] Erik F Wilthil, Andreas L Flåten, and Edmund F Brekke. A target tracking system for ASV collision avoidance based on the PDAF. In Sensing and Control for Autonomous Vehicles, pages 269–288. Springer, 2017.
[7] F.E.T. Schöller, M. Blanke, M.K. Plenge-Feidenhans'l, and L. Nalpantidis. Vision-based object tracking in marine environments using features from neural network detections. IFAC-PapersOnLine, 53(2):14517–14523, 2020. doi: 10.1016/j.ifacol.2020.12.1455.
[8] D. K. Prasad, D. Rajan, L. Rachmawati, E. Rajabally, and C. Quek. Video processing from electro-optical sensors for object detection and tracking in a maritime environment: A survey. IEEE Transactions on Intelligent Transportation Systems, 18(8):1993–2016, 2017. doi: 10.1109/TITS.2016.2634580.
[9] Vineet Kosaraju, Amir Sadeghian, Roberto Martín-Martín, Ian Reid, Hamid Rezatofighi, and Silvio Savarese. Social-BiGAT: Multimodal trajectory forecasting using bicycle-GAN and graph attention networks. In Advances in Neural Information Processing Systems, pages 137–146, 2019.
[10] Amir Sadeghian, Vineet Kosaraju, Ali Sadeghian, Noriaki Hirose, Hamid Rezatofighi, and Silvio Savarese. SoPhie: An attentive GAN for predicting paths compliant to social and physical constraints. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 1349–1358, 2019. doi: 10.1109/CVPR.2019.00144.
[11] A. Gupta, J. Johnson, L. Fei-Fei, S. Savarese, and A. Alahi. Social GAN: Socially acceptable trajectories with generative adversarial networks. In 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2255–2264, 2018. doi: 10.1109/CVPR.2018.00240.
[12] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems, pages 5998–6008, 2017.
[13] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
[14] Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Ves Stoyanov, and Luke Zettlemoyer. BART: Denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension. arXiv preprint arXiv:1910.13461, 2019.
[15] Tom B Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. arXiv preprint arXiv:2005.14165, 2020.
[16] Francesco Giuliari, Irtiza Hasan, Marco Cristani, and Fabio Galasso. Transformer networks for trajectory forecasting. In 2020 25th International Conference on Pattern Recognition (ICPR), pages 10335–10342. IEEE, 2021.
[17] Sinong Wang, Belinda Li, Madian Khabsa, Han Fang, and Hao Ma. Linformer: Self-attention with linear complexity. arXiv preprint arXiv:2006.04768, 2020.
[18] Nikita Kitaev, Łukasz Kaiser, and Anselm Levskaya. Reformer: The efficient transformer. arXiv preprint arXiv:2001.04451, 2020.
[19] Krzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Davis, Afroz Mohiuddin, Lukasz Kaiser, et al. Rethinking attention with performers. arXiv preprint arXiv:2009.14794, 2020.
[20] Yarin Gal and Zoubin Ghahramani. Dropout as a Bayesian approximation: Representing model uncertainty in deep learning. In International Conference on Machine Learning, pages 1050–1059, 2016. doi: 10.5555/3045390.3045502.
[21] David JC MacKay. Bayesian neural networks and density networks. Nuclear Instruments and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment, 354(1):73–80, 1995.
[22] Mehdi Mirza and Simon Osindero. Conditional generative adversarial nets. arXiv preprint arXiv:1411.1784, 2014.
[23] Roger Koenker and Gilbert Bassett. Regression quantiles. Econometrica, 46(1):33–50, 1978. doi: 10.2307/1913643.
[24] Yamin Huang, Linying Chen, Pengfei Chen, Rudy R Negenborn, and PHAJM Van Gelder. Ship collision avoidance methods: State-of-the-art. Safety Science, 121:451–473, 2020.
[25] S. Hexeberg, A. L. Flåten, B. H. Eriksen, and E. F. Brekke. AIS-based vessel trajectory prediction. In 2017 20th International Conference on Information Fusion (Fusion), pages 1–8, 2017. doi: 10.23919/ICIF.2017.8009762.
[26] H. Rong, A.P. Teixeira, and C. Guedes Soares. Ship trajectory uncertainty prediction based on a Gaussian process model. Ocean Engineering, 182:499–511, 2019. ISSN 0029-8018. doi:10.1016/j.oceaneng.2019.04.024.
[27] Brian Murray and Lokukaluge Prasad Perera. A dual linear autoencoder approach for vessel trajectory prediction using historical AIS data. Ocean Engineering, 209:107478, 2020. ISSN 0029-8018. doi: 10.1016/j.oceaneng.2020.107478.
[28] Giuliana Pallotta, Michele Vespe, and Karna Bryan. Vessel pattern knowledge discovery from AIS data: A framework for anomaly detection and route prediction. Entropy, 15(6):2218–2245, 2013. ISSN 10994300. doi: 10.3390/e15062218.
[29] Huang Tang, Yong Yin, and Helong Shen. A model for vessel trajectory prediction based on long short-term memory neural network. Journal of Marine Engineering & Technology, 2019. doi: 10.1080/20464177.2019.1665258.
[30] Frederik ET Schöller, Thomas T Enevoldsen, Jonathan B Becktor, and Peter N Hansen. Trajectory prediction for marine vessels using historical AIS heatmaps and long short-term memory networks. IFAC-PapersOnLine, 54(16):83–89, 2021.
[31] Petar Veličković, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Liò, and Yoshua Bengio. Graph attention networks. International Conference on Learning Representations, 2018.
[32] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural Computation, 9(8):1735–1780, 1997. doi: 10.1162/neco.1997.9.8.1735.
[33] Junyoung Chung, Caglar Gulcehre, KyungHyun Cho, and Yoshua Bengio. Empirical evaluation of gated recurrent neural networks on sequence modeling. arXiv preprint arXiv:1412.3555, 2014.
[34] Travis A. O'Brien, Karthik Kashinath, Nicholas R. Cavanaugh, William D. Collins, and John P. O'Brien. A fast and objective multidimensional kernel density estimation method: fastKDE. Computational Statistics & Data Analysis, 101:148–160, 2016. ISSN 0167-9473. doi: 10.1016/j.csda.2016.02.014.
[35] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2019.
[36] I. Loshchilov and F. Hutter. SGDR: Stochastic gradient descent with warm restarts. In International Conference on Learning Representations (ICLR) 2017 Conference Track, April 2017.