Equations · Kingma and Welling, “Auto-Encoding Variational Bayes” (2014)

The ELBO (evidence lower bound), explained

The log-probability of the data is intractable for a latent-variable model, so a variational autoencoder maximizes this lower bound on it instead. The right-hand side is the ELBO.

log⁡pθ(x)≥Eqϕ(z∣x)[log⁡pθ(x∣z)]−DKL(qϕ(z∣x) ∥ p(z))\log p_\theta(\mathbf{x}) \geq \mathbb{E}_{q_\phi(\mathbf{z} \mid \mathbf{x})}\left[\log p_\theta(\mathbf{x} \mid \mathbf{z})\right] - D_{\mathrm{KL}}\left(q_\phi(\mathbf{z} \mid \mathbf{x}) \,\|\, p(\mathbf{z})\right)

Open in the decoder →

Term by term

  1. log⁡pθ(x)\log p_\theta(\mathbf{x})

    The log-evidence: how probable the model with parameters θ\theta makes the data point x\mathbf{x}.

  2. ≥\geq

    The right side is a lower bound, by Jensen's inequality. Raising it raises (or tightens toward) the left side.

  3. Eqϕ(z∣x)\mathbb{E}_{q_\phi(\mathbf{z} \mid \mathbf{x})}

    Average over latent codes z\mathbf{z} drawn from the encoder qϕq_\phi, given x\mathbf{x}. ϕ\phi are the encoder's parameters.

  4. log⁡pθ(x∣z)\log p_\theta(\mathbf{x} \mid \mathbf{z})

    The reconstruction term: how well the decoder recovers x\mathbf{x} from z\mathbf{z}.

  5. DKL(qϕ(z∣x) ∥ p(z))D_{\mathrm{KL}}\left(q_\phi(\mathbf{z} \mid \mathbf{x}) \,\|\, p(\mathbf{z})\right)

    The regularizer: how far the encoder's distribution strays from the prior p(z)p(\mathbf{z}), usually N(0,I)\mathcal{N}(\mathbf{0}, \mathbf{I}).

A small worked example

In practice the expectation is estimated with a single sample, z=μ+σ⊙ϵ\mathbf{z} = \boldsymbol{\mu} + \boldsymbol{\sigma} \odot \boldsymbol{\epsilon} with ϵ∼N(0,I)\boldsymbol{\epsilon} \sim \mathcal{N}(\mathbf{0}, \mathbf{I}) (the reparameterization trick), and the KL term between two Gaussians has a closed form.

Every symbol in it

log⁡pθ(x)\log p_\theta(x)Logarithmp(x),  q(z)p(\mathbf{x}), \; q(\mathbf{z})Probability p(x)pθ(x)p_\theta(x)Thetaxi,  Wq,  pθ,  dmodelx_i,\; W_q,\; p_\theta,\; d_{\text{model}}Subscript (index or label)log⁡p(x)≥LELBO\log p(x) \geq \mathcal{L}_{\text{ELBO}}InequalitiesEx∼p[f(x)]\mathbb{E}_{x \sim p}[f(x)]Expectationqϕ(z∣x)q_\phi(z \mid x)Phip(y∣x)p(y \mid x)Given (conditional bar)x∈Rd\mathbf{x} \in \mathbb{R}^{d}Bold lowercase (vector)DKL(q ∥ p)D_{\mathrm{KL}}(q \,\|\, p)KL divergence

Other equations