Before we start, one shared reminder of the machine we are testing — the four steps, drawn as a pipeline.
Read the picture left to right: raw activations x enter, we measure their meanμB (the balance point) and varianceσB2 (the spread), subtract the mean and divide by the spread to get x^ (centered, unit-width), then the two learnable dials γ (gain) and β (shift) place the result wherever training wants it: y=γx^+β.
So the core formula, with both symbols now earned, reads
σB2=m1∑i=1m(xi−μB)2,x^i=σB2+ϵxi−μB,yi=γx^i+β.
The mean μB comes first.Why? Variance is defined as the average of squared deviations from the mean, σB2=m1∑i(xi−μB)2 (recall m = batch size). You literally cannot compute a deviation until you know what you are deviating from. So μB is a prerequisite for σB2. In the figure above, the "measure balance point" box must fire before the "measure spread" box.
Recall Solution 1.2
Training → (b) mini-batch statistics. Each mini-batch B gets its own μB,σB2. This makes the output of BN depend on the other examples in the batch — a form of noise that acts as a mild regularizer.
Inference → running (population) statisticsμrun,σrun2, the exponential moving averages accumulated during training. Why the switch? At test time we may see one example at a time — no batch exists to average over — and we need the output to be deterministic.
Recall Solution 1.3
False. BN's first act is subtracting the batch mean. Adding a constant b to every activation shifts every xiand shifts μB by exactly the same b, so the deviation xi−μB is unchanged. The bias cancels perfectly. Its job is instead done by the learnable β. Practical rule: set bias=False in the layer feeding into BN.
Step 1 — mean.μB=42+4+6+8=420=5.
Step 2 — variance (biased, /m with m=4). deviations [−3,−1,1,3]; squares [9,1,1,9]; mean =420=5. So σB2=5, σB=5≈2.2360679.
Step 3 — normalize. Since ϵ=0, x^i=5xi−5:
x^=[5−3,5−1,51,53]≈[−1.3416,−0.4472,0.4472,1.3416].Sanity: mean of x^=0, variance =1. ✓ (Compare to Example 1 in the parent — same shape, just a wider input, so the same standardized pattern comes out.)
Recall Solution 2.2
Apply yi=γx^i+β=3x^i−1:
y≈[3(−1.3416)−1,3(−0.4472)−1,3(0.4472)−1,3(1.3416)−1]=[−5.0249,−2.3416,0.3416,3.0249].Why:γ stretches the unit-variance signal to standard deviation 3, and β slides the whole thing down by 1. So the output has mean β=−1 and standard deviation ∣γ∣=3.
Recall Solution 2.3
No batch — use the frozen running stats.
x^=1618−10=48=2,y=4⋅2+2=10.
The map x↦y is now a fixed affine function; the same x=18 always yields y=10 regardless of any neighbours (there are none).
Deviations all 0⇒σB2=0. So x^i=0+10−57−7=0.00316230=0 for all i. The ϵ turned a lethal 0/0 into a safe 0 — exactly the safety role defined at the top of the page.
Information destroyed: the common value7 — anything constant across the batch is centered to 0 and erased.
Small-batch link: with few examples, batches are more likely to be near-constant or have wildly swinging μB,σB2 from step to step, so the normalization is noisy/unreliable — motivating Layer Normalization or Group Normalization in that regime.
Recall Solution 3.2
To undo normalization we invert Step 4: we need γ⋆x^i+β⋆=xi. Since x^i=σB2+ϵxi−μB, choosing
γ⋆=σB2+ϵ=5≈2.2360679,β⋆=μB=5
gives yi=5⋅5xi−5+5=(xi−5)+5=xi. ✓
Check x1=2:x^1=5−3≈−1.3416; y1=2.2360679(−1.3416)+5≈−3.0+5=2. ✓ The identity is reachable, so BN adds no restriction — it only changes the optimization landscape.
Recall Solution 3.3
Why the forms:yi=γx^i+β, so ∂γ∂yi=x^i and ∂β∂yi=1. Both γ and β are shared across all m examples, so by the chain rule their total gradient is the sum of each example's contribution: ∂γ∂L=∑i∂yi∂L⋅x^i and ∂β∂L=∑i∂yi∂L⋅1. (See Backpropagation.)
Numbers with x^≈[−1.3416,−0.4472,0.4472,1.3416]:
∂γ∂L=0.1(−1.3416)+(−0.2)(−0.4472)+0.3(0.4472)+(−0.4)(1.3416)≈−0.4472.
Term by term: −0.13416+0.08944+0.13416−0.53664=−0.44720. So ∂γ∂L≈−0.4472.
∂β∂L=0.1−0.2+0.3−0.4=−0.2.
With b=3: pre-BN values =[4,5,6]. Mean =5; deviations [−1,0,1]; variance =31+0+1=32; σ=2/3≈0.8165. Normalized: [0.8165−1,0,0.81651]≈[−1.2247,0,1.2247].
With b=0: pre-BN values =[1,2,3]. Mean =2; deviations [−1,0,1]; same variance 32; normalized ≈[−1.2247,0,1.2247].
Identical.Why: adding b shifted every value and the mean by +3, leaving deviations untouched, and variance is a function of deviations only. Conclusion: the bias before BN is dead weight — confirms Exercise 1.3 quantitatively.
Recall Solution 4.2
Each step: μrun←0.9μrun+0.1μB.
After batch 1: 0.9(0)+0.1(10)=1.0.
After batch 2: 0.9(1.0)+0.1(12)=0.9+1.2=2.1.
After batch 3: 0.9(2.1)+0.1(8)=1.89+0.8=2.69.
Why so far below the true ~10? With small α the running average has long memory and warms up slowly; early in training the estimate lags. This is why running stats are unreliable if used too early, and why some frameworks debias them.
Recall Solution 4.3
Expand y=γσrun2+ϵx−μrun+β:
y=aσrun2+ϵγx+c(β−σrun2+ϵγμrun).a=164=44=1. c=2−44⋅10=2−10=−8. So y=x−8.
Check with x=18: 18−8=10 — matches Exercise 2.3. ✓ Because it is pure affine, this a,c can be absorbed into the preceding linear layer's weights and bias, giving BN zero inference cost.
Choose Layer Normalization (Transformers' standard), or Group Normalization for vision with tiny batches. Why not BN: with batch size 2, μB,σB2 are estimated from just two numbers — catastrophically noisy (Exercise 3.1's lesson taken to the limit); and single-example inference forces reliance on possibly-unwarmed running stats (Exercise 4.2). The axis rule: BN averages across the batch (same feature, many examples); Layer Norm averages across the features of a single example — so it is completely batch-independent, identical at train and test. That independence is exactly what small-batch / streaming settings need. This connects to Vanishing and Exploding Gradients and Optimization and Conditioning of the Loss Surface: all three normalizers aim at a better-conditioned surface, but by averaging over different axes.
Recall Solution 5.2
For a constant batch every xi=c, so μB=c and each deviation xi−μB=0exactly (not just in the limit). Then
x^i=σB2+ϵ0=0,yi=γ⋅0+β=β.
The ⋅+ϵ denominator is strictly positive (since ϵ>0), so no division blows up and the numerator being 0 forces yi=β regardless of c. Interpretation: the value of a constant feature is invisible to BN — it collapses to the learned shift β. The signal that survives BN is only the relative spread within the batch, which is why BN cannot help when a batch carries no within-batch variation.
Recall Solution 5.3
Prediction:b is irrelevant (Ex 1.3 / 4.1) — BN removes it. So compute as if pre-BN values were [0,5,10]'s the deviations only... but let's include b=100 honestly and watch it cancel.
Pre-BN: [100,105,110]. Mean =105. Deviations [−5,0,5]. Variance =325+0+25=350≈16.6667; σ=50/3≈4.0825.
x^=[4.0825−5,0,4.08255]≈[−1.2247,0,1.2247].
y=2x^+1≈[−1.4495,1.0,3.4495].
Same x^ (and hence y) as if b=0 — the huge bias 100 shifted the mean by 100 and vanished in the deviations. Prediction confirmed. ✓
Recall Final self-check (cover the answers)
Which comes first, mean or variance? ::: Mean — variance needs deviations from it.
Training uses which stats? ::: Per-mini-batch μB,σB2.
Inference uses which stats? ::: Running (population) μrun,σrun2.
Why drop the bias before BN? ::: BN subtracts the mean, cancelling any constant bias; β replaces it.
Which estimator for variance? ::: Biased, divide by m (batch size), not m−1.
Tiny-batch / streaming fix? ::: Use Layer Normalization or Group Normalization.