Next Article in Journal
Recent Advances in Early Earthquake Magnitude Estimation by Using Machine Learning Algorithms: A Systematic Review
Previous Article in Journal
The Impact of Linguistic Variations on Emotion Detection: A Study of Regionally Specific Synthetic Datasets
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A ResNet1D-AttLSTM-Based Approach for Ship Trajectory Classification

Naval University of Engineering, Wuhan 430033, China
*
Author to whom correspondence should be addressed.
Appl. Sci. 2025, 15(7), 3489; https://doi.org/10.3390/app15073489
Submission received: 16 January 2025 / Revised: 14 March 2025 / Accepted: 19 March 2025 / Published: 22 March 2025
(This article belongs to the Section Marine Science and Engineering)

Abstract

:
To improve the feature extraction method for ship trajectories and enhance trajectory classification performance, this paper proposes a ship trajectory classification model that combines a one-dimensional residual network (ResNet1D) and an attention-based Long short-term memory network (AttLSTM). The model aims to address the limitations of traditional methods in extracting feature patterns jointly represented by non-adjacent local regions in ship trajectories, optimized through the introduction of a self-attention mechanism. Specifically, the model first utilizes the ResNet1D module to progressively extract implicit motion pattern features from local to global levels, while the AttLSTM module captures temporal sequence features of ship trajectories. Finally, the fusion of these two types of features generates a more comprehensive and rich spatiotemporal motion feature representation, enabling accurate classification of five types of ship trajectories, including towing vessels, fishing vessels, sailing vessels, passenger ships, and tankers. Experimental results show that this model excels on extensive real-world trajectory datasets, achieving a classification accuracy of 89.7%, significantly outperforming models relying solely on single feature sets or lacking integrated attention mechanisms. This not only validates the model’s superior performance in ship trajectory classification tasks but also demonstrates its potential and effectiveness for practical applications.

1. Introduction

The analysis and mining of ship trajectory data hold significant application value in various fields, such as maritime traffic safety [1], traffic management and planning [2,3], and marine environmental protection [4]. This has spurred extensive research on ship trajectories, including trajectory prediction [5,6,7,8], anomaly detection [9,10,11], channel planning [12,13,14], behavior pattern recognition [15,16,17,18,19], and traffic flow analysis [20]. Trajectory category information plays a crucial supporting role in anomaly behavior detection and ship navigation supervision. However, the actual collected ship trajectory data may suffer from quality issues such as missing category information and labeling errors, which hinder the accuracy and reliability of subsequent tasks like navigation supervision and anomaly behavior detection. Therefore, research on ship trajectory classification methods is of great theoretical and practical significance.
Current ship trajectory classification algorithms mainly include traditional machine learning-based classification algorithms and neural network-based classification algorithms. The former includes algorithms based on logistic regression [21], conditional random fields [22], decision trees [23], random forests [24,25], K-nearest neighbors (KNNs) [26], support vector machines [27], etc. Although these algorithms have achieved some success, their reliance on expert-defined features makes the feature representation susceptible to subjective influences. Additionally, differences in navigation rules and environments across different sea areas necessitate frequent adjustments to feature combinations and parameter settings, limiting their practical application effectiveness. In contrast, neural network-based methods automatically learn deep-level features through nonlinear feature transformations, avoiding the limitations of manual feature engineering, and exhibit better generalization in practical applications due to their end-to-end learning capabilities. Currently, neural network-based ship trajectory classification algorithms mainly include convolutional neural networks (CNNs) and recurrent neural networks (RNNs).
CNNs and their variants, leveraging their translation invariance and convolutional kernel weight-sharing properties, can achieve feature extraction from the local to the global with a relatively small number of parameters, forming high-level abstract feature representations. This characteristic has facilitated their application in the field of trajectory classification. Kontopoulos et al. [28] transforms the ship trajectory classification problem into an image recognition task by visualizing four types of ship trajectory motion patterns and introducing pre-trained CNN models such as the Visual Geometry Group Network (VGG) [29] for classification. Yang et al. [30] generated trajectory images containing navigation pattern information based on the motion and shape characteristics of ship trajectories and constructed a CNN to achieve trajectory classification. Guo et al. [31] converted ship trajectory data into images and built a deep convolutional neural network classification model based on ResNet50.
RNNs and their variants, as neural network models specifically designed for processing sequential data, can effectively capture the temporal dependencies of sequential data, making them widely used in ship trajectory data analysis. Jiang et al. [32] proposed a partitioned gated recurrent unit (pGRU) architecture, enhancing the model’s expressive power in low-dimensional and heterogeneous feature spaces through partitioned activation learning in the feature space. De Freitas et al. [33] innovatively combined time series models with computer vision models, using bidirectional long short-term memory networks (Bi-LSTM) to extract temporal features from AIS data streams.
To further enhance the completeness and richness of ship trajectory feature representations, researchers have begun exploring hybrid architectures combining CNNs and RNNs. Zhang et al. [34] proposed a CNN-LSTM progressive trajectory classification model. By segmenting trajectories into sub-segments, the model uses CNNs to extract local motion pattern features within each sub-segment, which are then input into an LSTM for classification. However, this progressive method relies on the granularity of local motion patterns in sub-segments for temporal feature extraction, potentially leading to information loss. Cui et al. [35] proposed a 1DCNN-LSTM hybrid classification model, achieving classification by fusing the results of the two networks at the classifier level, but this fusion may limit the model’s comprehensive understanding of the original trajectory data.
Despite significant progress in using AIS data for ship classification, existing research still faces the following limitations: (1) Image-based methods may lead to information loss during data conversion, and their applicability is limited in small dataset scenarios due to the difficulty in visualizing certain types of features; (2) RNNs and their variants are constrained by sequential processing mechanisms and long-range dependency issues, as well as the sequential traversal characteristics of convolution operations, making it difficult for current methods to effectively extract joint motion patterns in non-adjacent regions; (3) when using convolutional networks to process trajectory sequences (rather than trajectory images), existing methods do not consider using residual blocks to expand network depth to enhance model scalability. As the number of network layers and input trajectory lengths increase, these methods may face challenges in addressing gradient vanishing or explosion issues.
To address these issues, this study proposes the following innovative solutions:
  • Non-adjacent co-feature extraction based on self-attention: To overcome the limitations in extracting features from non-adjacent regions, this study leverages the self-attention mechanism [36], which can directly attend to any position in the sequence and dynamically focus on the most useful information for the current task, to construct the AttLSTM module. By innovatively integrating the self-attention mechanism with the LSTM architecture, the model can more effectively extract feature patterns that require joint representation across multiple regions, even if these patterns are discontinuously distributed within a region.
  • Depth-scalable architecture with residual learning: To enhance model scalability in sequence tasks while minimizing gradient-related concerns, this study proposes the Resnet1D module. This module combines one-dimensional convolution with skip connections, constructing a multi-scale feature pyramid to ensure stable gradient propagation while expanding model depth.
