Functional transcendentals + scalar-affine: proofs and runtime regression checks #
Positive / negative example for the nn.functional.{exp, log, scale, shift, affine}
ops added for scientific forward models — e.g. the soil-moisture retrieval that
combines SMAP (Soil Moisture Active Passive) and NISAR (NASA–ISRO Synthetic
Aperture Radar) observations through the AVS (Attenuation–Volume–Surface) model,
whose surface term is $\exp(-2b\,\mathrm{NDVI})\,c\,|R|^2$.
The point is that these ops are differentiated by the autograd engine, so a forward model written once yields its gradient with no hand-coded derivative. This file has two layers:
- a proof layer handle for the real-valued
expop, usingProofs.Autograd.OpSpecFDerivCorrect.expand the genericbackward_eq_adjoint_fderivtheorem; - runtime regression checks that differentiate tiny Float functions and compare the autograd gradient to the closed form.
The runtime checks below are not the proof. They make sure the executable tape path used by scientific examples still follows the expected derivative numerically. The proof layer declarations show where the corresponding theorem-backed op-spec story lives.
Each runtime check differentiates a tiny function and compares the autograd gradient to the closed form:
- positive controls — the gradient matches the analytic value;
- negative controls — a deliberately wrong analytic value (notably the wrong-sign gradient of $\exp(-2x)$) does not match. That is exactly the defect class — a sign/factor error in a hand-coded Jacobian — that deriving the gradient by autograd eliminates.
checkAll runs as a compiled executable — lake exe transcendentals_check — and
exits non-zero on any regression. It is deliberately not an #eval check:
autograd uses the native tape externs, which the interpreter cannot load (see the
main entry point below).
Proof objects and runtime checks #
The theorem-backed real-valued exp op used by the proof layer.
This is the actual proof layer object: it packages the forward op, its JVP, a Fréchet-derivative candidate, and the theorem that the JVP is the true derivative. The runtime checks below exercise the executable Float tape; this declaration points to the corresponding real-valued theorem.
Instances For
For scalar exp over ℝ, the proved backward rule is the adjoint of the Fréchet derivative.
This is the theorem-level statement that the executable regression check is meant to complement.
Functions under test (written once; gradients come from autograd) #
$f(x)=e^{-2x}$ — the shape of the AVS canopy two-way transmittance as a function of the attenuation parameter.
Instances For
$f(x)=3x+1$ via the scalar-affine op.
Instances For
Float checks #
Absolute-tolerance float compare.
Instances For
Differentiate a scalar→scalar Fn at a Float point, returning the gradient.