前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >[高大上的DL] BEGAN: Boundary Equilibrium GAN

[高大上的DL] BEGAN: Boundary Equilibrium GAN

作者头像
用户1622570
发布2018-04-11 16:00:53
1.2K0
发布2018-04-11 16:00:53
举报

自己基本翻译了BEGAN,错误在所难免,希望有大神可以给我留言,我们也可以交流一下训练的一些事情。讲道理,我特别希望有人给我留言,不然我感觉我每天就是在自嗨!囧!

paper地址:https://arxiv.org/abs/1703.10717

by Google

摘要:Wepropose a new equilibrium enforcing method paired with a loss derived from theWasserstein distance for training auto-encoder based Generative Adversarial Networks.This method balances the generator and discriminator during training. Additionally,it provides a new approximate convergence measure, fast and stable training andhigh visual quality. We also derive a way of controlling the trade-off betweenimage diversity and visual quality. We focus on the image generation task,setting a new milestone in visual quality, even at higher resolutions. This is achievedwhile using a relatively simple model architecture and a standard training procedure.

提出了一种均衡驱动和通过计算Wasserstein距离损失驱动的新方法,这个方法基于GAN训练了自编码器模型。其中均衡驱动是指在训练中平衡生成器和判别器的学习能力。另外,BEGAN提出了一种近似判断模型是否收敛的方法,这个方法使训练过程更快,更稳定,生成图像的质量更高。本文也提出了一种平衡生成图像多样性和生成质量的方法,甚至在更高的分辨率上(128x128)。如此好的结果,但是BEGAN只使用了简单的模型,和一般的训练方法。

一句话概括一下就是基于auto-encoder模型,通过计算生成器和判别器损失的Wasserstein距离,利用简单的网络结果,达到了非常棒的效果。

contributions:

1). A GAN with a simple yet robustarchitecture, standard training procedure with fast and

stableconvergence.

利用简单而具有鲁棒性的模型,通过传统的训练方法,更快更稳定的训练了一个GAN模型。

2). An equilibrium concept that balances thepower of the discriminator against the generator.

提出equilibrium的概念,equilibrium就是平衡判别器和生成器的学习能力。

3). A new way to control the trade-off betweenimage diversity and visual quality.

提出一个新的方法来控制图像多样性和图像质量的的均衡。

4). An approximate measure of convergence. Toour knowledge the only other published measure is from Wasserstein GAN [1](WGAN), which will be discussed in the next section.

一个收敛的近似方法。除了WGAN,本文提出的是最牛逼的。

2 Related work

相关研究里面需要注意的是,提了一个比较重要的就是Energy Based GANs(能量GAN, EBGAN),他说这个GAN,This variant converges morestably and is both easy to train and robust to hyper-parameter variations.

更稳定,不仅容易训练,而且对超参数具有很强的鲁棒性。(But, 这篇我还没看….)

3 Proposed method

Weuse an auto-encoder as a discriminator as was first proposed in EBGAN [17].

和能量GAN一样,BeGAN也用了自动编码器。

Whiletypical GANs try to match data distributions directly, our method aims to matchauto-encoder loss distributions using a loss derived from the Wassersteindistance.

和传统GAN的区别是,传统GAN是直接拟合生成样本和真实样本之间的分布,而本文的方法是拟合auto-encoder(判别器)损失的分布,这个损失的计算方法是利用Wasserstein距离。

This is done using a typical GAN objective withthe addition of an equilibrium term to balance the discriminator and thegenerator. Our method has an easier training procedure and uses a simplerneural network architecture compared to typical GAN techniques.

和传统GAN的目标函数不同的是加了一个均衡项,这是为了平衡判别器和生成器。然后就是很牛逼!

3.1 Wasserstein distance for auto-encoders

We wish to study the effect of matching thedistribution of the errors instead of matching the distribution of the samplesdirectly. We first show that an auto-encoder loss approximates a normal distribution,then we compute the Wasserstein distance between the auto-encoder lossdistributions of real and generated samples.

