# Walking Gait Phase Detection Based on Acceleration Signals Using LSTM-DNN Algorithm
## 3 Materials and Methods
### Proposed LSTM-DNN Algorithm  
LSTM network is proposed based on a cyclic neural network (CNN). [PERSON] et al. [40] proposed the LSTM network by adding thresholds such as an input gate, forget gate, output gate, and memory unit, which solved the problem of gradient disappearance or gradient explosion of the RNN and improved the network's ability to process long sequence data. The difference between LSTM and an ordinary neural network is that the nodes between the hidden layers are connected, i.e., the input of the hidden layer at the given time not only contains the output of the hidden layer prior to the given time but also includes the output of the same hidden layer at a previous time. The historical information of the time series is stored in the network hidden layer [41]. The LSTM can be utilized to process sequence data. Since the acceleration signal we collect is a time-series signal, the LSTM network can be utilized to process the acceleration signal. Unlike traditional classifiers such as SVM, the LSTM can capture feature vectors conveniently and automatically. The feature vectors enter the network directly and a modified classification model is established, whereas a traditional classification model requires more time to extract the feature vectors, leading to possible failure in the data preprocessing stage [42]. The LSTM algorithm model is shown in Figure 5[43], where \(x_{t}\) is the input eigenvector of the current cell, \(h_{t-1}\) is the output of the last cell, sigma is the sigmoid function, \(f_{t}\) is the forget gate for information to be abandoned, \(c_{t-1}\) is the unit before the update, and the output value of \(f_{t}\) is a real number between 0 and 1; 0 means to forget all the information of the previous cell unit and 1 means to retain all the information of the previous cell unit and input the output value to \(c_{t-1}\). The calculation process of the forget gate is defined in Equation (2); the information is discarded when the input information passes through the forget gate. The input gate consists of two parts, i.e., a sigmoid layer  
Figure 4: Sliding window segmentation of acceleration data. Here RF represents the acquired foot acceleration data, RC represents the acquired calf acceleration data, and RT represents the collected thigh acceleration data. and the tanh layer. The sigmoid layer is responsible for information that requires updating and the tanh layer is responsible for creating the vector of the alternative update content; these two parts are combined and represent the output of the output gate. The calculation is defined in Equation (3) and Equation (4). After the information passes through the forget gate and input gate, the cell state will be updated. The calculation is defined in Equation (5); the old status \(c_{t-1}\) is updated to \(c_{t}\). Finally, the output gate also includes a sigmoid layer and a tanh layer. The sigmoid layer determines which input information needs to be output and the tanh layer processes the information of the cell state and combines the two parts as the output of the output gate. The calculation process is shown in Equations (6) and (7), where \(w_{f},w_{i},w_{c},w_{o}\) represent the weights of the input of the current eigenvector through each control gate and \(b_{f},b_{i},b_{c},b_{o}\) represent the bias terms of the control gate. \[f_{t}=\sigma(w_{f}\cdot(h_{t-1}+x_{t})+b_{f}) \tag{2}\]  
\[i_{t}=\sigma(w_{i}(h_{t-1}+x_{t})+b_{i}) \tag{3}\]  
\[g_{t}=\tan\mathrm{h}(w_{\mathrm{C}}\cdot(h_{t-1}+x_{t})+b_{c}) \tag{4}\]  
\[c_{t}=c_{t-1}\times f_{t}+i_{t}\times g_{t} \tag{5}\]  
\[o_{t}=\sigma(w_{o}\cdot(h_{t-1}+x_{t})+b_{0}) \tag{6}\]  
\[h_{t}=o_{t}\times\tan\mathrm{h}(c_{t}) \tag{7}\]  
DNN algorithms have been widely used in industry and academia in recent years. The DNN algorithm provides good recognition rates. As an important machine learning method, a DNN performs particularly well for multi-label classification [44]. This study focuses on the identification of two classes, namely, the stance phase and swinging phase.