Quick recap
The key takeaways of every lesson on one page. Read it in ten minutes to refresh the whole track; open a lesson when a point feels unclear.
01 Reverse-mode autodiff
- The derivative of at is a linear map . The JVP pushes a direction forward (); the VJP pulls a cotangent back ().
- The VJP is defined by for all . To derive one: write , then move everything in away from .
- Key VJPs: gives , ; gives , ; gives .
- Reverse mode visits the tape in reverse order and adds the cotangents of a value that is used more than once (fan-out). It is back substitution on a triangular system.
- A full Jacobian needs forward passes or reverse passes, each a small constant times the cost of . For a scalar loss, one reverse pass gives the whole gradient.
- Reverse mode pays in memory: the tape keeps every intermediate value a VJP needs.
- Check gradients in float64 with central differences in a random direction, with ; a bug shows as an error floor that does not move with .
02 Time stepping and stiffness
- A one-step method has order if its local truncation error is ; consistent + stable gives a global error . Measure as the slope of against .
- On the test equation a method multiplies by per step, . It is stable at if .
- (forward Euler), (backward Euler), (trapezoid / Crank–Nicolson). Forward Euler on the real axis: .
- Every explicit method has a bounded stability region. A-stable: the whole left half-plane is stable. L-stable: also (backward Euler yes, Crank–Nicolson no).
- For a system, every (eigenvalues of the Jacobian) must lie in the stability region. For explicit diffusion this gives in 1-D.
- CFL condition: the numerical domain of dependence must contain the exact one; for upwind advection . It is necessary, not sufficient.
- A problem is stiff when stability, not accuracy, sets the step. Then use implicit, IMEX or exponential methods.
03 Adjoints and neural ODEs
- The adjoint ODE is with the final condition , solved backward in time; then and .
- The adjoint method costs about one extra (backward) solve for any number of parameters; finite differences cost solves and forward sensitivities () about .
- A residual network is forward Euler for the neural ODE ; the adjoint method is backpropagation in time.
- The discrete adjoint (backprop through the solver steps, discretize-then-optimize) is the exact gradient of the computed loss; the continuous adjoint (optimize-then-discretize) differs from it by .
- Backsolve re-creates backward with memory, but every mode that decays forward grows backward, so it fails for damped or stiff problems; the adjoint equation itself is stable.
- Uniform checkpointing stores states and recomputes the rest; memory is smallest at , for less than one extra forward pass, and the gradient is unchanged.
- ODE trajectories cannot cross, so a 1D neural ODE can only learn increasing maps; augmented neural ODEs add dimensions.
04 Inverse problems and seismic imaging
- An inverse problem recovers a model from data . It is ill-posed when a solution fails to exist, to be unique, or to depend stably on the data (Hadamard); most inverse problems in science fail stability.
- For linear , the naive solution divides the noise by , so small singular values make it useless; the discrete Picard condition says must decay faster than .
- Tikhonov regularization multiplies each component by the filter factor , which is at ; truncated SVD uses .
- Choose with the discrepancy principle (), the corner of the L-curve, or GCV.
- Tikhonov is the MAP estimate for noise and prior ; the posterior covariance is , and with general Gaussians the cost is 3D-Var.
- Gauss–Newton solves at each step; in earthquake location the station geometry sets the conditioning of and the shape of the uncertainty ellipse.
- The adjoint-state method gives with : one forward and one adjoint solve per source, for any number of parameters. For FWI, .
- FWI cycle-skips when the predicted arrivals are wrong by more than about half a period; inverting low frequencies first widens the basin of the correct model.
05 Chaos, DMD and SINDy
- A fixed point is classified by the eigenvalues of the Jacobian there: real parts decide growth or decay, imaginary parts decide rotation. Lorenz-63 has three fixed points, and all are unstable.
- The Lyapunov exponents are for the tangent propagator . A bounded system with is chaotic; for Lorenz-63, .
- The sum of the Lyapunov exponents is the time average of (Liouville's formula), and a flow that does not stop at a fixed point has one zero exponent.
- An error reaches the size after : a 10 times smaller starting error adds only of forecast time.
- The Koopman operator is linear on observables even when is not; a Koopman eigenfunction evolves as . Chaotic systems have no exact finite Koopman-invariant subspace.
- Exact DMD fits through a rank- SVD without forming ; its modes are eigenvectors of , and each eigenvalue gives the growth rate and the angular frequency .
- SINDy writes with a sparse and finds it by sequentially thresholded least squares; the threshold must lie between the largest spurious and the smallest true coefficient.
06 Data assimilation
- Data assimilation is Bayes' rule: the analysis (posterior) is proportional to forecast (prior) × observation likelihood. For one variable, with and .
- The Kalman update follows from Gaussian conditioning: , , . and do not depend on the value of .
- An unobserved variable changes only through its forecast covariance with the observed quantities.
- The Kalman filter alternates the forecast step , and the analysis step; it is exact for linear-Gaussian models, but it is too costly for .
- The stochastic EnKF uses the sample covariance of members and perturbed observations (without them the analysis spread misses ); its increments lie in at most directions.
- Localisation () removes spurious long-range correlations and raises the rank; inflation () fixes underdispersion but keeps the span and the correlations.
- 3D-Var and 4D-Var compute the MAP estimate; for linear models the 3D-Var minimum is the Kalman mean and the Hessian is .
- The 4D-Var gradient is from one backward sweep : one forward and one adjoint run, whatever the size of the state.
07 Gaussian processes and UQ
- A Gaussian process is a distribution over functions: any finite set of values is jointly Gaussian with covariance . The length scale sets how fast the function varies; sets its size.
- GP posterior: with . It is Gaussian conditioning, and its covariance does not depend on .
- A new measurement has variance ; intervals without are too narrow.
- Compute with one Cholesky factor : , with , and . Never form or .
- Log marginal likelihood (data fit, complexity, constant). Its gradient is ; it can have several local maxima.
- A scoring rule is proper when the honest forecast minimises the expected score. The CRPS is strictly proper, has the units of , and equals the absolute error for a point forecast.
- Calibration: PIT values are uniform; a U shape means too narrow, a hump means too wide. Coverage checks several levels. The aim is maximum sharpness subject to calibration.
08 Spectral methods and FNO
- On a periodic grid, is multiplication by in Fourier space; the spectral derivative is , with the Nyquist mode set to zero for odd derivatives.
- Spectral accuracy: for analytic periodic functions the error falls like , faster than any power of ; with finitely many derivatives only like a power of .
- Aliasing: on points, modes and have the same samples, so .
- Orszag's 2/3 rule: for a quadratic term, keep with ; then the pseudo-spectral product is exact on the kept modes.
- Dealiased pseudo-spectral Burgers conserves energy for and dissipates it for , like the PDE; aliasing can create energy and blow up an under-resolved run.
- Cole–Hopf, , turns viscous Burgers into the heat equation and gives exact test solutions.
- An FNO Fourier layer multiplies the lowest modes by learned matrices ; its weights do not depend on .
- The Fourier layer is exactly discretisation-invariant for band-limited input; pointwise activations alias, so the full FNO is only approximately invariant.
09 Spherical harmonics and SFNO
- A latitude–longitude grid is not a periodic image: latitude is not periodic, and the rows near the poles hold many points on a small area.
- The real spherical harmonics (, ) are orthonormal on the sphere; has meridian nodal lines and latitude nodal lines.
- Spherical harmonics are eigenfunctions of the Laplacian: on the unit sphere, on radius ; so derivatives, Poisson solves and diffusion are multiplications per degree.
- The triangular truncation has real coefficients and the same resolution everywhere on the sphere.
- Compute with the normalised three-term recursion, never with factorials.
- A -node Gauss–Legendre rule is exact up to degree ; with Gauss latitudes and longitudes, the SHT (FFT in longitude, then Legendre quadrature) is exact for fields.
- A rotation maps the degree- coefficients by an orthogonal matrix ; so the power spectrum is rotation-invariant, and a filter that depends only on commutes with rotations.
- The SFNO layer is the FNO layer with the SHT: a learned channel matrix per degree, independent of , plus a pointwise skip and activation.
10 Equivariant networks
- A map is equivariant if for all ; energy is E(3)-invariant and forces are E(3)-equivariant, because the gradient of an invariant function is equivariant.
- Translations are handled by using only relative positions ; the real work is the group = rotations plus the inversion.
- The irreps of are the degrees with dimension ; adds a parity:
0escalar,0opseudoscalar,1ovector,1epseudovector,2esymmetric traceless matrix. - The real Wigner-D matrix is defined by ; it is an orthogonal representation, and in the order.
- Schur's lemma: an equivariant linear map between different irreps is zero, and between equal (real ) irreps it is ; so equivariant linear layers only mix channels within each degree and parity.
- Clebsch–Gordan: , parities multiply, and two vectors give (dot, cross, symmetric traceless).
- Nonlinearities act on scalars; higher degrees are multiplied by invariant gates or by functions of their norm.
- Test equivariance with random of both determinants and random shifts; an exact model gives errors at rounding level, and the test must be able to fail.
11 PINNs and failure modes
- PINN loss: , with the residual computed by automatic differentiation with respect to the inputs.
- Second derivatives need nested reverse sweeps (
create_graph=True) and a smooth activation; ReLU gives . - For advection, : a small residual guarantees a small error, so a failed PINN is a training failure, not a capacity failure.
- At large the residual term grows like and the zero field has a far lower loss () than the frozen initial condition ().
- Spectral bias: gradient descent fits low frequencies first, so fast oscillations in are learned slowly.
- Fixes: curriculum in , time marching over short windows, and causal weights treated as constants.
- For a clean forward problem a classical solver is far more accurate and cheaper; PINNs suit inverse problems with sparse data and a known PDE.
- Data misfit plus residual penalty is weak-constraint 4D-Var with the network as the trajectory.
12 SDEs and Fokker–Planck
- Brownian motion has independent increments . Its quadratic variation tends to while its total variation is infinite; in short, .
- Euler–Maruyama: with the coefficients at the left point; this defines the Itô SDE .
- Itô's lemma: is an Itô process with drift and diffusion coefficient . The term is the Itô correction.
- GBM has : mean growth rate , median growth rate .
- The OU process is Gaussian with mean and variance ; its stationary law is .
- Fokker–Planck: ; stationary densities have zero flux, and has the Gibbs density .
- Euler–Maruyama has strong order 1/2 (1 for additive noise) and weak order 1; Milstein adds and has strong order 1.
13 Score matching and diffusion
- The score points toward high density and does not depend on the normalising constant of .
- Denoising score matching: , because the marginal score is the posterior mean of the conditional score; the minimum is not zero.
- Tweedie's formula: ; learning to denoise and learning the score are the same task.
- Noising SDE : VE (, here , noise level ) and VP (an OU process); the marginals are the data convolved with a Gaussian.
- Reverse-time SDE (Anderson 1982): , run from to , has the same marginals .
- Probability-flow ODE: has the same marginals; it is deterministic, invertible and gives exact likelihoods.
- Both samplers follow from writing the Fokker–Planck equation as a continuity equation; any noise level between them also works.
- In practice: Euler–Maruyama for the SDE, Heun (second order) for the ODE, a geometric grid in , and a start from .
14 Flow matching and OT
- Flow matching learns the velocity of an ODE from noise () to data () by regression on the conditional target along straight lines ; no ODE is solved during training.
- Marginalization trick: generates the path , and the CFM loss equals the FM loss plus a constant (the conditional variance), so both have the same gradients.
- With an independent coupling, lines cross and the learned paths bend; for noise and data one Euler step sends every sample to .
- Rectified flow (re-pairing with the flow's own end point ) does not increase any convex transport cost; for the squared cost the drop is , and reflow straightens the paths.
- 1D optimal transport is sorting; for Gaussians, (Bures).
- Entropic OT has the plan ; Sinkhorn alternates row and column scalings (log domain for small ), and its cost is above the exact one by at most .
- Pairs of an optimal plan for the squared cost never meet at the same time, so OT paths are straight and one Euler step is exact; minibatch OT moves the coupling part of the way toward this.
15 Flow matching on the sphere
- The tangent plane of at is , with the projection ; the geodesic distance is , and geodesics are great circles at constant speed.
- , and with and ; they are inverse for .
- is undefined at the antipode (the cut locus of ), and its direction jumps near it.
- The geodesic conditional path is slerp, and its velocity is , with constant speed .
- The Riemannian CFM loss regresses a tangent model on ; it has the same gradient as Riemannian flow matching, needs no simulation on the sphere, and is the CFM of lesson 14 in .
- Plain Euler steps leave the sphere (); exponential-map steps or projected steps (a retraction) keep samples on it.
16 ML weather and climate models
- An ML weather model learns the map from reanalysis data (ERA5, made with 4D-Var) and rolls it out to 10–15 days; families differ in how they move information on the sphere (mesh GNNs, 3D transformers, SFNO, hybrid physics–ML, diffusion ensembles).
- Rollout fine-tuning trains on several autoregressive steps with the gradient through all of them, so the model learns to handle its own errors; it cannot remove chaotic error growth.
- Forecast errors grow with lead time and level off: a single forecast near , an ensemble mean near the climatological .
- Theorem 1: , so MSE training produces the smooth conditional mean, and a sharp realistic forecast pays the double penalty (twice the floor).
- On a latitude–longitude grid, weight each row by its area, ; poleward of 60° are 33.6 % of the rows of the 0.25° grid but 13.4 % of the area.
- The fair ensemble CRPS is unbiased for the CRPS of the member distribution; the standard version punishes small ensembles.
- Theorem 2: for a perfect -member ensemble, skill² spread², so spread/skill (0.953 for ).
- A fair comparison fixes the test year (WB2: 2020), the ground truth, the grid and regridding, the time convention and the units, and tests differences with paired scores and a block bootstrap.