The Modern Mathematics of Deep Learningexplained for non-mathematicians

Batch normalized gradient norm

Penguin learning project

The project uses 342 complete Palmer penguin records: 240 training-pool and 102 held-out rows. The selected training rows determine feature scaling and model parameters. Source CSV

This project trains weights with softmax, unlike the homepage lab, which uses nearest species averages. Same penguin measurements; different classification methods. Predictions can differ.

Batch normalization · Describe batch normalization and its derivatives.

The project uses a linear rule with two features. The fitted weights produce scores or normalized mass.

Consider this concept alongside the project; its source assumptions may differ. These observations do not prove a theorem.

Input: 12 × 2; Held-out evaluation: 102 · #58 · 40.6 mm, 193 mm. Known answer: Adélie; Prediction: Adélie · [≈0.7383, ≈0.2444, ≈0.01737].

Used in these source sections: 6.4 Adjusting the scale

The gradient formula removes the mean direction and the normalized-batch direction from the incoming gradient.

These operations define structured network layers and their analysis.

Source formula example

∥∇(r∘B(β,γ))(b)∥22=γ2σb2(∥∇r(b)∥2−1m⟨1,∇r(b)⟩2−1m⟨B(0,1)(b),∇r(b)⟩2),\|\nabla(r\circ\mathcal{B}^{(\beta,\gamma)})({b})\|_{2}^{2}=\frac{\gamma^{2}}{\sigma_{b}^{2}}\big(\left\|\nabla r({b})\right\|^{2}-\frac{1}{m}\langle\mathbf{1},\nabla r({b})\rangle^{2}-\frac{1}{m}\langle\mathcal{B}^{(0,1)}({b}),\nabla r({b})\rangle^{2}\big),

illustration · The invented finite inputs illustrate this expression. They do not prove a general identity, bound, or existence claim.

Symbols

bb
Real batch vector of length m.
σbσb
Positive batch standard deviation.
γγ
Real scale.
rr
Differentiable scalar loss.
B(0,1)B⁽⁰,¹⁾
Normalized batch with zero shift and unit scale.
11
Vector of ones.

Source formula example

This source example uses its own inputs and assumptions. Editing it does not change the project.

Edit a value or the code, then run the example. This is a finite demonstration, not a proof of the paper’s theorem.

This example’s data flow

You choose

  • input.gamma = 1

Initial values in code

  • g = [1, 0, 1]

Calculated here

Result expression: { gradient, squaredNorm, rightSide }

  • sigma = Math.sqrt(2 / 3)
  • z = [-1 / sigma, 0, 1 / sigma] Uses: sigma
  • meanComponent = dot([1, 1, 1], g) / 3 Uses: dot, g
  • normalizedComponent = dot(z, g) / 3 Uses: dot, z, g
  • gradient = g.map( (v, i) => (input.gamma / sigma) * (v - meanComponent - normalizedComponent * z[i]), ) Uses: g, input.gamma, sigma, meanComponent, normalizedComponent, z
  • squaredNorm = dot(gradient, gradient) Uses: dot, gradient
  • rightSide = (input.gamma ** 2 / (sigma * sigma)) * (dot(g, g) - dot([1, 1, 1], g) ** 2 / 3 - dot(z, g) ** 2 / 3) Uses: input.gamma, sigma, dot, g, z

Returns

Example result
gradient
array (3 items): [≈0.4082, ≈-0.8165, ≈0.4082]
squaredNorm
1
rightSide
1

Read numbers from input and return the result. JavaScript basics.

Result

Enable JavaScript to run this example.

Technical statement

Use batch [−1,0,1], r(z) = z₁+z₃, and γ as shown. The gradient of this linear loss is [1,0,1] everywhere, so it agrees at b and at the normalized output. The code computes the chain-rule gradient using the Jacobian and both sides of the squared-norm identity. the source proposition takes m ≥ 2, real β and γ, and differentiable r. The formula requires σb > 0 even though the displayed source statement says every batch; constant batches make its denominator zero. The printed source uses ∇r(b); for general nonlinear r the usual chain rule evaluates the incoming gradient at B(b), so that printed argument may need clarification.

Source: Source expression