Papers · Generative models · 2022

Classifier-Free Diffusion Guidance

Jonathan Ho, Tim Salimans

The notation of the Classifier-free guidance paper, explained: its 9 displayed equations, then every symbol it uses, grouped by category and shown the way the paper writes it.

Read the paper on arXiv

Read from arXiv's HTML version: 9 displayed equations and 133 pieces of inline math. 40 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)
    q(zλ∣x)=N(αλx,σλ2I), where αλ2=1/(1+e−λ), σλ2=1−αλ2q(\mathbf{z}_{\lambda}|\mathbf{x}) =\mathcal{N}(\alpha_{\lambda}\mathbf{x},\sigma_{\lambda}^{2}\mathbf{I}),\ \text{where}\ \alpha_{\lambda}^{2}=1/(1+e^{-\lambda}),\ \sigma_{\lambda}^{2}=1-\alpha_{\lambda}^{2}
    Decode →
  2. (2)
    q(zλ∣zλ′)=N((αλ/αλ′)zλ′,σλ∣λ′2I), where λ<λ′, σλ∣λ′2=(1−eλ−λ′)σλ2q(\mathbf{z}_{\lambda}|\mathbf{z}_{\lambda^{\prime}}) =\mathcal{N}((\alpha_{\lambda}/\alpha_{\lambda^{\prime}})\mathbf{z}_{\lambda^{\prime}},\sigma_{\lambda|\lambda^{\prime}}^{2}\mathbf{I}),\ \text{where}\ \lambda<\lambda^{\prime},\ \sigma^{2}_{\lambda|\lambda^{\prime}}=(1-e^{\lambda-\lambda^{\prime}})\sigma_{\lambda}^{2}
    Decode →
  3. (3)
    μ~λ′∣λ(zλ,x)=eλ−λ′(αλ′/αλ)zλ+(1−eλ−λ′)αλ′x,σ~λ′∣λ2=(1−eλ−λ′)σλ′2\tilde{\boldsymbol{\mu}}_{\lambda^{\prime}|\lambda}(\mathbf{z}_{\lambda},\mathbf{x})=e^{\lambda-\lambda^{\prime}}(\alpha_{\lambda^{\prime}}/\alpha_{\lambda})\mathbf{z}_{\lambda}+(1-e^{\lambda-\lambda^{\prime}})\alpha_{\lambda^{\prime}}\mathbf{x},\quad\tilde{\sigma}^{2}_{\lambda^{\prime}|\lambda}=(1-e^{\lambda-\lambda^{\prime}})\sigma_{\lambda^{\prime}}^{2}
    Decode →
  4. (4)
    pθ(zλ′∣zλ)=N(μ~λ′∣λ(zλ,xθ(zλ)),(σ~λ′∣λ2)1−v(σλ∣λ′2)v)p_{\theta}(\mathbf{z}_{\lambda^{\prime}}|\mathbf{z}_{\lambda})=\mathcal{N}(\tilde{\boldsymbol{\mu}}_{\lambda^{\prime}|\lambda}(\mathbf{z}_{\lambda},\mathbf{x}_{\theta}(\mathbf{z}_{\lambda})),(\tilde{\sigma}^{2}_{\lambda^{\prime}|\lambda})^{1-v}(\sigma^{2}_{\lambda|\lambda^{\prime}})^{v})
    Decode →
  5. (5)
    Eϵ,λ ⁣[∥ϵθ(zλ)−ϵ∥22]\mathbb{E}_{{\boldsymbol{\epsilon}},\lambda}\!\left[\|{\boldsymbol{\epsilon}}_{\theta}(\mathbf{z}_{\lambda})-{\boldsymbol{\epsilon}}\|^{2}_{2}\right]
    Decode →
  6. ϵ~θ(zλ,c)=ϵθ(zλ,c)−wσλ∇zλlog⁡pθ(c∣zλ)≈−σλ∇zλ[log⁡p(zλ∣c)+wlog⁡pθ(c∣zλ)],\tilde{{\boldsymbol{\epsilon}}}_{\theta}(\mathbf{z}_{\lambda},\mathbf{c})={\boldsymbol{\epsilon}}_{\theta}(\mathbf{z}_{\lambda},\mathbf{c})-w\sigma_{\lambda}\nabla_{\mathbf{z}_{\lambda}}\log p_{\theta}(\mathbf{c}|\mathbf{z}_{\lambda})\approx-\sigma_{\lambda}\nabla_{\mathbf{z}_{\lambda}}[\log p(\mathbf{z}_{\lambda}|\mathbf{c})+w\log p_{\theta}(\mathbf{c}|\mathbf{z}_{\lambda})],
    Decode →
  7. p~θ(zλ∣c)∝pθ(zλ∣c)pθ(c∣zλ)w.\tilde{p}_{\theta}(\mathbf{z}_{\lambda}|\mathbf{c})\propto p_{\theta}(\mathbf{z}_{\lambda}|\mathbf{c})p_{\theta}(\mathbf{c}|\mathbf{z}_{\lambda})^{w}.
    Decode →
  8. ϵθ(zλ)−(w+1)σλ∇zλlog⁡pθ(c∣zλ)≈−σλ∇zλ[log⁡p(zλ)+(w+1)log⁡pθ(c∣zλ)]=−σλ∇zλ[log⁡p(zλ∣c)+wlog⁡pθ(c∣zλ)],\begin{gathered}{\boldsymbol{\epsilon}}_{\theta}(\mathbf{z}_{\lambda})-(w+1)\sigma_{\lambda}\nabla_{\mathbf{z}_{\lambda}}\log p_{\theta}(\mathbf{c}|\mathbf{z}_{\lambda}) \approx-\sigma_{\lambda}\nabla_{\mathbf{z}_{\lambda}}[\log p(\mathbf{z}_{\lambda})+(w+1)\log p_{\theta}(\mathbf{c}|\mathbf{z}_{\lambda})] \\ =-\sigma_{\lambda}\nabla_{\mathbf{z}_{\lambda}}[\log p(\mathbf{z}_{\lambda}|\mathbf{c})+w\log p_{\theta}(\mathbf{c}|\mathbf{z}_{\lambda})],\end{gathered}
    Decode →
  9. (6)
    ϵ~θ(zλ,c)=(1+w)ϵθ(zλ,c)−wϵθ(zλ)\tilde{{\boldsymbol{\epsilon}}}_{\theta}(\mathbf{z}_{\lambda},\mathbf{c})=(1+w){\boldsymbol{\epsilon}}_{\theta}(\mathbf{z}_{\lambda},\mathbf{c})-w{\boldsymbol{\epsilon}}_{\theta}(\mathbf{z}_{\lambda})
    Decode →