Based on these innovations, this paper constructs the ResNet1D-AttLSTM hybrid classification model for ship trajectories, achieving multi-level, multi-dimensional feature extraction and fusion: the model performs multi-granularity spatial feature mining through the ResNet1D module, captures temporal dynamic evolution patterns using AttLSTM, and finally generates high-integrity spatiotemporal joint feature representations through a designed projection fusion strategy for ship trajectory classification.

2. Methods

The ship trajectory classification method proposed in this paper primarily comprises two parts: data preprocessing and the construction of a trajectory classification model. During the data preprocessing phase, we focus on denoising techniques and methods for constructing trajectory sequences from the dataset of trajectory points. For the construction of the trajectory classification model, we designed a hybrid classification model that integrates ResNet1D and AttLSTM.

2.1. Data Preprocessing

Data quality plays a crucial role in classification algorithms based on neural network models, and the process of collecting ship trajectory data can introduce noisy data. Therefore, it is necessary to perform data preprocessing. Taking the AIS dataset as an example, the data preprocessing workflow is illustrated in Figure 1.
Noise removal is necessary because AIS data can contain false or erroneous information due to intentional tampering by third parties, operational errors, or system malfunctions during its generation. Missing value data, outlier data, and duplicate data are common types of noise found in AIS datasets, with specifics as follows:
  • Missing value data refers to records where critical attributes such as longitude, latitude, speed over ground, course over ground, and time are absent.
  • Outlier data includes records where the values for important attributes like longitude, latitude, speed over ground, course over ground, and time fall outside reasonable ranges.
  • Duplicate data consists of identical records that appear multiple times within the dataset.
For these three types of noisy data, we adopt a deletion approach for handling them. Field selection aims to reduce the dimensionality of the dataset to lower computational complexity. In the AIS dataset, this paper selects seven key fields: maritime mobile service identity (MMSI), vesseltype, time, course over ground (COG), speed over ground (SOG), latitude and longitude. Other fields are removed. These selected fields effectively reflect the dynamic behavior and location information of vessels while minimizing redundant data. Additionally, category filtering refers to the process of removing data from all categories except those relevant to the study. Specifically, this involves retaining records from five specific types of vessels—towing vessels, fishing vessels, sailing vessels, passenger ships, and tankers—based on their distinct characteristics and the availability of sufficient data, while excluding data from other categories in the AIS dataset. This step is necessary because the original AIS dataset contains numerous ship categories, which could introduce unnecessary complexity and dilute the focus of the analysis.
In the AIS dataset, certain types of vessels are overrepresented, resulting in a significantly larger volume of trajectory point data for these categories, while other types have relatively fewer data points. To address this imbalance and facilitate subsequent preprocessing steps, after completing the noise removal process, we performed random undersampling on the majority classes. This involved randomly removing a portion of the trajectory data for the overrepresented vessel types to achieve a more balanced distribution across all categories.
As trajectory classification algorithms process objects composed of a series of ordered trajectory points forming trajectory segments, and the AIS dataset is a collection of numerous independent trajectory points, it is necessary to organize these isolated points into trajectory segments according to certain principles. In other words, we need to extract ship trajectory sequences. The method used for extracting ship trajectory sequences directly impacts the design of the classification algorithm; different extraction methods can generate trajectory sequences with varying important feature patterns, thus requiring the design of corresponding classification algorithms and the establishment of appropriate model hyperparameters.
For instance, the significant features of trajectories differ across various time scales. If we define long-term trajectories as navigation records over three months and short-term trajectories as those within one hour, then, in long-term trajectories, characteristics such as anchoring habits, route selection, and destination preferences are more discriminative for ship types. In contrast, these features hold less importance in short-term trajectories. This paper focuses on the research of classification algorithms for short-term trajectories, and the method for extracting trajectory sequences is as follows:
  • Fixed time window-based segmentation: For the navigation records of each ship in the AIS dataset, an initial trajectory segmentation is performed using a sliding window approach. Specifically, a fixed time window of 60 min is employed to traverse the entire navigation record in chronological order. Each window’s trajectory points are aggregated into an independent trajectory sequence.
  • Removal of anchoring points: A speed threshold, V T , is set; if the speed of a trajectory point is less than V T , it is considered an anchoring point and removed from the trajectory sequence. Anchoring points are removed because they contain static data that contribute little to the analysis of vessel navigation behavior and may even introduce noise.
  • Outlier removal: An heuristic outlier detection method [34] is employed. Using the current trajectory point as the center and V m a x × t as the radius (where V m a x is the upper limit of the reasonable speed range and t is the time interval between the current and next trajectory points), a circular region is defined. If the next trajectory point falls outside this circular region, it is identified as an outlier. Outliers are typically caused by sensor malfunctions, signal interference, or other external factors leading to data anomalies, which can interfere with the analysis of true vessel navigation behavior.
  • Trajectory segmentation: A time interval threshold, T s e g , is set. In the trajectory sequence, the time interval between each trajectory point and the previous one is calculated. If the time interval exceeds T s e g , it is marked as a segmentation point, dividing the trajectory sequence into multiple subsequences. The primary purpose of trajectory segmentation is to ensure that the trajectory points within each segment are more closely related in space and time, avoiding data dispersion caused by long time intervals. This helps the model learn more accurate behavioral patterns.
  • Sequence length filtering: A trajectory point count threshold, P n u m , is established. The number of trajectory points in each sequence is calculated, and sequences with fewer points than P n u m are discarded. Removing overly short sequences reduces the impact of noise and allows the model to focus on high-quality data.
