# Surface Electromyography-Based Action Recognition and Manipulator Control
## 2 Method and Mathematical Background
### Selection of Classifier
#### 2.5.1 BP Neural Network  
The neural network possesses powerful physical computing skills to simulate the neural network structure and function of the creatures. The biosignals are always very complicated and bring great non-stationarity and diversity. The BP neural network has an excellent classification effect on non-stationary signals, and can be used to classify the action by surface EMG signals. BP neural network is the most popular in artificial neural network and is widely applied for the classification of diverse data. The BP neural network is a multilayer network composed of the input layer, at least 1 hidden layer, and an output layer. This multilayer network, and the weights and thresholds of each layer form a complete feedforward neural network. The error is transferred forward from the output layer to the input layer, through the hidden layer. Contrary to error, the input transfers from the input layer to the output layer through the hidden layer. During the transfer, the value of the neurons in each layer only directly affects that in the next layer, while the other layers are not affected. After being transmitted to the output layer, the result is compared with the expectation. If the error exceeds the preset, the error is transmitted forward. In the meantime, the weights and thresholds of each layer are constantly modified. The network training does not stop until the error is reduced below the preset [36; 37]. We selected a 3-layer BP neural network. \(\omega_{ji}\) is the weight between the input layer and the hidden layer, and \(\omega_{kj}\) is the weight between the hidden layer and the output layer. The number of input nodes is \(n\), the number of hidden layer nodes is \(l\), and that of the output nodes is \(m\). The process can be simply regarded as a function mapping. \(a_{j}\), \(j=1,\ 2,\dots,\ l\) and \(b_{k}\), \(k=1,\ 2,\dots,\ m\) are the exact thresholds of the \(j\)th node of the hidden layer and the \(k\)th node of the output layer separately. When doing the classification, we first need to train the eigenvalues extracted from the sEMG signals. When the training is completed, we can test the samples and predict whether these samples can meet the expectation. The whole process can be divided into 7 steps:  
(i) Neural network initialization. The number \(n\) is equal to the number of rows of eigenvalue matrix. The number \(m\) is the number of actions to be classified, and then the number of nodes in the hidden layer is needed to be calculated. It is also necessary to initialize the \(\omega_{ji}\), \(\omega_{kj}\), \(a_{j}\), and \(b_{k}\). Then the learning rate, training times, transfer function, training error, etc. are gained. (ii) Calculate the output of the hidden layer. Here, \(X\)= \(\{x_{1},\ x_{2},\dots,\ x_{n}\}\) is the eigenvalue sequence extracted from the EMG signals, so the output \(H\)= \(\{h_{1},\ h_{2},\dots,\ h_{l}\}\) is:  
\[h_{j}=f\bigg{(}\sum_{i=1}^{n}\omega_{ji}x_{i}-a_{j}\bigg{)}\quad j=1,2,\dots,l \tag{9}\]  
where \(f(\cdot)\) is the excitation function of the hidden layer. (iii) Calculate the result of the output layer. The final output \(O=\{o_{1},\ o_{2},\dots,\ o_{m}\}\) is:  
\[o_{k}=\sum_{j=1}^{l}h_{ji}\omega_{kj}-b_{k},\quad k=1,2,\dots,m \tag{10}\]  
(iv) Calculate the prediction error between the output and the expectation:  
\[e_{k}=y_{k}-o_{k},\quad k=1,2,\dots,m \tag{11}\]  
in which \(y_{k}\) is the expectation. (v) Modify and change the weights \(\omega_{\rm{ij}}\), and \(\omega_{kj}\) according to error \(e\). \[\left\{ \begin{array}{l}\omega_{ii}=\omega_{ji}+\eta h_{j}(1-h_{j})x_{i}\sum \limits_{k=1}^{m}\omega_{ki}\epsilon_{k}\\ \omega_{kj}=\omega_{kj}+\eta h_{j}e_{k}\\ i=1,2,\ldots,n;\quad k=1,2,\ldots,m\end{array} \right. \tag{12}\]  
(vi) Update the thresholds \(a_{j}\) and \(b_{k}\) by the error \(e\). \[\left\{ \begin{array}{l}a_{j}=a_{j}+\eta h_{j}(1-h_{j})\sum\limits_{k=1}^{m} \omega_{kj}\epsilon_{k},\quad j=1,2,\ldots,l\\ b_{k}=b_{k}+e_{k},\quad k=1,2,\ldots,m\end{array} \right.