# Roll Motion Prediction of Unmanned Surface Vehicle Based on Coupled CNN and LSTM
## 2 Methodology
### LSTM-Based USV Roll Motion Modeling  
LSTM is an elegant variant of the recurrent neural network (RNN) developed by [PERSON] and [PERSON] [37]. It solves the problems of gradient explosion and gradient disappearance in RNN. The core concept of LSTM is cell state and \"gate\". The cell state is equivalent to the path of information transmission, allowing information to pass through the sequence chain, which can be regarded as the \"memory\" of the network. In theory, the cell state is able to pass on relevant information during the sequence processing. The \"gates\" are internal mechanisms that regulate the flow of information by removing or adding information to the cell state. The LSTM cell includes a forget gate, input gate, and output gate as depicted in Figure 4, which are composed of sigmoid and tanh activation functions, pointwise multiplication operation, and pointwise addition operation. In our proposed model, the input of the LSTM layer is the feature maps of the convolution layer output. These feature maps are three-dimensional matrices of \(1\times D-k+1\times N\) with time-series characteristics. The third dimension of these matrices represents the features extracted by the convolution layer. The second dimension of these matrices is used as the time step of the LSTM. \(X_{t}\), \(S_{t}\), and \(C_{t}\) denote the input, the hidden state, and the cell state at time step \(t\), respectively; \(W_{f}\), \(W_{i}\), \(W_{C}\), \(W_{o}\), \(b_{f}\), \(b_{i}\), \(b_{C}\), and \(b_{o}\) denote the weight matrices and the basic matrices of the forget gate, the input  
Figure 4: Diagram of an LSTM cell. Figure 3: Processing of the \(M\)-channel \(1D\)-convolution operation. gate, the cell state, and the output gate, respectively. The process of USV roll motion modeling based on LSTM is as follows:  
* At time step \(t\), the first step is to decide what past step feature maps information will be discarded or retained by the following forget gate \(f_{t}\): \[f_{t}=\sigma(W_{f}\cdot[S_{t-1},X_{t}]+b_{f}).\] (6) The information from the previous time step \(S_{t-1}\) and \(X_{t}\) are passed to the sigmoid function at time step \(t\). The closer the output value is to 0, the more it will be discarded. The closer it is to 1, the more it will be retained. * Then, what new information will be stored in the cell state by the input gate \(i_{t}\) is determined. First, the information of the previous time step \(S_{t-1}\) and \(X_{t}\) are passed to the sigmoid function to decide what information will be updated. Second, the information of the previous time step \(S_{t-1}\) and \(X_{t}\) are passed to the tanh function to create a new candidate value vector \(\widetilde{C}_{t}\). Finally, pointwise multiplication of \(i_{t}\) by \(\widetilde{C}_{t}\) is given as the output. The description is as follows: \[i_{t}=\sigma(W_{i}\cdot[S_{t-1},X_{t}]+b_{i}),\] (7) \[\widetilde{C}_{t}=tanh(W_{c}\cdot[S_{t-1},X_{t}]+b_{c}).\] (8)
* The next step is to update the cell state. First, the previous time step \(C_{t-1}\) is pointwise multiplied by \(f_{t}\). This value is then added point by point with the output value of the input gate. This can be given as: \[C_{t}=C_{t-1}\otimes f_{t}\oplus\widetilde{C}_{t}.\otimes i_{t}\] (9)
* The final step is to produce the output by the output gate \(o_{t}\). First, the information of the previous time step \(S_{t-1}\) and \(X_{t}\) are passed to the sigmoid function to determine which parts of cell state will be produced as output. Then, the updated cell state \(C_{t}\) is passed to the tanh function, creating a new candidate value vector. Finally, the output of the tanh function is multiplied pointwise by \(o_{t}\) to calculate \(S_{t}\). After that, \(S_{t}\) is taken as the output of the current cell, while \(S_{t}\) and \(C_{t}\) are passed to the next time step.