# Unsupervised Domain Adaptive Person Re-Identification via Intermediate Domains
## 3 Proposed Method
### Intermediate Domains
#### 3.1.2 Generating Intermediate Domains  
Intermediate domains have been shown to be helpful for addressing domain adaptation problems that can connect source and target domains. In this way, the model pre-trained on source domain can be fine-tuned on intermediate domains first and then adopted to target domain. We focused on image-level translating based on DLOW [8] and directly translated source images into different styles. In this way, the intermediate domains generated by the GAN model can be utilized as a bridge to connect source and target domains. The baseline of the GAN model is shown in Figure 3. Our method can be integrated with other UDA approaches to improve the cross-domain ability of the model. There are samples \(x\in\mathcal{S}\) and \(y\in\mathcal{T}\) that belong to data distributions \(P_{S}\) and \(P_{T}\) in the domain adaptation problem. We denoted an intermediate domain as \(\mathcal{M}^{(\lambda)}\) and the data distribution of \(\mathcal{M}^{(\lambda)}\) as \(P_{M}\) according to DLOW, where \(\lambda\in[0,1]\) is the domainness factor that decides the relatedness between source and intermediate domains. A smaller \(\lambda\) indicates that \(P_{S}\) and \(P_{M}\) are closer to each other. For example, we have \(\mathcal{M}^{(0)}=\mathcal{S}\) when \(\lambda=0\) and \(\mathcal{M}^{(1)}=\mathcal{T}\) when \(\lambda=1\). The DLOW model regarded a domain with given data distribution as a point residing at the manifold connecting source and target domain:  
\[\text{JSD}(P_{S},P_{M})+\text{JSD}(P_{M},P_{T})=\text{JSD}(P_{S},P_{T}) \tag{7}\]  
where \(\text{JSD}(\cdot,\cdot)\) is the Jessen-Shannon (JS) divergence for measuring differences between two distributions. Therefore, the following distance from \(\mathcal{S}\) to \(\mathcal{M}^{(\lambda)}\) should also be proportional to the distance between \(\mathcal{S}\) and \(\mathcal{T}\) for a specific \(\lambda\):  
\[\frac{\text{JSD}(P_{S},P_{M})}{\text{JSD}(P_{S},P_{T})}=\lambda\qquad\frac{ \text{JSD}(P_{M},P_{T})}{\text{JSD}(P_{S},P_{T})}=1-\lambda \tag{8}\]  
Thus, finding the data distribution \(P_{M}\) corresponding to a specific \(\lambda\) becomes finding a point satisfying Equation (8). The loss function can be expressed as follows:  
\[\mathcal{L}=(1-\lambda)\cdot\text{JSD}(P_{S},P_{M})+\lambda\cdot\text{JSD}(P_ {M},P_{T}) \tag{9}\]  
Figure 3: The overview of our proposed GAN model based on SPGAN to generate intermediate domains. \(\lambda\) represents the domainness factor to control the style of the images generated by GAN. The loss function is declared in Equation (14). By using the expression of JS divergence, we have:  
\[ \begin{split}\text{JSD}&(P_{S},P_{M})=\frac{1}{2}\mathbb{ E}_{\mathbf{x}\sim P_{S}}\Big{[}\log\frac{P_{S}(\mathbf{x})}{P_{S}(\mathbf{x})+P_{M}(\mathbf{x})} \Big{]}\\ &+\frac{1}{2}\mathbb{E}_{\mathbf{x}\sim P_{M}}\Big{[}\log\frac{P_{M}( \mathbf{x})}{P_{S}(\mathbf{x})+P_{M}(\mathbf{x})}\Big{]}+\log 2\end{split}  \tag{10}\]  
Specifically, we denoted \(D_{\mathcal{S}}\) to discriminate the images in \(\mathcal{S}\) and \(\mathcal{M}\) and \(D_{\mathcal{T}}\) to discriminate the images in \(\mathcal{M}\) and \(\mathcal{T}\). The optimal discriminator \(D_{\mathcal{S}}\) for a fixed \(G\) is expressed as follows:  
\[D_{\mathcal{S}}=\frac{P_{S}(\mathbf{x})}{P_{S}(\mathbf{x})+P_{M}(\mathbf{x})} \tag{11}\]  
Ignoring the coefficients and constant terms in Equation (10), we have:  
\[ \begin{split}\mathcal{L}^{*}&=(1-\lambda)\cdot[ \mathbb{E}_{\mathbf{x}\sim P_{S}}[\log D_{\mathcal{S}}(\mathbf{x})]+\mathbb{E}_{\mathbf{x }\sim P_{M}}[\log(1-D_{\mathcal{S}}(\mathbf{x}))]]\\ &+\lambda\cdot[\mathbb{E}_{\mathbf{x}\sim P_{S}}[\log D_{\mathcal{T} }(\mathbf{x})]+\mathbb{E}_{\mathbf{x}\sim P_{M}}[\log(1-D_{\mathcal{T}}(\mathbf{x}))]]\\ &=(1-\lambda)\cdot\mathcal{L}_{adv}(G,D_{\mathcal{S}})+\lambda \cdot\mathcal{L}_{adv}(G,D_{\mathcal{T}})\end{split}  \tag{12}\]  
Equation (12) shows the adversarial loss of \(\mathcal{S}\rightarrow\mathcal{T}\). We can similarly apply it to another direction as follows:  
\[