Skip to main contentfinslerax

Learned metrics

A learned metric replaces a prescribed formula for F with a parametrised model. JAX can differentiate many geometric outputs back to that model, but the observations still decide which parts of the metric are identifiable.

The inverse problem

Everything so far has run in one direction: the metric was given, and the geometry followed from it. In an inverse problem the metric is unknown. What exists instead is a record of what happened — vessels took these routes and arrived at these times, a fire reached these places on these days, an arm executed these motions and drew this much current — and the question is which geometry accounts for it.

Metrics are Equinox modules, and their floating-point arrays are JAX PyTree leaves. Losses can therefore differentiate through the metric and through the solvers that provide a derivative rule. The eikonal solvers, for example, differentiate their converged fixed point with an implicit adjoint, so backward-pass memory does not grow with the number of forward sweeps.

Loading learned-wind…

learned-wind

Step through a training run recovering an unknown current from four observed tracks — positions against time, so the record carries the timings and not only the routes. The loss is the mean squared distance between each observed track and the one the estimated current would produce, shot forward from the same start and heading. The slider shows the fitted field and its predicted tracks over one recorded training run.

Three ways to make a metric learnable

NeuralRanders, NeuralRiemannian
Networks predicting the metric at a point: a positive-definite field for the sea and a vector field for the wind, with the causal bound applied by the parent class. The direct option when the domain is the space of interest — a map, a terrain, a configuration space — and the geometry on it is what is wanted.
PullbackRanders, PullbackRiemannian, PullbackGNet
The Riemannian part is the regularised decoder pullback G(z) = J(z)ᵀJ(z) + εI, with J from jax.jacfwd; PullbackRanders adds a learned wind. The decoder is stored in the module and must be frozen explicitly when that is the intended training setup. Latent distance then measures change after decoding rather than coordinate distance alone.
CovariateConditionedRanders, KernelWindField
Condition the metric on an observed field — terrain, fuel, a measured current — so the geometry is a function of covariates and transfers to a scene it was not fitted on. KernelWindField is the non-parametric alternative: a Nadaraya–Watson average of anchor velocities, useful when there are observed pseudo-velocities but no reason to impose a functional form.

What paths cannot determine

Write the metric in affine form F=α+βF = \alpha + \beta and suppose β\beta is exact, β=df\beta = df. For any curve γ\gamma from aa to bb,

∫γF  =  ∫γα  +  ∫γdf  =  ∫γα  +  f(b)−f(a),\int_\gamma F \;=\; \int_\gamma \alpha \;+\; \int_\gamma df \;=\; \int_\gamma \alpha \;+\; f(b) - f(a),

and the added term is the same for every curve joining the same two points. The functional being minimised therefore differs from the Riemannian one by a constant on each fixed-endpoint class, so FF and α\alpha have the same geodesics as curves — the same images, traversed on different schedules, since the two are parametrized by their own constant speeds. Whatever β\beta is doing, it is not bending any route.

A loss that observes only unparametrised path images therefore cannot identify an exact admissible one-form. It is constant along the corresponding infinite-dimensional family, irrespective of how many path shapes are added. An optimiser may choose a member through initialisation or regularisation, but the data have not selected it.

The invariance preserves path shape but not path cost. Relative to the symmetric metric, a journey from aa to bb changes in cost by f(b)−f(a)f(b) - f(a). More directly, comparing a curve with the same curve reversed cancels the symmetric contribution and gives 2 (f(b)−f(a))2\,(f(b) - f(a)). If the symmetric costs are known, timed journeys supply the same endpoint differences; paired measurements of the same route in opposite directions supply them without that assumption. The sum of the two directions, by contrast, cancels the exact term. A connected network of differences recovers the sampled values of ff up to one additive constant.

This distinction is useful whenever a directional cost contains a potential difference: that exact component changes endpoint costs without bending fixed-endpoint minimisers. A general wind or current need not be exact and can therefore alter the observed path shape as well.

Staying inside the theory while training

The supplied neural metrics are built on constrained families rather than a free scalar network. NeuralRiemannian predicts a positive-definite tensor.NeuralRanders predicts that tensor and a wind, then uses the smooth rescaling described on the Randers page to keep ∥W∥h<1\lVert W \rVert_h < 1. The validity conditions are therefore part of the parametrisation rather than soft penalties.

For a metric that is a network from the start the same guarantees are not in place. A general FF has no reason to satisfy F(x,λv)=λF(x,v)F(x,\lambda v) = \lambda F(x,v), and no reason to be strongly convex either, and a function failing either condition is not a Finsler metric however well it fits. The library documents both as requirements on metric_fn and does not currently enforce either for an arbitrary learned FF; a homogeneous construction of the form F(x,v)=∥v∥⋅net(x,v/∥v∥)F(x,v) = \lVert v \rVert \cdot \mathrm{net}(x, v/\lVert v \rVert)enforces homogeneity away from zero, but does not by itself ensure positivity or strong convexity. That construction is specified but not implemented in the pinned release; a custom family must currently be validated by its author.

  • finslerax.training supplies geometry-aware loss components rather than a single objective: terms matching observed paths, terms matching arrival times, residuals of the Euler–Lagrange and spray equations, alignment terms in the Zermelo parametrization, and regularisers on the metric itself. GeodesicLearningSolver is the geodesic solver in the form used when paths are part of the objective and gradients have to pass through the solve.

    TrainingPipeline runs multi-phase schedules with per-phase parameter freezing. This is useful when the symmetric tensor and the wind can compensate for one another: fitting them in separate phases can make that ambiguity easier to control than updating both from a cold start.