Optimization

Weight Initialization: Xavier, He & muP

How to pick weight scales so activations/gradients stay stable: Xavier/Glorot, He/Kaiming, and width-scaling ideas like muP.

status: reviewimportance: importantdifficulty 3/5math: undergraduateread: 14mdemo planned

Concept Structure

Weight Initialization: Xavier, He & muP

01Intuition

Start with the picture, metaphor, or geometric mechanism.

02Math

Make the objects explicit and connect them with notation.

03Code

Mirror the equations with runnable implementation details.

04Interactive Demo

Manipulate the mechanism and watch the idea respond.

2prerequisites
1next concepts
1related links

Learning map

Weight Initialization: Xavier, He & muP
BeforeLoss Landscapes, Sharpness & Flat MinimaNow3/4 sections readyTryUse the demo notes to predict the mechanism before moving on.NextScaling Laws & Emergent Abilities

Object flow

3/4 sections readyAsk about thisResearch room
ConceptWeight Initialization: Xavier, He & muPOptimization
Local snapshot ready
concept:optimization/weight-initialization

Conceptual Bridge

What should feel connected as you move through this page.

Carry inLoss Landscapes, Sharpness & Flat Minima

Bring the mental model from Loss Landscapes, Sharpness & Flat Minima; this page will reuse it instead of restarting from zero.

Work hereWeight Initialization: Xavier, He & muP

How to pick weight scales so activations/gradients stay stable: Xavier/Glorot, He/Kaiming, and width-scaling ideas like muP.

Carry outScaling Laws & Emergent Abilities

The next edge should feel earned: use the demo prediction here before following Scaling Laws & Emergent Abilities.

Test the linkUse the demo notes to predict the mechanism before moving on.Then continue to Scaling Laws & Emergent Abilities
01

01

Intuition

Build the mental picture first so the rest of the page has something to attach to.

Section prompt

Initialization is the starting geometry of learning.

If weights are too small, signals shrink as they pass through layers and gradients vanish. If weights are too large, activations and gradients explode and training becomes unstable.

Good initializations aim to keep the "scale" of information roughly constant as it flows forward (activations) and backward (gradients).

Two classics:

  • Xavier/Glorot: good for tanh/sigmoid-like activations.
  • He/Kaiming: good for ReLU-like activations (because ReLU zeros out about half of inputs).

Modern scaling work adds another layer: you want hyperparameters to transfer as width changes. muP is one way to parameterize networks so you can tune on a small model and scale up with fewer surprises.

02

02

Math

Translate the story into symbols, assumptions, and a derivation you can inspect.

Section prompt

Consider a linear layer h=Wxh = Wx where xRninx\in\mathbb R^{n_{in}} has i.i.d. components with Var(xi)=σ2\mathrm{Var}(x_i)=\sigma^2. Assume WijW_{ij} are i.i.d. with mean 0 and variance Var(Wij)=v\mathrm{Var}(W_{ij}) = v.

Then each output coordinate is a sum of ninn_{in} terms, so:

Var(hj)ninvσ2.\mathrm{Var}(h_j) \approx n_{in}\,v\,\sigma^2.

To keep variance stable across layers (Var(hj)σ2\mathrm{Var}(h_j) \approx \sigma^2), set:

v1nin.v \approx \frac{1}{n_{in}}.

This motivates Xavier-like scaling. For ReLU, roughly half the mass is zeroed, so to keep variance stable you use about twice the variance:

Var(Wij)2nin.\mathrm{Var}(W_{ij}) \approx \frac{2}{n_{in}}.

muP (Maximal Update Parameterization) extends this idea to updates: scale parameters and learning rates with width so that update magnitudes stay comparable across model sizes.

03

03

Code

Keep the implementation aligned with the notation so the algorithm is legible.

Section prompt
import numpy as np

rs = np.random.RandomState(0)

