Classify a critical point from its Hessian

Why it matters Understanding saddles versus minima explains why gradient descent slows on plateaus and why curvature-aware optimisers and noise help training escape.

At a point where the gradient is zero, the Hessian tells you whether you are at a minimum, a maximum or a saddle. Saddles are everywhere in neural network loss surfaces.

Write classify_critical_point(H, tol=1e-9). H is a symmetric (d, d) Hessian. Compute its eigenvalues with np.linalg.eigvalsh. Return "min" if all eigenvalues are > tol, "max" if all are < -tol, "saddle" if at least one is > tol and at least one is < -tol, and "degenerate" otherwise (some eigenvalue within tol of 0 and no sign conflict).

Signaturedef classify_critical_point(H, tol=1e-9)

Example

H [[2, 0], [0, -3]] gives "saddle".

Understand the idea

At the bottom of a bowl, at the top of a hill and at the centre of a horse saddle, the ground is flat: the gradient is zero. To tell them apart, look at the curvature. The Hessian's eigenvalues are the curvatures along special directions.

All positive: every direction curves up, so it is a minimum. All negative: a maximum. Mixed: up in some directions and down in others, a saddle.

Worked example: f(x, y) = x^2 - 1.5 y^2 has Hessian [[2, 0], [0, -3]] at the origin. Eigenvalues 2 and -3 have mixed signs, so it is a saddle: walking along x goes uphill, along y goes downhill. For [[2, 1], [1, 2]] the eigenvalues are 1 and 3, so it is a minimum. For [[-2, 0], [0, -1]] the determinant is +2, just like a minimum, but both eigenvalues are negative, so it is a maximum. That is why the determinant alone is not enough.

Rule: classify by the signs of eig(H); any eigenvalue near 0 without mixed signs is degenerate.

In deep learning, most zero-gradient points are saddles, not bad minima.

solution.pyPython idle
Ctrl/Cmd + Enter runs sample tests

Run checks the first 2 tests. Submit checks all 5.

  • Sample 1: exampleclassify_critical_point([[2, 0], [0, -3]])
  • Sample 2: bowlclassify_critical_point([[2, 1], [1, 2]])
  • Test 3: hilltopclassify_critical_point([[-2, 0], [0, -1]])
  • Test 4: flat directionclassify_critical_point([[1, 0], [0, 0]])
  • Test 5: 3d saddleclassify_critical_point([[1, 0, 0], [0, 2, 0], [0, 0, -1]])