A visual exploration of optimization

One landscape, four ways down. Begin with the gradient, add memory, learn a scale, then learn the geometry itself.

01

The overview

Four ways to read a slope

step 0 / 180 loss —
A noisy, curved loss landscape
  • gradient
  • update
  • minimum
θ₁
θ₂

Start with the slope

Stochastic gradient descent

SGD trusts the current mini-batch gradient. It is cheap and honest—but one global learning rate must serve every direction.

\[\begin{aligned} g_t&=\nabla_\theta\mathcal{L}(\theta_t;\mathcal{B}_t),\\ \theta_{t+1}&=\theta_t-\eta g_t \end{aligned}\]

The orange arrow is the raw gradient; the blue arrow is the step it produces.

gradient norm
update norm

The through-line

Each step adds structure: SGD reads the slope, Momentum remembers direction, Adam rescales coordinates, and Shampoo learns rotations between them. The destination is fixed; the geometry of getting there is not.

Primary notes Adam Shampoo
02

Beyond the plane

What does 24-dimensional optimization look like?

Follow one \(6\times4\) tensor through its trajectory, loss, parameters, and learned geometry.

Correlated tensor loss \[\mathcal{L}(W)=\tfrac12\lVert AWB\rVert_F^2,\qquad W\in\mathbb{R}^{6\times4}\] \[A\in\mathbb{R}^{6\times6},\qquad B\in\mathbb{R}^{4\times4}\]

The matrices \(A\) and \(B\) couple rows and columns. Adam can scale each of the 24 entries; Shampoo can also learn which entries move together.

step 0 / 140 loss —
Adam loss
Shampoo loss
01

PCA of the loss geometry. Each state becomes \(Z=AWB\), where \(\mathcal{L}=\tfrac12\lVert Z\rVert_F^2\), and the two most informative directions form the view.

02

Every coordinate at once. The \(6\times4\) heatmap fades toward paper as the parameter tensor approaches zero.

03

Structure becomes visible. Shampoo’s row and column statistics reveal correlations that a diagonal second moment cannot represent.

03

Inside the update

What changes between a gradient and a step?

Compare four increasingly expressive views of gradient information: observation, memory, scale, and geometry.

Mini-batch gradient
batch 01 · 12 samples
01 / 96

Observe

A batch estimates the slope

Individual samples disagree. Their average reveals a useful direction without removing the noise entirely.

\[g_t=\frac{1}{|\mathcal B_t|}\sum_{i\in\mathcal B_t}\nabla_\theta\ell_i(\theta_t), \qquad \mathbb E[g_t]=\nabla_\theta\mathcal{L}(\theta_t)\]

Samples form the cloud. The batch mean becomes \(g_t\).

  1. 01gradientsignal
  2. 02memorytime
  3. 03scalecoordinates
  4. 04geometrycorrelations