Papers · Generative models · 2013

Auto-Encoding Variational Bayes

Diederik P. Kingma, Max Welling

The notation of the VAE paper, explained: its 30 displayed equations, then every symbol it uses, grouped by category and shown the way the paper writes it.

Read the paper on arXiv

Reading this paper

The VAE paper: train an encoder and a decoder together by maximizing a lower bound on the data's log-likelihood, made differentiable by the reparameterization trick.

Watch the two sets of parameters: θ\boldsymbol{\theta} belongs to the generative model pθ(x∣z)p_{\boldsymbol{\theta}}(\mathbf{x} \mid \mathbf{z}) (the decoder), ϕ\boldsymbol{\phi} to the approximate posterior qϕ(z∣x)q_{\boldsymbol{\phi}}(\mathbf{z} \mid \mathbf{x}) (the encoder). The superscript in x(i)\mathbf{x}^{(i)} indexes the data point; it is not a power. A tilde marks an estimate: L~\widetilde{\mathcal{L}} is the sampled estimator of the bound L\mathcal{L}.

Read from arXiv's HTML version: 30 displayed equations and 135 pieces of inline math. 42 symbols and constructs from the catalog.

The paper's displayed equations

Open any of them in the decoder for a symbol-by-symbol reading.

  1. (1)
    log⁡pθ(x(i))=DKL(qϕ(z∣x(i))∣∣pθ(z∣x(i)))+L(θ,ϕ;x(i))\log p_{\boldsymbol{\theta}}(\mathbf{x}^{(i)})=D_{KL}(q_{\boldsymbol{\phi}}(\mathbf{z}|\mathbf{x}^{(i)})||p_{\boldsymbol{\theta}}(\mathbf{z}|\mathbf{x}^{(i)}))+\mathcal{L}(\boldsymbol{\theta},\boldsymbol{\phi};\mathbf{x}^{(i)})
    Decode →
  2. (2)
    log⁡pθ(x(i))≥L(θ,ϕ;x(i))=Eqϕ(z∣x)[−log⁡qϕ(z∣x)+log⁡pθ(x,z)]\log p_{\boldsymbol{\theta}}(\mathbf{x}^{(i)})\geq\mathcal{L}(\boldsymbol{\theta},\boldsymbol{\phi};\mathbf{x}^{(i)}) =\mathbb{E}_{q_{\boldsymbol{\phi}}(\mathbf{z}|\mathbf{x})}\left[-\log q_{\boldsymbol{\phi}}(\mathbf{z}|\mathbf{x})+\log p_{\boldsymbol{\theta}}(\mathbf{x},\mathbf{z})\right]
    Decode →
  3. (3)
    L(θ,ϕ;x(i))=−DKL(qϕ(z∣x(i))∣∣pθ(z))+Eqϕ(z∣x(i))[log⁡pθ(x(i)∣z)]\mathcal{L}(\boldsymbol{\theta},\boldsymbol{\phi};\mathbf{x}^{(i)})=-D_{KL}(q_{\boldsymbol{\phi}}(\mathbf{z}|\mathbf{x}^{(i)})||p_{\boldsymbol{\theta}}(\mathbf{z}))+\mathbb{E}_{q_{\boldsymbol{\phi}}(\mathbf{z}|\mathbf{x}^{(i)})}\left[\log p_{\boldsymbol{\theta}}(\mathbf{x}^{(i)}|\mathbf{z})\right]
    Decode →
  4. (4)
    z~=gϕ(ϵ,x)with ϵ∼p(ϵ)\widetilde{\mathbf{z}}=g_{\boldsymbol{\phi}}(\boldsymbol{\epsilon},\mathbf{x})\text{\quad with \quad}\boldsymbol{\epsilon}\sim p(\boldsymbol{\epsilon})
    Decode →
  5. (5)
    Eqϕ(z∣x(i))[f(z)]=Ep(ϵ)[f(gϕ(ϵ,x(i)))]≃1L∑l=1Lf(gϕ(ϵ(l),x(i)))where ϵ(l)∼p(ϵ)\mathbb{E}_{q_{\boldsymbol{\phi}}(\mathbf{z}|\mathbf{x}^{(i)})}\left[f(\mathbf{z})\right]=\mathbb{E}_{p(\boldsymbol{\epsilon})}\left[f(g_{\boldsymbol{\phi}}(\boldsymbol{\epsilon},\mathbf{x}^{(i)}))\right] \simeq\frac{1}{L}\sum_{l=1}^{L}{f(g_{\boldsymbol{\phi}}(\boldsymbol{\epsilon}^{(l)},\mathbf{x}^{(i)}))}\text{\quad where \quad}\boldsymbol{\epsilon}^{(l)}\sim p(\boldsymbol{\epsilon})
    Decode →
  6. (6)
    L~A(θ,ϕ;x(i))=1L∑l=1Llog⁡pθ(x(i),z(i,l))−log⁡qϕ(z(i,l)∣x(i))where z(i,l)=gϕ(ϵ(i,l),x(i))and ϵ(l)∼p(ϵ)\begin{gathered}\widetilde{\mathcal{L}}^{A}(\boldsymbol{\theta},\boldsymbol{\phi};\mathbf{x}^{(i)}) =\frac{1}{L}\sum_{l=1}^{L}\log p_{\boldsymbol{\theta}}(\mathbf{x}^{(i)},\mathbf{z}^{(i,l)})-\log q_{\boldsymbol{\phi}}(\mathbf{z}^{(i,l)}|\mathbf{x}^{(i)}) \\ \text{where \quad}\mathbf{z}^{(i,l)} =g_{\boldsymbol{\phi}}(\boldsymbol{\epsilon}^{(i,l)},\mathbf{x}^{(i)})\text{\quad and \quad}\boldsymbol{\epsilon}^{(l)}\sim p(\boldsymbol{\epsilon})\end{gathered}
    Decode →
  7. (7)
    L~B(θ,ϕ;x(i))=−DKL(qϕ(z∣x(i))∣∣pθ(z))+1L∑l=1L(log⁡pθ(x(i)∣z(i,l)))where z(i,l)=gϕ(ϵ(i,l),x(i))and ϵ(l)∼p(ϵ)\begin{gathered}\widetilde{\mathcal{L}}^{B}(\boldsymbol{\theta},\boldsymbol{\phi};\mathbf{x}^{(i)}) =-D_{KL}(q_{\boldsymbol{\phi}}(\mathbf{z}|\mathbf{x}^{(i)})||p_{\boldsymbol{\theta}}(\mathbf{z}))+\frac{1}{L}\sum_{l=1}^{L}(\log p_{\boldsymbol{\theta}}(\mathbf{x}^{(i)}|\mathbf{z}^{(i,l)})) \\ \text{where \quad}\mathbf{z}^{(i,l)} =g_{\boldsymbol{\phi}}(\boldsymbol{\epsilon}^{(i,l)},\mathbf{x}^{(i)})\text{\quad and \quad}\boldsymbol{\epsilon}^{(l)}\sim p(\boldsymbol{\epsilon})\end{gathered}
    Decode →
  8. (8)
    L(θ,ϕ;X)≃L~M(θ,ϕ;XM)=NM∑i=1ML~(θ,ϕ;x(i))\mathcal{L}(\boldsymbol{\theta},\boldsymbol{\phi};\mathbf{X})\simeq\widetilde{\mathcal{L}}^{M}(\boldsymbol{\theta},\boldsymbol{\phi};\mathbf{X}^{M})=\frac{N}{M}\sum_{i=1}^{M}\widetilde{\mathcal{L}}(\boldsymbol{\theta},\boldsymbol{\phi};\mathbf{x}^{(i)})
    Decode →
  9. (9)
    log⁡qϕ(z∣x(i))=log⁡N(z;μ(i),σ2(i)I)\log q_{\boldsymbol{\phi}}(\mathbf{z}|\mathbf{x}^{(i)}) =\log\mathcal{N}(\mathbf{z};\boldsymbol{\mu}^{(i)},\boldsymbol{\sigma}^{2(i)}\mathbf{I})
    Decode →
  10. (10)
    L(θ,ϕ;x(i))≃12∑j=1J(1+log⁡((σj(i))2)−(μj(i))2−(σj(i))2)+1L∑l=1Llog⁡pθ(x(i)∣z(i,l))wherez(i,l)=μ(i)+σ(i)⊙ϵ(l)and ϵ(l)∼N(0,I)\begin{gathered}\mathcal{L}(\boldsymbol{\theta},\boldsymbol{\phi};\mathbf{x}^{(i)}) \simeq\frac{1}{2}\sum_{j=1}^{J}\left(1+\log((\sigma_{j}^{(i)})^{2})-(\mu_{j}^{(i)})^{2}-(\sigma_{j}^{(i)})^{2}\right)+\frac{1}{L}\sum_{l=1}^{L}\log p_{\boldsymbol{\theta}}(\mathbf{x}^{(i)}|\mathbf{z}^{(i,l)}) \\ \text{where\quad}\mathbf{z}^{(i,l)} =\boldsymbol{\mu}^{(i)}+\boldsymbol{\sigma}^{(i)}\odot\boldsymbol{\epsilon}^{(l)}\text{\quad and \quad}\boldsymbol{\epsilon}^{(l)}\sim\mathcal{N}(0,\mathbf{I})\end{gathered}
    Decode →
  11. ∫qθ(z)log⁡p(z) dz=∫N(z;μ,σ2)log⁡N(z;0,I) dz=−J2log⁡(2π)−12∑j=1J(μj2+σj2)\begin{gathered}\int q_{\boldsymbol{\theta}}(\mathbf{z})\log p(\mathbf{z})\,d\mathbf{z} =\int\mathcal{N}(\mathbf{z};\boldsymbol{\mu},\boldsymbol{\sigma}^{2})\log\mathcal{N}(\mathbf{z};\mathbf{0},\mathbf{I})\,d\mathbf{z} \\ =-\frac{J}{2}\log(2\pi)-\frac{1}{2}\sum_{j=1}^{J}(\mu_{j}^{2}+\sigma_{j}^{2})\end{gathered}
    Decode →
  12. ∫qθ(z)log⁡qθ(z) dz=∫N(z;μ,σ2)log⁡N(z;μ,σ2) dz=−J2log⁡(2π)−12∑j=1J(1+log⁡σj2)\begin{gathered}\int q_{\boldsymbol{\theta}}(\mathbf{z})\log q_{\boldsymbol{\theta}}(\mathbf{z})\,d\mathbf{z} =\int\mathcal{N}(\mathbf{z};\boldsymbol{\mu},\boldsymbol{\sigma}^{2})\log\mathcal{N}(\mathbf{z};\boldsymbol{\mu},\boldsymbol{\sigma}^{2})\,d\mathbf{z} \\ =-\frac{J}{2}\log(2\pi)-\frac{1}{2}\sum_{j=1}^{J}(1+\log\sigma^{2}_{j})\end{gathered}
    Decode →

