# Effective Attention-Based Mechanism for Masked Face Recognition
## 3 Proposed Method
### Convolutional Block Attention Module (CBAM)  
The proposed method adopts the CBAM presented by [PERSON] et al. (2019) in the network model. The CBAM consists of a channel attention module and a spatial attention module, which are arranged in a particular order, as shown in Figure 2. It is a lightweight module that can smoothly integrate with any CNN architecture. Given an input feature map \(F\in\mathbb{R}^{C\times H\times W}\) of the convolutional layer, where \(C\), \(H\), and \(W\) are channel size, height, and width, respectively, let \(M_{channel}\in\mathbb{R}^{C\times 1\times 1}\) denote a 1D channel attention map and \(M_{spatial}\in\mathbb{R}^{1\times H\times W}\) denotes a 2D spatial attention map. The overall attention process can then be shown as shown in Equations (1) and (2).  
\[F^{\prime}=M_{channel}(F)\otimes F \tag{1}\]  
\[F^{\prime\prime}=M_{spatial}\left(F^{\prime}\right)\;\otimes\;F^{\prime} \tag{2}\]  
where \(\otimes\) denotes element-wise multiplication and \(F^{\prime\prime}\) is the final output of the feature maps or refined feature maps.  
1 Channel Attention Module  
The channel attention module focuses on the major features of the input image. This module uses both average-pooling and max-pooling operations on the input feature map to generate two different spatial information vectors: \(F^{ch}_{aug}\) and \(F^{ch}_{max}\) which denote average-pooled features and max-pooled features, respectively. Both vectors are consecutively forwarded to a shared network multi-layer perceptron (MLP) with filter kernel size \(1\times 1\) to produce a channel attention map \(M_{channel}\in\mathbb{R}^{C\times 1\times 1}\). Next, the output feature vectors from the shared network are merged using element-wise submission. The final output of the \(M_{channel}\in\mathbb{R}^{C\times 1\times 1}\) after element-wise submission is then passed to the sigmoid function \(\sigma\) to generate the channel weights, as shown in Equation (3). The channel attention module process can be depicted as shown in Figure 3.  
\[M_{channel}(F)=\sigma(MLP(AvgPooling(F))+MLP(MaxPooling(F))) \tag{3}\]  
where \(\sigma\) is the sigmoid function and \(MLP\) uses the ReLu activation function.  
Figure 3: Structure of the channel attention module.  
Figure 2: Overall structure of the convolutional block attention module.  
The spatial attention module focuses on an informative region of the input images features. Similar to the channel attention module, the spatial attention module adopts the average-pooling and max-pooling operations to obtain two 2D maps: \(F^{sp}_{avg}\) and \(F^{sp}_{max}\) denote average-pooling and max-pooling features, respectively. Those are then concatenated with a convolution layer with a filter kernel size of \(7\times 7\) to obtain a 2D spatial attention map \(M_{spatial}\in\mathbb{R}^{1\times H\times W}\). The spatial attention module process can be illustrated as shown in Figure 4 and Equations (4) and (5).  
\[M_{spatial}(F) =\sigma\Big{(}f^{7\times 7}([AvgPooling(F);MaxPooling(F)])\Big{)} \tag{4}\] \[=\sigma\Big{(}f^{7\times 7}\Big{(}\Big{[}F^{sp}_{avg};F^{sp}_{ max}\Big{]}\Big{)}\Big{)} \tag{5}\]  
where \(\sigma\) is the sigmoid function and \(f^{7\times 7}\) denotes a convolution operation with the filter kernel size of seven.