# A ResNet1D-AttLSTM-Based Approach for Ship Trajectory Classification
## 2 Methods
### Construction of the ResNet1D-AttLSTM Model
#### 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, SOC, 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_{in}\times h\) (where \(c_{in}\) 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},\,\ldots,w_{c}\}\) are set, with each kernel size being \(k\times h\). In the second convolutional layer, \(c\) convo  
Figure 3: Structural design of the residual block.  
lution kernels for which \(U=\{u_{1},u_{2},\,\ldots,\,u_{c}\}\) are set, with each kernel size being \(c\times h\). Zero-padding and a stride of 1 are used to maintain the feature dimensions after the convolution operations.  
Assuming the sequence length is \(len\), 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},\,\cdots,\,x_{k,i;i+h-1}\}\big{(}0\leq i \leq len\big{)}\). 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):  
\[\left\{\begin{array}{l}f_{1}=ReLU\Big{(}BN\Big{(}\sum_{m=1}^{c}\,\,\sum_{n= 0}^{h-1}\,\,w_{m,n}\cdot x_{m,i+n}+b_{1}\Big{)}\Big{)}\\ f_{2}=ReLU\Big{(}BN\Big{(}\sum_{m=1}^{c}\,\,\sum_{n=0}^{h-1}\,\,u_{m,n}\cdot f _{1,m,i+n}+b_{2}\Big{)}\Big{)}\\ Y_{i}=ReLU\big{(}f_{2}+X_{i}\big{)}\end{array}\right. \tag{1}\]  
In the equation, \(BN\) 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},\,\cdots,\,y_{c,i}\}\) (\(0\leq i\leq len\)).