After extracting the trajectory sequences, the dataset may still suffer from class imbalance. To address this issue, we performed undersampling on the majority classes in the trajectory sequence dataset by randomly removing a portion of the trajectory sequences from these classes to achieve a more balanced distribution across all categories.
Furthermore, because certain features within the trajectory data have different scales and units, to prevent the model from becoming overly sensitive to some features—which could lead to a decrease in robustness—we applied min–max normalization. This method standardizes all features to a uniform range, ensuring that no single feature disproportionately influences the model due to its scale.

2.2. Construction of the ResNet1D-AttLSTM Model

As shown in Figure 2, the ResNet1D-AttLSTM ship trajectory classification model primarily comprises a feature extraction module based on ResNet1D and AttLSTM, as well as a classification module based on a multilayer perceptron (MLP).
After completing the data preprocessing, the model first organizes the ship trajectory sequences into a five-channel format based on five features of each trajectory point (longitude, latitude, SOG, COG, and time) and inputs them into the ResNet1D module. Through convolutional operations and multiple residual block processes, this module extracts high-level motion features from the sequence. Simultaneously, the ship trajectory sequences are also fed into the AttLSTM module to capture the temporal variation characteristics of the trajectory sequences.
Finally, the two types of features extracted from the ResNet1D and AttLSTM modules are concatenated and fused. These combined features are then passed through a multilayer perceptron to output the predicted results for trajectory type classification.

2.2.1. ResNet1D Module

ResNet1D is a network model whose design is based upon residual network architecture [37], utilizing exclusively one-dimensional convolutional layers. It is specifically tailored for handling one-dimensional sequence data such as time series and audio signals. ResNet1D inherits the residual blocks and skip connections from ResNet, which facilitate the learning of identity mappings, thereby alleviating the problems of vanishing and exploding gradients that are common in deep networks. Additionally, ResNet1D is constructed in a modular fashion, allowing for the easy expansion of network depth by stacking multiple residual blocks to meet the requirements of various tasks.
As illustrated in Figure 2, within the ResNet1D module, the trajectory sequences are organized into a five-channel representation based on five features of each trajectory point (longitude, latitude, SOG, COG, and time), which serves as the input. This module initially passes the trajectory sequences through a one-dimensional convolutional layer, followed by a batch normalization layer and a ReLU activation function to extract low-level features from the trajectory sequences. The convolutional layer is configured with k convolutional kernels, each of size c i n × h (where c i n is the number of input channels and h is the width of the convolution kernel).
Subsequently, the data flows through an intermediate layer composed of n residual blocks. To enhance the model’s generalization capability and address the issue of variable feature dimensions caused by trajectories of non-uniform length, a global average pooling layer is applied. This results in a high-level feature representation of ship trajectory sequences with fixed dimensions. The architecture of the residual block is illustrated in Figure 3.
Each residual block consists of two one-dimensional convolutional layers with the same number of output channels, followed by a batch normalization layer and a ReLU activation function after each convolutional layer. The input data bypasses these two convolution operations through a skip connection, which adds the input directly to the output before the final ReLU activation.
In the first convolutional layer, c convolution kernels for which W = { w 1 , w 2 , …, w c } are set, with each kernel size being k × h . In the second convolutional layer, c convolution kernels for which U = { u 1 , u 2 , …, u c } are set, with each kernel size being c × h . Zero-padding and a stride of 1 are used to maintain the feature dimensions after the convolution operations.
Assuming the sequence length is l e n , the one-dimensional convolution operation is performed along the sequence direction using convolution kernels W and U on the input X i = x 1 , i : i + h 1 ,   x 2 , i : i + h 1   , ,   x k , i : i + h 1 0 i l e n . The result of this operation is then added to X i , and the sum passes through the activation function to produce new features. The new features, Y i , generated by each residual block can be represented by Equation (1):
f 1 = R e L U B N m = 1 c   n = 0 h 1   w m , n x m , i + n + b 1 f 2 = R e L U B N m = 1 c   n = 0 h 1   u m , n f 1 , m , i + n + b 2 Y i = R e L U f 2 + X i
In the equation, B N denotes the batch normalization operation, m represents the current channel index, and n represents the position index within the convolution kernel width h . b 1 and b 2 denote the biases, while f 1 and f 2 represent the output features after the first and second convolution-BN-ReLU operations, respectively. Thus, the new features obtained by the residual block are given by Y i = { y 1 , i ,   y 2 , i , ,   y c , i }   0 i l e n .

2.2.2. AttLSTM Module