Famous equations in this paper

Symbols, by category

Most used first. The examples are written as the paper writes them.

Notation conventions

  1. pθp_{\boldsymbol{\theta}}, qϕq_{\boldsymbol{\phi}}, gϕg_{\boldsymbol{\phi}}

    Subscript (index or label) 277 uses

    A subscript picks an element (xᵢ), a time step (h_t), a named copy (W_q), or the parameters (p_θ).

  2. x(i)\mathbf{x}^{(i)}, ϵ(l)\boldsymbol{\epsilon}^{(l)}, z(i,l)\mathbf{z}^{(i,l)}

    Superscript in parentheses 154 uses

    An index in a superscript: x⁽ⁱ⁾ is the i-th training example, W⁽ˡ⁾ the weights of layer l. Not a power.

  3. gg, ff, LL

    Italic letters (variables) 136 uses

    A plain italic letter is a variable; conventions say what kind (x input, y target, W weights…).

  4. L~A\widetilde{\mathcal{L}}^{A}, L~B\widetilde{\mathcal{L}}^{B}, L~M\widetilde{\mathcal{L}}^{M}

    Superscript (power or label) 38 uses

    Usually a power (x² = x·x), but a capital or a word up there is often just a label (W^Q).

  5. L\mathcal{L}

    Loss (ℒ) 28 uses

    The loss: the number training tries to make small. Also written L, J(θ) or ℓ.

  6. z~\widetilde{\mathbf{z}}, L~\widetilde{\mathcal{L}}, θ~\widetilde{\boldsymbol{\theta}}

    Tilde accent 15 uses

    A modified version of the variable: noisy, corrupted, proposed or intermediate.

  7. θ∗\boldsymbol{\theta}^{*}

    Star (optimal) 5 uses

    As a superscript, the optimal value: θ* is the best θ. Between two terms, convolution.

  8. ⋯\cdots

    Dots (ellipsis) 1 use

    “And so on”: continue the pattern.

