对抗生成网络

目录

Generative adversarial nets

A generative model G: capture the data distribution(数据分布)
A discriminative model D: estimate the probability that a sample came from the training data rather than G

Adversarial nets

\[ \min_{G}{\max_{D}{V(D, G) = \mathbb{E}_{x \thicksim p_{data}(x)} [\log{D(x)}] + \mathbb{E}_{z \thicksim p_{z}(z)}[\log{(1 - D(G(z)))}] }} \]
generator's distribution: $ p_{g} $
a prior on input noise variables: \(p_{z}(z)\)
mapping to data space: \(G(z; \theta_{g})\)
multilayer perceptron with parameters \(\theta_{g}\): \(G\)
second multilayer perceptron: \(D(x; \theta_{d})\) (output a single scalar)
the probability that \(x\) came from the data rather than \(p_{g}\): \(D(x)\)
value function: $ V(G, D) $
Train G to minimize: $ \log{(1 - D(G(z)))} $

Figure

G->D: G is poor, D can reject samples with high confidence
D-->G: log(1-D(G(z))) saturates(充满,饱和)
Note left of G: Training G maximize\n log(D(G(z))) rather than\n Minimize log(1-D(G(z)))
G->D: G is not poor, whether D can reject samples
D-->G: G becomes perfect

Flowchart

st=>start: Start
e=>end
op1=>operation: update the discriminator
op2=>operation: update the generator
opm=>operation: m--
opk=>operation: k--
pgz=>inputoutput: noise prior
pdatax=>inputoutput: data generating distribution
noisesam=>inputoutput: minibatch of m noise samples
examples=>inputoutput: minibatch of m examples
cond1=>condition: m>0?
cond2=>condition: k>0?

st->cond2
cond1(yes)->op2->opm->e
cond1(no)->e
cond2(yes)->pgz->noisesam->pdatax->examples->op1(right)->opk(right)->cond2
cond2(no)->cond1

Cycle-Consistent Adversarial Networks

Model

X->Y: G
Note left of X: Dx
Note right of Y: Dy
Y->X: F

$ x \to G(x) \to F(G(x)) \approx x $ and $y \to F(y) \to G(F(y)) \approx y $

Formulation

Adversarial Loss

\[ \mathcal{L}_{GAN}(G, D_{Y}, X, Y) = \mathbb{E}_{y \thicksim p_{data}(y)} [\log D_{Y}(y)] + \mathbb{E}_{x \thicksim p_{data}(x)}[\log(1 - D_{Y}(G(x)))] \]
\(G\) tries to generate images \(G(x)\) that look similar to images from domain \(Y\)
\(D_{Y}\) aims to distinguish between translated samples \(G(x)\) and real samples \(y\)

Cycle Consistency Loss

\[ \mathcal{L}_{cyc}(G, F) = \mathbb{E}_{x \thicksim p_{data}(x)} [\| F(G(x)) - x \|_{1}] + \mathbb{E}_{y \thicksim p_{data}(y)}[\| G(F(y)) - y \|_{1}] \]

Full Objective

\[ \mathcal{L}(G, F, D_{X}, D_{Y}) = \mathcal{L}_{GAN}(G, D_{Y}, X, Y) + \mathcal{L}_{GAN}(F, D_{X}, Y, X) + \lambda \mathcal{L}_{cyc}(G, F) \]

Conditional Generative Adversarial Nets

cGANs

\[ \mathcal{L}_{cGAN}(G, D) = \mathbb{E}_{x,y \thicksim p_{data}(x, y)} [\log D(x, y)] + \mathbb{E}_{y \thicksim p_{data}(y), z \thicksim p_{z}(z)}[\log(1 - D(G(y,z),y))] \]
\(y\) is a kind of auxiliary information

上一篇:2019年牛客多校第二场 F题Partition problem 爆搜


下一篇:Flink(55):Flink高级特性之流式文件写入(Streaming File Sink)