Initialization & Normalization
Starting and keeping signals in a learnable range
How weights start and how intermediate values are scaled determines whether deep networks learn at all. Xavier/Kaiming init and batch/group normalization keep activations in a stable regime.
What you will learn
- Choose initialization schemes that match activation functions
- Explain what normalization layers fix and where to place them
- Diagnose stability issues that read as 'loss stuck' or 'gradient collapse'
What is this?
Initialization sets the first weight values before any training, and normalization rescales the signals inside the network during training. If weights start too large or too small, activations and gradients immediately blow up or vanish no matter the optimizer. Normalization layers re-center and re-scale layer outputs every step, so depth stops amplifying drift, enabling very deep nets.
Why do you need it?
- Zero-initializing all weights makes every neuron identical — symmetric, and training never breaks symmetry.
- Variance control: with N inputs, output variance scales with N unless init divides by √(fan_in).
- BatchNorm stabilizes the signal distribution per layer, letting you train deeper, faster, at higher LR.
- Without these, your first-debug is 'why won't my deep net learn' — with them it's usually something else.
Mental model
Starting a race from a mark, and adjusting stride on hilly terrain
Initialization and normalization
Init is choosing the correct starting position so nobody begins a meter into a wall; normalization is pacing so steep gradients mid-race don't make all participants trip simultaneously.
How it works
- Xavier: initialize uniform/normal with variance 1/(fan_in) — the right scale for sigmoid/tanh activations.
- Kaiming/He: variance 2/(fan_in) — tuned to ReLU, which halves the effective signal.
- BatchNorm: normalize per-channel across the batch to zero mean/unit variance, then learn scale/shift γ,β.
- LayerNorm normalizes per-sample across features (used in transformers where samples are independent).
- The normalized signal keeps gradients magnitude-stable across depth, so deep stacks converge.
Normalization keeps layer outputs from drifting as depth grows.
In production
- Image nets default to Kaiming-init + BatchNorm (pre-activation) with weight decay.
- Transformers use LayerNorm + a scaled init (GPT small init) to keep residual streams well-conditioned.
- GANs and style models rely on careful init and normalization schemes (adaptive/spectral variants) to stay stable.
Best practices
- Match init to activation: Kaiming for ReLU-family, Xavier for tanh/sigmoid.
- Put BatchNorm before the activation; keep it on and frozen consistently between train/eval.
- For residual nets, init the last layer of residual branches near zero so the network starts as identity.
- Beware BatchNorm's batch-size dependence — for small or dynamic batches prefer LayerNorm/GroupNorm.
Common mistakes
- Initializing everything to zeros — symmetry breaks learning entirely.
- Using Kaiming with tanh (wrong variance target) and getting saturated starts.
- Applying one global normalization scale across heterogeneous tasks (multi-task heads).
- Training with BatchNorm in a batch of 4 and wondering why val is noisy.
Common issues
Loss never moves from its initial random levelSaturated init (tanh/sigmoid) with perfectly zero gradients at the start
Switch to Kaiming/He-style init or reduce the initial weight variance by 10x.
Validation quality swings train-to-trainBatchNorm stats shift with tiny batches or stochastic order
Use running-stat Freezing/eval mode, larger batch, or LayerNorm.
First-layer activations are all identicalSymmetric init or a dataloader feeding one repeated batch
Reseed and randomize init; then visually dump one batch.
Debugging tips
- Run a few forward passes with random data: activation std should stay ~O(1), not 1e-4 or 1e4.
- Print first-batch gradient norms per layer; outliers expose init or normalization mismatches.
- Toggle normalization off for two steps and watch the same seed blow up — confirms it's doing work.
- In transformers, check activations at residual output gates, where drift accumulates first.
Interview checkpoint
Hands-on lab
- Compare zero, bad-scale and Kaiming initialization on the same training run
- Observe how normalization changes the first-batch loss trajectory
- Learn to diagnose saturation from activation statistics
Watch Init and Norm Affect Training
25 min · intermediate
Quick quiz
Which initialization scheme is designed for ReLU-family activations?
Batch normalization fully removes the need for good weight initialization.