def run(depth=20, width=512, scale=1.0, relu=True):
    x = rs.randn(width)
    vars = []
    for _ in range(depth):
        W = rs.randn(width, width) * (scale / np.sqrt(width))
        x = W @ x
        if relu: x = np.maximum(x, 0)
        vars.append(float(x.var()))
    return vars

for name, scale in [("too small", 0.3), ("xavier-ish", 1.0), ("too large", 3.0)]:
    v = run(scale=scale)
    print(name, "var@layer1", round(v[0], 3), "var@layer20", round(v[-1], 3))
04

04

Interactive Demo

Use direct manipulation to connect the explanation to a moving system.

Section prompt

No interactive demo yet for this concept. A good next step is a small "signal propagation" visualization that shows activation variance and gradient variance vs depth for different init choices.

No live visualization is registered for this concept yet.

The page still supports explanatory demo notes above; when a viz.tsx exists, it will render here without changing the route.

After The First Pass

Turn the concept into an inspected object.

Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.

Mechanism Storyboard

See the idea move before the page explains it

How to pick weight scales so activations/gradients stay stable: Xavier/Glorot, He/Kaiming, and width-scaling ideas like muP.

Demo notes open01 / Intuition
Prediction lens

Start with the picture, metaphor, or geometric mechanism.

Commit first

Before reading further, choose the kind of change Weight Initialization: Xavier, He & muP should make visible.

Visual Inquiry

Make the image answer a mathematical question

How to pick weight scales so activations/gradients stay stable: Xavier/Glorot, He/Kaiming, and width-scaling ideas like muP.

3/4 stages readyDemo notes connected
Prediction

Which visible object should carry the first intuition?

Commit first

Pick the cue that should make Weight Initialization: Xavier, He & muP easier to reason about before the page gives the answer.

Claim Review

How to pick weight scales so activations/gradients stay stable: Xavier/Glorot, He/Kaiming, and width-scaling ideas like muP.

StatusSubstantive claim review pending

Source IDs and witness objects are attached for review; they are not proof by themselves.

SourcesNo references

Add source metadata before claiming support.

Witnesses3 local objects

Use equation, code, and demo objects to check whether the source support is operational.

Practice Loop

Try the idea before it explains itself

How to pick weight scales so activations/gradients stay stable: Xavier/Glorot, He/Kaiming, and width-scaling ideas like muP.

Readiness0/3 checks ready
Predict

Before touching the demo, predict one visible change that should happen in Weight Initialization: Xavier, He & muP.

Hint 1

Reveal when your model needs a nudge.

Hint 2

Reveal when your model needs a nudge.

Hint 3

Reveal when your model needs a nudge.

Object research drawerClose
ConceptWeight Initialization: Xavier, He & muPOptimization

Research Room

Attach the question to an exact object

Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.
Next local actionNo local draft saved yet

Open the draft below to save one note and next action in this browser.

conceptOptimization

Weight Initialization: Xavier, He & muP

Anchored question

What is the smallest example that makes Weight Initialization: Xavier, He & muP click without losing the math?

Local action draftNo local draft saved yetExpand only when ready to capture one local next action
Local action draft

This draft stays locally in this browser for concept:optimization/weight-initialization.

No local draft saved.
Evidence to inspect
  • Definition, prerequisite, and contrast concept links
  • The equation or code witness that makes the concept operational
  • One demo state that shows the invariant instead of a slogan
What would resolve this
  • The learner can state the mechanism in their own words
  • The learner can name the prerequisite that would repair confusion
  • The learner can predict how the mechanism changes under one perturbation
Grounded AI handoff

I am working in Continuous Function's research reading room. Object: concept - Weight Initialization: Xavier, He & muP Object key: concept:optimization/weight-initialization Context: Optimization Anchor id: concept/concept-notebook/optimization/weight-initialization Open question: What is the smallest example that makes Weight Initialization: Xavier, He & muP click without losing the math? Evidence to inspect: - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.

Open source object
concept/concept-notebook/optimization/weight-initialization concept:optimization/weight-initialization