ERA v5 · Session 1

Why Neural Networks Work

Four live experiments proving the foundations of deep learning — activations, depth, embeddings, and generalization — running entirely in your browser.

Experiment 01

Activations Exist for a Reason

A model with no nonlinearity can only draw a straight line. It cannot separate two concentric rings. Adding one ReLU hidden layer lets the boundary wrap around the inner ring — accuracy jumps from ~55% to ~99%.

Linear Model 1 layer · no activation
ReLU Model 2→16→1 · ReLU hidden
💡
Key insight: The linear model's boundary is literally a straight line — the weights can only define a hyperplane in 2D. The ReLU model pieces together multiple linear regions, carving out the inner ring. Only the activation changed. Everything else is identical.
Experiment 02

Depth Without Nonlinearity Is a Lie

Five stacked linear layers mathematically collapse into one linear map. A 5-layer linear network is no stronger than a 1-layer network — both draw the same straight-line boundary. Insert ReLUs and the five layers suddenly solve it.

1-Layer Linear 2→1 · sigmoid
5-Layer Linear no activations
5-Layer ReLU ReLU between layers
💡
Key insight: W₁W₂W₃W₄W₅ = W_eff — a single linear transformation. No matter how deep you stack linear layers, composition of linear functions is still linear. Nonlinearity is what makes depth meaningful.
Experiment 03

Embeddings Learn Similarity from Nothing but Next-Token

A model trained only to predict the next word in a tiny synthetic language spontaneously clusters animals with animals, fruits with fruits, verbs with verbs — no similarity labels were ever given.

Animals
catdogcow
Fruits
applemango
Verbs
eatchasesee
Template
[animal] [verb] [animal/fruit]
Embedding Space (PCA → 2D) learned from next-token only
Nearest Neighbors

Train to see clusters emerge

Training Loss
💡
Key insight: Tokens that appear in similar contexts have similar next-token distributions. Minimizing cross-entropy forces the embedding table to encode this structure. Semantic similarity is a side-effect of next-token prediction — it's never explicitly taught.
Experiment 04

Memorization vs Generalization

An over-parameterized model on tiny data drives training loss to zero while test loss stays high — it memorizes, not learns. Growing the dataset closes the gap. Data is everything.

n = 20 Memorization
n = 200 Transition
n = 2000 Generalization
Train vs Test Loss · All Three Runs generalization gap closes with data
Train Test Solid = n=2000 · Dashed = n=200 · Dotted = n=20
💡
Key insight: With n=20, the model has enough parameters to memorize every training point, so train loss → 0 but test loss stays high. With n=2000, the sheer variety of examples forces the model to learn the underlying structure. You cannot regularize your way out of too little data.