KatInterview

Why Early Layers Stop Learning: Diagnosing Tiny Gradients

Machine LearningModel answer
HardModel answerMachine Learningdeep-learningbackpropagationvanishing-gradients

Last updated

Explain why gradients can shrink as they flow backward through depth or time, how to detect it, and which fixes apply to which architectures, without confusing it with convergence.

Early layers that barely update

You are training a neural network and notice that the layers closest to the input (or the earliest time steps of a sequence) change very little from one step to the next, while the layers near the output keep learning.

Write up how you would handle this. Your answer should:

  1. Describe the vanishing-gradient problem and show mathematically why it can arise. Pick one setting, either a deep feed-forward network or a recurrent network, and say which you chose.
  2. Explain how you would tell apart two situations: (a) backpropagated gradients that are tiny because signal is being lost along the path, and (b) gradients that are small because the model has reached a good minimum with low loss.
  3. Lay out a diagnostic workflow: what you would measure, and what other bugs could look similar.
  4. List remedies. No architecture or activation function is given, so state which remedies depend on those choices.
  5. Explain why an intervention that improves gradient flow does not by itself show that the model generalizes better, and how you would evaluate the change properly.

Hints

Hint 1

Write the gradient for an early layer as a product of per-layer Jacobians. What happens to the norm of that product if each factor has norm below 1, and how do activation derivatives and weight scale enter?

Hint 2

Small gradients at a good optimum come with low training loss and small gradients everywhere. Vanishing gradients show a sharp decay in gradient norm as you move toward the input while the loss stays high or plateaus. Compare per-layer gradient norms and relative update sizes.

Hint 3

Split fixes into groups: activation choice, initialization, normalization, residual or gated connections, and optimizer or clipping choices. Then ask which of these are only meaningful for certain architectures, and how you would validate the result on held-out data.