# Improvement of Learning Stability of Generative Adversarial Network Using Variational Learning
## 3 Improving the Learning Stability of Generative Adversarial Networks Using Variational Learning
### Hybrid Generative Adversarial Networks for Solving Vanishing Gradient Problem
To learn  
Figure 2: Architectures of GAN and VAE, and their inference parts. (**a**) architecture of GAN; (**b**) inference part of GAN; (**c**) architecture of VAE; (**d**) inference part of VAE. the proposed structure, we propose an algorithm that accomplishes the dual learning of the model, which corresponds to the generator (decoder), based on the use of both the loss function of GAN (Equation (1)) and the loss function of VAE (Equation (10)). First, it builds a mini-batch with \(M\) new data for VAE and GAN for each iteration. In the learning of VAE, \(M\) data are input through the encoder \(Q_{\phi}(z|x)\), which yield \(z\) with the noise distribution \(P(\epsilon)\) based on the standard isotropic Gaussian \(N(0,I)\) and the reparameterization trick [18] (the dimension of \(z\) is \(L\)). Subsequently, the restored data \(x\) pass through the decoder \(P_{\theta}(x|z)\), which approximates the expected value of Equation (9) by the Monte-Carlo estimation method [39]. \[L^{M}(\theta,\phi,x^{M},\epsilon)=\frac{1}{M}\sum_{i=1}^{M}(-\beta KLD(Q_{\phi} (z|x^{(i)})||P(z))+\frac{1}{L}\sum_{l=1}^{L}(log_{\theta}(x^{(i)}|z^{(i)l})) \tag{12}\]  
Parameters \(\theta\) and \(\phi\) are updated by the SGD algorithm or the Adagrad algorithm or the ADAM algorithm using Equation (12) as the loss function. In the learning of GAN, \(M\) fake data are generated by the generator \(P_{\theta}(x|z)\) from \(M\) data and \(M\) noise data sampled using a given prior \(P(z)\). After this, the expected value of Equation (2) is approximated based on a Monte-Carlo estimation process using the real data, \(x_{data}\), and the generated fake data. \[\frac{1}{m}\sum_{i=1}^{M}(\log P_{\psi}(x^{(i)})+(1-P_{\psi}(P_{\theta}(x|z^{( i)})))) \tag{13}\]  
The discriminator \(P_{\psi}(x)\) is learnt by updating \(\psi\) to minimize Equation (13) (in this experiment, the hyperparameter \(k\) was set to 1). Lastly, for the learning of the generator of GAN, \(M\) fake data are generated by the generator \(P_{\theta}(x|z)\) from the \(M\) noise data sampled while using the given prior \(P(z)\). Accordingly, by using the discriminator \(P_{\psi}(x)\) learned in the previous step, the expected value of Equation (3) is approximated based on a Monte-Carlo estimation. Figure 3: The architecture of the proposed VLGAN. \[\frac{1}{m}\sum_{i=1}^{m}(1-P_{\psi}(P_{\theta}(x|z^{(i)}))) \tag{14}\]  
The parameter \(\theta\) is updated to minimize Equation (14). The algorithm of the proposed method (VLGAN) is summarized in Algorithm 1. ```
1:Initiate \(\theta\),\(\phi\),\(\psi\)
2:for Number of training iteration do
3:\(x^{M}\leftarrow\) Sample mini-batch of \(M\) examples from data distribution \(p_{data}(x)\)
4:\(\epsilon\leftarrow\) Sample noises from noise distribution \(p(\epsilon)\). 5:\(\theta,\phi\leftarrow\) Update parameters using gradient
6:\(\bigtriangledown_{\theta\phi}\hat{L}^{M}(\theta,\phi\ x^{M},\epsilon)\)
7: with SGD or Adagrad or ADAM algorithm. 8:for k step do
9:\(z^{M}\leftarrow\) Sample noise \(M\) examples from prior \(p_{\theta}(z)\)
10:\(x^{M}\leftarrow\) Sample mini-batch of \(M\) examples from data distribution \(p_{data}(x)\)
11:\(\psi\leftarrow\) Update parameters using gradient
12:\(\bigtriangledown_{\psi}\frac{1}{M}\sum_{i=1}^{M}(log(1-p_{\psi}(label|x^{(i) }))+log(p_{\psi}(label|p_{\theta}(x|z^{(i)}))))\)
13: with SGD or Adagrad or ADAM algorithm. 14:endfor
```  
**Algorithm 1** The number of steps to apply to the discriminator, \(k\), is a hyperparameter. We used \(k=1\), the least expensive option, in our experiments. \(\beta\) is a hyperparameter. \(M\) is the batch size. \(\theta\),\(\phi\),\(\psi\) are parameters for generator, encoder, and discriminator, respectively. \(label\) is 0 or 1.