# Person Re-Identification Based on Attention Mechanism and Context Information Fusion
## 2 Methods
### Channel Attention Module to Improve the Network  
The attention mechanism has been shown to be an effective way to improve deep convolutional neural networks. SE-Net [21] first proposes a method to learn channel attention, and achieves satisfactory results. Then, the development of attention mechanism can be divided into two aspects: (1) the fusion of enhanced features; (2) the integration of channels and spatial attention. CBAM [22] fuses feature by using maximum pooling and average pooling. To achieve more effective feature fusion, a second-order pooling is introduced [23]. GE [24] uses deep convolution to explore spatial expansion to aggregate features. scSE [25] and CBAM use two-dimensional convolution with a kernel size of \(k^{*}k\) to calculate spatial attention, and then combine spatial attention with channel attention. It can be seen that the above methods obtain effective performance by designing complex  
Figure 1: Overall framework of the person re-identificaton (ReID) model we propose. The channel attention module is introduced into the ResNet50. Feature map \(f_{5}\) is generated by context information fusion module, and it is cascaded with feature map \(f_{4}\). Feature map \(f_{8}\) is used for the inference stage. attention modules. Different from the above attention mechanism, the goal of the attention mechanism we used is to learn effective channel attention while reducing the complexity of the model. Generally, channel attention is achieved by mapping channel features to a low-dimensional space, and then mapping it back, which makes the relationships between channels and their weights indirect. Studies have shown that the change of channel dimensionality and the interaction between channels can affect the performance of channel attention to some extent [26]. Keeping the channel dimension constant helps to learn effective attention, and cross-channel interaction also helps to learn effective attention. Based on the SE module, the Efficient Channel Attention (ECA) module [26] reduces the complexity of the model and improves the efficiency of learning attention by increasing local cross-channel interaction and channel sharing parameters. The channel weight calculation formula is shown as follows:  
\[\omega_{i}=\sigma(\sum_{j=1}^{k}\alpha^{i}y_{i}^{j}),y_{i}^{j}\in\Omega_{i}^{k}, \tag{1}\]  
\(\Omega_{i}^{k}\) represents the \(k\) domain channels of \(y_{i}\), \(y_{i}\) is the feature representation of channel \(i\) after global average pooling, \(\alpha^{j}\) is the shared parameter, and \(\sigma\) is the activation function. \(w_{i}\) is the weight of channel \(i\). The structure of the ECA module is shown in Figure 2.  
The calculation of the weight can be realized by one-dimensional convolution with a kernel size of \(k\). It can be seen that \(k\) is a key parameter, because \(k\) determines the range of interaction between channels. It is generally believed that the larger the channel dimension, the larger the range of interaction, and the smaller the channel dimension, the smaller the range of interaction. It is reasonable to assume that the interaction range \(k\) is proportional to the channel dimension \(C\). A linear function is the simplest mapping, but the relation determined by linear function is too limited. In general, channel dimension \(C\) is a power of 2. Thus, this linear relationship can be extended to a nonlinear one, as shown in Formula (2). \[C=\phi(k)=2^{(\gamma*k-b)}, \tag{2}\]  
Given the channel dimension \(C\), the formula for the one-dimensional convolution kernel size \(k\) is shown as follows:  
\[k=\psi(C)=\left|\frac{\log_{2}(C)}{\gamma}+\frac{b}{\gamma}\right|_{old}, \tag{3}\]  
Figure 2: Efficient channel attention (ECA) module diagram. After global average pooling, the channel weights are generated by one-dimensional convolution of size k, and k is adaptively determined by the channel dimension. \(\left|t\right|_{odd}\) is the nearest odd number to \(t\). According to the experiment, setting \(\gamma\) to 2 and \(b\) to 1 is more effective.