Greek letters

  1. θ\theta

    Theta 178 uses

    The model’s parameters: all of its weights and biases, as one collection.

  2. ϕ\phi

    Phi 157 uses

    The parameters of a second model (often the encoder q_φ), or a feature map φ(x).

  3. ϵ\epsilon

    Epsilon 74 uses

    A tiny constant for numerical safety (10⁻⁸ in Adam), or noise ε ~ 𝒩(0, I).

  4. σ\sigma

    Sigma (lowercase) 36 uses

    Either the sigmoid function σ(z) = 1/(1+e⁻ᶻ) or a standard deviation. The context decides.

  5. μ\mu

    Mu 29 uses

    A mean: the average of a distribution, a batch, or a layer’s features.

  6. ζ\zeta

    Zeta 17 uses

    A spare letter: an auxiliary variable, a noise term, or the Riemann zeta function ζ(s).

  7. α\alpha

    Alpha 10 uses

    Often a learning rate or step size; also attention weights αᵢⱼ or a mixing weight.

  8. π\pi

    Pi 2 uses

    A policy π(a | s) in reinforcement learning, or the constant 3.14159…

Vectors and matrices

  1. θ\boldsymbol{\theta}, x\mathbf{x}, ϕ\boldsymbol{\phi}

    Bold lowercase (vector) 909 uses

    A bold lowercase letter is a vector: a list of numbers.

  2. X\mathbf{X}, W\mathbf{W}

    Bold uppercase (matrix) 35 uses

    A bold capital letter is a matrix (or a higher-order tensor).

  3. I\mathbf{I}

    Identity matrix 17 uses

    The matrix with 1s on the diagonal and 0s elsewhere; multiplying by it changes nothing.

  4. ⊙\odot

    Hadamard (elementwise) product 6 uses

    Multiply two arrays of the same shape entry by entry.

  5. ⋅\cdot

    Centre dot 4 uses

    A dot product between vectors, plain multiplication between numbers, or an empty slot f(·).

  6. Inverse 1 use

    The matrix inverse, A⁻¹A = I; for a function, its inverse function; for a number, 1/x.

