## 4 Proposed Method
### Problem Formulation  
This section presents the formal modelling of our algorithm. We consider the domain adaptation problem from the target data \(X_{T}\) to the source data \(X_{S}\). The source data are provided with full semantic labels \(Y_{S}\) while the target data are not initially provided with labels. The first step of the algorithm is concerned with training a semantic segmentation model \(M_{S}\) on the source data. The following equation is correspondent to the source model \(M_{S}\) with the use of the cross-entropy loss:  
\[L_{M_{S}}(M_{S},X_{S},Y_{S})=-\mathbf{E}_{(x_{s},y_{s})\sim(X_{S},Y_{S})}\sum_{ c=1}^{C}\mathbf{I}_{[c=y_{s}]}log(Softmax(M_{S}^{(c)}(x_{s}))) \tag{2}\]  
where \(\mathbf{E}_{(x,y_{s})\sim(X_{S},Y_{S})}\) denotes the expectation on \(x_{s},y_{s}\), which is drawn by the \(X_{S}\) and \(Y_{S}\) distribution. \(C\) is the number of classes of the segmentation task. \(\mathbf{I}_{[c=y_{s}]}\) represents the loss for the class \(c\) separated from other classes. Due to the advancements in the semantic segmentation field, \(M_{S}\) could have a good accuracy if the source data are well constructed. However, when we use this model to segment images from the target domain, the accuracy will decrease because of the domain shift that exists between the source and the target. Hence, we will apply our proposed algorithm and begin by picking out significant samples from the target domain and labeling them. This small dataset will guide the mapping process from the target to the source. It will be used to train the first GAN Network, which will learn through an adversarial loss how to generate pixel-wise labels of the target images. The mapping model from the target domain to the semantic labels \(G_{T\longrightarrow L}\) is trained for a segmentation task in an adversarial manner. The discriminator \(D_{T\longrightarrow L}\) will be trained on the other side to detect fake pairs of data from the real ones. This GAN model can be seen as a standard GAN where we applied three modifications. First, we substituted the noise vector by input images from the target domain. Second modification is to set the output of the GAN to semantic segmentation labels of  
Figure 5: Flowchart of the domain adaptation algorithm. the input image. Third, is to set the input for the discriminator as pair of image for the target domain \(x_{t}\), and semantic label real or generated by the discriminator ( \(l_{t\_real}\) or \(l_{t\_generated}\)). Also, the GAN model can be treated as a modification of a conditional GAN [49]. Generally, conditional GANs or cGANs make a mapping between an input and an output. The input are formed by an image \(x\) from a distribution \(X\) concatenated to a noise vector \(z\). The output is an image \(y\) from a distribution \(Y\). The mapping is formulated by \(G_{cGAN}:\{x,z\}\longrightarrow y\) and the loss function of a conditional GAN can be formulated as:  
\[L_{cGAN}(G,D,X,Y,z)=\mathbf{E}_{(x\sim X,y\sim Y)}[logD(x,y)]+\mathbf{E}_{(x \sim X,z)}[log(1-D(x,G(x,z))] \tag{3}\]  
During the training, \(G\) (the generator) is trying to minimize this loss, whereas \(D\) (the discriminator) is trying to maximize it. The loss function can be expressed more clearly as:  
\[L=arg\ min_{G}\ max_{D}\ L_{cGAN}(G,D,X,Y,z) \tag{4}\]  
As proven in [20], mixing this GAN objective with \(L1\) loss gives beneficial results. In fact, this helps the generator to be more able to fool the discriminator by being closer to the ground truth in an \(L1\) sense. This loss does not affect the discriminator. The \(L1\) loss related to the cGAN can be expressed as:  
\[L_{L1}=\mathbf{E}_{(x\sim X,y\sim Y,z)}[\|y-G(x,z)\|_{1}] \tag{5}\]  
The final objective of the cGAN can be expressed as:  
\[L=\lambda_{1}arg\ min_{G}\ max_{D}\ L_{cGAN}(G,D,X,Y,z)+\lambda_{2}L_{L1} \tag{6}\]  
where \(\lambda_{1}\) and \(\lambda_{2}\) are the weights for the original GAN loss and the \(L1\) loss, respectively. Concerning the noise vector \(z\), it is added to the cGAN to give stochasticity inside the given output.