# Conditional Generative Adversarial Networks for Domain Transfer: A Survey
## 2 The Development Methods of CGAN
### The Improvement of CGAN
#### 2.2.1 The Loss Function of CGAN  
As mentioned above, the main part of GAN is the generative network, while the discriminative network is only a complex loss function. The same is true of CGAN. However, maximizing the classification error of the discriminative network will only have a limited effect on CGAN. Faced with a variety of complex application scenarios, researchers  
Figure 1: The generic framework of GAN. Compared with GAN, it also takes the condition \(\mathbf{y}\) as the input of the generator and discriminator. have also proposed many other loss functions for the training of CGAN. Representing the parameters in the CGAN as \(\mathbf{\theta}\), and then these loss functions as \(L_{1}(\mathbf{x};\mathbf{\theta})\), \(L_{2}(\mathbf{x};\mathbf{\theta})\),..., \(L_{n}(\mathbf{x};\mathbf{\theta})\), then the training of CGAN becomes a multi-objective optimization problem, using the weighted sum of each loss as the final loss function,  
\[L(\mathbf{x};\mathbf{\theta})=\sum_{i=1}^{n}\eta_{i}L_{i}(\mathbf{x};\mathbf{\theta}),(\sum_{i =1}^{n}\eta_{i}=1). \tag{3}\]  
Here, \(\eta_{i}\) represents the coefficient. The losses commonly used except for discriminant losses are described below. 1. Content loss: This loss is primarily used to measure the gap between the generated image and the user's expectations. For example, when training CGANs whose task is to transfer gray-level images to color images, the general strategy is to first render a set of color images grayscale and then use the paired gray level image \(\mathbf{y}\) and color image \(\mathbf{x}\) as training data. During the training process, when the generative network inputs gray level images and outputs color images, users usually expect the output results to be as close as possible to the corresponding color image in the training set. Therefore, the loss is expressed as the difference between the values of each pixel in the generated images and the training data, which is generally characterized by mean square error (MSE), \[L_{\text{content}}(\mathbf{x};\mathbf{\theta})=\frac{1}{CHW}\sum_{i=1}^{C}\sum_{j=1}^{H }\sum_{k=1}^{W}(G(\mathbf{y})_{ijk}-\mathbf{x}_{ijk})^{2}.\] (4) Here \(C\), \(H\) and \(W\), respectively, represent the number of channels, height and width of the image, \({}_{ijk}\) represents the \(i\)-th channel, \(j\)-th row and \(k\)-th column of a sample. However, it is worth noting that excessive increases in this loss will lead to image blurring. 2. Perception loss: Although content loss can monitor the content of the generated image, it gives more consideration to the underlying semantics of the image due to its pixel-by-pixel differential mechanism. In order to monitor the high-level semantic consistency between the generated image and the actual image, perception loss is often used. In essence, it is still the MSE of two tensors, except that the two tensors are no longer about the image itself, and instead, the feature map is derived from the images with a certain model. For example, ESRGAN [14] takes the generated image and the actual image as the input of the VGG19 network [24], respectively, and then calculates the MSE of hidden variables of each layer in the middle of the VGG19 network. Generally, the expression of the loss is: \[L_{\text{perception}}(\mathbf{x};\mathbf{\theta})\] (5) \[=\frac{1}{CHW}\sum_{i=1}^{C}\sum_{j=1}^{H}\sum_{k=1}^{W}(F(G(\mathbf{y}))_{ijk}-F (\mathbf{x})_{ijk})^{2}.\] Here, similarly, \(C\), \(H\) and \(W\), respectively, represent the number of channels, height and width of the image, \({}_{ijk}\) represents the \(i\)-th channel, \(j\)-th row and \(k\)-th column of a sample, and \(F\) can be any model. 3. Hidden variable loss: Both content loss and perception loss are evaluated by the final images generated by the generated network. However, when the network is deep, the idea of end-to-end learning can swiftly cause the problem of gradient disappearance or gradient explosion. For this reason, we would consider monitoring hidden variables in the network.