Calculus and gradients

  1. ∫\int

    Integral 20 uses

    An integral: a continuous sum. In ML it is usually an expectation or a marginalization.

  2. ∇ϕ\nabla_{\boldsymbol{\phi}}, ∇qϕ(z)\nabla_{q_{\boldsymbol{\phi}}(\mathbf{z})}, ∇qϕ(z(l))\nabla_{q_{\boldsymbol{\phi}}(\mathbf{z}^{(l)})}

    Nabla (gradient) 13 uses

    The gradient: the vector of partial derivatives. ∇_θ L is how the loss changes with each parameter.

Probability and statistics

  1. pp, qq

    Probability p(x) 219 uses

    A probability or probability density; p is usually the true or model distribution, q an approximation.

  2. ∣|

    Given (conditional bar) 92 uses

    “Given”: p(y | x) is the probability of y given that x is known.

  3. log⁡\log

    Logarithm 76 uses

    A logarithm, almost always the natural log (base e) in ML papers.

  4. ;;

    Semicolon (parameterized by) 42 uses

    In p(x; θ), the semicolon separates the variable x from fixed parameters θ.

  5. ∼\sim

    Distributed as (tilde) 26 uses

    “Is drawn from” or “is distributed as”: x ~ p means x is a sample from the distribution p.

  6. N\mathcal{N}

    Normal distribution 25 uses

    The normal (Gaussian) distribution with the given mean and variance.

  7. DKLD_{KL}, ∣∣||

    KL divergence 18 uses

    How different distribution q is from p. Zero when they match; not symmetric.

  8. Ep(ϵ)\mathbb{E}_{p(\boldsymbol{\epsilon})}, Eqϕ(z)\mathbb{E}_{q_{\boldsymbol{\phi}}(\mathbf{z})}, EN(z;μ,σ2)\mathbb{E}_{\mathcal{N}(z;\mu,\sigma^{2})}

    Expectation 9 uses

    The expected value: the average of what is inside, weighted by the probabilities in the subscript.

  9. U\mathcal{U}

    Uniform distribution 1 use

    𝒰(a, b) is the uniform distribution: every value between a and b is equally likely.

Functions and operators

  1. 1L\frac{1}{L}, NM\frac{N}{M}, 12\frac{1}{2}

    Fraction 30 uses

    Division: the top divided by the bottom.

  2. ∑l=1L\sum_{l=1}^{L}, ∑i=1M\sum_{i=1}^{M}, ∑j=1J\sum_{j=1}^{J}

    Summation 21 uses

    Add up the expression for every value of the index, from the bottom limit to the top.

  3. ←\leftarrow

    Assignment arrow 10 uses

    Assignment in an algorithm: replace the variable on the left with the value on the right.

  4. ∏i\prod_{i}

    Product 3 uses

    Multiply the expression for every value of the index.

  5. tanh⁡\tanh

    Hyperbolic tangent 2 uses

    An S-shaped activation squashing any number into (−1, 1).

Reinforcement learning

  1. JJ

    Objective J 9 uses

    J(θ) is the objective: the quantity to maximize, such as the expected return of a policy.

Sets, shapes and definitions

  1. ≃\simeq

    Approximately equal 12 uses

    Approximately equal: often a Monte Carlo estimate or a Taylor approximation.

  2. {x(i)}\{\mathbf{x}^{(i)}\}, {z(l)}\{\mathbf{z}^{(l)}\}

    Set braces 6 uses

    A set: a collection of items. {x | condition} is every x that satisfies the condition.

  3. ≥\geq, <<

    Inequalities 2 uses

    Less than / greater than (or equal). ≪ means “much smaller than”.

Formulas from arXiv's HTML version of the paper, © their authors; the explanations are this site's. Title and authors as arXiv lists them.

More generative models papers