# Wi-GC: A Deep Spatiotemporal Gesture Recognition Method Based on Wi-Fi Signal
## 4 Method Design
### RAGRU Model
#### 4.5.1 BAGRU  
Due to the time-dependent capture and sequence modeling ability, Recurrent Neural Networks (RNNs) have been successfully applied in many fields [37]. However, initial RNNs do not make good use of historical information and, if the learned data sequence is too long, it will lead to vanishing gradients and significant problems [38]. The length of the learning sequence is generally positively related to the system's performance. In most cases, long learning sequences are necessary. A new RNN structure proposed in Ref. [39], namely LSTM, is proposed, which effectively compensates for the shortcomings of traditional RNNs by adding memory units of special gates. GRU is a very successful variant of LSTM. It was first presented in Ref. [40].  
In our Wi-GC method, the BiGRU network is used to extract the timing features of gesture recognition. It differs from the traditional GRU network and the BiGRU has two layers: forward and backward. In the process of learning CSI information features, both past information and future information may be considered. Specifically, the forward layer encodes the information of the past time steps into the current hidden state, thus taking into account the past data of the CSI sequence. The backward layer encodes the information of future time steps into the current hidden state, thus taking into account the future information of the CSI sequence. We use the BiGRU network, which learns all the information from the CSI data.  
In addition, in the traditional BiGRU network, the learned features have the same weight in gesture classification. To resolve the problem, we introduce a self-attention mechanism in BiGRU, BAGRU, which can be used for each time step and feature, assign a weight and learn the importance of each time step and feature autonomously. Therefore, assigning higher weights to more important time steps and features improves method performance.  
As shown in Figure 8, when \(x_{t}\) and \(h_{t-1}\) are input, the GRU at time \(t\) updates itself in the following way.  
\[z_{t}=\sigma(W_{z}\cdot[h_{t-1},x_{t}]), \tag{6}\]  
\[r_{t}=\sigma(W_{r}\cdot[h_{t-1},x_{t}]), \tag{7}\]  
\[\widetilde{h}_{t}=\tanh(W_{h}\cdot[r_{t}\times h_{t-1},x_{t}]+b_{h}), \tag{8}\]  
\[h_{t}=(1-z_{t})\times h_{t-1}+z_{t}\times\widetilde{h}_{t}, \tag{9}\]  
where \(w_{z},w_{r}\) and \(w_{h}\) are the weights and \(b_{h}\) is the bias. The \(\tanh(\cdot)\) function is the hyperbolic tangent and the \(\sigma(\cdot)\) function is the Sigmoid activation function. \(r_{t}\) is the reset gate, \(z_{t}\) is the update gate, \(\widetilde{h}_{t}\) is the candidate's hidden state and \(h_{t}\) is the hidden state passed to the next moment. \([r_{t}\times h_{t-1},x_{t}]\) represents the splicing of \(r_{t}\times h_{t-1}\) and \(x_{t}\). The \(\tanh(\cdot)\) activation function constrains each element of \(h_{t}\) to be within the range of \([-1,1]\), while the Sigmoid activation function can assign each element a value between \([0,1]\) to selectively forget or remember the current input, where 0 means forget all and 1 means all are reserved.  
To consider both past and future CSI information, BAGRU consists of two layers, as shown in Figure 7. \(h_{f}^{t}\) is the hidden forward state at time \(t\) and \(h_{b}^{t}\) is the hidden state of the backward layer at time \(t\). Therefore, the hidden state of BAGRU can be represented as follows:  
\[h_{t}=h_{f}^{t}\oplus h_{b}^{t}, \tag{10}\]