## 2 Methodology
### Cascaded Unidirectional and Bidirectional LSTM-Based DRNN Model for HAR  
A recurrent neural network (RNN) is composed of cyclic connections that can learn the temporal dynamics of sequential data. As the data collected from gaits using an IMU sensor are sequential, RNN may be suitable for classifying normal and abnormal gaits. However, training regular RNNs can be challenging due to vanishing or exploding gradient problems which interfere with the network's ability to backpropagate gradients over long time intervals [52; 53]. To solve this problem, LSTM-based RNNs were suggested [54; 55; 56]. However, LSTM-based RNNs can replace traditional nodes with memory cells with internal and outer recurrence to the model temporal sequence and a wide range of dependencies. The architecture of an LSTM cell is presented in Figure 4.  
Figure 4: LSTM cell architecture. Figure 3: Graphical summary of experimental site and procedure; (**a**) site and sections; (**b**–**m**) representative pictures of each section; (**n**) first stage of experiment (data collection); and (**o**) second stage of experiment (examination and record of environmental barrier expressed by participants). The architecture in Figure 4 is defined as the following Equations (1)-(6). The training process of an LSTM-based DRNN is focused on the parameters \(b\), \(U\), and \(W\) of the cell gates. \[f_{t}=\sigma\ \left(W_{f}x_{t}+U_{f}h_{t-1}+b_{f}\right) \tag{1}\]  
\[i_{t}=\sigma\ (W_{i}x_{t}+U_{i}h_{t-1}+b_{i}) \tag{2}\]  
\[o_{t}=\sigma(W_{o}x_{t}+U_{o}h_{t-1}+b_{o}) \tag{3}\]  
\[g_{t}=\sigma\big{(}W_{g}x_{t}+U_{g}h_{t-1}+b_{g}\big{)} \tag{4}\]  
\[c_{t}=g_{t}\odot i_{t}+f_{t}\odot c_{t-1} \tag{5}\]  
\[h_{t}=\tanh(c_{t})\odot o_{t} \tag{6}\]  
The \(\odot\) symbol represents the Handarmard product (element-wise multiplication of vectors), and the \(\sigma\) symbol represents the sigmoid function. All the LSTM cells in each layer share the same weights (\(W_{p}\), \(U_{f}\), \(W_{i}\), \(U_{i}\), \(W_{o}\), \(U_{o}\), \(W_{g}\), and \(U_{g}\) and biases \(b_{f}\), \(b_{i}\), \(b_{o}\), and \(b_{g}\)). The output of each LSTM cell is used as the input for the next cell. Moreover, the outputs of each LSTM cell in the first layer in the DRNN are fed as inputs to the second layer. The suggested LSTM-based DRNN model consists of two types of LSTM networks, unidirectional and bidirectional, as shown in Figure 5. The model includes four types of layers in which the first layer is bidirectional and the upper layers (second, hidden, and output layers) are unidirectional RNNs. The first layer includes two parallel LSTM tracks. In the first layer, there are forward LSTMs (sky-blue boxes) and backward LSTMs (green boxes). The sequences such as \(x_{1}\), \(x_{2}\),..., \(x_{t}\) are inputted in the first layer; the sequences are inputted to forward LSTMs and backward LSTMs, respectively. After inputting sequences, the \(LSTM^{\text{1}}\) (forward LSTM) generates an output (\(y_{1}^{\text{1}}\), \(y_{2}^{\text{1}}\),..., \(y_{T}^{\text{1}}\)) and the \(LSTM^{\text{b1}}\) (backward LSTM) generates an  
Figure 4:0 The structure of cascaded unidirectional and bidirectional LSTM-based DRNN. output \((y_{1}^{b1},\ y_{2}^{b1},\ \cdots,y_{T}^{b1})\). The two types of outputs from forward and backward LSTM are concatenated to generate a new output \((y_{1}^{1},\ y_{2}^{1},\ \cdots,y_{T}^{b1})\) that is inputted into the second layer. This process of bidirectional LSTM follows Equations (7)-(9). Figure 4:1  
Figure 4:2  
Figure 4:3  
The second layer is a unidirectional LSTM structure. The concatenated output \((y_{1}^{1},\ y_{2}^{1},\ \cdots,y_{T}^{1})\) are inputted to the second layer. After inputting the concatenated output, the second, the hidden, and output layers are operated as following a general process of a unidirectional LSTM-based DRNN.