LSTM networks alleviate the vanishing gradient problem in traditional RNNs to a certain extent by introducing gating mechanisms, thereby improving the ability to model long-term dependencies. However, when processing sequential features, LSTMs adopt a sequential approach, capturing information only from the beginning of the sequence to the current time step, while underutilizing information beyond the current position. Moreover, LSTMs have limitations in extracting feature patterns jointly expressed by multiple non-adjacent regions. Specifically, LSTMs struggle to effectively capture complex patterns that are discontinuously distributed in the sequence. Although theoretically capable of capturing such patterns at the final step of processing, their modeling capability may degrade due to the loss of early information.
To address these issues, this study constructs an AttLSTM module by integrating a multi-head self-attention mechanism into the final layer of the LSTM. The self-attention mechanism directly calculates the correlations between each position in the trajectory sequence and all other positions, enabling the effective capture of global feature patterns that are discontinuously distributed while simultaneously focusing on the joint behavior of multiple regions. The application of the multi-head mechanism further enhances the model’s understanding of the entire sequence, thereby improving its ability to model complex patterns.
As shown in Figure 4, the AttLSTM module consists of an LSTM layer and an attention layer. The input to this module is the preprocessed ship trajectory sequences. Due to the variable lengths of these input sequences, we statistically determine the maximum length L m a x from all trajectory sequences in the dataset to standardize the input length for the LSTM layer. For trajectory sequences shorter than L m a x , zero-padding is applied to extend them to L m a x .
First, the trajectory points in the sequence are fed into the LSTM layer in chronological order to initially capture the temporal variation characteristics of the trajectory sequences. Then, a multi-head self-attention mechanism is applied to further extract and emphasize information from key time points within the sequence. This enhances the model’s focus on important temporal features.
In the LSTM layer, the number of network layers is set to N . Each LSTM unit within a layer contains three gates (input gate i t ( l ) , forget gate f t ( l ) , and output gate o t ( l ) ) where l denotes the current layer index. Each LSTM unit performs the following process for time step t : given the input x t ( l ) , the previous hidden state h t 1 ( l ) , and the previous cell state c t 1 ( l ) , it calculates the current hidden state h t ( l ) and the current cell state c t ( l ) . The update process is described by Equations (2)–(8), as follows:
f t ( l ) = σ W f ( l ) [ h t 1 ( l ) , x t ( l ) ] + b f ( l )
i t ( l ) = σ W i ( l ) [ h t 1 ( l ) , x t ( l ) ] + b i ( l )
j t ( l ) = t a n   h W j ( l ) [ h t 1 ( l ) , x t ( l ) ] + b j ( l )
c t ( l ) = f t ( l ) c t 1 ( l ) + i t ( l ) j t ( l )
o t ( l ) = σ W o ( l ) [ h t 1 ( l ) , x t ( l ) ] + b o ( l )
h t ( l ) = o t ( l ) t a n   h c t ( l )
x t ( l + 1 )   : = h t ( l )
In the equations:
  • denotes element-wise multiplication (Hadamard product).
  • : = denotes assignment.
  • W and b represent the weight matrices and bias parameters of the gate controllers, respectively.
  • σ and t a n   h denote the Sigmoid activation function and the hyperbolic tangent activation function, respectively.
  • j t represents the new information to be added to the cell state.
The update process of the LSTM unit is illustrated in Figure 5. Finally, the output of the LSTM layer is H = { h 1 N , h 2 N , , h L m a x ( N ) } , which serves as the input to the attention layer.
In the attention layer, i attention heads are set up. As the LSTM layer is capable of extracting positional information of trajectory points within the sequence, no positional encoding is added to the input. The computation process for multi-head attention is as follows:
For each attention head i , the input H undergoes three linear transformations to obtain the query matrix Q i , key matrix K i , and value matrix V i , as shown in Equation (9):
Q i = H W i Q , K i = H W i K , V i = H W i V
where W i Q , W i K , and W i V are the linear transformation matrices.
Next, the output for each attention head based on scaled dot-product attention is computed according to Equation (10):
h e a d i = s o f t m a x Q i K i T d k V i
where d k is the dimensionality of the key vectors.
Finally, the outputs from all attention heads are concatenated and passed through a linear transformation with weight matrix W O to produce the output of the attention layer, as given by Equation (11):
O = Concat h e a d 1 , , h e a d h W O = { o 1 , o 2 , , o L m a x }

2.2.3. Trajectory Classification Based on Multilayer Perceptron

First, to effectively integrate the features extracted by the ResNet1D module and the AttLSTM module, we applied global average pooling (GAP) to the feature maps output by the ResNet1D module. By calculating the average value of each channel across the time dimension, we obtained a fixed-length one-dimensional vector. For the output feature O of the AttLSTM module, we selected the state at the last time step as its one-dimensional representation. These two processing methods not only reduce the number of parameters but also retain the main information of the features, thereby helping to prevent overfitting.
Next, we concatenated the two aforementioned one-dimensional feature vectors to form a comprehensive feature vector. This vector was then fed into a multi-layer perceptron (MLP) for classification tasks. The configuration of the MLP in this study is as follows:
  • Number of layers: 2 hidden layers.
  • Number of neurons per layer:
    • The first hidden layer has twice the number of neurons as the dimensionality of the comprehensive feature vector.
    • The second hidden layer has half the number of neurons as the first hidden layer.
  • Activation Function: ReLU activation function is used for all hidden layers.
Finally, the MLP outputs a one-dimensional vector of length s , where s equals the number of ship types. For each value z i ( 1 i s ) in the output vector, we apply the softmax function for probability normalization to obtain the probability distribution across categories, as shown in Equation (12):
P i = e z i k = 1 s   e z k
where P i represents the probability that the ship trajectory is predicted to be of the i-th type and satisfies i = 1 s P i = 1. The category with the highest probability value is chosen as the predicted class for the corresponding ship trajectory.

3. Experiment

3.1. Data Analysis and Preprocessing

The dataset used in this study is sourced from publicly available automatic identification system (AIS) ship trajectory data collected by the United States Coast Guard, USA. The data is accessible at https://marinecadastre.gov/ais/ (accessed on 3 April 2024). For this experiment, we selected 86,431,580 AIS records from 1 June to 10 June 2022, as our research subjects. Due to the large volume of data, the storage and preprocessing processes were implemented within a MySQL database.
During the denoising process based on our data preprocessing methods, we set the reasonable speed range to between 0 and 40 knots ( V m a x = 40 ), allowed for all possible headings, and considered global latitude and longitude ranges. According to these filtering criteria, a total of 565,710 trajectory points with missing values, outliers, or duplicates were identified and removed. After field selection and category filtering, the data distribution across different vessel categories was summarized (see Table 1). The results indicate that tugboats accounted for more than thirty thousand records, whereas cruise ships numbered only 5020.
To address the issue of imbalanced trajectory data, we randomly downsampled each vessel category to 5000 instances to improve the balance during model training.
During the extraction of trajectory sequences, the speed threshold for anchoring points V T was set to 0.3 knots, the time interval threshold for trajectory segmentation T s e g was set to 10 min, and the trajectory sequence length threshold P n u m was set to 15. Based on these parameters, a preliminary extraction yielded 551,324 trajectory sequences.
Subsequently, we performed undersampling on the majority classes (fishing, sailing, passenger, and tanker) based on the distribution of trajectory sequences across categories (see Figure 6). A portion of the trajectory sequences from the majority classes was randomly deleted to ensure that each vessel category had an equal number of sequences. Ultimately, the dataset was processed to contain 247,750 trajectory sequences, with each vessel category comprising 49,550 sequences.
Statistically, the maximum length of the trajectory sequences L m a x was found to be 60. Finally, the trajectory sequence dataset underwent min–max normalization, and was split into training and testing sets in an 8:2 ratio.

