Optimizers interview question

Deep LearningOptimizersLoss Functionshard

A teammate multiplies a recommender's training loss by 100 so the dashboard shows larger numbers. For one weight the gradient has been steady at g = 0.004 per step. Compare plain SGD (lr = 0.01, no momentum) with Adam (lr = 10⁻³, default β and ε = 10⁻⁸) in steady state. How does each optimizer's step for this weight change, and what does that imply?

  1. ASGD: 4×10⁻⁵ becomes 4×10⁻³; Adam: about 10⁻³ becomes about 10⁻², because v̂ grows by 100 and its square root by 10, so Adam damps the change without removing it; reuse Adam's old lr divided by 10.
  2. BBoth steps grow 100×, from 4×10⁻⁵ and 10⁻³ respectively, because every first-order optimizer moves in proportion to the gradient; dividing both learning rates by 100 recovers the original training run.
  3. CSGD: 4×10⁻⁵ becomes 4×10⁻³; Adam: stays about 10⁻³, because m̂ and √v̂ both scale by 100 and cancel. Adam's old lr therefore carries over, while SGD needs its lr divided by 100 to train as before.
  4. DSGD: 4×10⁻⁵ becomes 4×10⁻³; Adam: stays about 10⁻³. Because Adam ignores the scale of the gradient, the weights λ in a multi-term loss L₁ + λ·L₂ have no effect under Adam either, so they need no tuning.
Show the answer and explanation

Correct answer: C, SGD: 4×10⁻⁵ becomes 4×10⁻³; Adam: stays about 10⁻³, because m̂ and √v̂ both scale by 100 and cancel. Adam's old lr therefore carries over, while SGD needs its lr divided by 100 to train as before.

Explanation Optimizers

Adam's update is Δθ = −η · m̂ / (√v̂ + ε), with m̂ the running mean gradient and v̂ the running mean squared gradient. Scaling the loss by c scales every gradient by c, so m̂ → c·m̂ and √v̂ → c·√v̂: the ratio is unchanged, apart from ε, which matters only when √v̂ is about as small as ε.

Before (g = 0.004)After (g = 0.4)
SGD, η = 0.010.01 · 0.004 = 4×10⁻⁵4×10⁻³ (100×)
Adam, η = 10⁻³, steady gη · 0.004 / (0.004 + ε) ≈ 10⁻³η · 0.4 / (0.4 + ε) ≈ 10⁻³ (unchanged)

Practical consequences:

  • Reusing a learning rate. With SGD, a loss rescale (including switching reduction from mean to sum at a fixed batch size) changes the effective learning rate by the same factor. With Adam the old lr carries over.
  • Loss weighting. Adam only cancels a global scale per parameter. In L₁ + λ·L₂, the shared backbone sees a mixture of both gradients, so λ still changes the direction and balance of its updates. Only parameters touched by a single term (such as one head) become insensitive to that term's scale.
  • Gradient clipping thresholds and ε are not scale-invariant, so after a large rescale they behave differently.

Why the distractors fail: v̂ averages squared gradients, so it grows by 100² and its root by 100, not 10. Adam's step does not grow with the gradient, unlike SGD's. And scale invariance does not extend to relative loss weights on shared parameters.

Interview tip: "With Adam the learning rate sets the step size in parameter units, roughly independent of loss scale; with SGD the step is learning rate × gradient."

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More Deep Learning questions

  1. In neural network training, what is an epoch?
  2. What is the ReLU activation, and why is it a popular default for hidden layers?
  3. In neural network training, what is backpropagation?
  4. What does dropout do while a neural network is being trained?
  5. What does a 2-D convolutional layer compute at each output position?