本文希望用拟合损失分布的方法代替直接拟合样本分布。首先证明了auto-encoder的损失近似一个正态分布,然后计算真实数据经过auto-encoder得到的损失和生成样本损失之间的Wasserstein距离。

接下来作者定义了一个新的计算pixel-wise(逐像素)的auto-encoder损失的函数L。里面的D是auto-encoder的模型函数。其中v的维度是N。

For a sufficient large number of pixels, ifwe assume that the losses at the pixel level are independent and identicallydistributed, then the Central Limit Theorem applies and the overalldistribution of image-wise losses follows an approximate normal distribution.In our model, we use the L1 norm between an image and its reconstruction as ourloss. We found experimentally, for the datasets we tried, the loss distributionis, in fact, approximately normal.

对于大量的像素值来说,我们假设在像素级别的损失是独立同分布的,利用中心极限定理,则 image-wise(基于整个图像)的损失也是近似服从正态分布的。本文在图像和其重建图像上使用的是L1范数。也就是上面公式的aita=1.通过实验我们也发现了这个理论,即损失的分布服从正态分布。

给两个正态分布,mu1,mu2,其均值为m1,m2,协方差C1,C2。W(mu1,mu2)就是Wasserstein距离的平方的计算公式。当p=1. 简化为下面这个公式。

我们希望通过实验证明仅优化

就可以优化W的平方。

这个要结论要成立,当公式1是个常数或者关于(w.r.t,with regard to)W单调递增。既然如此,那么问题就简单了,W的平方正比于公式(1-1)。

接下来作者重申,本文的优化目标是计算损失的分布之间的Wasserstein距离。判别器是auto-encoder,那么假定拟合损失的分布可以近似代替拟合样本的分布。

本文设计的判别器最大化公式2auto-encoder之间的损失。真实样本x的损失记为L(x), 它服从正态分布,记为mu1(看图片里面的记法)。生成器的损失记为L(G(z)),G是生成器的模型函数,z服从[-1,1]的均匀分布,它的损失也服从正态分布,记为mu2。

因为m1,m2属于正实数,所以有以下两种可以最大化公式2的解决方法。本文选择第二种,因为最小化m1,就是auto-encoder真实的数据。(这里很关键,GAN的目的是生成一些图片,和训练样本尽可能的像。那么它两个之间的损失的均值如果最小,趋于0。那么就说明生成的图像很像真实的图像?应该是这么理解的,不太肯定。)公式(3)对于G模型和D模型的损失的优化目标,比较简单了。

This equation, while similar to the onefrom WGAN, has two important differences:

1. We match distributions between assumednormally distributed losses.

2. This simplifies the function for theWasserstein distance; our solution does not require a

k-Lipschitz function.

公式(3)和WGAN的区别:

1. 再说一遍,拟合的是损失的分布,前提是假设损失服从正态分布。

2. 优化的目标函数仅仅计算一下Wasserstein距离,不要求满足k-Lipschitz连续的函数。

For function approximations, in our casedeep neural networks, we must also consider the representational capacities ofeach function G and D. This is determined both by the model implementing thefunction and the number of parameters. It is typically the case that G and Dare not well balanced and the discriminator D wins easily. To account for thissituation we introduce an equilibrium concept.

为了逼近真实的分布函数, 在我们的深层神经网络中, 还必须考虑生成器和判别器的表达能力。这不仅通过实现函数的模型,而且需要根据参数个数来确定。通常情况下, 生成器和判别器不要太平衡好一点, 要让判别器 D 更容易获胜比较好。然后作者提出了一个均衡的概念。

3.3 Equilibrium

In practice it is crucial to maintain a balancebetween the generator and discriminator losses; we consider them to be atequilibrium when:

在实际中,平衡生成器和判别器的损失是很重要的。当满足公式(4)的时候,就说他们是均衡的。

If we generate samples that cannot bedistinguished by the discriminator from real ones, the distribution of theirerrors should be the same, including their expected error. This concept allowsus to balance the effort allocated to the generator and discriminator so thatneither wins over the other.

