## 2 Methods
### Generative Adversarial Networks
#### 2.1.2 The Principle of Generative Adversarial Networks (GANs)
The optimal generator achieved by the generative model is denoted as \(\mathrm{G}^{*}\):  
\[G^{*}=\min_{G}\max_{D}V(D,G). \tag{3}\]  
Given the data and a fixed generator G, consider \(P_{data}(x)\) and \(P_{G}(x)\) as constants. Adjust the discriminator D to maximize \(V(D)\):  
\[\mathrm{D}^{*}(x)=\frac{P_{data}(x)}{P_{data}(x)+P_{G}(x)}. \tag{4}\]  
Substituting \(\mathrm{D}^{*}\) into the previously optimal generation result, we obtain:  
\[\max_{D}V(D,G)=-2\log 2+KL\bigg{(}P_{\mathrm{dan}}(x)\bigg{\|}\frac{P_{ \mathrm{dan}}(x)+P_{G}(x)}{2}\bigg{)}+KL\bigg{(}P_{G}(x)\|\frac{P_{\mathrm{dan }}(x)+P_{G}(x)}{2}\bigg{)}. \tag{5}\]  
We adjust \(D\) to maximize the value of \(V(G,D)\), where the two KL divergences together constitute the maximum, thus measuring the degree of difference between \(P_{data}(x)\) and \(P_{G}(x)\). The generator \(G\) aims to minimize the KL divergence between the generated data and real data, while the discriminator \(D\) attempts to maximize it. The model training process is illustrated in Figure 3, where the horizontal line \(z\) represents the input random vector, the horizontal line \(x\) represents real data, and the arrows between the two parallel lines represent the mapping from the input random vector to the generated data, i.e., the mapping from uniformly distributed data to non-uniformly distributed data. The green solid line reflects the distribution of generated data, the black dashed line reflects the distribution of real data, and the blue dashed line represents the discriminator. Figure 3a-d  
Figure 2: GAN principle diagram. represent the model training initial state, fixing \(G\) to train \(D\), fixing \(D\) to train \(G\), and the final convergence stage, respectively. By the (d) stage of training, the distribution of generated data perfectly matches the distribution of real data. The training algorithm for GAN discriminators and generators, as shown in Algorithm 1, involves sampling \(m\) examples \(\{x_{1},\ldots,x_{m}\}\) from the real data distribution \(\mathcal{P}_{G}\) and \(m\) examples \(\{z_{1},\ldots,z_{m}\}\) from the generated data distribution \(P_{G}\) to enhance training efficiency. During the training process, the discriminator \(D\) undergoes cyclic training with real and generated data distributions for \(k\) iterations, followed by training the generator \(G\) with a smaller learning rate. \(G\) progressively reduces the gap between real and generated samples during iterative training, achieving convergence. ```
1:for number of training iterations do
2:for\(k\) steps do
3: Sample m sets of noise data \(\{z_{1},\ldots,z_{m}\}\) from the random distribution \(P_{G}(z)\);
4: Sample m sets of samples x1,..., xm from the real data distribution \(P_{data}(x)\);
5: Update the \(D\) network: \(\
abla_{d}\frac{1}{m}\sum_{i=1}^{m}[\log D(x^{(i)}+\log(1-D(G(z^{(i)})))]\);
6:endfor
7: Sample m sets of noise data \(\{z_{1},\ldots,z_{m}\}\) from the random distribution \(P_{G}(z)\);
8: Update the \(G\) network: \(\
abla_{g}\frac{1}{m}\sum_{i=1}^{m}\log(1-D(G(z^{(i)})))\). 9:endfor
```  
**Algorithm 1** GAN Training Algorithm