Xiangxiang's Personal Site

Machine Learning & Security Engineer
生命不息,折腾不止,留下一点活着的记录.

View on GitHub
16 February 2019

Generative adversarial networks

by xiangxiang

Dive into Generative adversarial networks

0x00 核心思想(Likelihood-free learning)

$ S_1 = \{ x \sim P \} $

$ S_2 = \{ x \sim Q \} $

零假设(null hypothesis):         $ H_0: P = Q $

备择假设(alternative hypothesis) $ H_1: P \neq Q $

双侧检验,检验水平(显著性水平)$ \alpha $

$ t = \frac { \overline { X _ { 1 } } - \overline { X _ { 2 } } } { \sqrt { \frac { \left( n _ { 1 } - 1 \right) S _ { 1 } ^ { 2 } + \left( n _ { 2 } - 1 \right) S _ { 2 } ^ { 2 } } { n _ { 1 } + n _ { 2 } - 2 } } \left( \frac { 1 } { n _ { 1 } } + \frac { 1 } { n _ { 2 } } \right) } $

根据实际得到的样本数据计算得到统计量t值,然后与查表得到的t界值对比,决定是否拒绝原假设

其中:

  1. $ S _ { 1 } ^ { 2 } $和$ S _ { 2 } ^ { 2 } $ 表示样本方差

  2. $ \overline { X _ { 1 } } $和$ \overline { X _ { 2 } } $ 表示样本均值

  3. $ n _ { 1 } $和$ n _ { 2 } $ 表示样本容量

0x01 应用Likelihood-free learning思想到机器学习中

Optimize a surrogate objective that instead maximizes some distance between $ S _ {1} $ and $ S _ {2} $

0x02 GANs在machine learning体系的位置

1. 使用何种模型结构(model),比如是LR还是NN
2. 使用怎么样的正则化技巧(regularization),比如是L1/L2/dropout 
3. 训练使用什么优化算法(optimization/training), 比如是Adam、SGD
GANs are a model architecture for training a generative model

0x03 GANs如何实现Likelihood-free learning

  1. $ G_\theta $: a directed latent variable model that deterministically generates samples x from latent virable z
  2. $ D_\phi $: a function whose job is to distinguish samples from the real dataset and the generator

$ \min _ { \theta } \max _ { \phi } V \left( G _ { \theta } , D _ { \phi } \right) = \mathbb { E } _ { x \sim p _ { data } } \left[ \log D _ { \phi } ( \mathbf { x } ) \right] + \mathbb { E } _ { z \sim p _ { z } } \left[ \log \left( 1 - D _ { \phi } \left( G _ { \theta } ( \mathbf { z } ) \right) \right) \right] $

  1. The generator minimizes a two-sample test objective $ p_{data} = p_{\theta} $
  2. The discriminator maximizes the objective $ p_{data} \neq p_{\theta} $

$ \mathbb { E } _ { x \sim p _ { data } } \left[ \log D _ { \phi } ( \mathbf { x } ) \right] + \mathbb { E } _ { z \sim p _ { z } } \left[ \log \left( 1 - D _ { \phi } \left( G _ { \theta } ( \mathbf { z } ) \right) \right) \right] $

` $ \Leftrightarrow $ `

$ \mathbb { E } _ { x \sim p _ { data } } \left[ \log D _ { \phi } ( \mathbf { x } ) \right] + \mathbb { E } _ { x \sim { Generator } } \left[ \log \left( 1 - D _ { \phi } \left( x \right) \right) \right] $

` $ \Leftrightarrow $ `

$ \int _ { x } \left( p _ {data} \left( x \right) \log D _ { \phi } \left( x \right) + p _ { generator } \left( x \right) \log \left( 1 - D _ { \phi } \left( x \right) \right) \right) d x $

接下来的内容后面补充

0x04 GAN traning

  1. Sample minibatch of size m from data: $ x ^ { (1) }, x ^ { (2) }, ..., x ^ { (m) } \sim Data $

  2. Sample minibatch of size m of noise: $ z ^ { (1) }, z ^ { (2) }, ..., z ^ { (m) } \sim p _ { z } $

  3. Take a gradient descent step on the generator parameters $ \theta $

  4. Take a gradient ascent step on the discriminator parameters $ \phi $

  5. Repeat n epochs

0x05 GAN training optimization challenges

If the generator updates are made in function space and discriminator is optional at every step, 
then the generator is guaranteed to converge to the data distribution

0x06 常见的GANs模型

未完待续

tags: GANs machine-learning deep-learning