当生成的样本不能被判别器从真实样本中区分开的时候,他们的损失应该是一样的,包括损失的数学期望也是一样的。如此就可以让我们平衡分配给生成器和判别器任务,让他们都不能赢对方。

当保持这个完美的平衡时,公式1在m1-m2趋于0的时候变得不稳定。我们引入了一个新的超参数gama,gama的定义是公式(5)。BEGAN的判别器有两个任务,一个是auto-encoder真实的图像,一个是从生成样本中找出来真实的样本。Gama可以平衡这两个目标。一个比较小的gama值,会影响图片的多样性,因为判别器会偏向auto-encoder真实数据。我们称gama为多样化比率。一个自然的边界(极限)值,就是要让图像既清晰又保持细节特征。

3.4 Boundary Equilibrium GAN

Boundary Equilibrium GAN就是BEGAN,下面这个大括号里面的就是BEGAN的目标函数。Ld表示判别器的损失,LG表示生产器的损失。第三个式子是比例控制系数的更新公式。作者这里说是用了比例控制理论?来保持生成器和判别器损失的期望平衡。Lambda k叫做比例增益,也就是学习率。其实这也可以看做是closed-loop feedback control(闭环反馈控制)的一种形式,kt就是每次循环时候调整来控制方程(5)。

在训练开始的时候,G生成器对于auto-encoder来说更容易重建数据(生成图像),因为当生成数据趋于0的时候,真实数据分布还没有被学习。所以开始的时候生成器的损失要小于判别器的损失,而作者提出的平衡控制方法可以在整个训练过程中控制这种情况。

用公式(2)来做近似的方法和公式(5)中的gama,对于计算Wasserstein距离有影响。所以作者用不同的gama来做实验。

最后这段说的是和传统GAN的区别。BEGAN不需要讲生成器和判别器单独训练,或者预训练,最重要的是还能保证训练过程的稳定。BEGAN的优化器是两个独立的Adam分别求最优的生成器和判别器的参数。Batch size 是16。

3.4.1 Convergence measure

Determining the convergence of GANs isgenerally a difficult task since the original formulation is defined as azero-sum game. As a consequence, one loss goes up when the other goes down. Thenumber of epochs or visual inspection are typically the only practical ways toget a sense of how training has progressed.

由于GAN是一个零和博弈,所以怎么确定GAN是否收敛是一个很困难的问题。一般来说,当一个的损失上升,而另一个下降的时候就说收敛了。随着迭代次数的增加,通过看生成图像的质量,只是一个经验性的方法,来确定训练的过程到底是怎么样的。

因为评价GAN这种类型的模型,没有一个标准。所以作者提出了一个评价模型好坏的方法。就是上面这个公式。通过计算Mglobal来确定模型是不是达到最佳或者模型奔溃。

3.5 Model architecture

接下来是模型结构的说明,主要就是下面这个图。生成器是Decoder的过程,判别器是先encoder然后decoder。

BEGAN的判别器是一个auto-encoder,但是这个模型我之前也没有学过,简单查了一下,auto-encoder的主要思想就是学习一个输入输出的关系,使得输出尽可能和输入保持一致。这也是为什么作者要用auto-encoder的原因,前面说了,BEGAN计算的是训练的损失的分布,输入数据给auto-encoder,auto-encoder学习到输入数据的分布,然后利用学习的损失可以近似代替原来输入数据的分布,BEGAN的巧妙之处就在于此。

后面的实验部分,就要靠自己去实验喽~。

祝大家玩的开心!

哦,对,还有个事,每天发二维码,我也腻了,所以我就去网上找好看的图片,但是那么多呢,下载挺麻烦的,然后我百度了一把,写了个爬虫的代码,下次和大家分享!先给大家看下,我爬下来的美图,hahahha!

本文为作者原创,如有雷同,必然是别人抄我的。

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2017-05-20,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 机器学习和数学 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档