## 4 Reasoner Development
### Long Short-Term Memory Reasoner  
With the data from the EMA model simulation, the prospect of a reasoner employing Long Short-Term Memory (LSTM) is studied. The ability of remembrance demonstrated by this NN approach makes it of particular interest in applications related to forecasting and time series classification [24]. This ability comes from the incorporation of a memory cell in its architecture.. Each cell takes in an input, the previous cell state, the weight and biases parameters determine what values are passed on to the next cell and which data are retained or ultimately forgotten [25]. Formulas governing the LSTM model used can be found from Equations (5)-(10) [26]:  
\[\text{Cell state, }\texttt{c}_{t}=f_{t}\odot\texttt{c}+i_{t}\odot g_{t} \tag{5}\] \[\text{Hidden state, }\texttt{h}_{t}=\texttt{o}_{t}\odot \sigma_{c}(\texttt{c}_{t})\] (6) \[\text{Input gate, }\texttt{i}_{t}=\sigma_{g}(W_{i}X_{t}+R_{i}h_{t-1}+b_ {i})\] (7) \[\text{Output gate, }\texttt{o}_{t}=\sigma_{g}\big{(}W_{o}X_{t}+R_{g}h_{t- 1}+b_{o}\big{)}\] (8) \[\text{Forget gate, }\texttt{f}_{t}=\sigma_{g}\big{(}W_{f}X_{t}+R_{f}h_{t- 1}+b_{f}\big{)}\] (9) \[\text{Cell candidate, }\texttt{g}_{t}=\sigma_{c}(W_{o}X_{t}+R_{o}h_{t- 1}+b_{o}) \tag{10}\]  
where \(W\), \(X\), \(R\), \(h\) and \(b\) denote weight, input, recurrent weights, and biases. The gate activation function is represented by \(\sigma_{g}\).  
The use of LSTM is chosen for the experiment due to a number of reasons, including the ability to learn information in a considerably long time period, ability to remember previous states, LSTM's insensitivity to gap length, noise handling, and no need for fine-tuning of parameters [27; 28].  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Feature Name** & **Label** \\ \hline EMA Electric Motor Open Circuit Fault & 1 \\ EMA Electric Motor Intermittent Open Circuit Fault & 2 \\ EMA Electric Motor Jamming & 3 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Data Obtained from EBS Model.  
MATLAB R2020b was used for the LSTM reasoner modelling. The implemented model consists of five layers which are namely the input, bi-directional, fully-connected, softmax and classification layers as shown in Figure 6. The input layer takes in the sequence followed by the bi-directional layer responsible for studying the dependencies through the length of the time series. The activation function for state and cell in this layer is a hyperbolic tangent function on which the sigmoid function dictates the gate activation function.  
The fully connected layer is a feed-forward neural network, and the number of hidden layers within this network is customisable. This is followed by a final layer of activation function, the softmax layer, which is a normalisation function that converts the output of the previous layer to a value in the range of 0 to 1. This layer then passes the values to the next classification layer, which calculates the cross-entropy between the prediction and the classified label.  
Cross-entropy is defined as the extra bits required to represent an event from one distribution to another [29]. The lower the value of cross-entropy, the better the classification of the label. The cross-entropy function employed by the training network is defined in [30] and is shown in Equation (11).  
\[Loss=-\frac{1}{N}\sum_{n=1}^{N}\sum_{k=1}^{K}w_{i}t_{ni}\ln y_{ni} \tag{11}\]  
in which \(N\) denotes the number of samples, \(i\) and \(w\) represent the class and weight, respectively. \(t_{ni}\) corresponds to the class of the \(n\)th sample and \(y_{ni}\) to the output for the \(n\)th sample of \(i\)th class. The learning rate optimiser employed in the model is an adaptive moment estimation. LSTM reasoner model parameters are shown in Table 4.