Laplace approximation tutorials¶
These eight standalone Jupyter notebooks demonstrate Laplace HypoPINN from data preparation through training, curvature fitting, posterior sampling and plotting. Read the HTML lessons below to see the explanations, code and six saved figures without running Python. Each lesson also links its editable notebook on GitHub. Start with GGN diagonal to learn the corrected residual-Jacobian workflow, or historical diagonal to study notebook compatibility.
| HTML lesson and notebook | What you will implement and inspect |
|---|---|
| 01 · Historical diagonal · Notebook | Fit the archived loss-gradient statistic from resampled batches; compare marginal parameter spread with damping alone. |
| 02 · GGN diagonal · Notebook | Build weighted residual Jacobians and diagonal precision; inspect precision and marginal standard deviations. |
| 03 · GGN block diagonal · Notebook | Retain exact within-layer GGN blocks; visualize precision couplings while omitting between-layer correlations. |
| 04 · Full GGN · Notebook | Fit dense GGN with a memory budget; inspect between-layer couplings and sample using Cholesky factors. |
| 05 · KFAC · Notebook | Use coordinate jets to fit Kronecker factors for derivative residuals; inspect factor and product spectra. |
| 06 · EFB · Notebook | Replay residuals in a fixed KFAC eigenbasis; inspect the corrected GGN diagonal entries in that basis. |
| 07 · INF · Notebook | Select EFB eigenpairs and fit diagonal-plus-low-rank precision; examine retained rank and clipped diagonal remainder. |
| 08 · VaLLA · Notebook | Fit fixed inducing residuals variationally; plot objective history and coherent linearized predictive fields. |
The method reference gives the equations and source papers. EFB is an EKFAC-style correction; the maintained KFAC, INF and VaLLA implementations have explicit PINN-specific conventions. They are research adaptations, not claims to reproduce every result of their source publications.
Run a notebook¶
After the repository installation, activate the same virtual environment and run these commands from the repository root:
python -m pip install -e '.[notebooks]' jupyterlab
python -m ipykernel install --sys-prefix --name laplace-hypopinn --display-name 'Laplace HypoPINN'
jupyter lab examples/notebooks
Choose the Laplace HypoPINN kernel and run Restart Kernel → Run All. No GPU, downloaded data, earlier notebook or cached checkpoint is required. The analytic velocity model supplies synthetic receiver observations and reference fields. The notebook index in the repository records the tested execution environment.
Read the figures and assumptions¶
Each lesson plots velocity and receiver geometry, convergence and receiver fit, reference and trained fields with signed error, method-specific diagnostics, field spread and sampled source locations, and a travel-time cross-section. Coordinates are in km and travel time in seconds; depth increases downward.
The teaching configuration retains the EX2 Mish network with 2,737 parameters, seed 4321 and a 101 × 151 grid. It uses 800 training updates, 512 collocation points and 64 posterior draws. Historical diagonal uses 64 curvature batches, INF retains up to eight directions per layer, and VaLLA uses 32 inducing rows with 100 variational updates. These are teaching budgets, not full reproduction settings.
Posterior regularization is post-hoc damping because training uses no parameter prior. The cross-section band is sample mean ± two sample standard deviations, not a calibrated 95% interval. VaLLA evaluates linearized predictions; all other lessons evaluate nonlinear models at sampled weights. Each complete sampled field reuses one parameter perturbation across its grid chunks.
Extend a lesson¶
Change the configuration cell and rerun training and fitting to investigate different widths, depth or budgets. The architecture guide defines custom-model contracts, including the coordinate-derivative adapter needed for KFAC/EFB/INF. Consult performance measurements before scaling dense methods and reproduction settings before comparing with the historical experiments. The original notebooks remain preserved separately.