Papers · Training · 2016

Layer Normalization

Jimmy Lei Ba, Jamie Ryan Kiros, Geoffrey E. Hinton

The notation of the Layer norm paper, explained: its 35 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

Layer normalization: normalize over the hidden units of a layer, for each example separately, so it works for any batch size and for recurrent networks.

The superscript ll in μl\mu^l, σl\sigma^l and aila_i^l is the layer index, not a power. HH is the number of hidden units in the layer, aila_i^l the summed input to unit ii, and gg and bb the learned gain and bias (other papers write them γ\gamma and β\beta).

Read from arXiv's HTML version: 35 displayed equations and 73 pieces of inline math. 43 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)
    ail=wil⊤hlhil+1=f(ail+bil){a}^{l}_{i}={{w}^{l}_{i}}^{\top}{h}^{l}\qquad{h}^{l+1}_{i}={f}({a}^{l}_{i}+{b}^{l}_{i})
    Decode →
  2. (2)
    aˉil=gilσil(ail−μil)μil=Ex∼P(x)[ail]σil=Ex∼P(x)[(ail−μil)2]\bar{{a}}^{l}_{i}={{g}^{l}_{i}\over\sigma^{l}_{i}}\left({a}^{l}_{i}-\mu^{l}_{i}\right)\qquad\mu^{l}_{i}=\mathop{\mathbb{E}}_{{\mathbb{x}}\sim P({\mathbb{x}})}\left[{a}^{l}_{i}\right]\qquad\sigma^{l}_{i}=\sqrt{\mathop{\mathbb{E}}_{{\mathbb{x}}\sim P({\mathbb{x}})}\left[\left({a}^{l}_{i}-\mu^{l}_{i}\right)^{2}\right]}
    Decode →
  3. (3)
    μl=1H∑i=1Hailσl=1H∑i=1H(ail−μl)2\mu^{l}=\frac{1}{H}\sum_{i=1}^{H}{a}^{l}_{i}\qquad\sigma^{l}=\sqrt{\frac{1}{H}\sum_{i=1}^{H}\left({a}^{l}_{i}-\mu^{l}\right)^{2}}
    Decode →
  4. (4)
    ht=f[gσt⊙(at−μt)+b]μt=1H∑i=1Haitσt=1H∑i=1H(ait−μt)2{\mathbb{h}}^{t}={f}\left[{{\mathbb{g}}\over\sigma^{t}}\odot\left({\mathbb{a}}^{t}-\mu^{t}\right)+{\mathbb{b}}\right]\qquad\mu^{t}=\frac{1}{H}\sum_{i=1}^{H}{a_{i}^{t}}\qquad\sigma^{t}=\sqrt{\frac{1}{H}\sum_{i=1}^{H}\left({a_{i}^{t}}-\mu^{t}\right)^{2}}
    Decode →
  5. (5)
    hi=f(giσi(ai−μi)+bi)h_{i}=f({{g}_{i}\over\sigma_{i}}\left(a_{i}-\mu_{i}\right)+b_{i})
    Decode →
  6. (6)
    h′=f(gσ′(W′x−μ′)+b)=f(gσ′((δW+1γ⊤)x−μ′)+b)=f(gσ(Wx−μ)+b)=h.\begin{gathered}{\mathbb{h}}^{\prime}= f({{\mathbb{g}}\over\sigma^{\prime}}\left(W^{\prime}{\mathbb{x}}-\mu^{\prime}\right)+{\mathbb{b}})=f({{\mathbb{g}}\over\sigma^{\prime}}\left((\delta W+{\bf 1}{\bm{\gamma}}^{\top}){\mathbb{x}}-\mu^{\prime}\right)+{\mathbb{b}}) \\ = f({{\mathbb{g}}\over\sigma}\left(W{\mathbb{x}}-\mu\right)+{\mathbb{b}})={\mathbb{h}}.\end{gathered}
    Decode →
  7. (7)
    hi′=f(giσ′(wi⊤x′−μ′)+bi)=f(giδσ(δwi⊤x−δμ)+bi)=hi.{h}_{i}^{\prime}= f({{g}_{i}\over\sigma^{\prime}}\left(w_{i}^{\top}{\mathbb{x}}^{\prime}-\mu^{\prime}\right)+{b}_{i})=f({{g}_{i}\over{\delta\sigma}}\left(\delta w_{i}^{\top}{\mathbb{x}}-\delta\mu\right)+{b}_{i})={h}_{i}.
    Decode →
  8. (8)
    ds2=DKL[P(y ∣ x; θ)∥P(y ∣ x; θ+δ)]≈12δ⊤F(θ)δ,ds^{2} =\mathrm{D}_{\rm KL}\big[P(y\,|\,{\mathbb{x}};\ \theta)\|P(y\,|\,{\mathbb{x}};\ \theta+\delta)\big]\approx\frac{1}{2}\delta^{\top}{F}(\theta)\delta,
    Decode →
  9. (9)
    F(θ)=Ex∼P(x),y∼P(y ∣ x)[∂log⁡P(y ∣ x; θ)∂θ∂log⁡P(y ∣ x; θ)∂θ⊤],{F}(\theta) =\mathop{\mathbb{E}}_{{\mathbb{x}}\sim P({\mathbb{x}}),y\sim P(y\,|\,{\mathbb{x}})}\left[{\partial\log P(y\,|\,{\mathbb{x}};\ \theta)\over\partial\theta}{\partial\log P(y\,|\,{\mathbb{x}};\ \theta)\over\partial\theta}^{\top}\right],
    Decode →
  10. (10)
    log⁡P(y ∣ x; w,b)=(a+b)y−η(a+b)ϕ+c(y,ϕ),\log P(y\,|\,{\mathbb{x}};\ w,b) =\frac{({a}+b)y-\eta({a}+b)}{\phi}+c(y,\phi),
    Decode →
  11. (11)
    E[y ∣ x]=f(a+b)=f(w⊤x+b),  Var[y ∣ x]=ϕf′(a+b),\mathop{\mathbb{E}}[y\,|\,{\mathbb{x}}]=f({a}+b) =f({w}^{\top}{\mathbb{x}}+b),\ \ \text{Var}[y\,|\,{\mathbb{x}}]=\phi f^{\prime}({a}+b),
    Decode →
  12. (12)
    F(θ)=Ex∼P(x)[Cov[y ∣ x]ϕ2⊗[xx⊤xx⊤1]].{F}(\theta) =\mathop{\mathbb{E}}_{{\mathbb{x}}\sim P({\mathbb{x}})}\left[\frac{\text{Cov}[{\mathbb{y}}\,|\,{\mathbb{x}}]}{\phi^{2}}\otimes\begin{bmatrix}{\mathbb{x}}{\mathbb{x}}^{\top}&{\mathbb{x}}\\ {\mathbb{x}}^{\top}&1\end{bmatrix}\right].
    Decode →

