# RANDnet: Vehicle Re-Identification with Relation Attention and Nuance-Disparity Masks
## 3 Vehicle Re-Identification With RANDnet
### Nuance-Disparity Masks  
In this section, we introduce the construction principles and methodologies for the nuance-disparity masks, which are automatically generated by the network. These masks are designed to adaptively mine a broader spectrum of discriminative regions within vehicle images while concurrently suppressing extraneous information. The nuance mask is specifically engineered to augment the network's capability to recognize a more comprehensive set of target features, whereas the disparity mask focuses on mitigating background interference. This enables a refined focus on essential details critical for effective vehicle identification. The N&D mask generation process is shown in Figure 3.  
_IAF_. In order to better describe the composition of the disparity and nuance masks, we first define the identity-associated features (IAFs) and identity intersection features (IIFs). In the re-identification network, a global average pooling (GAP) layer and a fully connected (FC) layer are involved to obtain a vehicle ID embedding. Let the feature vector after GAP operation be \(\mathbf{f}=[f_{1},f_{2},\ldots,f_{i},\ldots,f_{c}]\), where \(c\) denotes the number of channels. \(f_{k}\)  is defined as  
\[f_{k}=\frac{1}{h\cdot w}\sum_{i=1}^{h}\sum_{j=1}^{w}F_{i,j,k}, \tag{1}\]where \(F\) denotes an \(h\times w\times c\) feature map embedded by the backbone network. \(h\) and \(w\) denote the height and width of the feature map, respectively. Then, the result of the GAP layer is converted into a 1D tensor via the FC layer. For a given vehicle image, its identity is labeled as \(gt\). Then, the IAF is denoted as \(M^{gt\in\mathbb{R}^{h\times w}}\):  
\[M^{gt}_{i,j}=\sum_{k=1}^{c}W_{gt,k}\cdot F_{i,j,k}, \tag{2}\]  
where each spatial unit \((i,j)\) of the feature map \(F\) is utilized, together with the FC layer parameter \(W\). Note that, for each class, the average value of the IAF is equal to the corresponding dimension of the softmax input, for category \(gt\),  
\[\frac{1}{h\cdot w}\sum_{j=1}^{h}\sum_{k=1}^{w}M^{gt}_{j,k}=\arg\max\ softmax(\mathbf{ \mathcal{Z}}), \tag{3}\]  
where \(\mathbf{\mathcal{Z}}\) is the input of softmax, namely \(\mathbf{\mathcal{Z}}=\mathbf{W}\times f\). For an IAF, a larger \(M^{l}_{i,j}\) means that the spatial position \((i,j)\) contains more significant clues that lead to a higher predicted probability of label \(gt\). _IIF_. Identity intersection features are proposed based on the following analysis. The IAF adeptly captures the most discriminative regions of a vehicle specific to a particular ID. However, it is not good enough to determine the discrimination area directly through the IAF. The region indicated by the highly active position in \(M^{gt}\) may not be sufficient, and some other important information might be neglected. This is especially prominent when there are some exclusive characteristics in a particular vehicle image, e.g., special cargo or self-made signs. Thus, utilizing solely IAFs can diminish the model's generalization capability. Furthermore, when the IAF vanishes from the feature maps due to likely occurrences of viewpoint changes or foreground occlusions, the network exhibits a deficiency in localizing sub-discriminative regions within these feature maps. This significantly exacerbates the increase in intra-class variance. For distant classes with significant differences in car types, the IIF of the input vehicle images predominantly occurs in the background, indicating that both positive and negative samples share a similar backdrop. In contrast, in the case of ambiguous classes where car types are subtly distinct, the IIF tends to concentrate on specific vehicle components such as emblems, headlights, and tires, signifying that the positive and negative samples possess similar vehicular parts. Consequently, by suppressing the IIF in distant classes, we can effectively mitigate the interference of background noise on model performance.