Log inStart free
LESSON 36.03 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Pruning and sparsity

Zero out a trained net's small weights, retrain it, and count what it saves.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 36.03 · PRUNING BAY80 WEIGHTS · 198 B · ACCURACY 94%
01
Stage 1 of 6 · Dense weights
The teacher stores 80 weights in W1 and W2. A larger square shows a larger weight.
Explain it simply

The test grid shows the teacher's guess for each test point. Blue marks are right and red marks are wrong. In W1 and W2, each square is one weight, and a bigger square is a bigger weight. A hollow square is a negative weight.

Left: the test grid, 159 of 169 guesses right. Right: W1 with 2 rows and W2 with 3 rows, one column per hidden unit, 16 columns. Square size shows the size of each weight.

inputs x₁, x₂, training pointsweights (solid +, hollow −), cut, shared valuesright guesses, classes, accuracywrong guessesweights to remove, pruned weights (0), the cut, unused shared values, true class borders, the teacher
−3−30033x₁x₂dense weightsthe teacher's guesses on the test grid159 of 169 right · accuracy 94%80 weights + 19 biases = 99 parametersW1 · input → hidden unitW2 · hidden unit → classx₁x₂class 0class 1class 212345678910111213141516unit−3−30033x₁x₂dense weightsthe teacher's guesses on the test grid159 of 169 right · accuracy 94%80 weights + 19 biases = 99 parametersW1 · input → hidden unitW2 · hidden unit → classx₁x₂class 0class 1class 212345678910111213141516unit
Toy: the 36.C1 teacher (2-16-3, 80 weights), 72 training points, a 13 × 13 test grid; fine-tuned in the browser
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
z=W2 tanh⁡(W1x+b1)+b2\sy{z}{out}{z} = \sy{w2}{param}{W_2}\,\tanh(\sy{w1}{param}{W_1}\sy{x}{data}{x} + b_1) + b_2
80 weights+19 biases=99, right=159/16980\ \text{weights} + 19\ \text{biases} = 99,\ \text{right} = 159/169

Two weight matrices turn a point into 3 class scores.

Common mix-ups

MYTHHalf the weights at zero makes the net twice as fast.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01At 75% sparsity, does fine-tuning bring accuracy back to 94%?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.