3.2. Experimental Setup

3.2.1. Experimental Environment

The hardware and software environment used in this study is detailed in Table 2.

3.2.2. Model Implementation and Training

The ResNet1D-AttLSTM model was implemented using Python based on the PyTorch. During the training process, we utilized the Adam optimizer as the optimization algorithm, with an initial learning rate set to 0.0001 and a batch size of 256. The loss function employed was cross-entropy. To effectively prevent overfitting, we implemented the early stopping criterion during training.
In terms of hyperparameter settings, the following applies:
  • For the ResNet1D module, the convolutional layers were configured with 32 convolutional kernels of size 3;
  • Within the residual blocks, the convolutional layers were configured with 64 convolutional kernels of the same size;
  • In the AttLSTM module, the dimension of the memory cells was set to 128.

3.3. Model Evaluation and Analysis

3.3.1. Evaluation Metrics

To analyze the classification performance of the model, this study employs four key metrics: accuracy, precision, recall, and F1-score. The specific calculation methods for these metrics are provided in Equations (13)–(16).
A c c u r a c y = N C o r r e c t N
P r e c i s i o n = N T P N T P + N F P
R e c a l l = N T P N T P + N F N
F 1 = 2 × P r e c i s i o n × R e c a l l Precision + Recall
where the following applies:
  • N C o r r e c t : The number of correctly classified ship trajectory sequences.
  • N : The total number of ship trajectory sequences.
  • N T P : The number of true positives, i.e., the number of ship trajectory sequences correctly classified as belonging to a particular class.
  • N F N : The number of false negatives, i.e., the number of ship trajectory sequences that belong to a particular class but were incorrectly classified as belonging to another class.
  • N F P : The number of false positives, i.e., the number of ship trajectory sequences that do not belong to a particular class but were incorrectly classified as belonging to that class.
These metrics provide a comprehensive evaluation of the model’s performance by considering both the correctness of classifications and the balance between precision and recall.

3.3.2. Hyperparameter Tuning of ResNet1D-AttLSTM

To evaluate the performance of the ResNet1D-AttLSTM model under different hyperparameter settings, we employed four-fold cross-validation and calculated the average classification accuracy across four independent validation sets. As shown in Table 3, the model achieved the highest classification accuracy under Scheme 5. This scheme includes two residual blocks, two LSTM layers (each with a memory cell dimension of 128), eight attention heads (with an embedding dimension of 256), and a dropout rate of 0.3 in the feature fusion layer.
As indicated in Table 3, Scheme 1 and Scheme 2 achieved accuracies of 79% and 81.1%, respectively, suggesting that relying solely on either ResNet1D or LSTM for ship trajectory classification has limited performance. Scheme 3, which integrates features extracted by ResNet1D with the temporal information captured by LSTM, achieved an accuracy of 84.3%, higher than Schemes 1 (79%) and 2 (81.1%). This indicates that combining spatial and temporal features significantly improves model performance. Scheme 4 further improved the accuracy to 87.4%, demonstrating that introducing the attention mechanism allows the model to more effectively capture key information, thereby enhancing classification performance.
However, Scheme 7 showed a slight decrease in accuracy to 88.5% compared with Scheme 6. This phenomenon could be ascribed to the heightened model complexity induced by an overabundance of attention heads and residual blocks, potentially resulting in overfitting.

3.3.3. Classification Performance on Different Ship Types

Next, this study conducted a detailed statistical analysis of the classification results for each type of ship trajectory in the test set. The detailed classification results, confusion matrix, and metrics such as precision, recall, and F1-score are presented in Table 4.
From Table 4, several observations can be made:
  • F1-score analysis:
    • The model demonstrates good recognition ability across all categories of ship trajectories, with F1 scores exceeding 87% for each category. The highest F1 score is achieved for towing vessels at 91.6%, while the lowest is for sailing vessels at 87.3%.
    • The superior classification performance for towing vessels may be attributed to their distinctive movement patterns: relatively fixed navigation paths, low and stable speeds, and regular turning behaviors.
    • The lower F1 score for sailing vessels could be due to their variable heading and speed characteristics, as well as their broad and unfixed activity areas.
  • Precision analysis:
    • The model achieves the lowest precision for fishing vessels at 86.3% and the highest for passenger ships at 93%. This indicates that many non-fishing vessel trajectories were misclassified as fishing vessels, whereas most predicted passenger ship trajectories were correctly identified.
    • Further analysis of the confusion matrix reveals that the low precision for fishing vessels primarily stems from confusion between sailing and fishing vessel trajectories. Under specific sailing conditions, these two types of vessels exhibit similar trajectory features. For example, when wind conditions allow small fishing boats and sailboats to have comparable speed and heading changes, or when they operate in similar waters, it becomes challenging for the model to distinguish between them. This confusion also contributes to the lower recall rate for sailing vessels.
  • Recall analysis:
    • The recall for passenger ship trajectories is relatively low at 86.8%, while it is highest for oil tankers at 93.2%. This suggests that some passenger ship trajectories were misclassified as other types, whereas most actual oil tanker trajectories were correctly identified.
    • The analysis shows that many passenger ship trajectories were misidentified as oil tankers. Oil tankers typically have more fixed routes and higher data quality, which helps the model better distinguish them from other types of ships.
Overall, the classification performance is best for towing vessel and oil tanker trajectories, while fishing and sailing vessel trajectories exhibit relatively poorer classification results. To improve the model’s ability to distinguish between the trajectories of fishing and sailing vessels, we plan to add more training data for these two types in future work in order to assist the model to better differentiate them. Additionally, we intend to introduce more discriminative, manually defined features, such as operational type and weather conditions, as contextual information, and optimize the model by refining its architecture and loss function to enhance overall performance.

