飙血推荐
  • HTML教程
  • MySQL教程
  • JavaScript基础教程
  • php入门教程
  • JavaScript正则表达式运用
  • Excel函数教程
  • UEditor使用文档
  • AngularJS教程
  • ThinkPHP5.0教程

论文解读(GAN)《Generative Adversarial Networks》

时间:2022-02-10  作者:BlairGrowing  

Paper Information 

Title:《Generative Adversarial Networks》
Authors:Ian J. Goodfellow, Jean Pouget-Abadie, M. Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron C. Courville, Yoshua Bengio
Sources:2014, NIPS
Other:26700 Citations, 41 References
Code:Download
Paper:Download

Abstract

  本文提出一个 new framework , 通过一个 adversarial process 来估计生成模型。该模型同时训练两个模型:

    • A generative model $G$ that captures the data distribution.
    • A discriminative model $D$ that estimates the probability that a sample came from the training data rather than $G$.

  Generative model $G$ 主要做的是:使得  fake sample 尽可能的欺骗 discriminative model $D$  ,使其辨别不出来。

  Discriminative model $D$ 主要做的是:将 generative model $G$ 生成的 fake sample 与 true sample 识别出来。

  该过程可以总结为:This framework corresponds to a minimax two-player game(minmax 双人博弈).

  模型的优点

    • $G$ and $D$ are defined by multilayer perceptrons, the entire system can be trained with backpropagation.
    • There is no need for any Markov chains or unrolled approximate inference networks during either training or generation of samples.

1 Introduction

  • Discriminative models:Map a high-dimensional, rich sensory input to a class label.

    优点:基于 backpropagation 和 dropout algorithms 取得了巨大的成功。​

  • Deep generative models​
    缺点:
      • 由于极大似然估计和其他方法中出现的难以计算的概率问题。​
      • 在 generative context 中不好利用分段线性单元的优势。
  在本文提出的GAN模型中:​
    • The discriminative model that learns to determine whether a sample is from the model distribution or the data distribution.​
    • The generative model can be thought of as analogous to a team of counterfeiters, trying to produce fake currency and use it without detection, while the discriminative model is analogous to the police, trying to detect the counterfeit currency.​
    • Competition in this game drives both teams to improve their methods until the counterfeits are indistiguishable from the genuine articles.​

2 Related work

  VAE(variational autoen-coders)经常与GAN一起出现,也提出了 VAE-GAN。

3 Adversarial nets

  当对抗网络的双方都是多层感知机(multilayer perceptrons)的时候。   Some definition:
  • 数据 $x$
  • 基于数据 $x$ 的 generator 上的数据分布 $p_g​ $
  • 先验的输入噪声变量 $p_{z}(z) $
  • 基于噪声变量的数据空间映射表示为 $G\left(z ; \theta_{g}\right) $ ,其中 $ G$  是具有参数 $\theta_{g}$​  的 MLP 
  • MLP函数:$D\left(x ; \theta_{d}\right)$ ,输出一个标量
  • 真实数据分布:  $D(x) $ 表示  $x$  来自真实数据分布而不是  $p_{g}$  的概率。
  通过训练  $D$  来最大化正确分配标签给训练样本和  $G$  产生的样本的概率。同时训练  $G$  来最小化  $\log (1-D(G(z)))$ 。   解释
    • 假设判别器 $D$ 能够正确区分来自 $\mathrm{G} $ 的生成数据和真实数据,那么 $D(G(z))$ 应为 $0$(判别为"负"类),则 $\log (1-D(G(z))) =log(1-0) = 0 $ 。
    • 假设判别器 $D$ 不能区分来自 $G $的生成数据与真实数据,最极端的情况下,把所有的数据都当作真实数据,那么$ D(G(z))$ 为 $1$ (判别为"正"类),则 $\log (1-D(G(z))) =log(1-1) $ 是负无穷。
  In other words, $D$ and $G$ play the following two-player minimax game with value function $V (G, D)$。

  目标函数如下:

    $\underset {G}{min}\underset {D}{max}V(D, G)=\mathbb{E}_{\boldsymbol{x} \sim p_{\text {data }}(\boldsymbol{x})}[\log D(\boldsymbol{x})]+\mathbb{E}_{\boldsymbol{z} \sim p_{\boldsymbol{z}}(\boldsymbol{z})}[\log (1-D(G(\boldsymbol{z})))]\quad \quad \quad (1)$

  分析上式,  $x$  是真实数据,  $D(X)$  表示给真实数据打的分数,  $G(z)$  表示生成器生成的数据,  $D(G(z))$  表示给生成数据打的分数。我 们希望  $D(x)$  大的同时  $D(G(z)) $ 也很大。

  例子:

    

  • 判别分布D(蓝色、虚线)

  • 数据生成分布 $p_x$(黑色,虚线)

  • 噪声生成分布 $P_{g}(G)$(G 绿色,实线)

  • 下面的水平线为均匀采样 $z$ 的区域,上面的水平线为 $x$ 的部分区域。

  • 朝上的箭头显示映射 $x=G(z)$ 如何将非均匀分布 $p_{g}$ 作用在转换后的样本上。

  • $G$ 在 $p_{g}$ 高密度区域收缩,且在 $p_{g}$ 的低密度区域扩散。

  • Figure1 (a) 考虑一个接近收敛的对抗的模型对: $p_{g}$  与 $p_{\text {data }}$  分布相似,且 $D$  是个部分准确的分类器【密度中心部分可以大致识别出来】。(可以发现$p_{g}$  与 $p_{\text {data }}$ 的密度中心不一样,判别器 $D$ 在 $p_{data}$ 的密度中心值高,在 $p_{g}$的密度中心值低。(红色区域相交部分))

  • Figure1 (b) 在算法的内循环中,训练 $D$  来判别数据中的样本,收敛到:$ D^{*}(X)=\frac{p_{\text {data }}(x)}{p_{\text {data }}(x)+p_{g}(x)} $。

  • Figure1 (c) 在 G 更新后, $D$  的梯度引导  $G(z) $ 与真实数据分布越发接近。

  • Figure1 (d) 经过若干步训练后,如果 $G$  和 $D$  性能足够,它们接近某个稳定点并都无法继续提高性能,因为此时 $p_{g}=p_{\text {data }}$  。判别器将无法区分训练数据分布和生成数据分布,即 $D(x)=\frac{1}{2}$  。

