Sideways Against Forward

OptimizersHard+30 XP+30

Sideways Against Forward

Two weights sit in the kind of narrow valley this chapter keeps returning to: steep across, shallow along.

  • The along weight runs down the valley floor. Its gradient is +0.5+0.5+0.5 at every step.
  • The across weight runs between the steep walls. Every step overshoots the floor and lands on the opposite wall, so its gradient alternates: +6, −6, +6, −6, …+6,\ -6,\ +6,\ -6,\ \dots+6, −6, +6, −6, …

To isolate what each optimizer does with the gradients it is handed, assume both weights keep receiving exactly this pattern for thousands of steps, whichever optimizer is running. Two optimizers are compared.

Plain gradient descent, learning rate 0.010.010.01: each weight moves by 0.01×g0.01 \times g0.01×g.

Adam, learning rate 0.0010.0010.001, default memory settings. Each weight keeps its own two memories, both starting at 000. At step t=1,2,3,…t = 1, 2, 3, \dotst=1,2,3,… it receives gradient ggg and does

m←0.9 m+0.1 g(direction memory)m \leftarrow 0.9\,m + 0.1\,g \qquad \text{(direction memory)}m←0.9m+0.1g(direction memory)

s←0.999 s+0.001 g2(size memory)s \leftarrow 0.999\,s + 0.001\,g^2 \qquad \text{(size memory)}s←0.999s+0.001g2(size memory)

step size=0.001×∣ m / (1−0.9t) ∣s / (1−0.999t)\text{step size} = 0.001 \times \frac{\left|\,m \,/\, (1 - 0.9^t)\,\right|}{\sqrt{s \,/\, (1 - 0.999^t)}}step size=0.001×s/(1−0.999t)​∣m/(1−0.9t)∣​

The two divisions by 1−0.9t1 - 0.9^t1−0.9t and 1−0.999t1 - 0.999^t1−0.999t are the bias correction from the lesson. The tiny constant that real implementations add to the denominator is negligible here and left out.

For either optimizer, define its sideways-to-forward ratio as

size of the across weight’s stepsize of the along weight’s step\frac{\text{size of the across weight's step}}{\text{size of the along weight's step}}size of the along weight’s stepsize of the across weight’s step​

measured once the run has gone on long enough for this ratio to settle.

How many times smaller is Adam's settled sideways-to-forward ratio than plain gradient descent's?

Give a whole number.

Hints

Solve it to unlock the solution

Once you get it right, the reasoning behind the answer shows up here.