## 3 Proposed Method
### Attention-Guided Transformer Module (AGTM)
#### 3.2.3 Channel-Wise Multi-Head Transformer Block (CMTB)  
Following the pre-processing of the inner feature maps with guiding blocks, there still remains a demand for effectively aggregating previous feature data across various channels to facilitate high-quality face image restoration. However, the usual spatial-wise transformers are limited to position-specific windows, and their partition strategy may potentially alter the structure of the facial image [19]. To address this limitation, we introduce the Channel-wise Multi-head Transformer Block (CMTB)--a novel approach capable of achieving image-size receptive fields based on channels rather than position-specific windows. Furthermore, CMTB is more computation-friendly, rendering it a suitable match for the previous guiding blocks. As depicted in Figure 4, CMTB comprises two key components: the Channel-wise Multi-head Self-attention Network (CMSN) and the Gated-Dconv Feed-Forward Network (GDFN). While CMSN serves as the primary component, GDFN aims to encode information from spatially neighboring pixel positions to enable effective learning of local image structures. CMTB has been proposed to achieve image-size receptive fields based on different channels of feature maps rather than position-specific windows. Suppose feature maps \(\mathbf{X}_{in}\in\mathbb{R}^{H\times W\times C}\) as the input of the CMSN, which is reshaped into tokens \(\mathbf{X}\in\mathbb{R}^{HW\times C}\) based on channels. Here, \(H\), \(W\), and \(C\) denote the height, width, and channel numbers of the feature maps, respectively. Then \(\mathbf{X}\) is linearly projected to obtain three different matrices: _query_\(\mathbf{Q}\in\mathbb{R}^{HW\times C}\), _key_\(\mathbf{K}\in\mathbb{R}^{HW\times C}\), and _value_\(\mathbf{V}\in\mathbb{R}^{HW\times C}\):  
\[\mathbf{Q}=\mathbf{X}\mathbf{W}^{\mathbf{Q}},\quad\mathbf{K}=\mathbf{X} \mathbf{W}^{\mathbf{K}},\quad\mathbf{V}=\mathbf{X}\mathbf{W}^{\mathbf{V}} \tag{4}\]  
where \(\mathbf{W}^{\mathbf{Q}}\), \(\mathbf{W}^{\mathbf{K}}\), and \(\mathbf{W}^{\mathbf{V}}\in\mathbb{R}^{C\times C}\) are learnable parameters; _biases_ are omitted here for simplification. Afterwards, \(\mathbf{Q}\), \(\mathbf{K}\) and \(\mathbf{V}\) are split into _N heads_ along the channel dimension:  
Figure 4: Architectures of the Channel-wise Multi-head Transformer Block (CMTB). Here,,,, and  denotes the sigmoid function, reshape, and split, respectively. PE denotes the position embedding generator. \[\mathbf{Q}=[ \begin{array}{ccccc}\mathbf{Q}_{1},&\ldots,&\mathbf{Q}_{N}\end{array} ], \mathbf{K}=[ \begin{array}{ccccc}\mathbf{K}_{1},&\ldots,&\mathbf{K}_{N}\end{array} ], \mathbf{V}=[ \begin{array}{ccccc}\mathbf{V}_{1},&\ldots,&\mathbf{V}_{N}\end{array} ],\]  
where the dimension of each head is \(d=C/N\). Therefore, the self-attention matrix for \(\mathit{head}_{i}\) is:  
\[\mathbf{A}_{i}=softmax(\sigma_{i}\mathbf{K}_{i}^{T}\mathbf{Q}_{i}),\quad \mathit{head}_{i}=\mathbf{V}_{i}\mathbf{A}_{i} \tag{5}\]  
where \(\mathbf{K}_{i}^{T}\) denotes the transposed matrix of \(\mathbf{K}_{i}\). By implementing the reshape strategy, the size of the generated attention maps will be \(d\times d\) instead of \(HW\times HW\), which greatly reduces the computational complexity. Moreover, a learnable parameter \(\sigma_{i}\in\mathbb{R}^{1}\) is introduced to further improve the flexibility of the network. Subsequently, \(N\)_heads_ outputs are concatenated and fed to a full connection layer. The resulting attention matrix is then added with the embedding values from the position embedding generator:  
\[\mathit{CMSN}(\mathbf{X})=(\underset{i=1}{\overset{N}{\mathit{Concat}}(head_ {i})})\mathbf{W}+f_{p}(\mathbf{V}) \tag{6}\]  
where \(\mathbf{W}\in\mathbb{R}^{C\times C}\) are learnable parameters. \(f_{p}(\cdot)\) represents the position embedding generator, which is designed to encode the position information from various channel dimensions.