# A High-Quality Hybrid Mapping Model Based on Averaging Dense Sampling Parameters
## 3 Methods  
### Cyclic Adversarial Generation Network Based on SWAD Optimization Method  
CycleGAN realizes mapping from one domain to another via generators and discriminators. In this section, we propose a method that averages the parameters of generators sampled from different iterations with the dense sampling strategy in CycleGANs. First, we illustrate the framework of SWAD-CycleGAN, as shown in Figure 2. CycleGAN involves four models: \(G_{A2B}\), \(G_{B2A}\), \(D_{A}\) and \(D_{B}\). \(G_{A2B}\) transforms \(Real\)\(A\) inputs into \(Cyclic\)\(B\) outputs, while \(G_{B2A}\) handles the transformation of \(Cyclic\)\(B\) inputs into \(Cyclic\)\(A\) outputs. The concept of cycle consistency in adversarial networks involves both forward cycle consistency and backward cycle consistency. Forward cycle consistency refers to the fact that when an input from the source domain passes through a generator and a reverse generator, it should map back to an output within the source domain while maintaining consistency with the original input. Similarly, backward cycle consistency ensures that an input from the target domain, after going through the reverse generator and generator, should map back to an output within the target domain, remaining consistent with the original input. The cycle consistency loss helps in preventing the adversarial networks from learning mapping functions \(G\) and \(F\), while learning mapping functions \(G\) and \(F\) tends to make the source and target domains have the same distribution. Despite the network having the capacity to map source domain images to any image in the target domain and generate a distribution equivalent to that of the target domain, cycle consistency loss is beneficial to constraining this behavior. Additionally, the identity loss function ensures that when A-class-style maps are inputted into \(G_{A2B}\), the generated output resembles B-class-style images and vice versa. However, this may not always hold true, so the identity loss function is designed to impose constraints on this aspect.  
\(D_{A}\) and \(D_{B}\) are responsible for discriminating between the authenticity of \(A\) and \(B\). Additionally, there are four types of loss functions: \(G_{loss}\), \(D_{loss}\), \(Cycle_{loss}\), and \(identity_{loss}\). The loss function \(G\_loss\) for the Generator as Equation (1), with a target to make the generated images closely align with the distribution of target images, ultimately \"deceiving\" the discriminator.  
\[\mathcal{L}_{\text{GAN}}(G,D_{\gamma},X,Y)=\mathbb{E}_{y\sim p_{\text{data}} \left(y\right)}[\log D_{\gamma}(y)]+\mathbb{E}_{x\sim p_{\text{data}}\left(x \right)}[\log(1-D_{\gamma}(G(x)))]\enspace, \tag{1}\]  
where \(p_{data\left(y\right)}\) denotes probability distribution on the output. \(G\) and \(D\) denote the generators and discriminators. On the other hand, the loss function for the Discriminator (\(D_{loss}\)) has the opposite objective, namely the distinguishment of the images generated by the Generator. The cycle loss (\(Cycle_{loss}\)) function is depicted as Equation (2):  
\[\mathcal{L}_{\text{cyc}}(G,F)=\mathbb{E}_{x\sim p_{\text{data}} \left(x\right)}[\|F(G(x))-x\|_{1}]+\mathbb{E}_{y\sim p_{\text{data}}\left(y \right)}[\|G(F(y))-y\|_{1}]. \tag{2}\]  
The generator and discriminator we designed are based on residual networks, and the specific internal network structures are shown in Figures 3 and 4. While previous work has mainly laid stress on improving loss functions, our target is to enhance the optimization methods for the four models and compare them with several state-of-the-art techniques.  
Figure 2: Forward experimental model and reverse experimental model of SWAD-CycleGAN.