3.3.4. Comparative Analysis

To further evaluate the performance of the ResNet1D-AttLSTM model, this study conducted comparative experiments, comparing it with trajectory classification models based on FishNet [31], pGRU [32], and CNN-LSTM [34] network architectures. The selection of these models was based on their methodological relevance to our work, as they employ deep learning architectures for ship trajectory classification, to process trajectory data as a sequence task without converting it to an image, and to address similar maritime application scenarios. Among these, FishNet employs a one-dimensional convolutional neural network architecture, while pGRU represents an advanced recurrent neural network variant that achieves efficient modeling of low-dimensional heterogeneous data by partitioning each input feature within the activation function and assigning independent parameters to each partition. The comparative experiments used accuracy as the evaluation metric, and the results are presented in Table 5 and Figure 7.
According to the data in Table 5 and Figure 7, the ResNet1D-AttLSTM model outperforms all other models in the trajectory classification task, achieving an accuracy of 89.7%, which is significantly higher than the others. This model integrates a one-dimensional residual network with an attention-based long short-term memory network, enabling it to effectively capture long-term dependencies in ship trajectory sequences and learn key features through the self-attention mechanism. In contrast, the accuracies of FishNet and pGRU are 81.4% and 82.2%, respectively, while that of CNN-LSTM is 84.1%. These results indicate that the ResNet1D-AttLSTM model exhibits superior accuracy and robustness when handling complex trajectory data.

4. Conclusions and Future Work

This paper presents an innovative ship trajectory classification model. The proposed model combines the advantages of ResNet1D and LSTM for local multi-level feature detection and learning long-term dependencies, respectively. It also employs self-attention mechanisms to enhance the understanding of critical information, thereby generating high-integrity spatiotemporal motion feature representations of ship trajectories, effectively improving the performance of ship trajectory classification. Experimental results show that the proposed ResNet1D-AttLSTM model outperforms other models that rely on single feature sets or lack an integrated attention mechanism in terms of accuracy. On a real AIS trajectory dataset, the overall classification accuracy of this model reached 89.7%, with particularly notable performance in the identification of towing vessel and tanker trajectories. However, there is room for improvement in the classification of fishing boat and sailing yacht trajectories.
Future research directions include the following:
  • Expanding the training dataset: Increase the diversity and volume of training data, especially for less represented vessel types like fishing and sailing boats, to improve classification accuracy and robustness.
  • Integrating contextual features: Incorporate additional discriminative features such as operational type and weather conditions into the model to better capture the context of vessel movements, thereby improving classification performance.
  • Refining data preprocessing techniques: Optimize preprocessing methods, considering the periodic nature of certain navigational data (e.g., longitude and COG), to ensure that these steps more accurately reflect actual navigation scenarios.
  • Optimizing model architecture: Explore various optimization strategies for the ResNet1D-AttLSTM architecture, including the testing of different activation functions or the introduction of partitioned activation mechanisms, to potentially achieve even better model performance.
  • Enhancing classification system diversity: Expand the scope of the classification system to include a wider range of vessel types, making it adaptable to diverse maritime environments and specific application scenarios.
  • Generalizing to other domains: Investigate the applicability of the developed methods to other domains, such as urban traffic management, to validate the generalizability and adaptability of the proposed techniques.

Author Contributions

Conceptualization, F.L. and B.F.; methodology, F.L. and B.F.; software, J.K. and Y.L.; validation, J.K.; formal analysis, J.K. and F.L.; investigation, J.K.; resources, B.F.; data curation, Y.L.; writing—original draft preparation, J.K.; writing—review and editing, F.L.; visualization, Y.L.; supervision, F.L.; project administration, F.L. and B.F.; funding acquisition, B.F. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The original contributions presented in the study are included in the article, further inquiries can be directed to the corresponding author.

Acknowledgments

