3.2.5 · D1Training Deep Networks

Foundations — Adam and AdamW optimizers

1,831 words8 min readBack to topic

This page assumes you have seen nothing. We name every letter, draw the picture it stands for, and say why the topic can't live without it. Read top to bottom — each item uses only the ones above it.


0. What are we even doing? (parameter, loss, gradient)

Before any Greek letters, picture the whole job.

The subscript (as in , ) just means "at time step " — step 1, step 2, step 3… One minibatch of data = one .


1. The base move: SGD and the learning rate

The simplest possible rule, Stochastic Gradient Descent, is: Read the arrow as "becomes": the new knob value is the old one minus a step of size in the downhill direction. That minus sign is why we go down the hill, not up.


2. The averaging tool: the EMA and its decay

Adam never trusts a single noisy gradient. It keeps a running smoothed value. The tool for that is the exponential moving average.

Why is this the exponential moving average? Unrolling the recursion, the value from steps ago is multiplied by — and shrinks like a decaying exponential. See Exponential Moving Average for the full unrolling; Adam uses it twice.

The parent note calls (beta raised to the power ) the "bias factor" — that is just multiplied by itself times, and because , it shrinks toward as grows. Hold that thought; it powers bias correction.


3. Two EMAs: direction () and magnitude ()

Adam runs the EMA machine on two different streams.

The little hats — and — are the bias-corrected versions, and . Because , the raw EMAs start too small; dividing by un-shrinks them. The parent note proves this exactly; here just know: a hat means "fixed for the cold start."


4. The remaining small symbols

The figure shows the ratio as a signal-to-noise dial: consistent gradients (mean size) give a full step near ; noisy gradients (mean size) give a step near . That normalization is the reason Adam adapts per-parameter.


Prerequisite map

parameter theta

SGD update

loss L

gradient g

learning rate eta

EMA with decay beta

first moment m direction

second moment v magnitude

bias correction hats

Adam update

AdamW adds lambda decay

Each arrow means "you need the left box before the right one makes sense." Notice how everything funnels through the gradient — that single arrow is the whole reason optimizers work.


Equipment checklist

Cover the right side and test yourself.

What does the knob physically represent?
One tunable number (weight) inside the network; the same update runs on every one.
What single number is , and what do we do to it?
The loss — a badness score we try to make small.
What two facts does the gradient carry?
Its sign (which way is uphill) and its size (how steep).
Why do we step against (the minus sign)?
points uphill; we want to go downhill toward lower loss.
What does the learning rate control?
The length of each step.
Write the EMA recursion from memory.
, with .
What does near do to the EMA's memory?
Makes it long / very smooth / slow to react.
What stream feeds vs ?
gets the gradient ; gets the squared gradient .
What does a "hat" () signify?
Bias-corrected — un-shrunk to fix the cold start from .
Why divide by and not ?
The square root restores original gradient units so numerator and denominator match.
What two jobs does do?
Prevents divide-by-zero and caps the maximum effective step.
What does control in AdamW?
The strength of uniform weight decay pulling each weight toward zero.