# Attention-Aware Adversarial Network for Person Re-Identification
## 3 Method
### Attention Assignment Network  
Based on the baseline classification network, the proposed attention assignment network is trained. The procedure is shown in Algorithm 1.  
```
1:Nperson images;
2:While\(N>0\)do
3:The feature maps of the middle layer are divided equally into 16 with a square grid;
4:Each grid in the feature maps is occluded and reproduced in sequence;
5:These 16 groups of feature maps are entered together into the classification network;
6:Select the feature maps with the lowest classification probability to guide the generation of feature maps of the attention assignment mechanism;
7:Update the parameters of the attention assignment mechanism;
8:\(N\gets N-1\);
9:end
10:Retain the weight of the overall network structure
```  
**Algorithm 1** The training strategy of the attention assignment network.  
The attention assignment network aims to guide the attentions to be assigned to nearly all parts of the target objects. Concretely, besides the regions that contribute to the final result most, other important regions are further focused on according to the attention assignment mechanism. This is implemented in an adversarial manner. In detail, the occlusion sample with the lowest classification prediction probability is selected as a template in each iterative training process. This allows the attention map to fit the feature response range, which means that some areas of the image that are important to the classification get high values in the attention map. The framework of the attention assignment network is demonstrated in Figure 2. The architecture can be regarded as two branches. Given an input person image, the convolutional modules in the baseline network are employed to extract representative feature maps, denoted as \(f_{r}\). For one branch, the feature maps are input into several stacked convolutional layers to generate an attention map, which indicates the interesting important regions in the person image for detection and recognition. For the other branch, the feature maps are regularly occluded by 16 non-overlapped rectangular boxes, respectively. As a result, 16 groups of feature maps with occluded area are generated. Each group of occluded feature maps is fed into a fully-connected layer, and the corresponding classification scores are output after a \(softmax\) operation. The occluded feature maps obtaining the lowest classification accuracy are picked out as a difficult sample. Subsequently, both the attention map \(M_{att}\) and the difficult sample \(M_{occ}\) are input to the adversarial loss,  
\[\mathcal{L}_{adversarial}(M_{att},M_{occ})=\mathcal{L}_{att}(M_{att},M_{occ})+ \mathcal{L}_{r}(M_{att}). \tag{1}\]  
The first term is the data term, which enforces the attentions assigned to other important area, and has the following form:  
\[\mathcal{L}_{att}=\|[\max(M_{att},0)-M_{occ})]*M_{att}\|_{1}. \tag{2}\]  
The second term is the regularization term, which prevents the network from over-fitting. Meanwhile, it can also maintain the structure of the original feature maps,  
\[\mathcal{L}_{r}=\log(1+e^{-\|M_{att}\|_{1}}). \tag{3}\]  
During the training phase, the attention assignment network is fine-tuned by the common layers of the baseline network, including the convolution modules of the resnet-50 network and the fully-connected layer. These parameters are fixed in the backward stage. The rest of the parameters are initialized randomly. As a result, an attention map generation mechanism is learned in this network. The attention map is able to re-assign attentions to the area except for the most import region that contributes most to the final result. Therefore, nearly all parts of the target person are highlighted under this attention assignment mechanism.