Differentiation and Optimization Geometry
Compute the sensitivity; then ask what the local geometry permits.
On this page
A training loss depends on many intermediate quantities and parameters. Differentiation tells us how a small change propagates through those computations. Optimization then chooses a finite update. These are connected operations, not the same question.
Start with coordinate slices and local rules. Combine them into a graph, add every backward path, and interpret the resulting gradient. Only then use curvature to distinguish steepness, stationary points and possible escape directions.
Local change before optimizer choice
A derivative is local. A negative first-order prediction does not prove that a large update lowers the loss. Curvature, nonsmooth boundaries and changes in the data can invalidate a distant extrapolation.
Differentiability is stronger than having some coordinate derivatives. The gradient-based linear approximation needs the appropriate regularity. ReLU boundaries and other nonsmooth points require an explicit derivative/subgradient convention.
Partial derivatives and coordinate slices
For , and . At (2,3), f=30 and . The two partials are the slopes of the surface's coordinate slices.
If y itself depends on x, the total derivative also includes the path through y: . Holding y fixed and moving along a curve are different experiments.
For , the two parameter sensitivities are and . Plain gradient descent computes both at the same old (w,b), then updates them together.
Products add two paths of change
Think of a rectangle with sides f and g. Its area change is gΔf+fΔg+ΔfΔg. The small corner is second order in the input change, so it disappears after division by the step and a limit.
For x²sin(x), the derivative is . The two terms arise because x reaches the product through two factors. A graph's repeated input therefore needs the sum of both backward contributions.
Compositions multiply local rates
If temperature changes by 2°C/hour and a sensor changes by .5 units/°C, its reading changes by 1 unit/hour. Multiplying the rates both propagates sensitivity and checks units.
For at x=.5: a=.25, b=sin(a)=.247404, h=exp(b)=1.280696. The local rates are 2x=1, cos(a)=.968912 and exp(b)=1.280696. Their product is 1.240883.
A deep model composes vector operations, not only scalar functions. The same rule applies, with Jacobians and sums over intermediate coordinates. Associativity permits efficient grouping; matrix multiplication generally does not commute.
Values go forward; sensitivities come back
The same scalar graph can have one chain or an added edge a→L. An adjoint is ∂L/∂node. All incoming backward contributions must be added.
No extra edge: only c contributes to L.
Backward: a=x² sends 2x times a's total adjoint to x. .
Exact scalar illustration, not a trained network. Playback follows operation order; x and output expression remain fixed. Zero adjoints before their propagation mean not yet accumulated, not necessarily a final zero derivative.
Jacobians and vector–Jacobian products
At a scalar node v, its adjoint is . Reverse traversal applies for each parent u. The += matters when several children depend on the same u.
For a scalar loss with many parameters, reverse mode computes all parameter gradients in one backward traversal. Forward mode instead pushes an input-direction tangent through the graph, producing Jv. Choose the mode by input/output dimension and the requested derivative product.
Reverse mode needs forward values for local derivatives. Saving them costs memory; recomputation trades compute for storage. These choices affect execution, not the derivative identity.
Automatic differentiation and checks
Automatic differentiation evaluates local derivative rules on the executed program. It is neither symbolic simplification of the whole function nor a finite-difference approximation, although floating-point arithmetic still introduces rounding.
A small PyTorch reference computes the chain derivative. This snippet is illustrative; the pure numerical model is tested separately.
import torch
x = torch.tensor(0.5, dtype=torch.float64, requires_grad=True)
a = x.square()
h = a.sin().exp()
h.backward()
# x.grad is approximately 1.2408826092PyTorch backward ↗ accumulates leaf gradients. Reset or intentionally accumulate them between passes. A nonscalar output needs an output seed of matching shape; summing outputs is one particular scalar objective, not a neutral substitute.
A numerical check uses . Compare several step sizes in high precision away from nonsmooth points. Large ε has truncation error; very small ε has cancellation. For vectors, a directional check compares that quotient along d with .
Detached tensors, in-place modification of saved values, ignored branches or custom backward rules can change what the program differentiates. A plausible loss curve is not a derivative correctness test.
Steepest direction depends on the norm
The gradient collects the coordinate sensitivities into one column vector. Its Euclidean norm combines those components into a length.
Negative normalized gradient gives Euclidean steepest descent. A different norm, metric or parameter scaling can give a different steepest direction. This distinction matters when comparing preconditioned updates.
For , the norm is 5, unit ascent is [.6,.8] and unit descent is [−.6,−.8]. The norm is the largest directional derivative among Euclidean unit directions, not a promise that every small displacement changes f by that amount.
At zero gradient there is no unique steepest first-order direction. The zero vector is the gradient, not a defined unit direction. Momentum, stochasticity or higher-order structure can still produce movement; not every optimizer automatically stops.
A descent direction is not a safe finite step
A large gradient with a large learning rate can overshoot. Small gradient norm can mean a useful stationary region, bad scaling, cancellation or a plateau. It does not distinguish these cases on its own.
For with λ>0, the update is . This scalar quadratic converges when . At the upper boundary it oscillates without reducing magnitude; above it, magnitude grows. Gradient direction is unchanged, but finite-step stability is not.
Clipping preserves a nonzero gradient's direction while reducing its magnitude. It can prevent a large update, but it does not correct NaNs, a wrong derivative or an unsuitable objective. Gradient Clipping reference → retains the training-specific implementation conditions.
Curvature classifies stationary points
At an interior stationary point, removes the linear Taylor term. The Hessian gives the quadratic term, which can vanish in some or all directions. Diagonalize the symmetric Hessian: in an orthonormal eigenbasis.
| Hessian signature | Conclusion |
|---|---|
| All eigenvalues positive | Strict local minimum |
| All negative | Strict local maximum |
| Positive and negative | Saddle |
| Some zero, no definitive mixed-sign test | Higher-order analysis may be needed |
Positive curvature away from a stationary point does not mean the current point is a minimum. Positive semidefinite curvature at a stationary point is necessary for a smooth local minimum, but it is not sufficient. x⁴ has a strict minimum with zero second derivative; −x⁴ has a maximum with the same zero second derivative.
One negative eigenvalue rules out a smooth local minimum. To call a nondegenerate critical point a saddle rather than a maximum, it must also have positive curvature. A constrained boundary requires a different stationarity and feasible-direction analysis.
One point, several possible directions
Every example is stationary at the origin. Horizontal axis: displacement r from −1 to 1. Vertical axis: Δf on a fixed scale, with the zero line through the burgundy origin.
Negative curvature: moving away from zero along this slice lowers f.
Exact toy functions. Angle sweeps are not optimizer trajectories. A flat quadratic slice in the saddle does not make the entire Hessian zero.
Index and coordinate invariance
For f(x,y)=xy, the Hessian is [[0,1],[1,0]]. Both coordinate-axis curvatures are zero, yet its eigenvalues are ±1. With and , . Mixed terms can hide an escape direction.
An invertible linear coordinate change preserves the positive/negative/zero counts of a quadratic form. Eigenvalue magnitudes need not remain the same under arbitrary scaling. At a stationary point, smooth local coordinate changes preserve this signature; away from stationarity, extra Hessian transformation terms matter.
High dimension is not a landscape model
Two different claims must stay separate: critical points occupy little ambient volume, and minima are uncommon among critical points. For a Morse function, nondegenerate critical points are isolated. This volume-zero fact already appears in one dimension; it does not establish saddle dominance.
The second question needs a sampling model over functions or critical points. Merely writing does not specify it. Gradient-zero events can have probability zero at a fixed random location, so a conditional density or point-counting construction is needed.
A minimum requires every curvature direction to be nonnegative, and every eigenvalue positive in the nondegenerate case. Mixed signs supply both up and down directions. But dimension alone determines neither sign distribution nor optimizer behavior.
For example, has exactly one critical point, its global minimum, in any dimension. It has no saddles. This strongly convex example rules out a universal dimension-only claim.
What the GOE result actually says
The Gaussian Orthogonal Ensemble (GOE) models a centered real symmetric random matrix with Gaussian entries and an appropriate normalization. Its limiting eigenvalue density is symmetric around zero, so a large centered matrix usually has many eigenvalues of each sign.
Dean and Majumdar ↗ report the Gaussian-ensemble N² exponent. It describes a specified matrix ensemble. A landscape Hessian can correlate with the loss value and gradient; conditioning on a low value can shift its spectrum upward.
Do not turn a vanishing fraction into zero absolute count. A landscape can have increasingly many minima while saddles grow faster. Nor does uniformly counting critical points match how an optimizer visits their attraction regions.
Counting points requires conditional weighting
The gradient density locates candidate zeros; the determinant weights their local Jacobian volume change; the indicator selects an index. Counting minima sets k=0, while nondegenerate saddles sum k=1 through N−1.
This determinant-weighted conditional expectation explains why sampling an unconditional GOE matrix is not the same as sampling a typical landscape critical point. Gaussian field and spin-glass calculations can use random-matrix tools, but their conditioning and energy regimes remain part of the result.
Morse theory organizes the local geometry
A Morse function has nondegenerate critical points. The Hessian's invertibility isolates such a gradient zero locally. This is a structural statement, not a probability estimate.
The Morse lemma gives local coordinates with k negative squares and N−k positive squares at an index-k point. It explains why index is the invariant. It does not by itself prove that saddles outnumber minima.
The linked landscape article also connects index to topology as a level set crosses a critical value. That reference is useful for the topological extension; the optimization argument here remains conditional on the landscape model.
Translate geometry into training diagnostics
Real neural losses have parameter symmetries, degenerate directions, structured data and nonsmooth operations. A random-Hessian model can provide intuition without being an empirical diagnosis of a particular run.
| Signal | What it can support | What else to inspect |
|---|---|---|
| Small gradient norm | Small local first-order change in this metric | Loss scaling, clipping, update norms, curvature |
| Large norm | Large possible Euclidean directional rate | Batch reduction, outliers, step size, numerical errors |
| Negative Hessian direction | A local escape direction at stationarity | Magnitude, feasible directions, optimizer noise |
| Near-zero eigenvalues | Weak quadratic curvature | Higher orders, symmetry and parameterization |
| Training loss decreases | The chosen objective improved on these batches | Validation, generalization and actual update behavior |
Separate full-objective gradients from minibatch estimates. Stochastic gradients need not shrink to zero near a population optimum. Per-parameter rescaling can also change gradient norm without changing the represented function.
Gradient-norm training reference → and batch/LR reference → own run-specific scaling and update choices. Losses and Objectives → defines what those derivatives measure.
Sources and related owners
Hessians, random landscapes and Morse points ↗ · Gaussian-matrix large deviations ↗ · Autograd backward ↗