What comes out of a layer whose weights are pure noise?
Part 4 measured the model from the outside. Now open it up. The 0.7 for mat came out of 80 layers of multiplications, and before training began, every weight in those layers was a random draw from a Gaussian.
Why a Gaussian, and why at that particular size? One rule answers both: variances add. The same rule then explains how a model samples any Gaussian it likes, how a diffusion model destroys an image without letting it grow, and why the squared-error loss is a Gaussian in disguise.
The 30-second version
A standard deviation of about 64. Each output is a sum of 4,096 independent products, and independent terms add their variances: 4,096 in total, so the spread is √4,096 = 64, the typical size of the dot product of two random 4,096-number vectors. Scale the weights by 1/√4,096 = 1/64 and the spread is back to 1. Get that scale 10% wrong and 80 layers turn the mistake into a factor of 1.1⁸⁰ ≈ 2,048.What is a Gaussian?
A bell, set by two numbers: where it is centred and how wide it is (MML 6.62).
\[p(x \mid \mu, \sigma^2) = \frac{1}{\sqrt{2\pi\sigma^2}}\exp\!\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)\]In words: the density falls off with the squared distance from the centre $\mu$, measured in units of the variance $\sigma^2$.
With many coordinates the centre becomes a vector $\boldsymbol\mu$ and the width becomes a covariance matrix $\Sigma$, and the bell’s contour lines become ellipses (MML 6.63). $\mathcal N(\mathbf 0, I)$, centre zero and identity covariance, is the standard normal.
Why does this one shape keep turning up? MML gives the reason in a margin note: it arises naturally whenever many independent things are added up. Part 4’s benchmark scores were such a sum, and they piled into a bell. So is every neuron.
Why do variances add?
Add two independent random numbers and their variances add (MML 6.48, with the covariance terms zero by independence, §6.4.5). Scale them first and the scales come in squared:
\[\mathbb V[aX + bY] = a^2\,\mathbb V[X] + b^2\,\mathbb V[Y]\]That is the rule for spread, and it is not the rule for standard deviations. Two independent standard normals add to a variance of 2, a spread of 1.41, not 2. MML’s Example 6.7 says the same for Gaussians: a weighted sum of independent Gaussians is a Gaussian with exactly this variance.
A neuron is a sum. It computes $z = \sum_i w_i x_i$ over its $n$ inputs. Each product has variance $\mathbb V[w]\,\mathbb V[x]$ when both are centred and independent, and there are $n$ of them:
\[\mathbb V[z] = n\,\mathbb V[w]\,\mathbb V[x]\]Guess the spread for 4,096 inputs before you slide.
Variance 4,096, spread 64: the typical size of the dot product of two random 4,096-number vectors. A neuron with random weights is exactly that dot product.
The inset holds a small surprise. One product $w_i x_i$ is a sharp spike with long tails, nothing like a bell. Add enough of them and the bell appears anyway.
Why do weights start at one over the square root of n?
Because that is the scale that keeps the spread where it was. With $\mathbb V[w] = \sigma_w^2$, the output’s variance is $n\sigma_w^2$ times the input’s, so it stays put when
\[\sigma_w = \frac{1}{\sqrt{n}} = \frac{1}{64} \qquad \text{for } n = 4{,}096\]Find it yourself: slide the weights’ spread until the histogram sits on the dashed bell.
Dividing by $n$ instead of $\sqrt n$ is the classic slip, and it overshoots the other way: the output shrinks to a spread of 1/64. Initialisation schemes such as Xavier’s are this calculation written down once.
What does depth do to a small mistake?
It raises it to a power. If each layer’s weights are $\sigma_w = c/\sqrt n$, each layer multiplies the spread by $c$, and 80 layers multiply it by $c^{80}$.
At $c = 1.1$, ten percent too big, the activations end $1.1^{80} \approx 2{,}048$ times wider than they started. At $c = 0.9$ they fade to $0.9^{80} \approx 0.0002$. Nothing in between is safe except $c = 1$.
A ReLU changes the bookkeeping. It zeroes about half of what the next layer sees, so the next layer gets half the mean square of its inputs. At $\sigma_w = 1/\sqrt n$ the spread then shrinks by $\sqrt 2$ per layer, to $2^{-40} \approx 10^{-12}$ after 80. Doubling the weight variance, $\sigma_w = \sqrt{2/n}$, cancels the half: that is He initialisation.
Modern transformers also rescale their activations inside every block with normalisation layers, so they forgive a sloppy start far more than this bare stack does. The arithmetic of variances is still why every initialiser divides by $\sqrt n$.
How do you draw from any Gaussian you like?
A linear map keeps a Gaussian Gaussian. It moves the mean to $A\boldsymbol\mu + \mathbf b$ and the covariance to $A\Sigma A^\top$ (MML 6.50, 6.51 and 6.88). So a computer needs only one kind of randomness, standard noise $\boldsymbol\varepsilon \sim \mathcal N(\mathbf 0, I)$, and a matrix:
\[\mathbf x = \boldsymbol\mu + L\boldsymbol\varepsilon \quad\Longrightarrow\quad \mathbf x \sim \mathcal N(\boldsymbol\mu,\; LL^\top)\]That is MML’s recipe in §6.5.4: factor the covariance as $LL^\top$ with a triangular $L$, its Cholesky factor, and stretch the noise. For the figure’s covariance:
\[\Sigma = \begin{bmatrix}4&2\\2&2\end{bmatrix} = LL^\top, \qquad L = \begin{bmatrix}2&0\\1&1\end{bmatrix}\]The arrows are the columns of $L$. A matrix sends each axis to one of its columns, so the arrows show where the axes of the noise land.
This is also the reparameterisation trick behind variational autoencoders. The encoder outputs a mean and a spread, and the sample is the mean plus the spread times fresh noise. The randomness lives in $\boldsymbol\varepsilon$, so gradients flow straight through the mean and the spread.
Stretching changes the density too. The unit square of noise lands on a parallelogram of area $\lvert\det L\rvert = 2$, so the same probability is spread over twice the area and the density halves (MML Theorem 6.16). It is the determinant from Gradient Part 2, doing the job promised there.
How does a diffusion model turn data into noise?
On purpose, in many small steps, so that it can learn to run the process backwards. After any number of steps the noisy point is a share of the original plus fresh Gaussian noise, with $\bar\alpha$ the share of signal still kept:
\[\mathbf x_t = \sqrt{\bar\alpha}\;\mathbf x_0 + \sqrt{1 - \bar\alpha}\;\boldsymbol\varepsilon\]At $\bar\alpha = 0.64$ the weights are 0.8 and 0.6. Guess why they are square roots before you press play.
It is the variance rule again. With data of variance 1 the mix has variance $0.8^2 + 0.6^2 = 0.64 + 0.36 = 1$, at every step. Weights of 0.64 and 0.36 add to 1 as well, but their squares do not, and the cloud shrinks.
Keeping the variance at 1 all the way down means the process ends at the standard normal, $\mathcal N(\mathbf 0, I)$, once almost no signal is left. Generation starts there: draw standard noise and let the trained model take the steps in reverse.
Why is squared error a Gaussian in disguise?
Suppose a model predicts a number $f$ and the truth $y$ scatters around it as a Gaussian, $p(y \mid f) = \mathcal N(y \mid f, \sigma^2)$. That is MML’s Example 8.4 for linear regression. Take the negative log, the move Part 2 made for a whole sentence:
\[-\log p(y \mid f) = \frac{(y - f)^2}{2\sigma^2} + \frac12\log\left(2\pi\sigma^2\right)\]The log cancels the exponential and leaves half the squared error, plus a constant that does not care about $f$. With $y = 3$, $f = 1$ and $\sigma = 1$: $2 + 0.919 = 2.919$.
So minimising the average squared error is maximising a Gaussian likelihood, and choosing that loss is a claim about the noise. A language model makes the same move with a different distribution: its prediction is the 20 tickets, not a bell, and the negative log of the right ticket’s share is $-\log 0.7$. Part 6 takes that number apart.
Rapid fire: can you do these from memory?
- Two independent standard normals are added. What are the variance and the standard deviation of the sum?
- A neuron has 1,024 inputs of variance 1 and weights drawn from N(0, 1). What is the spread of its output, and what weight spread fixes it?
- Weights are 5% too big in every layer of a 100-layer linear stack. Roughly how much do the activations grow?
- Why does a ReLU network need weights at √(2/n) rather than 1/√n?
- x = Lε with ε standard normal. What is the covariance of x, and why does a sampler factor Σ to get L?
- What does the reparameterisation trick move the randomness into, and why does that help training?
- A noised point is xₜ = 0.6 x₀ + 0.8 ε. What share of the signal is kept, and what is the variance of xₜ if x₀ has variance 1?
- Write −log N(y | f, σ²) and say which part of it training actually minimises.
Where can you go deeper?
All of this is Chapter 6, Probability and Distributions, of Mathematics for Machine Learning by Deisenroth, Faisal and Ong (Cambridge University Press, 2020), free at mml-book.github.io, plus one example from Chapter 8:
- §6.5, the Gaussian distribution: the univariate and multivariate densities (6.62 and 6.63), and the margin note on why sums of independent variables become Gaussian.
- §6.4.4, sums and transformations of random variables: the variance of a sum (6.48) and the mean and covariance after an affine map (6.50 and 6.51). §6.4.5 for independence, which removes the covariance terms.
- §6.5.3, sums and linear transformations of Gaussians: Example 6.7’s weighted sum, and 6.86 to 6.88 for $A\mathbf x$.
- §6.5.4, sampling from a multivariate Gaussian: standard noise stretched by a Cholesky factor.
- §6.7.2, change of variables: Theorem 6.16 and Example 6.17, the determinant that rescales a density.
- §8.3.1, maximum likelihood: Example 8.4’s Gaussian likelihood and the negative log-likelihood 8.17, which turns it into squared error.