Neural-Field Inversion recovers hidden physical fields from a single measurement and a differentiable model of the instrument.
The physics is enforced exactly, a coordinate neural field represents the unknown, and no training data is needed.
Documentation · Get started · Gallery · Interactive 3-D · Papers
Why nefi
- The physics stays exact. Every candidate field passes through a differentiable model of your instrument, whether FFT optics, PDE solvers with exact adjoints, wave propagation or scattering, so the answer is always consistent with the physics rather than a soft penalty away from it.
- No training data. The unknown is optimized for the measurement at hand with a coarse-to-fine, frequency-annealed schedule. There is nothing to collect, nothing to amortize and nothing to go stale.
- It adapts itself. Noise level, budget, learning rate, regularization strength and even the representation can be chosen automatically, and gauge freedoms that the data cannot resolve are detected and fixed.
- The representation is the prior. Neural fields, grids, level sets, layered media and coordinate warps are interchangeable, and the library measures which one matches your operator.
- It tells you how far to trust the result. Noise-floor verdicts, ill-posedness diagnostics, a benchmark protocol with confidence intervals and an inverse-crime guard, and refinements that are refused when the data do not support them.
Quickstart
pip install nefi # torch, numpy, scipy, pyyaml, tqdm ("nefi[viz]": + matplotlib)
nefi run toy1d # generate → invert → evaluate → runs/toy1d-<hash>/
nefi bench toy1d --methods neural,grid --n 4 --seeds 0,1
nefi diagnose toy1d # sensitivity, iter-0 gradient, filter rows, spectrum
import nefi
from nefi.instances.toy1d import make_problem
problem, gt, meas = make_problem(n=128, seed=0) # 1-D deblurring, seconds on a CPU
result = nefi.invert(problem) # neural field + annealed two-stage curriculum
print(nefi.metrics.psnr(result.fields["x"], gt["x"]))
Bring your own problem — any measurement process you can write in PyTorch, no subclassing:
import torch
import nefi
k = torch.tensor([1.0, 4.0, 6.0, 4.0, 1.0])
k = (k[:, None] * k[None]) / 256
def forward(x): # your physics: a blurred, saturating camera
blurred = torch.nn.functional.conv2d(x[None, None], k[None, None], padding=2)[0, 0]
return torch.tanh(1.5 * blurred)
x_true = torch.zeros(64, 64); x_true[20:44, 16:40] = 1.0
y = forward(x_true) + 0.01 * torch.randn(64, 64) # your data
problem = nefi.from_forward(forward, y, shape=(64, 64),
prior="nonnegative + piecewise_constant") # what you know
result = nefi.invert(problem)
print(nefi.quick_report(result, problem, gt=x_true)) # did the fit reach the noise floor?
from_forward chooses the representation, initialization, noise level, loss weights, learning
rate and curriculum; every decision is logged and overridable
(guide).
Gallery
Twelve of the registered systems as ground truth · measurement · reconstruction, from one gallery run on a CPU. Browse the gallery →
What's inside
| Representations | neural fields with annealed Fourier features, grids, hash grids, low-rank, level sets, Gaussian splats, Deep Decoder; geometric fields (layered media, anomalies, star shapes, warps) with adaptive annealing, capacity growth and held-out selection — geometry |
| Operators & physics | FFT convolution, NV dipolar spectra, magnetostatics, Radon, Poisson, elliptic PDEs with implicit-function adjoints, implicit-Euler heat with a discrete adjoint, waves with PML and checkpointing, Born and Lippmann–Schwinger scattering, angular-spectrum optics, Gray–Scott — physics |
| Losses & priors | MSE, log-MSE, Poisson NLL, Huber, TV, ℓ1, Laplacian, physics penalties; value heads as hard priors; a prior DSL ("nonnegative + sparse") — zoo |
| Curriculum & solver | multiscale stages, annealing resets, LR schedules, discrepancy stopping, NaN guard with rollback, EMA, restarts, time budgets, checkpoints |
| Diagnostics | sensitivity maps, iter-0 gradient and center bias, filter-kernel rows Gθei, singular values, energy barriers, the data-fit paradox — diagnostics |
| Benchmarking | paired samples × seeds, 95 % confidence intervals, runtime and memory, ablations, sweeps, inverse-crime guard, sharded cluster campaigns — benchmarking |
| Auto-tuning | gauges, budgets and learning rates against the noise floor, Morozov regularization, an acquisition report — auto-tuning |
| Edge refinement | multi-phase level sets, phase fields, TV sharpening, with a data-fit acceptance test and a control run — refinement |
| Visualization | comparison figures, measurement viewers, training dynamics, 3-D slices and isosurfaces, a dependency-free interactive 3-D viewer — visualization |
| Performance | batched multi-measurement solving (vmap), whole-step torch.compile, CUDA graphs, mixed precision, a fast heat stencil — performance |
| CLI | nefi list · run · bench · bench-merge · diagnose · autotune · ablate · sweep — reference |
Instances
The registered problems, each runnable end to end with nefi run <name> --smoke and
documented on its own page.
| group | instance | problem | physics |
|---|---|---|---|
| papers | nv_relaxometry |
spin sources + Larmor field from NV noise spectra (NeTMY) | dipolar tensor kernel × Lorentzian |
thermal_tomography |
3-D diffusivity from pulsed-thermography frames (NeFTY) | implicit-Euler heat, discrete adjoint | |
| classic imaging | toy1d |
1-D deblurring (tutorial, CI) | FFT blur |
deconvolution |
image deblurring, Gaussian or Poisson noise | FFT convolution | |
sparse_view_ct |
sparse-view and limited-angle CT | differentiable Radon transform | |
| elliptic | poisson_source |
sources from sparse potentials | spectral Poisson solver |
eit |
conductivity from boundary voltages | elliptic PDE, implicit-function adjoint | |
darcy_flow |
log-permeability from well pressures | elliptic PDE, implicit-function adjoint | |
current_density |
sheet current from its NV stray field | planar magnetostatics | |
| wave · optics · reaction | wave_fwi |
sound speed from acoustic traces | wave equation, leapfrog + PML |
diffraction_tomography |
scattering contrast from scattered fields | Born / Rytov | |
holography |
phase from multi-distance intensities | angular-spectrum propagation | |
reaction_diffusion |
Gray–Scott feed rate from snapshots | reaction–diffusion time stepping | |
| volumetric | ct3d |
3-D sparse-view CT | slice-stacked Radon transform |
deconvolution3d |
fluorescence z-stack deconvolution | 3-D FFT convolution | |
dot3d |
diffuse optical tomography | diffusion equation, Robin boundaries | |
photoacoustic3d |
photoacoustic tomography, planar array | 3-D wave equation |
Interactive 3-D
Ground truth · smooth · edge-refined, one camera, IoU and Dice computed in the browser — a self-contained HTML file written by nefi.viz.save_volume_viewer. Rotate it live →
Reproducing the papers
configs/nv_relaxometry_paper.yaml and configs/thermal_tomography_paper.yaml hold the papers'
settings table by table. The server runbook
lists the exact commands for the headline tables, their GPU cost and the caveats to check
first, and the paper → code map traces
every equation to the code.
nefi bench configs/nv_relaxometry_paper.yaml --methods netmy,f1,grid,grid_f1 \
--classes all --by-class --n 64 --seeds 0,1,2 --device cuda # NeTMY Tab. 1
nefi run configs/thermal_tomography_paper.yaml --device cuda # one NeFTY specimen
Development
git clone https://github.com/CAB-Lab-Princeton/NEFI.git && cd NEFI
pip install -e ".[dev]" # + pytest, ruff, mypy, scikit-image, matplotlib, typer, rich
make test # fast CPU suite; make lint, make smoke
The latest development version installs with
pip install git+https://github.com/CAB-Lab-Princeton/NEFI.git; see CONTRIBUTING.md.
Documentation
Get started · Tutorials · Guides · Gallery · Physics · Instances · Research · API · CLI · Contributing · Changelog
Every page is also readable as markdown under docs/.
Citation
If you use nefi, please cite the papers it implements:
@article{zhao2026netmy,
title = {Neural Fields for {NV}-Center Inverse Sensing},
author = {Zhao, Zhixuan and Zhong, Tao and Hu, Yixun and de Leon, Nathalie P. and
Allen-Blanchette, Christine},
journal = {arXiv preprint arXiv:2605.13988},
year = {2026}
}
@article{zhong2026nefty,
title = {Neural Field Thermal Tomography: A Differentiable Physics Framework for
Non-Destructive Evaluation},
author = {Zhong, Tao and Hu, Yixun and Zheng, Dongzhe and Sood, Aditya and
Allen-Blanchette, Christine},
journal = {arXiv preprint arXiv:2603.11045},
year = {2026}
}
License
MIT © 2026 CAB Lab, Princeton University. See LICENSE.
Acknowledgements
nefi is developed and maintained by the CAB Lab at Princeton University. It grew out of the lab's series of papers on neural-field inversion, of which NeTMY and NeFTY are the first two, and we thank the authors of both.
Metadata
Release files for nefi 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nefi-0.1.2.tar.gz | 933.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nefi-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.9 MB
Release files / nefi-0.1.2.tar.gz
| Download URL | nefi-0.1.2.tar.gz |
|---|---|
| Size | 933.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0011a42e5369c8bd5005dc98ab4226c3e6fa81496552cfa0c6508b342797a22
|
|
BLAKE2b-256 checksum How to use checksums |
b78c480a1ab131a54f2a3d219efa08e7f051ad0a843798a7b8952b7eb3cd8fc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logRelease files / nefi-0.1.2-py3-none-any.whl
| Download URL | nefi-0.1.2-py3-none-any.whl |
|---|---|
| Size | 917.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7f14af1588c1c71488437782b7f1df39a4a38c1a8a62b8bad90fb3205a4c2488
|
|
BLAKE2b-256 checksum How to use checksums |
93f18c2e08de3f614164a6b46a67810409e2c1eb79ac1d4a4bf8f1be19cde09a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency log