Gradients and Hessians in tangent charts
The gradient of a scalar function and its Hessian product, read in the tangent charts a retraction provides, and why the passes of automatic differentiation compute them unchanged.
The first note reads the derivative of a map between manifolds in tangent coordinates, as a matrix, and computes it through a retraction. This note reads the first and second derivatives of a scalar function the same way: its gradient as a vector, and its second derivative along a direction. Each is what an optimizer or a sampler needs at a point, and none needs a metric. It ends by showing that the passes of automatic differentiation compute them unchanged.
By Proposition 3, derivatives in tangent coordinates compose exactly as Jacobians do, so the passes apply to a program whose steps are maps between manifolds, as long as each step’s derivative is read in tangent coordinates, by Proposition 10. The transpose of a derivative is taken in coordinates: a cotangent at is a column of numbers acting on tangent coordinates, and maps it to a cotangent at . No inner product on the tangent spaces is involved.
The gradient#
For a scalar function , its gradient in the chart at is
the cotangent that a reverse pass seeded with delivers. It says how changes along a step: . With no metric in play, it is the differential of written in chart coordinates, not a Riemannian gradient.
The Hessian product#
The second derivative needs a choice that the first does not, because moving along a direction moves the chart as well. The chart Hessian differentiates the gradient along a direction , reading the gradient at each point in that point’s own chart. It compares the tangent coordinates at nearby points, so it is defined where is smooth near (Proposition 7), which this note assumes from here on:
The other candidate is the Hessian of the pull-back , which keeps the chart at fixed. On a flat manifold the two are the same matrix, the ordinary Hessian. On a curved one they differ by a term proportional to the gradient.
Let be smooth near , and let and , defined near for small . Then
so at every stationary point, where .
For small and near , , with the identity and by (9). So near , and
Differentiating at , with and , gives the claim.
∎On the rotations, with the retraction , the Baker–Campbell–Hausdorff formula gives , up to terms of order and , so the correction is : the chart Hessian is the Hessian of the pull-back plus the skew-symmetric matrix , and it is not symmetric away from a stationary point. On the positive reals, with , the charts commute instead: , whose derivative does not move with , so the correction vanishes and the two Hessians agree everywhere. Which symmetric matrix to use where they differ, if one is needed, is the algorithm’s decision. At a stationary point, which is where curvature is most often read (a Laplace approximation, a Newton step’s convergence), the two agree.
Programs over manifolds#
The chart Hessian is the one a forward-over-reverse pass computes, provided each step’s second-order map is read in charts the same way.
Let a program’s steps be maps between manifolds, with partial derivatives taken in tangent charts. Then for a scalar target , the reverse pass delivers the chart gradient at the roots. If moreover is smooth near each slot’s value, and each step’s second-order map at its inputs , with velocities , is
then forward-over-reverse with velocities delivers the chart Hessian product .
First order is Proposition 3 applied step by step. For the second, the reverse recurrence holds identically in , with every evaluated at the slot values computed from and read in the charts at those values. Differentiate it along . Each slot traces a curve through whose velocity in the chart at is , the velocity the forward pass computes. The derivative of the smooth function along a curve depends only on the curve’s velocity, so it equals the derivative along , which is . The product rule then gives the forward-over-reverse recurrence, and at a root the differentiated quantity is , whose derivative is (2).
∎Built on by
- Queries and programs A query names what to compute from a snapshot and what is observed; compiled for a device and a precision, it becomes a program whose passes give values, tangents, gradients and Hessian-vector products in tangent charts.
- Product manifolds A product of manifolds is a manifold whose tangent space stacks its factors', and whose retraction acts factor by factor; derivatives in its charts are block matrices of the factors'.
- Quotients by a finite group A manifold divided by a finite group that acts freely is a manifold again, and a retraction that commutes with the group descends to it, so that a point of the quotient is computed with through any of the points over it.
- The normal distribution in a chart The normal on a manifold with a global chart is the law of a point moved from its mean by Gaussian noise through the chart; its density is the Gaussian's less the chart's log-volume, its sampler is exact, and its expected information has a closed form, exact on flat and positive spaces and in the scale's block on curved ones.
- Newton's method and trust regions A smooth function on a manifold is minimized by steps that each minimize a quadratic model of it in the chart at the current point; Newton's model has the function's own curvature and converges quadratically, any other curvature with the exact gradient converges to the same points at a linear rate, and a trust region keeps the step where the model can be believed, judging it by the ratio of the decrease obtained to the decrease promised.
- Linearization and elimination: Mathematics How a query of a model is linearized at a point into factors of whitened rows and linear terms over its free quantities' tangent coordinates, and how eliminating those factors gives the step of a Gauss–Newton or Levenberg–Marquardt method, a Laplace approximation's marginals, and a retirement's replacement, an improper Gaussian that is the update and prediction of a Kalman filter when it determines the blanket; and how the roots of the expected information give a second assembly, for Fisher scoring of free scales.
- Rotations and rigid motions: Mathematics The rotations as unit quaternions with the stereographic chart, global and full with a declared volume so that they carry the normal, the rigid motions SE(3) and SE₂(3) as their semidirect products with the left-translated chart, and the usual maps of all three, each a composite of the core's operations.
- Normal distributions: Mathematics skoro's one normal distribution, the law of a point moved by normal noise through its chart, defined on every space whose chart is global and whose volume is known, so that flat, positive and curved quantities alike, measurements among them, are drawn and scored exactly; with its scale, its sampler, its properties, its expected information, its roles, and its use as a likelihood factor.
- The core: Mathematics The mathematics the core rests on, from quantities, their charts and their products, through operations and their derivatives of first and second order composed over programs, to queries, terms, importance weights, random keys and retirement.
- The core: Implementation Three crates (skoro-tensor, skoro-core and skoro) in which a model is built inside a writer's scope from typed quantities and operations, read as two graphs, compiled per query for a device and a precision, and differentiated to second order in tangent charts.