Vanishing gradients: causes, effect on training, and common fixes
Company: Pinterest
Role: Machine Learning Engineer
Category: Machine Learning
Difficulty: medium
Interview Round: Technical Screen
In the machine learning fundamentals part of a screen, you are asked about the vanishing gradient problem in deep neural networks, in three parts: why it happens, how it affects training, and how it is commonly addressed.
### Clarifying Questions
- Should the answer cover recurrent networks, where gradients flow back across time steps, as well as deep feedforward networks?
- Is a chain-rule derivation expected, or an intuitive explanation backed by a concrete example?
### Part 1 — Why gradients vanish
Explain what causes gradients to shrink as they are propagated back through a deep network.
```hint Follow the chain rule
Write the gradient for a weight in an early layer as a chain-rule product over the layers above it, and look at the size of each factor.
```
#### What This Part Should Cover
- The backpropagated gradient as a product of per-layer factors (activation derivatives and weights)
- Why saturating activations and small weight scales shrink that product as depth grows
- The same effect across time steps in recurrent networks
### Part 2 — Effect on training
What happens to training when gradients vanish, and how would you recognize it?
```hint Which layers learn
Compare how much the weights near the input and near the output change per update.
```
#### What This Part Should Cover
- Which layers stop learning and what the network then effectively becomes
- Effects on convergence, the loss curve and long-range dependencies
- Diagnostics that separate this problem from other causes of slow training
### Part 3 — Common fixes
What are the common ways to prevent or reduce vanishing gradients, and why does each one help?
```hint Attack each factor
For each factor in the chain-rule product, think of a design choice that keeps it close to one, or a way for the gradient to skip the product.
```
#### What This Part Should Cover
- Activation functions and weight initialization
- Architectural changes such as normalization, residual connections and gated recurrent units
- The limits and costs of each remedy, and how they differ from fixes for exploding gradients
### What a Strong Answer Covers
- A correct chain-rule explanation that links cause, symptom and remedy
- A concrete numerical illustration of how quickly the gradient shrinks with depth
- Clear separation of vanishing gradients from exploding gradients and from other reasons training is slow
- Trade-offs of each remedy rather than a list of names
### Follow-up Questions
- ReLU's derivative is exactly one for positive inputs. Why can deep ReLU networks still be hard to train, and what is a dead ReLU?
- Why does a residual connection let the gradient reach early layers? What does it add to the Jacobian of a block?
- Gradient clipping is a standard fix for exploding gradients. Why does it not help with vanishing ones?
- Why do LSTMs suffer less from vanishing gradients than plain recurrent networks?
Overview: A machine learning fundamentals question on vanishing gradients in deep and recurrent networks, covering why gradients shrink during backpropagation, how this slows or stalls training, and which common remedies help. It tests chain-rule reasoning about activations, initialization, normalization, and residual or gated architectures.
Read the full Pinterest Machine Learning Engineer interview experience this question came from