Symbols, by category

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

Notation conventions

  1. zλ\mathbf{z}_{\lambda}, αλ\alpha_{\lambda}, σλ2\sigma_{\lambda}^{2}

    Subscript (index or label) 273 uses

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

  2. vv, ww, TT

    Italic letters (variables) 102 uses

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

  3. σλ2\sigma_{\lambda}^{2}, αλ2\alpha_{\lambda}^{2}, σλ∣λ′2\sigma_{\lambda|\lambda^{\prime}}^{2}

    Superscript (power or label) 29 uses

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

  4. μ~\tilde{\boldsymbol{\mu}}, σ~\tilde{\sigma}, ϵ~\tilde{{\boldsymbol{\epsilon}}}

    Tilde accent 26 uses

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

  5. ϵ∗{\boldsymbol{\epsilon}}^{*}, ϵ~∗\tilde{{\boldsymbol{\epsilon}}}^{*}

    Star (optimal) 10 uses

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

  6. ⋯\cdots, …\dotsc, …\ldots

    Dots (ellipsis) 4 uses

    “And so on”: continue the pattern.

Greek letters

  1. λ\lambda

    Lambda 214 uses

    Usually the strength of a regularization term; also eigenvalues.

  2. θ\theta

    Theta 66 uses

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

  3. ϵ\epsilon

    Epsilon 53 uses

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

  4. σ\sigma

    Sigma (lowercase) 28 uses

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

  5. α\alpha

    Alpha 13 uses

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

  6. μ\mu

    Mu 4 uses

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

