生成对抗网络
发布日期:2021-11-21 04:41:33 浏览次数:36 分类:技术文章

本文共 3496 字,大约阅读时间需要 11 分钟。

1. 为了更加稳定的设计准则[更新中]

Reference: cs231n

Radford et al, “Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks”, ICLR 2016

Generator is an upsampling network with fractionally-strided convolutions

Discriminator is a convolutional network 


Keras作者指出的trick

## A bag of tricks

Training GANs and tuning GAN implementations is notoriously difficult. There are a number of known "tricks" that one should keep in mind.
Like most things in deep learning, it is more alchemy than science: these tricks are really just heuristics, not theory-backed guidelines.
They are backed by some level of intuitive understanding of the phenomenon at hand, and they are known to work well empirically, albeit not
necessarily in every context.
Here are a few of the tricks that we leverage in our own implementation of a GAN generator and discriminator below. It is not an exhaustive
list of GAN-related tricks; you will find many more across the GAN literature.
* We use `tanh` as the last activation in the generator, instead of `sigmoid`, which would be more commonly found in other types of models.

* We sample points from the latent space using a _normal distribution_ (Gaussian distribution), not a uniform distribution.

* Stochasticity is good to induce robustness. Since GAN training results in a dynamic equilibrium, GANs are likely to get "stuck" in all sorts of ways. Introducing randomness during training helps prevent this. We introduce randomness in two ways: 1) we use dropout in the discriminator, 2) we add some random noise to the labels for the discriminator.

* Sparse gradients can hinder GAN training. In deep learning, sparsity is often a desirable property, but not in GANs. There are two things that can induce gradient sparsity: 1) max pooling operations, 2) ReLU activations. Instead of max pooling, we recommend using strided convolutions for downsampling, and we recommend using a `LeakyReLU` layer instead of a ReLU activation. It is similar to ReLU but it relaxes sparsity constraints by allowing small negative activation values.

* In generated images, it is common to see "checkerboard artifacts" (棋盘效应)caused by unequal coverage of the pixel space in the generator. To fix this, we use a kernel size that is divisible by the stride size (比如kernel选择4, stride选择2), whenever we use a strided `Conv2DTranpose` or `Conv2D` in both the generator and discriminator.

generator loss 越来越大,discriminator越来越小的问题一般是判别器过拟合,它似乎只注意到没有噪声的图像都是真的,在判别器前面加一个高斯噪声层就好了。另外软标签和分批向判别器送入真假图片貌似也能缓解这个问题?

Gan zoo: 

How to train a Gan   

2. GAN的应用

GAN的训练及其改进

上面使用GAN产生的图像虽然效果不错,但其实GAN网络的训练过程是非常不稳定的。

通常在实际训练GAN中所碰到的一个问题就是判别模型的收敛速度要比生成模型的收敛速度要快很多,通常的做法就是让生成模型多训练几次来赶上生成模型,但是存在的一个问题就是通常生成模型和判别模型的训练是相辅相成的,理想的状态是让生成模型和判别模型在每次的训练过程中同时变得更好。判别模型理想的minimum loss应该为0.5,这样才说明判别模型分不出是真实数据还是生成模型产生的数据。

Improved GANs

这篇文章提出了很多改进GANs训练的方法,其中提出一个想法叫Feature matching,之前判别模型只判别输入数据是来自真实数据还是生成模型。现在为判别模型提出了一个新的目标函数来判别生成模型产生图像的统计信息是否和真实数据的相似。让f(x)

表示判别模型中间层的输出, 新的目标函数被定义为
||Expdataf(x)Ezpzf(G(z))||22

, 其实就是要求真实图像和合成图像在判别模型中间层的距离要最小。这样可以防止生成模型在当前判别模型上过拟合。

InfoGAN

到这可能有些同学会想到,我要是想通过GAN产生我想要的特定属性的图片改怎么办?普通的GAN输入的是随机的噪声,输出也是与之对应的随机图片,我们并不能控制输出噪声和输出图片的对应关系。这样在训练的过程中也会倒置生成模型倾向于产生更容易欺骗判别模型的某一类特定图片,而不是更好的去学习训练数据的分布,这样对模型的训练肯定是不好的。InfoGAN的提出就是为了解决这一问题,通过对输入噪声添加一些类别信息以及控制图像特征(如mnist数字的角度和厚度)的隐含变量来使得生成模型的输入不在是随机噪声。虽然现在输入不再是随机噪声,但是生成模型可能会忽略这些输入的额外信息还是把输入当成和输出无关的噪声,所以需要定义一个生成模型输入输出的互信息,互信息越高,说明输入输出的关联越大。

下面三张图片展示了通过分别控制输入噪声的类别信息,数字角度信息,数字笔画厚度信息产生指定输出的图片,可以看出InfoGAN产生图片的效果还是很好的。

. GAN的理论学习 

机器之心公众号的发布文章 

转载地址:https://blog.csdn.net/xiaojiajia007/article/details/75041691 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:keras的运行机制
下一篇:卷积与反卷积(转置卷积)关系的公式推导 及其各自的形式

发表评论

最新留言

感谢大佬
[***.8.128.20]2024年03月28日 18时38分28秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

graphql-php enum,php – 如何在不写长查询的情况下查询所有的GraphQL类型字段? 2019-04-21
php date 函数用法,php中date()日期时间函数使用方法 2019-04-21
php除法获取整数和余数,PHP除法取整和取余数 2019-04-21
java迷宫路径,Java中的迷宫路径查找器 2019-04-21
php substr cnblog,php中substr用法示例 2019-04-21
php链接怎么截取,PHP 截取网页中的固定种子链接 2019-04-21
iis运行不起来php报500,解决IIS上安装thinkphp6运行报500错误 2019-04-21
php ajax上传图片过大500错误,javascript – JQuery AJAX文件上传错误500 2019-04-21
matlab 图中的legend,matlab中legend加图示命令的使用 2019-04-21
PHP exec xargs 不执行,Linux中的xargs命令及示例 2019-04-21
php 枚举cookie内容,php设置和获取cookie 2019-04-21
单防区扩展模块怎么用_AB罗克韦尔自动化Micro800 扩展 I/O模块型号及功能介绍 2019-04-21
java矩阵类_Java泛型——泛型矩阵类 2019-04-21
java车牌正则表达式_车牌正则表达式 2019-04-21
wordpress4.9.4 mysql_WordPress 将不再支持 PHP4 和 MySQL 4 2019-04-21
安卓是用java语言写的吗_android开发是用java语言吗? 2019-04-21
java 符号 t_java – 运算符”不能应用于’T’,’T’表示有界泛型类型 2019-04-21
用matlab写出信源熵,计算离散信源的熵matlab实现 2019-04-21
php表单yii2,Yii2创建表单(ActiveForm)方法详解 2019-04-21
php 程序授权机制,授权认证详细说明 2019-04-21