3.2.12 · D1Training Deep Networks

Foundations — L1 - L2 weight decay in deep nets

1,860 words8 min readBack to topic

This page assumes you know nothing. Before you can read the parent note L1 / L2 Weight Decay, every symbol it throws at you must first be built from the ground up. We go one symbol at a time, each resting on the last.


1. What is a "weight"? The symbol

The picture. Imagine a knob on a mixing board. Turning it up makes one input signal louder in the final output; turning it down mutes it. Each is one such knob. A deep net has millions of knobs.

Why the topic needs it. The entire note is about controlling the sizes of these numbers. If you don't know is "the dials we tune", nothing else makes sense.

Figure — L1 - L2 weight decay in deep nets
  • The subscript in just means "the -th knob". = the third knob.
  • A scalar is a single number (). A vector is an ordered list of numbers () — think of it as one point whose coordinates are all the knob positions at once.

2. "How big is the weight vector?" — the norm

The penalty measures bigness. To penalize size, we must first say what "size of a vector" means. That measurement is called a norm, written with double bars .

The picture. Stand at the origin and put a point at .

  • Straight flight (L2): .
  • Taxi ride (L1): .

Same point, two rulers. The topic uses both rulers because they penalize weights in geometrically different ways — and that difference is the whole L1-vs-L2 story.

Figure — L1 - L2 weight decay in deep nets
  • The symbol ("sigma-sub-i") is shorthand for "add up over every ". . It is just an addition machine, nothing scarier.
  • The bars mean absolute value — throw away the minus sign. . We use it because a weight of is just as "big" as .

3. What does "good" mean? The loss

The picture. Picture a hilly landscape. The horizontal ground = all possible knob settings . The height at each spot = the loss . Training walks downhill toward a valley.

Why the topic needs it. Weight decay changes this landscape. The parent note writes the new landscape as (J-with-a-tilde) — the original loss plus a penalty. Everything else is a comparison between and .


4. Slope of the landscape — the gradient

To walk downhill you need to know which way is down. That direction is the gradient.

The picture. Standing on a hillside, the gradient is the arrow pointing straight up the steepest slope. Water flows the other way. Each component answers: "if I nudge only knob , how fast does the loss change?"

  • The symbol (nabla) is just "collect all the slopes into one arrow".
  • ("partial derivative with respect to ") means "the slope in the direction, holding all other knobs fixed." A derivative is a rate of change — how much output moves per tiny wiggle of input.

Why we need a derivative here. We want the fastest way down a many-dimensional surface. The derivative is the one tool that answers "which direction changes the loss most, and how fast" — no other quantity gives us a direction to move. See Gradient Descent for the full machinery.

Figure — L1 - L2 weight decay in deep nets

5. How big a step? The learning rate

The picture. Down the hill, is your stride length. The update rule reads: "move each knob a little bit () in the downhill direction ()." The arrow means "replace the left value with the right" — it is an assignment, not an equation.

Why the topic needs it. The famous shrink factor that makes "weight decay" decay is built from multiplied by the penalty strength. Without there is no decay.


6. How hard to penalize? The strength

The picture. A seesaw. On one side sits "fit the data" (lower ); on the other sits "stay small" (lower ). is how much weight you drop onto the "stay small" side. This is the bias–variance tradeoff made adjustable — see Bias-Variance Tradeoff and Overfitting and Generalization.

  • Too small → overfitting (weights memorize noise).
  • Too large → underfitting (weights all near zero, network too dull).
  • Tune it on a validation set.

7. Putting it together — , , and

  • = the penalty function — a number that grows when weights grow.
  • (tilde-J) = the new landscape the optimizer actually walks on.
  • = a helper returning if , if , at zero. It appears because the slope of is on the right and on the left — a constant push whose only information is the direction toward zero. That constant-size push is the seed of L1 sparsity.

Prerequisite map

Weight w a tunable number

Norm size of weight vector

Loss J how wrong we are

Gradient grad J which way is down

Learning rate eta step size

Lambda penalty strength

Update rule move the weights

Penalty R w L1 or L2

Regularized loss J tilde

Sign function pushes toward zero

L1 L2 Weight Decay

Every arrow says "you must understand the source before the target makes sense." The final node is the parent topic itself.


Once these symbols are solid, the parent note connects out to: Gradient Descent (the walk downhill), Maximum a Posteriori (MAP) Estimation (the Bayesian "why" of penalties), Lasso and Ridge Regression (L1/L2 in linear models), Adam and AdamW Optimizers (why decay ≠ L2 for adaptive methods), and Dropout (a different anti-overfitting tool).


Equipment checklist

Test yourself — cover the right side and answer before revealing.

What is a weight ?
One tunable number (a "dial") inside the network; the collection is a vector .
What is the L2 norm geometrically?
Straight-line (Pythagorean) distance of the weight point from the origin: .
What is the L1 norm geometrically?
Taxi-cab distance — sum of absolute values ; its "unit ball" is a diamond.
What does the loss measure?
How wrong the network's predictions are for the current weights; lower is better.
What does the gradient point toward, and which way do we step?
It points uphill (steepest increase); we step in the opposite direction .
What does the learning rate control?
The size of each downhill step (stride length).
What does trade off?
Fitting the data (small ) against keeping weights small (small ) — the bias–variance dial.
What does return and why does it matter?
or by the sign of ; it is the slope of , a constant-size push toward zero that creates L1 sparsity.
What does the arrow mean in an update rule?
Assignment — replace the old value with the newly computed one.
What is ?
The regularized loss — the new landscape the optimizer actually descends.