# Estimation of Hand Motion from Piezoelectric Soft Sensor Using Deep Recurrent Network
## 3 Application of Recurrent Network
### Proposed Network  
To train the moving state of the sensor, we used a recurrent neural network (RNN), which is appropriate for training a sequential dataset. Using input vector \(x_{t}\) and previous hidden state \(h_{t}\), a simple RNN determines the hidden state as follows:  
\[h_{t}=\tanh(x_{t}W_{x}+h_{t-1}W_{h}+b), \tag{17}\]  
where \(W_{h}\), \(W_{x}\), and \(b\) are the network parameters.  
Given that hidden state \(h_{t}\) is determined with previous hidden state \(h_{t-1}\), simple RNN can contain sequential information based on the recurrent hidden state. However, when the length of the data becomes larger, the gradient vanishes and explodes. To solve the problem and transfer the hidden layer information deeper, Long Short-Term Memory is proposed in [24]. Using cell vector \(c_{t}\) and several gates, the hidden state \(h_{t}\) is calculated as follows:  
\[f_{t} =\sigma(x_{t}W_{x}^{(f)}+h_{t-1}W_{h}^{(f)}+b^{(f)}), \tag{18}\] \[g_{t} =\tanh(x_{t}W_{x}^{(g)}+h_{t-1}W_{h}^{(g)}+b^{(g)}),\] (19) \[i_{t} =\sigma(x_{t}W_{x}^{(i)}+h_{t-1}W_{h}^{(i)}+b^{(i)}),\] (20) \[o_{t} =\sigma(x_{t}W_{x}^{(o)}+h_{t-1}W_{h}^{(o)}+b^{(o)}),\] (21) \[c_{t} =f\odot c_{t-1}+g_{t}\odot i\] (22) \[h_{t} =o\odot\tanh(c_{t}) \tag{23}\]  
where \(i_{t}\), \(f_{t}\), and \(o_{t}\) are input gate, forget gate, and output gate vector, respectively; \(g_{t}\) and \(h_{t}\) are cell input and output activation functions; \(W\) and \(b\) denote weight matrices and bias vector of the network; \(\odot\) is the element-wise product of the vectors; and \(\tanh\) is output activation function. \(h_{t}\) of LSTM unit can save more sequential information than \(h_{t}\) of simple RNN unit. The network size of LSTM is four times larger than RNN. We applied both recurrent units into the proposed network and compared the performance.  
To implement the real-time moving state estimation, we propose the network as shown in Figure 6. At each time step \(t_{n}\), \(X(t_{n})\) passes two recurrent layers and produces the hidden layer \(h(t_{n})\), which contains the sequential information of \(X(t_{n})\). To convert the sequential information into a single moving state, the fully connected layer combines the information of \(h(t_{n})\) and determines the final output. Given that state 1 refers to moving and 0 refers to stopping, the final output of the network \(p(t_{n})\) states the probability of moving. Therefore, we define the predicted moving state \(m_{p}(t_{n})=[p(t_{n})]\).  
\begin{table}
\begin{tabular}{l c c} \hline \hline  & **Number of the Data** & **Number of the Movement** \\ \hline Training Set & 214,775 & 1080 \\ Test set & 59,660 & 270 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Summary for the dataset.  
We trained the network for 100 epochs and used stochastic gradient descent (SGD) as the optimizer. In addition, we applied a dropout layer after the final recurrent layer at a rate of 50% rate in training to avoid overfitting.  
As the recurrent unit, we used simple RNN and LSTM units and compared the result. Table 2 displays the result for accuracy of the training set and test set for both methods.  
From the result, the model using LSTM unit exhibited slightly higher accuracy for the test and training set. In addition, the test accuracy of the model using the LSTM unit is more consistent than that of the model using simple RNN. The result indicates that only simple substitution for the recurrent unit without network structure change results in performance improvement in the proposed network. As stated in [25], there exists a modeling weakness of a simple RNN structure