# Triplet Loss Network for Unsupervised Domain Adaptation
## 3 Architecture and Methodology
### Optimization  
The overall objective function that we aim to minimize in this work is the weighted sum of the three losses, which we call the triplet loss, and is given as follows:  
\[\mathcal{L}=\min_{W_{D},W_{C},W_{E}}\beta_{C}\mathcal{L}_{C}+\beta_{P}\mathcal{ L}_{P}+\beta_{Sep}\mathcal{L}_{Sep}, \tag{9}\]  
where \(\beta_{C},\beta_{P}\), and \(\beta_{Sep}\) are the balancing parameters. The detailed training process of our model, called TripNet, is described in Algorithm 1. The input number of iterations ranges from 500-1000. ```
Input:\(X^{s}\) -- Source domain images \(Y^{s}\) -- Source domain image labels \(X^{t}\) -- Target domain images \(I\) -- Number of iterations Output:\(W^{E}\) -- Weights of the encoder \(W^{C}\) -- Weights of the classifier  Pre-train \(E\) and \(C\) using \(X^{s}\) and \(Y^{s}\); for\(i\gets 1\)to\(I\)do  Sample a batch of images for both domains \(x^{t},(x^{s},y^{s})\);  Get pseudo-labelling \(\hat{y}^{t}\) for \(x^{t}\) using \(C\);  Update \(W^{D}\) by deriving \(\mathcal{L}_{D}\);  Update \(W^{C}\) by deriving \(\mathcal{L}_{C}\);  Update \(W^{E}\) by deriving \(\mathcal{L}_{C}\), \(\mathcal{L}_{P}\) and \(\mathcal{L}_{Sep}\);  end for return\(W^{C}\),\(W^{E}\)
```  
**Algorithm 1**The training process of TripNet  
``` Input:\(X^{s}\) -- Source domain images \(Y^{s}\) -- Source domain image labels \(X^{t}\) -- Target domain images \(I\) -- Number of iterations Output:\(W^{E}\) -- Weights of the encoder \(W^{C}\) -- Weights of the classifier  Pre-train \(E\) and \(C\) using \(X^{s}\) and \(Y^{s}\); for\(i\gets 1\)to\(I\)do  Sample a batch of images for both domains \(x^{t},(

### Novelty

The main novelty of our work is imposing the separability loss on the latent representation of both domains, in order to drive the encoder to close the gap between the two domains by clustering the latent representations of images using their labels (regardless of their domain) and keeping the class information within this latent space. At the same time, we use pseudo-labeling for the target domain to compensate for the absence of labeled data in the target domain. ## 4 Experiments and Results

We compared our model with several state of the art models, including DupGAN [12], TarGan [24], Maximum Classifier Discrepancy (MCD) [29], Gen2 Adpt [25], SimNet [13], Domain-Adversarial Training of Neural Networks (DANN) [30; 31], T. Adversarial Discriminative Domain Adaptation (ADDA) [32], Domain Separation Networks (DSN) [33], Deep Reconstruction-Classification Networks (DRCN) [34], Coupled Generative Adversarial Networks (CoGAN) [35], Unsupervised Image-to-Image Translation Networks (UNIT) [36], RevGrad [30], PixelDA [37], kNN-Ad [20], Image2 Image [21], and Asymmetric Tri-training for Unsupervised Domain Adaptation (ATDA) [27], for digit classification and object recognition. As we followed the same experimental set-up as the one that was employed for the compared networks, we evaluated our model based on the accuracy on the target test set, as this was the most-used metric within the previous works, which will enable us to compare it with the previously-mentioned papers using their reported results. The comparison will be made on three different tasks: (1) Digit classification, (2) object recognition, and (3) simulation-to-real object recognition. Then, we compare our model against DupGAN in terms of complexity (number of iterations). We will also compare our model against itself, using just the encoder and the classifier trained on the source domain only (noted as training on source only) and the target domain only (noted as training on target labels) to give a lower bound and approximation of the upper bound. This comparison, shown in Table 4, shows the degradation of the accuracy of the target domain before domain adaptation in the EC-SourceOnly row. This demonstrates the effectiveness and the usefulness of the adaptation technique generally, and our model specifically.