API reference¶
Generated by scripts/gen_api_docs.py from the docstrings (make docs regenerates it) — do not
edit by hand. Each subpackage has its own page (the sections below); objects are documented in the
module that defines them, and nefi/__init__.py re-exports the most common ones
(nefi.InverseProblem, nefi.Solver, nefi.invert, nefi.from_forward, ...). See
DESIGN.md for the contracts and paper_mapping.md for the paper →
code map.
nefi¶
nefi— nefi — Neural-Field Inversion.nefi.auto— Adaptive defaults — from your differentiable forward model to a ready-to-solve problem.nefi.cli—neficommand-line interface.nefi.config— Config helpers: dataclass <-> dict / YAML, and stable config hashing.nefi.domain— Physical domain: extents, resolution and normalized coordinate grids.nefi.errors— Exception hierarchy for nefi.nefi.measurement— Observed data container.nefi.priors— The prior catalogue: what you physically know about the unknown → heads, losses, hints.nefi.problem— The inverse problem: domain + field + operator + losses + measurement (+ post-processing).nefi.registry— A tiny registry so every component is constructible from config ({"type": name, ...}).
nefi.autotune¶
nefi.autotune— Auto-tuning: detect and fix the common failure modes of a per-measurement inversion.nefi.autotune.acquisition— Acquisition / identifiability report: what the measurement can and cannot determine.nefi.autotune.convergence— Fit-quality driven budget and learning rate: does the fit reach the noise floor, and when?nefi.autotune.gauge— Gauge / null-space detection and repair: transformations of the unknown the data cannot see.nefi.autotune.orchestrate— One-call auto-tuning: noise → gauges → acquisition → budget / learning rate → regularization → (held-out search), every decision logged and reported.nefi.autotune.regularization— Regularization strength by the discrepancy principle (Morozov), with a GradNorm fallback.nefi.autotune.search— Held-out hyper-parameter search: let the measurement itself choose the configuration.
nefi.baselines¶
nefi.baselines— Baseline parameterizations and solvers (NeTMY App. E.2, NeFTY App. F.2).nefi.baselines.admm— ADMM with an ℓ1 + box proximal split — the ADMM baseline (NeTMY App. E.2; Boyd et al. 2011).nefi.baselines.deep_decoder— Untrained convolutional decoder prior — the DeepDecoder baseline (Heckel & Hand 2018).nefi.baselines.direct— Non-iterative reference reconstructions (FBP, Wiener, ...) reported as a regularResult.nefi.baselines.gaussian_splat— Explicit Gaussian-splat parameterization — the GaussianSplat baseline (NeTMY App. E.2).nefi.baselines.lbfgs— L-BFGS curricula — the quasi-Newton free-density reference (NeTMY App. E.2, §5.3).nefi.baselines.thermography— Classical pulsed-thermography heuristics: PPT and TSR (NeFTY App. F.4).
nefi.bench¶
nefi.bench— Benchmarking: scene/data generators, protocols, ablations, reports.nefi.bench.ablation— Component ablations (NeTMY Tab. 3 / App. E.6, NeFTY Tab. 3 / Tab. 8).nefi.bench.base— Benchmark primitives: ground-truth scene generators and inverse-crime-safe data generators.nefi.bench.protocol— Benchmark protocol: paired, seeded, inverse-crime-safe comparisons with confidence intervals.nefi.bench.report— Report writers (markdown / CSV / JSON), confidence intervals and operator runtime tables.nefi.bench.sweep— One-axis hyperparameter sweeps (NeTMY Tab. 10: learning rate, hidden width, PE octaves).
nefi.diagnostics¶
nefi.diagnostics— Ill-posedness and optimization-geometry diagnostics.nefi.diagnostics.filtering— The filtering view of a parameterized update (NeTMY §4.4, Lemma 2, App. D.6).nefi.diagnostics.landscape— Loss-landscape diagnostics in field space (what a free-pixel solver sees).nefi.diagnostics.plots— Plot helpers for diagnostics and results (matplotlib is optional).nefi.diagnostics.report— Diagnostic reports: the data-fit paradox check and a one-call :func:diagnosebundle.nefi.diagnostics.sensitivity— Forward sensitivity: per-pixel Jacobian column norms of the operator (NeTMY Eq. 23, (P2)).nefi.diagnostics.spectrum— Spectral diagnostics: singular values of the linearized operator and Hessian conditioning.
nefi.fields¶
nefi.fields— Field parameterizations (the prior) and their building blocks.nefi.fields.adaptive— Adaptive representation tools: let the data and the operator choose the geometry.nefi.fields.adaptive.annealing— Adaptive annealing: open frequency bands when the data ask for them.nefi.fields.adaptive.capacity— Capacity growth: start small, add degrees of freedom when the residual plateaus.nefi.fields.adaptive.selection— Measurement-driven model selection: cross-validation for per-measurement inverse problems.nefi.fields.adaptive.spectrum— Radial spectra of representations and operators, and the match report that compares them.nefi.fields.base— Field base class: a parameterization of the unknown(s) queried on a coordinate grid.nefi.fields.encoding— Coordinate encodings.nefi.fields.geometric— Geometric representations: fields whose structure encodes the geometry of the unknown.nefi.fields.geometric.composite— Composite fields: one unknown assembled from several sub-fields (background ⊕ anomaly, ...).nefi.fields.geometric.layered— Stratified media: layered fields with learnable monotone interfaces (NeFTY layered setting).nefi.fields.geometric.shape— Explicit shape representations rendered with smooth, sharpening indicators.nefi.fields.geometric.spectral— Spectral representations: explicit Fourier bases and Fourier-domain preconditioning.nefi.fields.geometric.warp— Coordinate warps: reshape where a field spends its capacity.nefi.fields.grid— Free pixel/voxel parameterization (the "Tikhonov" / "Grid Opt." baseline of both papers).nefi.fields.hashgrid— Multiresolution hash-grid encoding (Instant-NGP-lite, Müller et al. 2022).nefi.fields.heads— Output heads: bounded / gated / masked transforms that encode physical priors on the unknowns.nefi.fields.levelset— Two-phase (binary) fields through a sharpening level-set head.nefi.fields.lowrank— Low-rank (CP / canonical-polyadic) tensor field.nefi.fields.modifiers— Extra heads used by the prior catalogue (:mod:nefi.priors).nefi.fields.neural— Coordinate neural field: annealed Fourier features -> MLP with skip -> heads.nefi.fields.parametric— Low-dimensional parametric fields (analytic ansätze with a handful of learnable numbers).nefi.fields.symmetric— Exact symmetries by coordinate folding: mirror planes and radial symmetry.
nefi.instances¶
nefi.instances— Strong exemplar instances.nefi.instances.base— Instance protocol: a self-contained, registered exemplar inverse problem.nefi.instances.ct3d— ct3d — 3-D parallel-beam sparse-view CT (rotation aboutz) with a differentiable Radon stack.nefi.instances.ct3d.radon3d— Differentiable 3-D parallel-beam Radon transform (rotation aboutz) and slice-wise FBP.nefi.instances.ct3d.scenes— Procedural 3-D CT phantoms (normalized coordinates, inside the scanner cylinder, in [0, 1]).nefi.instances.current_density— current_density — NV-magnetometry current imaging: sheet current from its stray field B_z.nefi.instances.current_density.scenes— Current-density scenes for NV magnetometry: wires, loops and branching current networks.nefi.instances.darcy_flow— darcy_flow — permeability recovery from steady pressure data (subsurface flow).nefi.instances.darcy_flow.operator— Steady single-phase Darcy flow: log-permeability → pressure at sparse sensors.nefi.instances.darcy_flow.scenes— Darcy-flow ground-truth permeability fields (log-permeabilityY = log k).nefi.instances.deconvolution— deconvolution — 2-D image deblurring with Gaussian / motion / disk PSFs.nefi.instances.deconvolution.data— Inverse-crime-safe blur data generation with Gaussian or Poisson (photon-count) noise.nefi.instances.deconvolution.phantoms— Procedural 2-D phantom primitives shared by the imaging instances.nefi.instances.deconvolution.psf— Point-spread functions as kernel functions of the grid spacing (rebuilt at every resolution).nefi.instances.deconvolution.scenes— Ground-truth scene classes for image deblurring (cell-averaged, resolution-consistent).nefi.instances.deconvolution.wiener— Classical Wiener deconvolution — the closed-form reference reconstruction.nefi.instances.deconvolution3d— deconvolution3d — fluorescence-microscopy z-stack deblurring with an anisotropic 3-D PSF.nefi.instances.deconvolution3d.classical— Classical 3-D deconvolution references: Wiener filtering and Richardson–Lucy.nefi.instances.deconvolution3d.scenes— Fluorescence-microscopy ground-truth volumes (physical µm coordinates, intensities ~[0, 1]).nefi.instances.diffraction_tomography— diffraction_tomography — 2-D Born / Rytov inversion of a weak scattering contrast.nefi.instances.dot3d— dot3d — continuous-wave diffuse optical tomography: absorption from surface reflectance.nefi.instances.dot3d.data— DOT data generation (fine-grid physics, multiplicative noise, source–detector mask) and the relative-residual data loss.nefi.instances.dot3d.operator— Continuous-wave diffuse optical tomography (DOT) forward model on a 3-D slab.nefi.instances.dot3d.scenes— Absorbing inclusions in a scattering slab (physical mm coordinates,μ_ain mm⁻¹).nefi.instances.eit— eit — electrical impedance tomography: conductivity from boundary voltages.nefi.instances.eit.operator— Continuum-model EIT forward operator: conductivity → boundary potentials for current patterns.nefi.instances.eit.scenes— EIT ground-truth scenes: homogeneous background with elliptical inclusions.nefi.instances.holography— holography — multi-distance inline (Gabor) holography phase retrieval.nefi.instances.nv_relaxometry— nv_relaxometry — NeTMY: sparse spin-density recovery from NV-center relaxometry spectra.nefi.instances.nv_relaxometry.data— Measurement generation for NV relaxometry (NeTMY App. E.1).nefi.instances.nv_relaxometry.losses— NeTMY-specific loss terms (App. D.4) and noise-map helpers.nefi.instances.nv_relaxometry.operator— NV relaxometry forward operators F1 / F2 (FFT-factorized) and F3 (direct, source-side).nefi.instances.nv_relaxometry.physics— NV-relaxometry physics: dipolar Green tensor, tensor power kernels and the Lorentzian.nefi.instances.nv_relaxometry.scenes— Sparse spin-source scenes for NV relaxometry (NeTMY App. E.1).nefi.instances.photoacoustic3d— photoacoustic3d — 3-D photoacoustic tomography (PAT) from a planar sensor array.nefi.instances.photoacoustic3d.scenes— Initial-pressure (absorbed-energy) phantoms for 3-D photoacoustic tomography (physical mm).nefi.instances.photoacoustic3d.sensor— Finite sensor bandwidth: a zero-phase Gaussian low-pass of the pressure traces.nefi.instances.poisson_source— poisson_source — PDE-constrained source recovery for the Poisson equation (elliptic).nefi.instances.poisson_source.data— Sparse / boundary observation data for the Poisson source problem, and masked downsampling.nefi.instances.poisson_source.operator— Differentiable spectral Poisson solver (discrete sine transforms viatorch.fft).nefi.instances.poisson_source.scenes— Non-negative source fields for the Poisson source problem (cell-averaged, grid-consistent).nefi.instances.reaction_diffusion— reaction_diffusion — recover a spatially varying Gray–Scott feed rateF(x)from snapshots.nefi.instances.sparse_view_ct— sparse_view_ct — parallel-beam CT from a few views with a differentiable Radon transform.nefi.instances.sparse_view_ct.radon— Differentiable parallel-beam Radon transform, back-projection and filtered back-projection.nefi.instances.sparse_view_ct.scenes— Procedural CT phantoms (normalized coordinates, inside the field of view, values in [0, 1]).nefi.instances.thermal_tomography— thermal_tomography — NeFTY: 3-D inverse heat conduction from pulsed-thermography surface frames.nefi.instances.thermal_tomography.pinn— Soft-constrained PINN baseline for thermal tomography (NeFTY Eq. 4, §3.3, App. C / F.1).nefi.instances.thermal_tomography.projection— Projections of a reconstructed 3-D diffusivity to 2-D defect masks and 2.5-D depth maps.nefi.instances.thermal_tomography.realdata— Real pulsed-thermography data: loading, ambient shift, physical ↔ unitless scaling (NeFTY App. A.5 / H).nefi.instances.thermal_tomography.scenes— Synthetic subsurface-defect scenes for pulsed-thermography tomography (NeFTY App. E.1).nefi.instances.toy1d— toy1d — recover a 1-D non-negative signal from its blurred, noisy observation.nefi.instances.wave_fwi— wave_fwi — acoustic full-waveform inversion (FWI) of a 2-D sound-speed map.nefi.instances.wave_fwi.losses— Band-limited trace misfit for multiscale (frequency-continuation) full-waveform inversion.
nefi.losses¶
nefi.losses— Loss terms and their composition.nefi.losses.base— Loss composition: a :class:Contextper step, :class:Lossterms, and a weighted :class:LossSet.nefi.losses.data— Data-fidelity terms.nefi.losses.physics— Physics-knowledge losses: soft PDE residuals, conservation, symmetry, support, monotonicity.nefi.losses.reg— Regularizers on fields.
nefi.metrics¶
nefi.metrics— Reconstruction metrics.nefi.metrics.basic— Basic reconstruction metrics (torch, device-agnostic).nefi.metrics.localization— Sparse-localization and distributional metrics — NeTMY App. E.3.nefi.metrics.segmentation— Segmentation, depth and frequency-domain metrics (NeFTY App. E.2 / G.5).
nefi.operators¶
nefi.operators— Differentiable forward operators.nefi.operators.base— Forward-operator base class and generic wrappers.nefi.operators.conv— Generic N-D linear convolution via FFT with per-resolution kernel caches.nefi.operators.function— Wrap any differentiable Python callable as a nefi :class:~nefi.operators.Operator.nefi.operators.linear— Linear measurement operators: resolution loss, sampling, Fourier (MRI-style) sampling, algebra.nefi.operators.nonlinear— Nonlinear measurement operators: phase retrieval, Beer–Lambert attenuation, detector saturation.nefi.operators.pde— Differentiable PDE operators: finite-volume heat conduction with a discrete adjoint (NeFTY).nefi.operators.pde.adjoint— Implicit-Euler time stepping and its discrete adjoint (NeFTY §4.3, App. D.3).nefi.operators.pde.heat— Differentiable 3-D heat conduction: implicit-Euler forward model and an explicit data simulator.nefi.operators.pde.linear_solvers— Matrix-free linear solvers for the implicit-Euler systemA(α) T^{n+1} = T^n.nefi.operators.pde.stencil— Finite-volume diffusion stencilL(α)with harmonic-mean face coefficients.nefi.operators.timestepping— Generic differentiable time integration with memory-controlled adjoints.
nefi.physics¶
nefi.physics— Physics zoo: reusable differentiable forward models for many physical systems.nefi.physics.elliptic— Variable-coefficient elliptic PDEs−∇·(σ∇u) + κu = fwith an implicit-function adjoint.nefi.physics.magnetostatics— Magnetostatics of planar sources imaged on a parallel plane (NV / SQUID / Hall microscopy).nefi.physics.optics— Scalar coherent optics: angular-spectrum propagation, thin phase objects, inline holography.nefi.physics.reaction_diffusion— Gray–Scott reaction–diffusion with spatially varying reaction parameters.nefi.physics.scattering— 2-D scalar diffraction tomography: Born / Rytov linearized scattering and Lippmann–Schwinger.nefi.physics.timestep— Generic explicit time integration with optional per-block gradient checkpointing.nefi.physics.wave— Scalar acoustic wave equation: differentiable time-domain simulation and wave-family operators.
nefi.solve¶
nefi.solve— Optimization: curriculum, solver, results, callbacks, post-processing, ensembles.nefi.solve.balancing— Adaptive loss balancing (GradNorm-style) as a solver callback.nefi.solve.batched— Batched multi-measurement solving:Nindependent problems in one optimization loop.nefi.solve.callbacks— Solver callbacks: logging, progress bars, checkpoints, plotting.nefi.solve.curriculum— Optimization curriculum: multiscale stages, frequency annealing, learning-rate schedules.nefi.solve.ensemble— Multi-seed ensembles: cheap uncertainty maps for per-measurement inversion.nefi.solve.postprocess— Post-processing applied once after optimization.nefi.solve.refine— Reconstruction-side edge refinement: a short, physics-constrained sharpening stage.nefi.solve.result— Result container with save / load and a compact summary.nefi.solve.solver— The per-measurement optimizer: runs a :class:Curriculumon an :class:InverseProblem.
nefi.utils¶
nefi.utils— Small utilities shared across nefi.nefi.utils.compat— Version shims for the PyTorch APIs used by the performance switches (torch >= 2.1).nefi.utils.device— Device resolution.nefi.utils.seed— Reproducibility helpers.nefi.utils.tensor— Tensor helpers: resampling across resolutions, cropping, FFT sizes.nefi.utils.timing— Wall-clock timing helper.
nefi.viz¶
nefi.viz— nefi.viz — figures, animations, dashboards and shareable reports for neural-field inversion.nefi.viz.fields— Field viewers: 1-D lines, 2-D images, 3-D slices / mosaics / projections / voxels, and the standard reconstruction figure :func:compare_fields(GT | measurement | reconstruction(s) | signed error, metrics in the panel titles).nefi.viz.hints— Display hints: how an instance wants its measurement and its fields drawn.nefi.viz.interactive— Interactive 3-D viewer: drag-to-rotate isosurfaces, voxels and slices in the browser.nefi.viz.isosurface— Isosurfaces of 3-D fields: threshold rules, volume-matched iso-levels, display transforms, marching-cubes meshes and the shaded static renderings ofgallery_3d.png/voxels.png.nefi.viz.measurement— Measurement viewers: spectra, time-series frames, sinograms, receiver traces, k-space masks, signals, sparse point observations — and :func:plot_fit(data vs prediction vs residual with the noise floor).nefi.viz.multiphysics— The multi-physics gallery: one smoke run per registered instance, one compact tile per physical system (GT | measurement | reconstruction, headline metric and wall-clock), a single overview figure, per-instance figures and a JSON manifest.nefi.viz.performance— Performance dashboards: per-step time, scaling with grid size, memory by gradient mode, wall-clock breakdowns and benchmark tables with confidence intervals.nefi.viz.qualitative— Qualitative comparison figures: the scenes × methods grid of a paper, failure-mode panels and a one-call baselines panel.nefi.viz.report— Shareable reports: one self-contained HTML file (figures embedded as base64, metrics and timing tables, config hash, environment) or a Markdown page with relative image links.nefi.viz.style— House style for nefi figures: palette, per-quantity colormaps, rc settings, sizes, saving.nefi.viz.training— Training-dynamics figures: loss history with stage boundaries and the annealing schedule, per-stage summaries, the coarse→fine multiscale view and snapshot animations.nefi.viz.volume— 3-D field views: depth mosaics, cross-sections through the anomaly, projections and voxel comparisons — the building blocks of the 3-D layout of :func:~nefi.viz.compare_fields, the gallery's 3-D rows andgallery_3d.png.