# CNN Attention Enhanced ViT Network for Occluded Person Re-Identification
## 3 Method
### MultiFeature Training Module  
The ViT has gained popularity for its unique global feature extraction, but its fixed training mode of using individual global features for classification brings challenges compared with the flexible and versatile characteristics of CNN. It has been studied that multi-feature of deep learning can correspond to the same label, and combining multiple features for the model training could help to improve its effectiveness [1; 22; 47]. We construct a MultiFeature Training Module (MFTM) for ViT to improve the effectiveness of AET-Net. As shown in the upper half of the blue, orange, and gray areas in Figure 4. The original ViT directly uses the classification representation \({g_{cls}}\in{R^{1\times C}}\) after Transformer Encoder as the global features, but directly using them for classification will inevitably lose some information of the remaining \(N\) encoding vectors. In detail, MFTM takes into consideration two characteristics of the global feature. First, the dimension of the global feature from spatial is 1. At the same time, it is strongly representative of the global feature as it integrates information from all channels in the entire image. However, when the occlusion exists, a large amount of occlusion and complex background is blended in this feature, which is unfavorable for the identity recognition of the occlusion condition. In other words, although the global features of the Transformer Encoder are highly representative, too much noise is involved in its channel dimension. In contrast to spatial attention, channel attention aims to emphasize the \"what\" is important for a given image. The proposed MFTM conducts its training process by constructing attention global features jointly with the original ViT global features, and the process of attention global features construction is shown in Figure 5b. It is divided into two stages: computation of channel attention map and generation of global attention features. For the calculation of the channel attention map, we first perform spatial compression on the reshaped vector \({f^{\prime}}\) after patch embedding; two feature descriptors are generated by aggregating spatial information using mean and maximum pooling. Next, two feature descriptors are fed into a shared multilayer perceptron to generate two channel features, and then the two channel features are combined into one whole channel feature. Finally, the synthesized channel features are fed into a sigmoid function which yields a channel attention map. The calculation process of a channel attention map is represented as follows:  
\[{w_{ca}}={sigmoid\big{(}CA({f^{\prime}})\big{)}}, \tag{5}\]where \(w_{ca}\) denotes the generated channel attention map, \(f^{\prime}\) denotes the reshaped vector \(f\) after patch embedding, and \(CA(\cdot)\) denotes the extraction process of channel attention. The detailed process of \(CA(\cdot)\) can be expressed as follows:  
\[CA(x)=MLP(AvgPool(x))+MLP(MaxPool(x)), \tag{6}\]  
where \(MLP(\cdot)\) denotes a multilayer perceptron shared by two feature descriptors. In this way, the global features of the Transformer encoder output will be applied to the channel attention map generating the attention global feature. This process can be simply defined as:  
\[g_{attn}=w_{ca}\times g, \tag{7}\]  
where \(g_{attn}\) denotes the attention global feature and \(g\) denotes the global feature output by Transformer Encoder. The generated \(g_{attn}\) and \(g\) further calculate Cross-Entropy loss and Triplet loss, respectively. Some studies have shown that the use of the attention mechanism may cause the model to ignore the attention to some important secondary information [25; 28; 37]. To make the model not overly biased to the attention global feature, we introduce a weight hyperparameter \(\delta\) to suppress the attention global feature, including its losses. Specifically, during training, \(\delta\) is used to balance the losses generated by the attention global feature \(g_{attn}\) and the global feature \(g\).