## 4 Anomaly Detection Model Training
### Long Short-Term Memory (LSTM)  
A recurrent neural network (RNN) is mainly used to learn ordered data or time-series data such as natural language processing and speech recognition [50; 51; 52; 53; 54; 55; 56; 57; 58; 59]. However, RNN has the vanishing gradient problem that significantly reduces the learning ability when the distance between the previous output and the point where it uses the information from that output is far away [60; 61]. LSTM is the proposed neural network architecture to solve this vanishing gradient problem. An LSTM network is composed of connected multiple LSTM cells as shown in Figure 7 [62].  
Equations (2)-(7) are the equations for an LSTM cell unit. In each equation, \(W_{q},~{}U_{q}\), and \(b_{q}~{}(q=f,~{}i,~{}o,~{}c)\) denote weight and bias, respectively. Here, \(x_{t}\) represents the input vector of the LSTM cell unit, \(f_{t}\) represents the forget gate's activation vector, \(i_{t}\) represents the input/update gate's activation vector, \(o_{t}\) represents the output gate's activation vector, \(\widetilde{c_{t}}\) represents the cell input activation vector, \(h_{t}\) represents the hidden state vector that is known as the LSTM cell unit's output vector, and \(\odot\) represents the Hadamard product [63].  
\[f_{t}=\sigma\Big{(}W_{f}~{}x_{t}+U_{f}~{}h_{t-1}+b_{f}~{}\Big{)} \tag{2}\]  
\[i_{t}=\sigma(W_{i}~{}x_{t}+U_{i}~{}h_{t-1}+b_{i}~{}) \tag{3}\]  
\[o_{t}=\sigma(W_{o}~{}x_{t}+U_{o}~{}h_{t-1}+b_{o}~{}) \tag{4}\]  
\[\widetilde{c}_{t}=tanh(W_{c}~{}x_{t}+U_{c}~{}h_{t-1}+b_{c}~{}) \tag{5}\]  
\[c_{t}=f_{t}\odot c_{t-1}+i_{t}\odot\widetilde{c}_{t} \tag{6}\]  
\[h_{t}=o_{t}\odot tanh(c_{t}~{}) \tag{7}\]  
We trained the engine clutch engagement/disengagement anomaly detection model using LSTM by configuring the input/output structure as shown in Figure 8. The network was constructed by sequentially connecting the LSTM layer, fully connected layer, softmax  
\begin{table}
\begin{tabular}{c c c} \hline \hline \multirow{2}{*}{**Model**} & **The Number of** & **The Number of** \\  & **Hidden Layers** & **Hidden Units per** \\  & & **Hidden Layer** \\ \hline MLP-m1 & 1 & 10 \\ MLP-m2 & 2 & 10 \\ MLP-m3 & 3 & 10 \\ MLP-m4 & 1 & 100 \\ MLP-m5 & 3 & 100 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Hidden layer and hidden unit settings for MLP-based anomaly detection models.  
Figure 7: LSTM architecture.  
layer, and classification layer, as shown in the figure. We inputted target signals per pattern into the LSTM layer and configured normal/anomaly per pattern as the output of the network. We also matched the LSTM's input data length to the length of the longest pattern using Equation (1). The data were normalized so that the average of the input data is zero before inputting the data.  
The number of LSTM layers and hidden units for the model based on LSTM were composed as shown in Table 5. We set these values to an appropriate value through trial and error. This configuration is for comparing training results according to the number of hidden units per LSTM layer and training results according to the number of LSTM layers. But as there are many learning parameters for each LSTM layer, it can be overfitted if there are many layers. Therefore, to prevent this, we reduced the number of hidden units per layer if there were three LSTM layers. For training, 80% of the data shown in Table 3 were randomly sampled, and other data were used as test data.