## 2 Materials and Methods
### Modeling  
#### 2.2.1 LSTM Architecture  
Based on the refined data, we developed an LSTM network model, an extension of an RNN, to predict the number of marine accidents by watch duty time. While the RNN is proven to be effective in sequence prediction tasks, numerous problems are still associated with its processing of large data sequences [20]. Due to the gradient propagation problem of the recurrent network over many layers, the RNN is challenging with regard to learning the long-term dependence. [PERSON] and [PERSON] [21] developed the LSTM network to address these concerns. The LSTM network replaces hidden layers with memory cells for modeling long-term dependencies. Figure 3 illustrates the LSTM architectures.  
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline \multirow{2}{*}{**Year**} & \multicolumn{5}{c}{**Frequency of Marine Accidents by Watch Duty Time**} & \multirow{2}{*}{**Total**} \\ \cline{2-2} \cline{4-7}  & **0–4** & **4–8** & **8–12** & **12–16** & **16–20** & **20–24** \\ \hline
1981 & 40 & 59 & 70 & 55 & 59 & 51 & 334 \\
1982 & 31 & 66 & 62 & 45 & 46 & 44 & 294 \\
1983 & 47 & 56 & 54 & 42 & 44 & 45 & 288 \\
1984 & 65 & 76 & 97 & 75 & 99 & 65 & 477 \\
1985 & 53 & 79 & 72 & 63 & 71 & 55 & 393 \\ \(\vdots\) & \(\vdots\) & \(\vdots\) & \(\vdots\) & \(\vdots\) & \(\vdots\) & \(\vdots\) & \(\vdots\) \\
2019 & 214 & 525 & 758 & 741 & 499 & 234 & 2971 \\
2020 & 216 & 586 & 826 & 773 & 499 & 256 & 3156 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Sample of processed data.  
Figure 2: Time series of marine accidents from 1981 to 2020 for: (**a**) original data; (**b**) rescaled data.  
LSTM models were implemented using Keras libraries in Python, and Tensorflow as the backend in the Spyder tool for Python. We initialized weights and biases for each layer using random values. The LSTM consists of forget gate (\(F_{t}\)), input gate (\(I_{t}\)), cell state (\(C_{t}\)), and output gate (\(O_{t}\)), which stores information in memory cells and transfers it to the next stage. The forget gate determines how much past information will be forgotten, and it is the process of applying the sigmoid function after multiplying the current data and the hidden layer values of the past by each weight. The input gate controls new information in the cell based on how important the information is. The cell state forgets the past information as calculated by the forget gate and calculates the current memory cell value by multiplying the current information value by the importance of the input gate. Finally, the output gate determines how the information in the cell will be used in the output cell. Each cell contains weights that are used to control each gate. Optimization of the weights is performed by a training algorithm based on an error resulting from network output [24,25]. The mathematical expression of the forget gate (\(F_{t}\)), input gate (\(I_{t}\)), cell state (\(C_{t}\)), and output gate (\(O_{t}\)) are defined in Equations (1)-(4) [23]:  
\[F_{t}=sigmoid\left(W_{xf}X_{t}+W_{hf}H_{t-1}+b_{f}\right) \tag{1}\]  
\[I_{t}=sigmoid(W_{xin}X_{t}+W_{hin}H_{t-1}+b_{in}) \tag{2}\]  
\[C_{t}=F_{t}C_{t-1}+I_{t}\cdot tanh(W_{xx}X_{t}+W_{hc}H_{t-1}+b_{c}) \tag{3}\]  
\[O_{t}=sigmoid(W_{xout}X_{t}+W_{hoat}H_{t-1}+b_{out}) \tag{4}\]  
where \(t\) is different time steps, \(X_{t}\) represents the \(t\)-th observations of variables, \(tanh\) denotes the hyperbolic tangent function, \(W\) and \(b\) are the parameters of the LSTM network, and \(H_{t}\) is the output of the LSTM, which is defined in Equation (5) [23]:  
\[H_{t}=O_{t}\cdot tanh(C_{t}) \tag{5}\]  
In this study, we used the LSTM models with one and two hidden layers and one output layer, since the time series data covered in this paper is relatively simple. The number of LSTM units and the number of Time Steps of input data in the hidden layer are optimized. The output layer is composed of a dense layer which is a fully connected layer.