Gradient LabStart the lesson

Lessons › Chapter 8: Neural networks

Weight initialization

Before training, every weight needs a starting value. All zeros won’t work: every neuron would compute the same thing and learn the same thing. So we start with small random numbers. But how small?

Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.

Start the interactive lesson

Step by step

Story

Nothing is learning

Leo’s deeper network won’t learn at all: the signal fades to nothing on its way through.

Concept

Weights must start somewhere

Before training, every weight needs a starting value. All zeros won’t work: every neuron would compute the same thing and learn the same thing. So we start with small random numbers. But how small?

Problem

Too small: the signal fades

With weights that are too small, the signal shrinks a bit in every layer. By layer 8 it has all but vanished, and so have the gradients, so the early layers stop learning.

Problem

Too big: the signal explodes

With weights that are too big, the signal grows in every layer until the numbers blow up. Training goes haywire.

Key idea

Scale to the layer size

Good initialization scales the random weights by how many inputs each neuron has. The signal then keeps roughly the same strength through every layer, and deep networks can train.

Real life

In real life: the telephone game

Whisper a message down a long line of people and it can fade to nothing, or get garbled and exaggerated. Deep networks pass signals through dozens of layers, and good initialization keeps the message at the right volume all the way through.

Quick check: Why not start every weight at exactly zero?

Identical starting weights make neurons identical; random starts break the symmetry.

Pseudocode

# too small: signals shrink layer after layer → nothing learns
# too big:   signals explode → numbers overflow
# just right: scale random weights to the layer size
w = random_normal() × sqrt(2 / inputs_per_neuron)    # “He” initialization

Key terms

initialization
How the weights are set before training starts.