Debugging Training Convergence with SageMaker Debugger
This lesson explains the ways training can fail to converge and how SageMaker Debugger detects many of them automatically while a job runs.
Learning outcomes
After completing this lesson, you will be able to:
- Relate convergence symptoms to causes.
- Use SageMaker Debugger built-in rules.
- Apply the typical fix for each convergence problem.
Symptoms and causes
Divergence, where loss grows or becomes NaN, usually comes from a learning rate that is too high, exploding gradients or unscaled inputs. A flat loss from the start suggests a learning rate that is too low, vanishing gradients in deep networks, saturated activations, dead ReLU units or a data problem such as shuffled labels. Oscillation suggests a learning rate or batch size problem. A plateau followed by no improvement may need a learning-rate schedule. Validation loss rising while training loss falls is overfitting rather than a convergence failure.
The following diagram compares gradient size by layer in a 30-layer network before and after the fix for vanishing gradients.

SageMaker Debugger
SageMaker Debugger captures tensors (weights, gradients, losses) during training and evaluates built-in rules in parallel: vanishing_gradient, exploding_tensor, loss_not_decreasing, overfit, overtraining, poor_weight_initialization, saturated_activation, dead_relu and class_imbalance, among others. Rules publish status to CloudWatch and can trigger actions such as stopping the training job or sending a notification, which saves cost when a run is clearly failing. Custom rules can be written too.
Debugger rules
Fixes
Each convergence problem points to a typical cause. A loss that does not decrease often means the learning rate is too low, the data is not shuffled or the labels are wrong. Exploding values usually mean the learning rate is too high or the inputs are not scaled. Vanishing gradients in deep networks call for different activation functions, better initialisation or normalisation layers, and overfitting calls for regularisation or more data. The following table maps convergence symptoms to the usual fixes.
| Symptom (Debugger rule) | Fix |
|---|---|
| Exploding tensor / NaN loss | Lower learning rate, gradient clipping, normalise inputs |
| Vanishing gradient | ReLU-family activations, batch normalisation, residual connections, better initialisation |
| Loss not decreasing | Raise learning rate, check labels and data pipeline, check initialisation |
| Saturated activation / dead ReLU | Change activation (Leaky ReLU), lower learning rate, normalise |
| Overfit / overtraining | Early stopping, regularisation, more data |
A network that will not learn
A failing deep network
A 30-layer network's training loss stays flat at its initial value for hours. Debugger flags vanishing_gradient on early layers, which use sigmoid activations.
- Replace sigmoid with ReLU activations and add batch normalisation between layers.
- Use He initialisation suited to ReLU.
- Configure the Debugger rule action to stop the job automatically if the rule fires again.
Loss now falls steadily. Raising the learning rate alone would not have helped, because gradients were close to zero by the time they reached the early layers.
What causes a flat loss in a deep network, and what helps?
Show answer
Vanishing gradients. ReLU activations and batch normalisation help.
Exam Tips
Remember for the exam
- NaN or growing loss: exploding gradients or learning rate too high; clip gradients.
- Flat loss in deep networks: vanishing gradients; ReLU, batch normalisation.
- Automatic detection during training: SageMaker Debugger built-in rules.
- Debugger rule actions can stop a failing job to save cost.
- Rising validation loss with falling training loss is overfitting, not divergence.