当前位置:网站首页>GAN:生成对抗网络 Generative Adversarial Networks
GAN:生成对抗网络 Generative Adversarial Networks
2022-07-29 05:21:00 【代码的路】
1 原理
对于生成对抗网络GAN,一个简单的理解是可以将其看做博弈的过程,我们可以将生成模型和判别模型看作博弈的双方,比如在犯罪分子造假币和警察识别假币的过程中:
- 生成模型G相当于制造假币的一方,其目的是根据看到的钱币情况和警察的识别技术,去尽量生成更加真实的、警察识别不出的假币。
- 判别模型D相当于识别假币的一方,其目的是尽可能的识别出犯罪分子制造的假币。 这样通过造假者和识假者双方的较量和朝目的的改进,使得最后能达到生成模型能尽可能真的钱币、识假者判断不出真假的纳什均衡效果(真假币概率都为0.5)。
2 训练
生成器G的目标是欺骗鉴别器D,其目标是能够区分真实数据和生成数据。因此,在训练生成器时,我们希望误差最大化,同时我们想要使鉴别器的误差最小化。
2.1 判别模型
目标函数是:
m a x D E x − p r [ l o g D ( x ) ] + E z − p g [ l o g ( 1 − D ( x ) ) ] max_D E_{x-p_r} [logD(x)]+E_{z-p_g } [log(1-D(x))] maxDEx−pr[logD(x)]+Ez−pg[log(1−D(x))]
其中D(x)是判别模型的输出结果,是一个0-1范围内的实数值,用来判断图片是真实图片的概率,其中Pr和Pg分别代表真实图像的分布与生成图像的数据分布情况,可以看出目标函数是找到使得后面两个式子之和最大的判别模型函数D(z),后面两个式子是一个加和形式,其中:
E x − p r [ l o g D ( x ) ] E_{x-p_r} [logD(x)] Ex−pr[logD(x)]
是指使得真实数据放入到判别模型D(x)输出的计算值和整个式子值尽可能大。
E z − p g [ l o g ( 1 − D ( x ) ) ] E_{z-p_g } [log(1-D(x))] Ez−pg[log(1−D(x))]
指使得造假数据放入到判别模型D(x)输出的计算值尽可能小和整个式子值尽可能大。
这样整合下来就是使得目标函数尽可能大,因此在训练时就可以根据目标函数进行梯度提升。
2.2 生成模型
目标是让判别模型无法区分真实图片和生成图片,其目标函数是:
m i n g ( m a x D E x − p r [ l o g D ( x ) ] + E z − p g [ l o g ( 1 − D ( x ) ) ] ) min_g (max_D E_{x-p_r} [logD(x)]+E_{z-p_g } [log(1-D(x))]) ming(maxDEx−pr[logD(x)]+Ez−pg[log(1−D(x))])
也就是找到生成函数g(z)使得生成模型的目标函数尽量小。
学习更多编程知识,请关注我的公众号:

边栏推荐
- 【TensorRT】将 PyTorch 转化为可部署的 TensorRT
- IDEA中设置自动build-改动代码,不用重启工程,刷新页面即可
- 【图像分类】如何使用 mmclassification 训练自己的分类模型
- 【数据库】数据库课程设计一一疫苗接种数据库
- Activity交互问题,你确定都知道?
- 并发编程学习笔记 之 Lock锁及其实现类ReentrantLock、ReentrantReadWriteLock和StampedLock的基本用法
- 【Transformer】ACMix:On the Integration of Self-Attention and Convolution
- 个人学习网站
- Research and implementation of flash loan DAPP
- asyncawait和promise的区别
猜你喜欢

Training log 6 of the project "construction of Shandong University mobile Internet development technology teaching website"

【Clustrmaps】访客统计

Are you sure you know the interaction problem of activity?

nacos外置数据库的配置与使用

Simple optimization of interesting apps for deep learning (suitable for novices)

Android Studio 实现登录注册-源代码 (连接MySql数据库)

性能优化之趣谈线程池:线程开的越多就越好吗?

Training log 4 of the project "construction of Shandong University mobile Internet development technology teaching website"

Process management of day02 operation

yum本地源制作
随机推荐
【Transformer】SegFormer:Simple and Efficient Design for Semantic Segmentation with Transformers
Ribbon learning notes II
微信小程序源码获取(附工具的下载)
【CV】请问卷积核(滤波器)3*3、5*5、7*7、11*11 都是具体什么数?
Huawei 2020 school recruitment written test programming questions read this article is enough (Part 1)
Spring, summer, autumn and winter with Miss Zhang (3)
Spring, summer, autumn and winter with Miss Zhang (5)
【Transformer】AdaViT: Adaptive Vision Transformers for Efficient Image Recognition
Super simple integration HMS ml kit face detection to achieve cute stickers
mysql插入百万数据(使用函数和存储过程)
"Shandong University mobile Internet development technology teaching website construction" project training log V
Machine learning makes character recognition easier: kotlin+mvvm+ Huawei ml Kit
Ribbon学习笔记二
Spring, summer, autumn and winter with Miss Zhang (1)
Ribbon learning notes 1
Exploration of flutter drawing skills: draw arrows together (skill development)
[competition website] collect machine learning / deep learning competition website (continuously updated)
SQL repair duplicate data
研究生新生培训第三周:ResNet+ResNeXt
Flink connector Oracle CDC synchronizes data to MySQL in real time (oracle19c)