We gratefully acknowledge Junsen Wang for his technical assistance in resolving theoretical doubts during this research.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Ma, Q.; Tang, H.; Liu, C.; Zhang, M.; Zhang, D.; Liu, Z.; Zhang, L. A Big Data Analytics Method for the Evaluation of Maritime Traffic Safety Using Automatic Identification System Data. Ocean Coast. Manag. 2024, 251, 107077. [Google Scholar] [CrossRef]
  2. El Mekkaoui, S.; Benabbou, L.; Caron, S.; Berrado, A. Deep Learning-Based Ship Speed Prediction for Intelligent Maritime Traffic Management. J. Mar. Sci. Eng. 2023, 11, 191. [Google Scholar] [CrossRef]
  3. Feng, C.; Fu, B.; Luo, Y.; Li, H. The Design and Development of a Ship Trajectory Data Management and Analysis System Based on AIS. Sensors 2022, 22, 310. [Google Scholar] [CrossRef] [PubMed]
  4. Shahir, A.Y.; Tayebi, M.A.; Glasser, U.; Charalampous, T.; Zohrevand, Z.; Wehn, H. Mining Vessel Trajectories for Illegal Fishing Detection. In Proceedings of the 2019 IEEE International Conference on Big Data (Big Data), Los Angeles, CA, USA, 9–12 December 2019; pp. 1917–1927. [Google Scholar]
  5. Li, H.; Jiao, H.; Yang, Z. Ship Trajectory Prediction Based on Machine Learning and Deep Learning: A Systematic Review and Methods Analysis. Eng. Appl. Artif. Intell. 2023, 126, 107062. [Google Scholar] [CrossRef]
  6. Park, J.; Jeong, J.; Park, Y. Ship Trajectory Prediction Based on Bi-LSTM Using Spectral-Clustered AIS Data. J. Mar. Sci. Eng. 2021, 9, 1037. [Google Scholar] [CrossRef]
  7. Murray, B.; Perera, L.P. Ship Behavior Prediction via Trajectory Extraction-Based Clustering for Maritime Situation Awareness. J. Ocean Eng. Sci. 2022, 7, 1–13. [Google Scholar] [CrossRef]
  8. Suo, Y.; Chen, W.; Claramunt, C.; Yang, S. A Ship Trajectory Prediction Framework Based on a Recurrent Neural Network. Sensors 2020, 20, 5133. [Google Scholar] [CrossRef]
  9. Yan, Z.; Song, X.; Zhong, H.; Yang, L.; Wang, Y. Ship Classification and Anomaly Detection Based on Spaceborne AIS Data Considering Behavior Characteristics. Sensors 2022, 22, 7713. [Google Scholar] [CrossRef]
  10. Rong, H.; Teixeira, A.P.; Guedes Soares, C. Data Mining Approach to Shipping Route Characterization and Anomaly Detection Based on AIS Data. Ocean Eng. 2020, 198, 106936. [Google Scholar] [CrossRef]
  11. Jin, J.; Zhou, W.; Jiang, B. An Overview: Maritime Spatial-Temporal Trajectory Mining. J. Phys. Conf. Ser. 2021, 1757, 012125. [Google Scholar] [CrossRef]
  12. Han, P.; Yang, X. Big Data-Driven Automatic Generation of Ship Route Planning in Complex Maritime Environments. Acta Oceanol. Sin. 2020, 39, 113–120. [Google Scholar] [CrossRef]
  13. Rong, Y.; Zhuang, Z.; He, Z.; Wang, X. A Maritime Traffic Network Mining Method Based on Massive Trajectory Data. Electronics 2022, 11, 987. [Google Scholar] [CrossRef]
  14. Kaklis, D.; Kontopoulos, I.; Varlamis, I.; Emiris, I.Z.; Varelas, T. Trajectory Mining and Routing: A Cross-Sectoral Approach. J. Mar. Sci. Eng. 2024, 12, 157. [Google Scholar] [CrossRef]
  15. Li, G.; Liu, M.; Zhang, X.; Wang, C.; Lai, K.; Qian, W. Semantic Recognition of Ship Motion Patterns Entering and Leaving Port Based on Topic Model. J. Mar. Sci. Eng. 2022, 10, 2012. [Google Scholar] [CrossRef]
  16. Zhou, C.; Liu, G.; Huang, L.; Wen, Y. Spatiotemporal Companion Pattern (STCP) Mining of Ships Based on Trajectory Features. J. Mar. Sci. Eng. 2023, 11, 528. [Google Scholar] [CrossRef]
  17. Feng, C.; Xu, J.; Zhang, J.; Li, H. A Spatiotemporal Co-Occurrence Pattern Mining Algorithm Based on Ship Trajectory Data. Adv. Mech. Eng. 2024, 16, 16878132241274449. [Google Scholar] [CrossRef]
  18. Gao, M.; Shi, G.-Y. Ship-Handling Behavior Pattern Recognition Using AIS Sub-Trajectory Clustering Analysis Based on the T-SNE and Spectral Clustering Algorithms. Ocean Eng. 2020, 205, 106919. [Google Scholar] [CrossRef]
  19. Liu, J.; Chen, Z.; Zhou, J.; Xue, A.; Peng, D.; Gu, Y.; Chen, H. Research on A Ship Trajectory Classification Method Based on Deep Learning. Chin. J. Inf. Fusion 2024, 1, 3–15. [Google Scholar] [CrossRef]
  20. Liu, Z.; Gao, H.; Zhang, M.; Yan, R.; Liu, J. A Data Mining Method to Extract Traffic Network for Maritime Transport Management. Ocean Coast. Manag. 2023, 239, 106622. [Google Scholar] [CrossRef]
  21. Sheng, K.; Liu, Z.; Zhou, D.; He, A.; Feng, C. Research on Ship Classification Based on Trajectory Features. J. Navig. 2018, 71, 100–116. [Google Scholar] [CrossRef]
  22. Hu, B.; Jiang, X.; Souza, E.; Pelot, R.; Matwin, S. Identifying Fishing Activities from AIS Data with Conditional Random Fields. In Proceedings of the 2016 Federated Conference on Computer Science and Information Systems (FedCSIS), Gdansk, Poland, 11–14 September 2016; pp. 47–52. [Google Scholar]
  23. Sánchez Pedroche, D.; Amigo, D.; García, J.; Molina, J.M. Architecture for Trajectory-Based Fishing Ship Classification with AIS Data. Sensors 2020, 20, 3782. [Google Scholar] [CrossRef] [PubMed]
  24. Luo, D.; Chen, P.; Yang, J.; Li, X.; Zhao, Y. A New Classification Method for Ship Trajectories Based on AIS Data. J. Mar. Sci. Eng. 2023, 11, 1646. [Google Scholar] [CrossRef]
  25. Baeg, S.; Hammond, T. Ship Type Classification Based on the Ship Navigating Trajectory and Machine Learning. Available online: https://hdl.handle.net/1969.1/199814 (accessed on 5 June 2024).
  26. Damastuti, N.; Siti Aisjah, A.; Masroeri, A.A. Classification of Ship-Based Automatic Identification Systems Using K-Nearest Neighbors. In Proceedings of the 2019 International Seminar on Application for Technology of Information and Communication (iSemantic), Semarang, Indonesia, 21–22 September 2019; pp. 331–335. [Google Scholar]
  27. Wang, H.; Zuo, Y.; Li, T.; Wang, Z. Classification Algorithm of Ship Trajectory Based on Machine Learning Techniques. In Proceedings of the 2020 IEEE Asia-Pacific Conference on Computer Science and Data Engineering (CSDE), Gold Coast, Australia, 16 December 2020; pp. 1–7. [Google Scholar]
  28. Kontopoulos, I.; Makris, A.; Tserpes, K. A Deep Learning Streaming Methodology for Trajectory Classification. ISPRS Int. J. Geo-Inf. 2021, 10, 250. [Google Scholar] [CrossRef]
  29. Simonyan, K.; Zisserman, A. Very Deep Convolutional Networks for Large-Scale Image Recognition. arXiv 2015, arXiv:1409.1556. [Google Scholar]
  30. Yang, T.; Wang, X.; Liu, Z. Ship Type Recognition Based on Ship Navigating Trajectory and Convolutional Neural Network. J. Mar. Sci. Eng. 2022, 10, 84. [Google Scholar] [CrossRef]
  31. Guo, T.; Xie, L. Research on Ship Trajectory Classification Based on a Deep Convolutional Neural Network. J. Mar. Sci. Eng. 2022, 10, 568. [Google Scholar] [CrossRef]
  32. Jiang, X.; Liu, X.; De Souza, E.N.; Hu, B.; Silver, D.L.; Matwin, S. Improving Point-Based AIS Trajectory Classification with Partition-Wise Gated Recurrent Units. In Proceedings of the 2017 International Joint Conference on Neural Networks (IJCNN), Anchorage, AK, USA, 14–19 May 2017; pp. 4044–4051. [Google Scholar]
  33. de Freitas, N.A.; Coelho Da Silva, T.; Fernandes De Macêdo, J.; Melo Junior, L.; Cordeiro, M. Using Deep Learning for Trajectory Classification. In Proceedings of the 13th International Conference on Agents and Artificial Intelligence; SCITEPRESS—Science and Technology Publications, Online Streaming, 4–6 February 2021; pp. 664–671. [Google Scholar]
  34. Zhang, P.X.; Li, L.Y.; Yang, M.; An, X.Y.; Xu, X.L. Ship Trajectory Classification Model Considering Changes in Movement Behavior Characteristics. Sci. Surv. Mapp. 2023, 48, 25–34. [Google Scholar] [CrossRef]
  35. Cui, T.T.; Wang, G.L.; Gao, J. Ship Trajectory Classification Method Based on 1DCNN-LSTM. Comput. Sci. 2020, 47, 175–184. [Google Scholar]
  36. Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, Ł.; Polosukhin, I. Attention Is All You Need. arXiv 2017, arXiv:1706.03762. [Google Scholar]
  37. He, K.; Zhang, X.; Ren, S.; Sun, J. Deep Residual Learning for Image Recognition. arXiv 2015, arXiv:1512.03385. [Google Scholar]
