该博客是根据台大李宏毅老师的关于GAN的视频教程所整理的笔记,建议大家可以直接看这个老师的视频(因在youtube,故需翻墙)
文章目录
Generative Adversarial Network
回顾
Auto-encoder (AE)
简单,但生成的图像的质量很no realistic,视觉上看会很模糊,更像是图像的求均运算
Variational Auto encoder (VAE)
NN Encoder会产生两个向量 m , σ ∈ R 3 m, \sigma \in R^3 m,σ∈R3, 然后再从一个正态分布中采样一个噪声 e ∈ R 3 e \in R^3 e∈R3,做 c = exp ( σ ) ⊙ e + m ∈ R 3 c=\exp{(\sigma)} \odot e + m \in R^3 c=exp(σ)⊙e+m∈R3 ,最后将 c c c 输入到NN Decoder中生成图像。优化的目标是使得 output 与 input 要尽可能地接近,同时为了引入正则项的目的是为了让 σ , m \sigma, m σ,m 尽可能地接近于 0,这样在测试时就可以去掉NN Encoder而直接使用 e e e 作为NN Decoder的输入了。
AE/VAE存在的问题:
即NN Decoder并不会产生真正realisctic的数据。例如图中的两张“7”,二者仅差了一个像素点,人会偏爱左边的,但对该模型来说,二者与真实的“7”均差了一个像素点,故无优劣之分
GAN
Maximum Likelihood Estimation
- Given a data distribution P d a t a ( x ) P_{data}(x) Pdata(x)
- We have a distribution P G ( x ; θ ) P_G(x; \theta) PG(x;θ) parameterized by θ \theta θ
- E . g . P G ( x ; θ ) \it{E.g.}\ P_G(x; \theta) E.g. PG(x;θ) is a Gaussian Mixture Model, then θ \theta θ are means and variances of the mixture Gaussian.
- goal: find θ \theta θ that P G ( x ; θ ) P_G(x; \theta) PG(x;θ) close to P d a t a ( x ) P_{data}(x) Pdata(x)
- note: the x here donates the data sampling from (output of) distribution P d a t a ( P G ) , not the input . \color{#F00}{\text{the }x\text{ here donates the data sampling from (output of) distribution }P_{data} (P_G)\text{, not the input}}. the x here donates the data sampling from (output of) distribution Pdata(PG), not the input.
Sampling { x 1 , x 2 , … , x m } \{x^1,x^2,\dots,x^m\} {
x1,x2,…,xm} from P d a t a ( x ) P_{data}(x) Pdata(x), we can compute P G ( x i ; θ ) , i = 1 , 2 , … , m P_G(x^i;\theta), i=1,2,\dots,m PG(xi;θ),i=1,2,…,m. Then Likelihood of generating the samples is: L = ∏ i = 1 m P G ( x i ; θ ) L=\prod_{i=1}^mP_G(x^i;\theta) L=∏i=1mPG(xi;θ). Our goal is to find θ ∗ \theta^* θ∗ maximizing the likelihood:
θ ∗ = arg max θ ∏ i = 1 m P G ( x i ; θ ) = arg max θ log ∏ i = 1 m P G ( x i ; θ ) = arg max θ ∑ i = 1 m log P G ( x i ; θ ) ( ∵ { x i , … , x m } from P d a t a ) ≈ arg max θ E x ∼ P d a t a log P G ( x ; θ ) ( when m = + ∞ ) = arg max θ ∫ x P d a t a ( x ) log P G ( x ; θ ) d x − ∫ x P d a t a ( x ) log P d a t a ( x ) d x ⎵ 与 θ 无 关 , 为 一 个 常 数 项 , 不 会 影 响 θ ∗ 的 求 值 = arg max θ ∫ x − P d a t a ( x ) log P d a t a ( x ) P G ( x ; θ ) d x = arg min θ KL ( P d a t a ( x ) ∥ P G ( x ; θ )