Vectors and matrices

  1. z\mathbf{z}, x\mathbf{x}, μ\boldsymbol{\mu}

    Bold lowercase (vector) 280 uses

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

  2. ×\times

    Times (cross) 10 uses

    Usually the “by” in a shape (n × d); also plain multiplication or a cross product.

  3. I\mathbf{I}

    Identity matrix 7 uses

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

  4. Norm 2 uses

    The length (size) of a vector. With subscript 2 or none, the Euclidean length √(Σxᵢ²).

Calculus and gradients

  1. λ′\lambda^{\prime}

    Prime 27 uses

    Either a derivative, f′(x), or simply "another one": x′ is a second sample, s′ the next state.

  2. ∇zλ\nabla_{\mathbf{z}_{\lambda}}, ∇θ\nabla_{\theta}

    Nabla (gradient) 9 uses

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

  3. ∞\infty

    Infinity 1 use

    Infinity; as a norm subscript, ‖x‖_∞ is the largest absolute entry.

  4. ∫\int

    Integral 1 use

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

Probability and statistics

  1. qq, pp

    Probability p(x) 73 uses

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

  2. ∣|

    Given (conditional bar) 50 uses

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

  3. log⁡\log

    Logarithm 13 uses

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

  4. N\mathcal{N}

    Normal distribution 9 uses

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

  5. ∼\sim

    Distributed as (tilde) 9 uses

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

  6. e−λe^{-\lambda}, eλ−λ′e^{\lambda-\lambda^{\prime}}, e−λmax/2e^{-\lambda_{\mathrm{max}}/2}

    Exponential 7 uses

    The exponential function eˣ, with e ≈ 2.718. Always positive.

  7. ∝\propto

    Proportional to 4 uses

    Equal up to a constant factor that does not depend on the variable of interest.

  8. Eϵ,λ\mathbb{E}_{{\boldsymbol{\epsilon}},\lambda}

    Expectation 1 use

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

Functions and operators

  1. min\mathrm{min}, max\mathrm{max}

    Max and min 17 uses

    The largest (or smallest) value, over the arguments or over the range in the subscript.

  2. tan⁡\tan, arctan⁡\arctan

    Tangent 3 uses

    The tangent function sin/cos; rare in ML papers, and not the same as tanh.

  3. →\rightarrow

    Arrow (maps to) 2 uses

    Maps to (f: X → Y), tends to (x → 0), or implies (⇒).

  4. ←\leftarrow

    Assignment arrow 1 use

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

  5. 1σλ\frac{1}{\sigma_{\lambda}}

    Fraction 1 use

    Division: the top divided by the bottom.

  6. ∑c\sum_{\mathbf{c}}

    Summation 1 use

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

Sets, shapes and definitions

  1. ∈\in

    Element of 9 uses

    “Is in” or “belongs to”: x ∈ S says x is a member of the set S.

  2. <<, >>, ≥\geq

    Inequalities 7 uses

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

  3. {0,0.1,0.2,…,4}\{0,0.1,0.2,\ldots,4\}, {0.1,0.2,0.5}\{0.1,0.2,0.5\}, {0.1,0.2}\{0.1,0.2\}

    Set braces 6 uses

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

  4. ≈\approx

    Approximately equal 5 uses

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

  5. ∅\varnothing

    Empty set 4 uses

    The set with nothing in it.

  6. R\mathbb{R}

    Real numbers (ℝ) and shapes 1 use

    The real numbers. ℝⁿˣᵈ is the set of n × d arrays of reals: it states a shape.

3 things the catalog has no entry for yet
  • ▹\triangleright \triangleright 7
  • ↓\downarrow \downarrow 2
  • ↑\uparrow \uparrow 2

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