4 Theoretical Results

算法:

    

4.1 Global Optimality of $p_g = p_{data}$

4.1.1 最优判别器

  Proposition 1. For $G$ fixed, the optimal discriminator $D$ is

    ${\large D_{G}^{*}(\boldsymbol{x})=\frac{p_{\text {data }}(\boldsymbol{x})}{p_{\text {data }}(\boldsymbol{x})+p_{g}(\boldsymbol{x})}} \quad \quad \quad (2)$

  证明

    首先考虑将生成器  $G$  固定, 优化最优判别器 $D$。此时最大化 $V (G, D)=V (D)$ :

    $\begin{aligned}V(G, D) =V (D)&=\int_{\boldsymbol{x}} p_{\text {data }}(\boldsymbol{x}) \log (D(\boldsymbol{x})) d x+\int_{\boldsymbol{z}} p_{\boldsymbol{z}}(\boldsymbol{z}) \log (1-D(g(\boldsymbol{z}))) d z \\&=\int_{\boldsymbol{x}} p_{\text {data }}(\boldsymbol{x}) \log (D(\boldsymbol{x}))+p_{g}(\boldsymbol{x}) \log (1-D(\boldsymbol{x})) d x\end{aligned}\quad \quad \quad (3)$

  回忆:$x=G(z)$  ,这里 $g(z)$ 可以看成是 $G(z)$  函数空间中的一个个例。$p_g(x)$  代替 $p_z(z)$,从 $z$ 域转换到 $x$ 域。

  令 $p_{data}(x)$ 为 $a$,$p_{g}(x)$ 为 $b$,$D(x)$ 为 $y$。 对于任意的  $(a, b) \in \mathbb{R}^{2} \backslash\{0,0\} $,函数 $y \rightarrow a \log (y)+b \log (1-y) $ 在 $ \frac{a}{a+b}\in  [0,1]  $ 取最值。

  请注意,$D$ 可以被解释为条件概率  $P(Y=y \mid \boldsymbol{x})$  的最大对数似然估计。这里,$Y$ 代表着  $\boldsymbol{x}$  来自  $p_{\text {data }}$  (with  $y=1$  ) 或者来自  $p_{g}$  (with  $y=0 $ )。

  Eq. 1 可以转换为:

    $\begin{aligned}C(G) &=\max _{D} V(G, D) \\&=\mathbb{E}_{\boldsymbol{x} \sim p_{\text {data }}}\left[\log D_{G}^{*}(\boldsymbol{x})\right]+\mathbb{E}_{\boldsymbol{z} \sim p_{z}}\left[\log \left(1-D_{G}^{*}(G(\boldsymbol{z}))\right)\right] \\&=\mathbb{E}_{\boldsymbol{x} \sim p_{\text {data }}}\left[\log D_{G}^{*}(\boldsymbol{x})\right]+\mathbb{E}_{\boldsymbol{x} \sim p_{g}}\left[\log \left(1-D_{G}^{*}(\boldsymbol{x})\right)\right] \\&=\mathbb{E}_{\boldsymbol{x} \sim p_{\text {data }}}\left[\log \frac{p_{\text {data }}(\boldsymbol{x})}{P_{\text {data }}(\boldsymbol{x})+p_{g}(\boldsymbol{x})}\right]+\mathbb{E}_{\boldsymbol{x} \sim p_{g}}\left[\log \frac{p_{g}(\boldsymbol{x})}{p_{\text {data }}(\boldsymbol{x})+p_{g}(\boldsymbol{x})}\right]\end{aligned}\quad \quad \quad (4)$