Famous equations in this paper

Symbols, by category

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

Notation conventions

  1. aa, ww, hh

    Italic letters (variables) 345 uses

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

  2. ail{a}^{l}_{i}, wil{w}^{l}_{i}, hil+1{h}^{l+1}_{i}

    Subscript (index or label) 298 uses

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

  3. (ail−μil)2\left({a}^{l}_{i}-\mu^{l}_{i}\right)^{2}, (ail−μl)2\left({a}^{l}_{i}-\mu^{l}\right)^{2}, ht{\mathbb{h}}^{t}

    Superscript (power or label) 48 uses

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

  4. ail{a}^{l}_{i}, wil{w}^{l}_{i}, hl{h}^{l}

    Superscript in parentheses 27 uses

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

  5. aˉ\bar{{a}}, Fˉ\bar{{F}}, Fˉ\bar{F}

    Bar (mean) 14 uses

    A bar usually marks an average: x̄ is the mean of the x values.

  6. ⋯\cdots, ⋱\ddots

    Dots (ellipsis) 11 uses

    “And so on”: continue the pattern.

  7. h^\hat{{\bf h}}

    Hat (estimate) 4 uses

    A hat marks an estimate or prediction: ŷ is the model’s guess for y.

Greek letters

  1. σ\sigma

    Sigma (lowercase) 57 uses

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

  2. μ\mu

    Mu 39 uses

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

  3. δ\delta

    Delta (lowercase) 34 uses

    A small change, or the error signal δ = ∂L/∂z in backpropagation.

  4. α\alpha

    Alpha 16 uses

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

  5. β\beta

    Beta 16 uses

    Usually a decay rate (Adam’s β₁, β₂), a shift parameter in normalization, or a weight on a loss term.

  6. θ\theta

    Theta 14 uses

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

  7. ϕ\phi

    Phi 10 uses

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

  8. χ\chi

    Chi 7 uses

    Almost always χ², the chi-squared distribution or test.

  9. γ\gamma

    Gamma 3 uses

    The discount factor in reinforcement learning, or the learned scale in normalization layers.

  10. η\eta

    Eta 2 uses

    The learning rate in most gradient-descent papers.

  11. ρ\rho

    Rho 1 use

    A correlation coefficient, a decay rate (RMSprop, Adadelta), or an importance ratio in RL.

