▶︎
all
running...
Last Updated On: 2020-07-11 16:31

Autoencoders

img

Table of Content

▶︎
all
running...

Introduction

Vanilla Autoencoder model and its variants

Regularized Autoencoders

Denoising Autoencoder

Sparse Autoencoder

Contractive Autoencoder

Variational Autoencoder

vae

Mathematics

Expectation

E(X)=ikxipxiE(X) = \sum_i^k{x_ip_{x_i}}

E(XZ)=zZX(z)ZZ={z1,z2,...zk}E(X|Z) = \frac{\sum_{z \in Z}{X(z)}}{|Z|} \hspace{30pt} \forall \hspace{30pt} Z = \{z_1,z_2,...z_k\}

Bayes Theorem

p(zx)=p(xz)p(z)p(x)p(z|x) = \frac{p(x|z)p(z)}{p(x)}

Naive Bayes Algorithm and its training strategies

Ref : http://www.cs.cornell.edu/courses/cs4780/2018sp/lectures/lecturenote05.html

Variational Inference

p(zx)=p(xz)p(z)zp(xz)p(z)dzz={z1,z2,z3,...}p(z|x) = \frac{p(x|z)p(z)}{\int_z{p(x|z)p(z)dz}} \hspace{35pt} \forall \hspace{35pt} z=\{z_1, z_2, z_3, ... \}

Kullback-Leibler (KL) Divergence

What VAE Offers

VAE graph

VAE Loss function Derivation

L(ϕ,θ)=Eqlog(p(xZ))+DKL(qϕ(Zx)pθ(Z))L(\phi, \theta) = - E_{\sim{q}}log(p(x|Z)) + D_{KL}(q_{\phi}(Z|x) || p_{\theta}(Z))

DKL(qϕ(Zx)pθ(Zx))=Eqϕ(Zx)(IpIq)=Eqϕ(Zx)[log(qϕ(Zx))log(pθ(Zx))]=Eqϕ(Zx)[log(qϕ(Zx))log(pθ(xZ)pθ(z)pθ(x))]=Eqϕ(Zx)[log(qϕ(Zx))log(pθ(xZ))log(pθ(Z))+log(pθ(x))]DKL(qϕ(Zx)pθ(Zx))log(pθ(x))=Eqϕ(Zx)[log(qϕ(Zx))log(pθ(xZ))log(pθ(Z))]=Eqϕ(Zx)log(pθ(xZ))+Eqϕ(Zx)[log(qϕ(Zx))log(pθ(Z))]=Eqϕ(Zx)log(pθ(xZ))+DKL(qϕ(Zx)pθ(Z))log(pθ(x))DKL(qϕ(Zx)pθ(Zx))=Eqϕ(Zx)log(pθ(xZ))DKL(qϕ(Zx)pθ(Z))\begin{aligned} D_{KL}(q_{\phi}(Z|x) || p_{\theta}(Z|x)) &= E_{q_{\phi}(Z|x)}(I_p -I_q) \\ &= E_{q_{\phi}(Z|x)}[log(q_{\phi}(Z|x)) - log(p_{\theta}(Z|x))] \\ &= E_{q_{\phi}(Z|x)}\biggl[log(q_{\phi}(Z|x)) - log\biggl(\frac{p_{\theta}(x|Z)p_{\theta}(z)}{p_{\theta}(x)}\biggr)\biggr] \\ &= E_{q_{\phi}(Z|x)}[log(q_{\phi}(Z|x)) - log(p_{\theta}(x|Z)) - log(p_{\theta}(Z)) + log(p_{\theta}(x))] \\ D_{KL}(q_{\phi}(Z|x) || p_{\theta}(Z|x)) - log(p_{\theta}(x)) &= E_{q_{\phi}(Z|x)}[log(q_{\phi}(Z|x)) - log(p_{\theta}(x|Z)) - log(p_{\theta}(Z))] \\ &= - E_{q_{\phi}(Z|x)}log(p_{\theta}(x|Z)) + E_{q_{\phi}(Z|x)}[log(q_{\phi}(Z|x)) - log(p_{\theta}(Z))] \\ &= - E_{q_{\phi}(Z|x)}log(p_{\theta}(x|Z)) +D_{KL}(q_{\phi}(Z|x) || p_{\theta}(Z)) \\ log(p_{\theta}(x)) - D_{KL}(q_{\phi}(Z|x) || p_{\theta}(Z|x)) &= E_{q_{\phi}(Z|x)}log(p_{\theta}(x|Z)) - D_{KL}(q_{\phi}(Z|x) || p_{\theta}(Z)) \end{aligned}

NOW : DKL(qϕ(Zx)pθ(Zx))0D_{KL}(q_{\phi}(Z|x) || p_{\theta}(Z|x)) \geq 0
Proof : //TODO

log(pθ(x))Eqϕ(Zx)log(pθ(xZ))DKL(qϕ(Zx)pθ(Z))log(p_{\theta}(x)) \geq E_{q_{\phi}(Z|x)}log(p_{\theta}(x|Z)) - D_{KL}(q_{\phi}(Z|x) || p_{\theta}(Z))

Derivative of loss function

log(pθ(x))1Li=1Llog(pθ(xZ))DKL(qϕ(Zx)pθ(Z))log(p_{\theta}(x)) \geq \frac{1}{L}\sum_{i=1}^{L}{log(p_{\theta}(x|Z))} - D_{KL}(q_{\phi}(Z|x) || p_{\theta}(Z))

Matrix Maths and Training

Conditional Variational Autoencoders

Adversarial Autoencoders

Tensorflow Implementation

Full Implementation of different Autoencoder is Available on my kaggle account link is here

References

  1. Chapter 14: Autoencoders {Deep Learning; Ian Goodfellow}.

Comments

  1. Autoencoders
    1. Table of Content
    2. Introduction
    3. Vanilla Autoencoder model and its variants
    4. Regularized Autoencoders
    5. Denoising Autoencoder
    6. Sparse Autoencoder
    7. Contractive Autoencoder
    8. Variational Autoencoder
      1. Mathematics
        1. Expectation
        2. Bayes Theorem
        3. Naive Bayes Algorithm and its training strategies
        4. Variational Inference
        5. Kullback-Leibler (KL) Divergence
      2. What VAE Offers
      3. VAE Loss function Derivation
        1. Derivative of loss function
      4. Matrix Maths and Training
    9. Conditional Variational Autoencoders
    10. Adversarial Autoencoders
      1. Tensorflow Implementation
    11. References
  2. Comments