4.1.2 最优生成器

  Theorem 1. The global minimum of the virtual training criterion  $C(G)$  is achieved if and only if  $p_{g}=p_{\text {data. }}$ . At that point,  $C(G)$  achieves the value  $-\log 4$ .

  证明:

    当 $p_{g}=p_{\text {data }}$ 时,最优判别器

    ${\large D_{G}^{*}(\boldsymbol{x}) =\frac{p_{\text {data }}(x)}{p_{\text {data }}(x)+p_{g}(x)}=\frac{1}{2}} $

    此时目标函数 $V (G, D)=V (G)$ 

    $ \begin{array}{l} V(G,D)&=V(G)\\&=\int_{x} p_{\text {data }}(x) \log \frac{p_{\text {data }}(x)}{p_{\text {data }}(x)+p_{g}(x)}+p_{g}(x) \log \left(1-\frac{p_{\text {data }}(x)}{p_{\text {data }}(x)+p_{g}(x)}\right) d x\end{array} $

    利用最优判别器 ${\large D_{G}^{*}(\boldsymbol{x}) =\frac{p_{\text {data }}(x)}{p_{\text {data }}(x)+p_{g}(x)}=\frac{1}{2}} $,对 $V (G)$ 做变换得:

    $\begin{array}{l} V(G,D)&=V(G)\\&=-\log 2 \int_{x} p_{g}(x)+p_{\text {data }}(x) d x\\&\quad+\int_{x} p_{\text {data }}(x)\left(\log 2+\log \frac{p_{\text {data }}(x)}{p_{\text {data }}(x)+p_{g}(x)}\right)+p_{g}(x)\left(\log 2+\log \frac{p_{g}(x)}{p_{\text {data }}(x)+p_{g}(x)}\right) d x \end{array}$

    其中:

    $\begin{array}{l} -\log 2 \int_{x} p_{g}(x)+p_{data }(x) d x\\=-2 \log 2\int_{x} p_{data}(x)dx\\=-\log4\end{array}$

    $\begin{array}{l}\log 2+\log \frac{p_{\text {data }}(x)}{p_{\text {data }}(x)+p_{g}(x)}&=\log \frac{2 p_{\text {data }}(x)}{p_{\text {data }}(x)+p_{g}(x)}\\&=\log \frac{p_{\text {data }}(x)}{\left(p_{\text {data }}(x)+p_{g}(x)\right) / 2}\end{array} $

    $\begin{array}{l}\log 2+\log \frac{p_{g }(x)}{p_{\text {data }}(x)+p_{g}(x)}&=\log \frac{2 p_{g }(x)}{p_{\text {data }}(x)+p_{g}(x)}\\&=\log \frac{p_{g }(x)}{\left(p_{\text {data }}(x)+p_{g}(x)\right) / 2}\end{array} $

    所以,最终结果为:

    $\begin{array}{l} V(G,D)&=V(G)\\&=-\log 4+D_{K L}\left(p_{\text {data }} \| \frac{p_{\text {data }}+p_{g}}{2}\right)+\left(p_{g} \| \frac{p_{\text {data }}+p_{g}}{2}\right)\end{array}\quad \quad \quad (5)$

    由于KL散度的非负性,得 $C(G)$ 的最小值为 $−\log4  $。

