# Research on CNN-BiLSTM Fall Detection Algorithm Based on Improved Attention Mechanism
## 3 Materials and Methods
### Construction of Fall Detection Model
#### 3.3.2 Convolutional Block Attention Module  
The convolutional block attention module (CBAM) is a simple and effective attention module of the convolutional neural network. Given a feature map \(F\in R^{C\times H\times W}\) as input, the CBAM derives a one-dimensional channel attention \(M_{C}\in R^{c\times 1\times 1}\) and a two-dimensional spatial attention \(M_{S}\in R^{1\times H\times W}\), in turn, as shown in Figure 7. The whole process can be represented by the following formulas:  
\[F^{\prime}=M_{C}(F)\otimes F \tag{7}\]  
\[F^{\prime\prime}=M_{S}\big{(}F^{\prime}\big{)}\otimes F^{\prime} \tag{8}\]  
wherein \(\otimes\) indicates multiplication of the corresponding elements. Before multiplication, the channel attention and space attention need to be broadcast according to the space dimension and channel dimension, respectively. \(F^{\prime}\) is the feature map after the channel attention's adjustment, and \(F^{\prime\prime}\) is the final output feature map. For effective calculation of the channel attention, global mean pooling and maximum pooling are used firstly to aggregate the spatial information of feature mapping, thus generating two different channel descriptors, \(F^{C}_{avg}\) and \(F^{C}_{max}\). The two descriptors are then forwarded to the shared network to generate the channel attention map \(M_{C}\in R^{c\times 1\times 1}\)  
Figure 7: (a) Channel attention module in CBAM; (b) spatial attention module in CBAM. The shared network consists of a multilayer perceptron (MLP) with a hidden layer. The mathematical expression of the channel attention module is as follows:  
\[M_{\text{C}}(F)=\sigma(MLP([AvgPool(F))+MLP([MaxPool(F)))=\sigma\Big{(}W_{1}\Big{(} W_{0}\Big{(}[F_{avg}^{C}\Big{)}\Big{)}+W_{1}\Big{(}W_{0}\Big{(}[F_{max}^{C} \Big{)}\Big{)}\Big{)} \tag{9}\]  
wherein \(\sigma\) represents the Sigmoid function; \(w_{0}\in R^{\xi\times C},W_{1}\in R^{\frac{C\times C}{\tau}}\); the weights \(W_{0}\) and \(W_{1}\) of MLP are shared; and \(F_{avg}^{\text{C}}\) and \(F_{max}^{\text{C}}\) represent the mean and maximum pooling features, respectively. The spatial attention module first performs global mean pooling and maximum pooling operations along the channel axis of the input feature map to generate two different spatial context descriptors \(F_{avg}^{S}\) and \(F_{max}^{S}\) and then makes connections and convolutions through the standard convolution layer to generate a two-dimensional spatial attention map. The mathematical expression of the attention module is as follows:  
\[M_{S}(F)=\sigma\Big{(}f^{\gamma\times 7}([AvgPool(F);MaxPool(F)])\Big{)}=\sigma \Big{(}f^{\gamma\times 7}\Big{(}[F_{avg}^{S};F_{max}^{S}]\Big{)}\Big{)} \tag{10}\]  
wherein \(\sigma\) represents the Sigmoid function, and \(f^{\gamma\times 7}\) represents the convolution operation with a convolution kernel size of \(7\times 7\). When calculating and generating the channel attention, it is necessary to map features using the dense layer characterized by a heavy calculation burden. This takes up more resources and increases the parameters of the modules. Therefore, when a large number of the CBAMs are inserted into a convolutional neural network, the number of network parameters increases greatly, and the calculation time becomes longer, which does not meet the requirement that the fall detection needs a lower delay while ensuring accuracy. According to the literature [36], in any given intermediate feature map of the CNN, the mapping of channel features with the dense layer produces a large number of redundant calculations. Therefore, the one-dimensional convolution operation is designed in this paper to aggregate the channel features of the one-dimensional channel attention in order to solve this issue. Different from the original CBAM, which uses the dense layer to aggregate the channel features, the model proposed in this paper uses one-dimensional convolution with a convolution kernel length of k to aggregate the information of k channels in the neighborhood of this channel.