# Triplet Loss Network for Unsupervised Domain Adaptation
## 3 Architecture and Methodology
### Architecture  
**Encoder:** The encoder \(E(.)\) is a Convolutional Neural Network (CNN)-like network with weights \(W^{E}\). The target of the encoder is to produce the latent representation of both source and target domain images, as below:  
\[z=E(x),x\in X^{s}\cup X^{t}, \tag{1}\]  
where \(z\in Z\) are the extracted features that we aim to be domain-invariant and category-informative. Therefore, in the case of an input image from the source domain \(x^{s}\), the output of the encoder is \(z^{s}=E(x^{s})\); and if the image is from the target domain \(x^{t}\), then the output is \(z^{t}=E(x^{t})\). The output of the encoder is fed to both the discriminator and the classifier.  
**Discriminator:** Discrimination between the source and the target in the latent space is a core part in many of the recent contributions in DA, as was mentioned in Section 2. Our Discriminator \(D(.)\) is a DNN with weights \(W^{D}\). The discriminator works as a binary classifier to label the latent representation of the images to one of the domains, as follows:  
\[a=D(z)=D(E(x)),\ a\ \in\mathcal{A},\ \mathcal{A}=\{0,1\}. \tag{2}\]  
**Classifier:** The classifier is a feed-forward neural network \(C(.)\) with weights \(W^{C}\) for either binary or multi-class classification. It takes, as input, the latent representation \(z\) and outputs the probabilities for each class \(\hat{y}\). \(C\) can be any kind of DNN with a softmax output activation function that fulfills the tasks \(T_{t}\) and \(T_{s}\).  
In the case of multi-class classification, \(C\) predicts the class probabilities, as follows:  
\[\hat{y}=C(z)=C(E(x)),\ x\in X,\ X=X^{s}\cup X^{t}, \tag{3}\]  
where \(\hat{y}\) is the vector of predicted class probabilities for the images of both domains \(\hat{y}\in\hat{Y},\ \hat{Y}=\hat{Y}^{s}\cup\hat{Y}^{t}\), and it shares the same dimensions as the one-hot-encoded source labels \(y^{s}\) and the target pseudo-labels \(y^{t}\). The classifier \(C\) and the encoder \(E\) are pre-trained on the source data alone, and are then used to generate the pseudo-labels for the target domain \(Y^{t}\)[12; 26; 27], using the output of the classifier on the  
Figure 2: Architecture of our model. This can be divided into three parts: An encoder, a discriminator, and a classifier. The encoder translates the images (i.e., the \(X\) space) to embeddings in the latent space (i.e., the \(Z\) space). In the latent space, each group of embeddings is marked by either \(S_{i}\) or \(M_{i}\), where \(i\) is the label of the image, and the prefix letter denotes whether it is from MNIST (M) or SVHN (S). Thus, the \(Z\) space can be expressed as \(Z=Z^{s}\cup Z^{t}\), where \(Z^{s}=\bigcup_{i}S_{i}\) and \(Z^{t}=\bigcup_{i}M_{i}\). The latent representation is fed to both the discriminator and the classifier. The discriminator distinguishes if the latent representation is from source or target domain, whereas the classifier finds the suitable label for it.  
target images that \(C\) is highly confident about. In the beginning, the number of samples chosen for pseudo-labeling will be small, or even zero, but it increases as we get more domain-invariant features.