Tips
  相对熵 (Relative Entropy) 也称 KL 散度。

  在机器学习中,$P$ 往往用来表示样本的真实分布,$Q$ 用来表示模型所预测的分布,那么KL散度就可以计算两个分布的差异,也就是Loss损失值。

    $D_{K L}(P \| Q)=E_{p(x)}\left[\log \frac{p(x)}{q(x)}\right]=\int_{x} p(x) \log \frac{p(x)}{q(x)}$

  • KL散度具有非负性。
  • 当且仅当 $P$ , $Q$ 在离散型变量下是相同的分布时,即 $ p(x)=q(x)$ , $ D_{K L}(P \| Q)=0$ 。
  • K L 散度衡量了两个分布差异的程度,经常被视为两种分布间的距离。
  • 请注意, $D_{K L}(P \| Q) \neq D_{K L}(Q \| P)$  ,即 $K L$  散度没有对称性。

   从KL的散度定义式可以看出其值域范围为 $[-\infty ,\infty]$ ,且不具有对称性,所以这里将 Eq.5. 转变为JS散度。

    $C(G)=-\log (4)+2 \cdot J S D\left(p_{data} \| p_{g}\right)\quad \quad \quad (6)$

   为什么选择JS散度:

    • JS散度具有非负性质
    • JS散度的值域范围在 $[0,1]$ ,$p$ 和 $q$ 分布相同的时候为 $0$,完全不同的时候为 $1$。

4.2 Convergence of Algorithm 1

  Proposition 2. If $G$ and $D$ have enough capacity, and at each step of Algorithm 1, the discriminator is allowed to reach its optimum given $G $, and $p_{g}$ is updated so as to improve the criterion

    $\mathbb{E}_{\boldsymbol{x} \sim p_{\text {data }}}\left[\log D_{G}^{*}(\boldsymbol{x})\right]+\mathbb{E}_{\boldsymbol{x} \sim p_{g}}\left[\log \left(1-D_{G}^{*}(\boldsymbol{x})\right)\right]$

  then $p_{g}$ converges to $p_{data }$

5 Experiments

  数据集:Minist、TFD 以及 CIFAR-10。

  生成器 Generator 使用的激活函数有 ReLU 和 sigmoid,判别器 Discirminator 使用的激活函数是 maxout。

  Dropout  算法被用于判别器网络的训练。

  虽然理论上可以在生成器的中间层使用 Dropout 和 其他噪声,但这里仅在 generator network 的最底层使用噪声输入。

  对 $G$ 生成的样本拟合  Gaussian Parzen window,并报告该分布下的  log-likelihood,来估计  $p_{g}$  下测试集数据的概率。高斯分布中的参数  $\sigma$  通过验证集的交叉验证得到的。

   Breuleux et al.引入该过程用于不同的似然难解生成模型上,结果在 Table1 中:

    

  我们可以看到结果中方差很大,并且在高维模型中表现不好。

  在 Figures 2 和 Figures 3,我们展示了训练后从  generator net 中提取的样本。

    

    

6 Advantages and disadvantag

  优点:无需马尔科夫链,仅用反向传播来获得梯度,学习间无需推理,且模型中可融入多种函数。

  缺点:(论文中说主要为  $p_{g}(x)$  的隐式表示 。且训练时  $\mathrm{G}$  和  $\mathrm{D}$  要同步,即训练  $\mathrm{G}$  后,也要训练  $\mathrm{D} $ ,且不能将 $G$ 训练太好而不去训练 $D$(通俗解释就是 $G$ 训练的太好很容易就"欺骗"了没训练的 $D$)。

    

7 Conclusions and future work

  1. A conditional generative model $p(\boldsymbol{x} \mid \boldsymbol{c})$ can be obtained by adding $\boldsymbol{c}$ as input to both $G$ and $D$ .

  2. Learned approximate inference can be performed by training an auxiliary network to predict $\boldsymbol{z}$  given $\boldsymbol{x}$ . This is similar to the inference net trained by the wake-sleep algorithm but with the advantage that the inference net may be trained for a fixed generator net after the generator net has finished training.

  3. One can approximately model all conditionals $p\left(\boldsymbol{x}_{S} \mid \boldsymbol{x}_{\not}\right) $ where $S$ is a subset of the indices of $x$ by training a family of conditional models that share parameters. Essentially, one can use adversarial nets to implement a stochastic extension of the deterministic MP-DBM .

  4. Semi-supervised learning: features from the discriminator or inference net could improve performance of classifiers when limited labeled data is available.

  5. Efficiency improvements: training could be accelerated greatly by divising better methods for coordinating $G$  and $D$  or determining better distributions to sample $\mathrm{z}$  from during training.

参考

GAN生成对抗网络

05-生成网络总结(VAE, GAN)

标签:编程
湘ICP备14001474号-3  投诉建议:234161800@qq.com   部分内容来源于网络,如有侵权,请联系删除。