The Maths You Actually NeedLesson 26 of 76

Module 3 · Change, slopes and the walk downhill

Reading a training failure from the numbers

In this lesson

  • 9 min read
  • 9 reading sections
  • Knowledge check
  • Lesson 8 of 9 in this chapter

This chapter’s goalCompute a partial derivative and a chain-rule derivative by hand, trace a gradient backwards through a two-layer network and say where the memory goes, and diagnose from a loss curve and a gradient-norm plot whether the learning rate, the curvature or a vanishing gradient is the cause.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
Four training failures, and the mechanism behind eachWhat the two logged numbers showLoss fine, then NaN within a few hundred stepsLoss flat from step one, gradient norm at ornear zeroLoss falls for a while, then spikes sharplyTraining loss falls while validation lossrisesWhat is actually happeningA gradient exploded, or an exp or a logoverflowedDead ReLUs, or a tensor detached from thegraphThe optimiser reached sharper curvature at theold rateNot an optimisation failure at all: the modelis overfittingOnly the last is invisible in the gradient norm, because nothing is going wrong with the descent: itis succeeding at the wrong objective. The other three are three different problems with threedifferent fixes, and the loss curve on its own cannot tell them apart.
Only the last is invisible in the gradient norm, because nothing is going wrong with the descent: it is succeeding at the wrong objective. The other three are three different problems with three different fixes, and the loss curve on its own cannot tell them apart.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 10Free · no account needed
Lesson steps

Four failures and their signatures

Training goes wrong in a small number of recognisable ways. Each has a mechanism from the earlier lessons in this module, and each has a signature you can see if you log the right two numbers.

Log these from the first run, always:

Python
grad_norm = sum(p.grad.pow(2).sum() for p in model.parameters() if p.grad is not None).sqrt()

plus the loss, and if you can, the mean absolute activation at a couple of layers. Three numbers, and they separate the four cases below.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Stuck on something?Ask Funke, your AI tutor

How to cite: Addaly (2026) ‘Reading a training failure from the numbers’, in The Maths You Actually Need. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/maths-you-need/when-gradients-vanish-or-explode (Accessed: 29 November 2026).