## 2 LSTM for Ship Motion Prediction  
### LSTM Theory  
The LSTM unit structure is composed of the forgetting gate, input gate, output gate, and unit state. The unit structure is shown in Figure 1. At the current time \(t\), there are three input parameters of the LSTM network: input value \(x_{t}\) at the current time (such as wave elevation), output value \(h_{t-1}\) at the previous time (such as roll motion), and unit state \(C_{t-1}\) at the previous time. There are two output parameters: the current time output value \(h_{t}\) and the current time unit state \(C_{t}\). Through the activation function \(\sigma\), the LSTM realizes the control of the three gates, so as to preserve and forget the historical information. Referring to study [21] for the specific principle of the mathematical expression of the gating structure. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Model** & **Input** & **Reference** \\ \hline KF & sway & [PERSON] and [PERSON] (1982) [1] \\ MCA & 6-DoF motion & [PERSON] et al. (2004) [2] \\ NARX & state attribute & [PERSON] et al. (2017) [3] \\ DNN-AR & roll & [PERSON] et al. (2018) [4] \\ IRF-AR & heave, pitch & [PERSON] et al. (2015) [5] \\ DWT-RBF & roll & [PERSON] et al. (2018) [6] \\ SVR-PSO & roll & [PERSON] and [PERSON] (2019) [7] \\ AR-EMD-SVR & heave, pitch & [PERSON] et al. (2015) [8] \\ RNN & 6-DoF motion & [PERSON] (2005) [9] \\ LSTM & roll, pitch & [PERSON] et al. (2017) [11] \\ GRU & state attribute & [PERSON] et al. (2021) [12] \\ CNN-LSTM & roll & [PERSON] et al. (2019) [13] \\ EMD-LSTM & motion & [PERSON] et al. (2020) [14] \\ PSO-EMD-LSTM & roll, pitch, heave & [PERSON] et al. (2019) [15] \\ EMD-PSO-LSTM & roll, pitch & [PERSON] et al. (2023) [16] \\ AM-LSTM & 6-DoF motion & [PERSON] et al. (2021) [17] \\ LSTM-GPR & roll, pitch & [PERSON] et al. (2022) [18] \\ BLSTM-TPA & roll & [PERSON] et al. (2021) [19] \\ MISO-BLSTM-TPA & roll & [PERSON] et al. (2021) [20] \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Summarization of machine learning models for ship motion prediction. The function of forgetting gate determines how many \(C_{t-1}\) unit states need to be retained until the current moment. The mathematical expression is as follows:  
\[f_{t}=\sigma(W_{f}\cdot[h_{t-1},x_{t}]+b_{f}) \tag{1}\]  
where \(W_{f}\) is the vector weight; \(b_{f}\) is the offset vector quantity. The gate will read the two input values, \(x_{t}\) and \(h_{t-1}\), and activate the function \(\sigma\) (sigmoid function) that controls the output of a value between 0 and 1 to \(C_{t-1}\), where 0 represents the complete rejection of \(C_{t-1}\) and 1 represents the complete retention of \(C_{t-1}\). The function of the input gate determines how much new data need to be saved to the cell state \(C_{t}\). The mathematical expression is as follows:  
\[i_{t}=\sigma(W_{i}\cdot[h_{t-1},x_{t}]+b_{i}) \tag{2}\]  
\[\widetilde{C}_{t}=\tanh(W_{c}\cdot[h_{t-1},x_{t}]+b_{c}) \tag{3}\]  
\[C_{t}=f_{t}\cdot C_{t-1}+i_{t}\cdot\widetilde{C}_{t} \tag{4}\]  
The gate needs two steps to realize the new unit state \(C_{t}\). The first step is to determine which information needs to be updated through Equation (2), and calculate the temporary state at the current time through Equation (3). The second step is to obtain the new unit state \(C_{t}\) at the current time through Equation (4). The function of the output gate controls how much of the unit state \(C_{t}\) needs to be output to \(h_{t}\). The mathematical expression is as follows:  
\[o_{t}=\sigma(W_{o}[h_{t-1},x_{t}]+b_{o}) \tag{5}\]  
\[h_{t}=o_{t}\cdot\tanh(C_{t}) \tag{6}\]  
The door activates the function through Equation (5) \(\sigma\) to determine the output part \(o_{t}\) in the cell state \(C_{t}\), and then determine the final output value \(h_{t}\) through Equation (6). ### LSTM Theory  
The main process of the ship motion prediction model based on the LSTM neural network includes data preprocessing, model parameter setting, model training, prediction data, and prediction result evaluation.