Figure 1. Data preprocessing workflow.
Figure 1. Data preprocessing workflow.
Applsci 15 03489 g001
Figure 2. Architecture diagram of the ResNet1D-AttLSTM model.
Figure 2. Architecture diagram of the ResNet1D-AttLSTM model.
Applsci 15 03489 g002
Figure 3. Structural design of the residual block.
Figure 3. Structural design of the residual block.
Applsci 15 03489 g003
Figure 4. Architecture of the AttLSTM module.
Figure 4. Architecture of the AttLSTM module.
Applsci 15 03489 g004
Figure 5. Architecture of an LSTM cell unit.
Figure 5. Architecture of an LSTM cell unit.
Applsci 15 03489 g005
Figure 6. Number of trajectory sequences by ship type.
Figure 6. Number of trajectory sequences by ship type.
Applsci 15 03489 g006
Figure 7. Comparison of accuracy among four models on five categories of vessel trajectory classification.
Figure 7. Comparison of accuracy among four models on five categories of vessel trajectory classification.
Applsci 15 03489 g007
Table 1. Overview of data volume statistics for various types of ships.
Table 1. Overview of data volume statistics for various types of ships.
Type of ShipFishingTowingSailingPassengerTanker
Number of track points4,423,13028,025,3803,609,6005,796,5002,518,370
Number of ships10,46033,88013,15099605020
Table 2. Experimental environment.
Table 2. Experimental environment.
Hardware/Software EnvironmentDetailed Information
Central processing unit (CPU)Intel(R) Core(TM) i9-13900HX, 2.20 GHz
Graphics processor unit (GPU)GeForce RTX 4060
Computer memory32 GB, DDR5
Computer systemWindows 11, 64-bit
Development frameworkPyTorch 2.0.1+cu118
Development languagePython 3.11.5
Table 3. Classification performance of the ResNet1D-AttLSTM model under different settings.
Table 3. Classification performance of the ResNet1D-AttLSTM model under different settings.
Scheme 1Scheme 2Scheme 3Scheme 4Scheme 5Scheme 6Scheme 7
Number of
residual blocks
111223
Number of LSTM
layers
222222
Memory cell
dimension
128128128128128128
Number of
attention heads
44812
Attention layer
embedding dimension
128128256256
Accuracy (%)7981.184.387.487.990.188.5
Table 4. Classification performance of the ResNet1D-AttLSTM model on different ship types.
Table 4. Classification performance of the ResNet1D-AttLSTM model on different ship types.
Actual ClassPredicted Class
TowingFishingSailingPassengerTankerPrecision(%)Recall(%)F1(%)
Towing45,849114488874192890.892.591.6
Fishing107544,863206063591786.390.588.4
Sailing1632373742,304840103789.285.487.3
Passenger10911390149243,007257093.086.889.8
Tanker845837690100846,17089.493.291.3
Table 5. Comparison of classification accuracy among different models.
Table 5. Comparison of classification accuracy among different models.
ModelAccuracy (%)
ResNet1D-AttLSTM89.7
FishNet [31]81.4
pGRU [32]82.2
CNN-LSTM [34]84.1
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Ke, J.; Lu, F.; Liu, Y.; Fu, B. A ResNet1D-AttLSTM-Based Approach for Ship Trajectory Classification. Appl. Sci. 2025, 15, 3489. https://doi.org/10.3390/app15073489

AMA Style

Ke J, Lu F, Liu Y, Fu B. A ResNet1D-AttLSTM-Based Approach for Ship Trajectory Classification. Applied Sciences. 2025; 15(7):3489. https://doi.org/10.3390/app15073489

Chicago/Turabian Style

Ke, Jiankang, Faxing Lu, Yifei Liu, and Bing Fu. 2025. "A ResNet1D-AttLSTM-Based Approach for Ship Trajectory Classification" Applied Sciences 15, no. 7: 3489. https://doi.org/10.3390/app15073489

APA Style

Ke, J., Lu, F., Liu, Y., & Fu, B. (2025). A ResNet1D-AttLSTM-Based Approach for Ship Trajectory Classification. Applied Sciences, 15(7), 3489. https://doi.org/10.3390/app15073489

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop