# Reducing Video Coding Complexity Based on CNN-CBAM in HEVC
## 2 The Proposed Methods
### Proposed Algorithm
#### 2.2.2 Structure of CBAM  
The proposed convolution block attention module (CBAM) by [33] can improve the network model performance by learning to focus or suppress key feature information, hence facilitating network information transmission. Figure 4 depicts the CBAM's detailed construction. For the given input feature map \(\mathbf{F}\in R^{C\times H\times W}\), where \(C\), \(H\), and \(W\) denote the number of channels, height, and width of the feature map, respectively. The CBAM sequentially contains \(\mathbf{M_{C}}\in R^{C\times 1\times 1}\) (channel attention map) and \(\mathbf{M_{S}}\in R^{1\times H\times W}\) (spatial attention map). The overall CBAM can be characterized as:  
\[\mathbf{F^{\prime}}\ =\mathbf{M_{C}}(\mathbf{F})\ \otimes\ \mathbf{F}, \tag{1}\]  
\[\mathbf{F^{\prime}}\ =\mathbf{M_{S}}(\mathbf{F^{\prime}})\ \otimes\ \mathbf{F^{\prime}}, \tag{2}\]  
where \(\otimes\) means the elements of the feature map and the two attention modules to produce the corresponding weight product operation. The two attention modules are detailed below. **Channel attention module:** First, in \(\mathbf{F}\in R^{C\times H\times W}\), maximum pooling and average pooling are carried out to summarize the spatial information of the feature map and produce two distinct spatial context descriptions, i.e., \(\mathbf{F^{\prime}}_{max}\) (maximum pooling) and \(\mathbf{F^{\prime}}_{avg}\) (average pooling). Second, the \(\mathbf{F^{\prime}}_{avg}\) and \(\mathbf{F^{\prime}}_{max}\) are passed to a hidden layer and multi-layer perceptron (MLP) to produce a channel attention map \(\mathbf{M_{C}}\in R^{C\times 1\times 1}\). In addition, we set the drop  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Branch** & **Layer** & **Output Size** & **Proposed CNN Configuration** \\ \hline \multirow{8}{*}{B1} & C\({}_{\text{1-1}}\) & \(2\times 2\times 128\) & S-32, Con-32 \(\times\) 32 \\  & C\({}_{\text{1-2}}\) & \(16\times 16\times 64\) & S-4, Con-4 \(\times\) 4 \\  & C\({}_{\text{1-3}}\) & \(16\times 16  
channel size of the hidden layer to \(R^{\hat{\xi}\times 1\times 1}\) to reduce the model parameter overhead, where \(\frac{c}{r}\) is an integer. Then, after implementing a shared network for each descriptor, two new descriptors are generated (i.e., \(\mathbf{F}^{c}_{avg}\) and \(\mathbf{F}^{c}_{max^{\prime}}\)). Finally, we utilize an element-by-element summing approach to obtain \(\mathbf{F}\) as the output. Therefore, the channel attention module is computed as:  
\[ \begin{array}{ll}\boldsymbol{M_{C}}(F)&=\alpha\big{(}MLP(Avgpool(\mathbf{F}))+MLP( Maxpool(\mathbf{F}))\big{)},\\ &=\alpha\Big{(}\boldsymbol{W}_{1}\Big{(}\boldsymbol{W}_{0}\Big{(}\mathbf{F}^{ c}_{avg}\Big{)}+\boldsymbol{W}_{1}(\boldsymbol{W}_{0}(\mathbf{F}^{c}_{max})) \Big{)},\end{array}  \tag{3}\]  
where \(\alpha\) represents the sigmoid function and \(\boldsymbol{W}_{0}\in R^{C/r\times C}\) and \(\boldsymbol{W}_{1}\in R^{C\times C/r}\) are the _MLP_ weights. **Spatial attention module:** Firstly, the first attention module's output result \(\mathbf{F}\) is used as the second attention module's input. Secondly, the maximum pooling and average pooling are performed along the channel, and the pooling results are concatenated to yield 2D valid feature descriptors (i.e., \(\mathbf{F}^{s}_{avg}\in R^{1\times H\times W}\) (average pooling) and \(\mathbf{F}^{s}_{max}\in R^{1\times H\times W}\) (maximum pooling)). Finally, for cascade-based feature descriptors, a convolution layer is applied to produce \(\boldsymbol{M_{s}}(F)\in R^{H\times W}\) (spatial attention map). Therefore, the spatial attention module is computed as:  
\[ \begin{array}{ll}\boldsymbol{M_{S}}(\mathbf{F})&=\alpha\ \big{(}f^{7\times 7} \big{(}[Avgpool(\mathbf{F});Maxpool(\mathbf{F})]\big{)}\big{)},\\ &=\alpha\ \Big{(}f^{7\times 7}\Big{(}\Big{[}\mathbf{F}^{s}_{avg};\mathbf{F}^{ s}_{max}\Big{]}\Big{)}\Big{)},\end{array}  \tag{4}\]  
where \(f^{7\times 7}\) represents a \(7\times 7\) convolution operation and \(\alpha\) is the sigmoid function.