Vectors and matrices

  1. wil⊤{{w}^{l}_{i}}^{\top}, γ⊤{\bm{\gamma}}^{\top}, wi⊤w_{i}^{\top}

    Transpose 40 uses

    Swap rows and columns. xᵀy is a dot product; xyᵀ is an outer product.

  2. γ\bm{\gamma}, α\bm{\alpha}, β\bm{\beta}

    Bold lowercase (vector) 35 uses

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

  3. ⊙\odot

    Hadamard (elementwise) product 14 uses

    Multiply two arrays of the same shape entry by entry.

  4. ∥w1∥22\|w_{1}\|_{2}^{2}, ∥w1∥2\|w_{1}\|_{2}, ∥wH∥2\|w_{H}\|_{2}

    Norm 14 uses

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

  5. Bold uppercase (matrix) 10 uses

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

  6. (⋅)(\cdot)

    Centre dot 6 uses

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

  7. †\dagger

    Dagger / pseudo-inverse 2 uses

    The Moore–Penrose pseudo-inverse A⁺ (written A† in many ML papers); in physics, the conjugate transpose.

  8. KK

    Q, K, V (query, key, value) 1 use

    In attention: queries Q, keys K and values V, each a matrix with one row per token.

  9. ⊗\otimes

    Tensor / Kronecker product 1 use

    An outer, Kronecker or tensor product: every entry of one times every entry of the other.

Calculus and gradients

  1. h′{\mathbb{h}}^{\prime}, σ′\sigma^{\prime}, W′W^{\prime}

    Prime 17 uses

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

  2. ∂\partial, ∂μi∂wi\frac{\partial{\mu_{i}}}{\partial{{w}_{i}}}, ∂σi∂wi\frac{\partial{\sigma_{i}}}{\partial{{w}_{i}}}

    Partial derivative 6 uses

    A partial derivative: how one quantity changes when one input changes and the others are held fixed.

Probability and statistics

  1. ∣|

    Given (conditional bar) 22 uses

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

  2. PP

    Probability p(x) 17 uses

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

  3. ;;

    Semicolon (parameterized by) 16 uses

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

  4. Cov\text{Cov}

    Covariance 12 uses

    How two random quantities vary together; positive when they rise together.

  5. ∼\sim

    Distributed as (tilde) 10 uses

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

  6. log⁡\log

    Logarithm 5 uses

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

  7. ∥\|

    KL divergence 1 use

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

  8. Var\text{Var}

    Variance 1 use

    How spread out a random quantity is: the expected squared distance from its mean, σ².

Functions and operators

  1. 1H\frac{1}{H}, 12\frac{1}{2}, (a+b)y−η(a+b)ϕ\frac{({a}+b)y-\eta({a}+b)}{\phi}

    Fraction 46 uses

    Division: the top divided by the bottom.

  2. tanh\text{tanh}

    Hyperbolic tangent 8 uses

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

  3. ∑i=1H\sum_{i=1}^{H}, ∑i=1D\sum_{i=1}^{D}

    Summation 7 uses

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

  4. 1D∑i=1D(zi−μ)2\sqrt{\frac{1}{D}\sum_{i=1}^{D}(z_{i}-\mu)^{2}}

    Square root 4 uses

    The square root. In attention, dividing by √d_k keeps dot products at a sensible scale.

  5. ::, →\to

    Arrow (maps to) 2 uses

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

Sets, shapes and definitions

  1. ≈\approx

    Approximately equal 1 use

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

12 things the catalog has no entry for yet
  • \bf \bf 87
  • x\mathbb{x} x 57
  • vecop⁡\operatorname{vecop} \vecop 14
  • b\mathbb{b} b 12
  • \over \over 10
  • E\mathop{\mathbb{E}} \mathbb{E} 10
  • g\mathbb{g} g 9
  • h\mathbb{h} h 5
  • y\mathbb{y} y 4
  • a\mathbb{a} a 2
  • ℜ\real \real 2
  • \rm \rm 1

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 training papers