# Wi-GC: A Deep Spatiotemporal Gesture Recognition Method Based on Wi-Fi Signal
## 4 Method Design
### RAGRU Model
#### 4.5.3 Improved ResNet18  
In recent years, CNN has become a research hotspot due to its good performance in areas such as image processing and speech recognition. ResNet is a high-performing variant of CNN, which is good at extracting local and spatial features of data, with excellent performance and fewer model parameters. However, the data features extracted by ResNet have the same weight. To solve this problem, we added the Convolutional Block Attention Module (CBAM) to ResNet18, which can adaptively focus on essential features in both channels and space [44]. The structure is shown in Figure 9.  
Figure 9: CBAM structure. The channel attention is in front of the spatial attention. The input feature map performs maximum global pooling and global draw pooling, respectively. Then the max pooling and average pooling results are processed using two shared, fully connected layers. Then add the processing results and obtain the normalized attention weight through the Sigmoid function. Finally, the obtained weights are multiplied by the original input feature map, thus completing the redefinition of the original features by channel attention. The formula is shown below:  
\[M_{c}(F) =\sigma(MLP(AvgPool(F))+MLP(MaxPool(F)))\] \[=\sigma\Big{(}W_{1}\Big{(}W_{0}\Big{(}F^{c}_{avg}\Big{)}\Big{)}+ W_{1}(W_{0}(F^{c}_{max}))\Big{)} \tag{14}\]  
\[F^{\prime}=M_{C}(F)\otimes F, \tag{15}\]  
The spatial attention mechanism will take maximum pooling and average pooling on the channel of each feature point of the input feature layer. After that, the two results are stacked. The feature map is then downscaled using a convolution with a channel number of 1, a convolution kernel of \(1\times 1\) and the Relu activation function. Then take a Sigmoid activation function. At this point, the weight of each feature point of the input feature layer is obtained. After obtaining the weight, we multiply this weight by the feature map obtained by channel attention and finally output a new feature map to complete the recalibration of the feature map in the two dimensions of space and channel. as shown in the formula below:  
\[M_{s}(F^{\prime}) =\sigma\big{(}f^{1\times 1}([AvgPool(F);MaxPool(F)])\big{)}\] \[=\sigma\Big{(}f^{1\times 1}\Big{(}\Big{[}E^{s}_{avg};F^{s}_{max} \Big{]}\Big{)}\Big{)} \tag{16}\]  
\[F^{\prime}=M_{S}(F^{\prime})\otimes F^{\prime}, \tag{17}\]  
With the emergence of neural network structures such as LeNet-5 and AlexNet, CNN has gradually developed from a neural network with a single convolution and pooling operation to a neural network with average pooling, maximum pooling, dropout and nonlinear functions. While the network structure has become increasingly complex, experts have found that the efficiency of the neural network has not achieved the expected effect. On the contrary, it is prone to gradient disappearance and so on. Therefore, the ResNet neural network appeared. It is a way of adding shortcuts between several convolutional layers to solve the problem of poor training when the number of neural network layers is gradually increased. We adopt ResNet18 because of its low complexity, few parameters and better performance. Our ResNet18 is structured by adding a CBAM after the first convolutional layer and a CBAM after the last residual block. The structure is shown in Figure 7. The ResNet18 residual block is shown in Figure 10.  
Figure 9:0 ResNet18 residual blocks. The figure above shows a residual block of ResNet18, where \(F(X)\) is the residual function, and the residual function we use is the Relu function. The advantage of the residual network is that the complete output learning problem is reduced to the residual learning problem. This structure's advantage is adding a shortcut outside the two convolutional layers, which not only solves the problem of gradient disappearance but also improves the computational efficiency. So \(X\) can be output as \(F(X)+X\) after passing through two convolutional layers.