[AI 笔记] GAN


参考资料:
CS231n
GAN论文

GAN

GAN 分为两个部分,一个生成器网络,一个判别器网络。如下图所示。

生成器通过学习 random noise z 到 真实图片的分布,生成与真实图片近似的图片。

判别器通过判别网络,来区分 real images 和 fake images。

原文:“In the proposed adversarial nets framework, the generative model is pitted against an adversary: a 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.”
在这里插入图片描述

Minimax objective function

GAN 的目标函数如下图中的 Minimax objective function 所示。

D(x) 为判别器输入为 real data x 时的输出;D(G(z)) 为判别器输入为 fake data G(z) 时的输出。

对于判别器而言,其目标是最大化目标函数,这样的话 D(x) 趋近于 1(判别为真),而 D(G(z)) 趋近于 0(判别为假)。即判别器成功区分 real data 和 fake data。

对于生成器而言,其目标是最小化目标函数,这样的话 D(G(z)) 趋近于 1(判别器判别为真)。即生成器成功骗过了判别器。
在这里插入图片描述
通过上述分析,对于 minimax 目标函数,可以针对判别器和生成器分别进行讨论,如下图所示。

对于判别器而言,其目标函数如下图序号1后所示,为 max 目标函数;对于生成器而言,其目标函数如下图序号2后所示,为 min 目标函数。

在实际训练中,生成器的 min 目标函数工作地不是很好。其曲线如右下角所示,在训练的一开始,判别器能轻松区分 real 和 fake,D(G(z)) 趋近于 0,在这一区域,曲线下降较慢,训练受阻,但是在训练后期,当生成器性能已经较好的时候,D(G(z)) 在 1 附近,曲线反而下降较快。这样显然不太好。(个人认为,这是 log 函数的原因 - -)
在这里插入图片描述
于是将生成器的目标函数变形为 max 目标函数,如下图所示(这边其实还要取下反,才能对应图中绿线),其训练曲线如右下角绿线所示。这样就好多了,在训练初期能够快速下降。
在这里插入图片描述

Train

由于 GAN 有两个网络,两个目标函数,其训练过程如下图所示。

其中有两层循环,对生成器的训练在大循环中,对判别器的训练的在小循环中。每训练一次生成器,要训练 k 次判别器。

另外:“in particular, G must not be trained too much without updating D, in order to avoid “the Helvetica scenario” in which G collapses too many values of z to the same value of x to have enough diversity to model pdata”
在这里插入图片描述
原文结果如下图所示:
没框出来的是生成图像,框出来的是与生成图像近似的 real images。
在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值