# Multi-Level Fusion Model for Person Re-Identification by Attribute Awareness
## 3 Proposed Method
### Loss Function  
In a person re-identification dataset, we can use \(D=\{(x_{1},y_{1}),(x_{2},y_{2}),...,(x_{n},y_{n})\}\) to represent the set with identity labels, where \(x_{i}\) and \(y_{i}\) are the input image and label, respectively, of identity \(i\), and \(n\) is the total number of input images [24; 25]. In the person re-identification dataset with attributes, we can use \(A\) to represent the attribute set of all identities, where \(A_{i}=(A_{i}^{1},A_{i}^{2},...,A_{i}^{m})\) is the attribute subset of identity \(i\), and \(m\) is the number of attributes of each identity. Therefore, we can use \(E=\{(x_{1},A_{1}),(x_{2},A_{2}),...,(x_{n},A_{n})\}\) to represent a set with attribute labels. For the two sets \(D\) and \(E\), we use a bidirectional parallel approach to solve the person re-identification problem [26; 27]. Therefore, we can define the following three functions. Figure 4: Batch normalization modules are used for different tasks. We design two modules: BN-1 for attribute recognition and BN-2 for identity recognition. “IDs” is the number of all different identities. For the set \(D\) with identity labels, we define two functions, both based on the objective function of identity labels. First is a classification function based on identity labels,  
\[L_{Id}=-\sum_{i=1}^{n}y_{i}\log q_{i} \tag{4}\]  
\[F_{Id}=\min_{w_{Id},\theta}\sum_{i=1}^{n}L_{Id}(f_{Id}(w_{Id},\phi(\theta,x_{i}) ),y_{i}) \tag{5}\]  
where \(q_{i}=\frac{e^{i}}{\sum_{i=1}^{n}e^{i\gamma}}\) is the confidence probability of the prediction label. \(\phi(\theta,x_{i})\) is the feature embedding function of the first \(i\)th identity. \(\theta\) is the training parameter of the feature embedding function. \(f_{Id}(w_{Id},\phi)\) is the classification function of the feature that embeds the identity label, and \(w_{Id}\) is the training parameter of the classification function. \(L_{Id}(f_{Id},y_{i})\) is the image label loss function of identity \(i\). The purpose of the function \(F_{Id}\) is to find the appropriate image feature embedding so that the identity obtained by training is as consistent as possible with the real label. The second is a metric learning function based on identity labels. \[L_{Tri}=\max([d_{p}-d_{n}+\alpha],0) \tag{6}\]  
\[F_{Tri}=\min_{\theta}\sum_{i=1}^{n}L_{Tri}(\phi(\theta,x_{i}),y_{i}) \tag{7}\]  
where \(d_{p}\) is the Euclidean distance of the positive pairs, \(d_{n}\) is the Euclidean distance of the negative pairs, \(\alpha\) is the decision boundary of the Triplet loss. \(L_{Tri}(\phi,y_{i})\) is the metric loss function of the feature embedding identity. The purpose of \(F_{Tri}\) is to find the appropriate image feature embedding so that the identities of the same labels are as close as possible, and those of different labels are separated as much as possible. We combine classification learning and metric learning to find an image feature embedding to better solve the person re-identification problem. For a set \(E\) with attribute labels, we define a function,  
\[L_{Att}=-\sum_{m=1}^{M}y_{m}log(p(m|x)) \tag{8}\]  
\[F_{Att}=\min_{w_{Att},\theta}\sum_{i=1}^{n}\sum_{j=1}^{m}L_{Att}(f_{Att_{j}}(w_ {Att_{j}},\phi(\theta,x_{i})),A_{i}^{j}) \tag{9}\]  
where \(y_{m}\) is the target class of the \(m\)-th attribute, \(p(m|x)\) is the confidence probability of the prediction attribute. \(f_{Att_{j}}(w_{Att_{j}},\phi)\) is the classification function of the feature that embeds the attribute of identity \(j\), and \(L_{Att}(f_{Att_{j}},A_{i}^{j})\) is the \(j\)-th classification loss function of identity \(i\). We integrate all the attributes of identity \(i\) to obtain its attribute set. The purpose of \(F_{Att}\) is to find a suitable image feature embedding so that the identity attribute set obtained by training is as consistent as possible with the real attribute set. In the testing phase, we use the feature embedding function \(\phi(\theta,x_{i})\) to embed the query set and all gallery set images in the feature space.