Convergence diagnostics
Quick answer
Convergence diagnostics are measurements that help decide whether an optimizer is improving, stalled, unstable or finished. Inspect objective values, gradient magnitude, parameter changes and validation performance separately. A stopping rule is a practical decision, not a general proof of optimality.
Read a trace instead of trusting one value
For J(w)=(w-3)², start at 7 and use η=.25. Track the iteration, objective and absolute gradient before each update. A gradient tolerance of .5 stops once |2(w-3)| ≤ .5. A maximum step budget makes the procedure bounded even if it fails to converge. In larger models use a defined gradient norm and report whether it is computed before or after the update. Relative loss change can be useful when objectives have different scales, but flat traces can indicate tiny step sizes or numerical saturation rather than optimality.
w=7.0for step in range(11): loss=(w-3)**2 g=2*(w-3) print(step, loss, abs(g)) if abs(g)<=0.5: break if step<10: w-=0.25*gExpected output (local Python 3.13.5):
0 16.0 8.01 4.0 4.02 1.0 2.03 0.25 1.04 0.0625 0.5The gradient criterion is satisfied after four updates, not at the exact minimum. The trace records the initial value as iteration zero.
Training improvement is not validation improvement
Suppose a fictional training run records the following losses at five checkpoints. Select the checkpoint with the smallest validation loss. In a real experiment, keep the final test set separate from checkpoint selection. A patience rule stops after a specified number of consecutive validation evaluations without meaningful improvement; define minimum improvement, tie handling and whether best parameters are restored. For noisy metrics compare across seeds and report uncertainty. A nonfinite loss is a failure signal, not a successful stopping criterion; check inputs, gradients, step size and stable loss computation before retrying.
import mathtrain=[5.0,3.0,2.0,1.0,0.5]valid=[5.5,3.4,2.5,2.7,3.2]best=min(range(len(valid)),key=lambda i:valid[i])print(best,train[best],valid[best])print(math.isfinite(float("inf")))Expected output (local Python 3.13.5):
2 2.0 2.5FalseCheckpoint index 2 has the lowest validation loss despite later training improvement. Infinity is not finite.
Common mistakes
Do not tune stopping rules against the final test set. Do not label every flat loss curve as convergence. Compare optimization traces at equal definitions and evaluation cadence; report stop reason, iteration count and budget. A small gradient can occur at a saddle or local maximum, and constraints can change the appropriate stationarity criterion.
Practice and next steps
Run the chapter milestone with four rates. Explain which traces converge, oscillate or diverge using the error multiplier. Change the starting point to the optimum and explain why the trace alone cannot expose an unstable rate. Next, continue to the following planned chapter.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Convergence diagnostics — knowledge check
Apply optimization reasoning to synthetic examples.
What should a maximum update budget prevent?
When may a tiny parameter change be misleading?
Which checkpoint is selected from validation losses [4,2,3]?
What is a suitable response to a nonfinite objective?
What does satisfying a gradient tolerance establish?