sweep-loss
A PyTorch library of misfit (loss) functions for Full Waveform Inversion (FWI).
Designed as a plugin for the sweep FWI
toolkit — but works in any PyTorch-based FWI / inversion workflow because the
losses are plain torch.nn.Module objects.
The package collects, from a single API, the loss functions that have been
proposed in the FWI literature - from classical least-squares to optimal-transport,
adaptive matching filters, and instantaneous-phase / envelope variants - and
exposes them as torch.nn.Module so they can be dropped into any PyTorch-based
FWI workflow (e.g. the sweep propagator).
Data convention
All losses accept tensors with the shape used throughout the sweep ecosystem:
(nshots, nt, nreceivers, nchannel)
nshots- number of independent source experiments in the mini-batch.nt- number of time samples (axis = -3, the time axis).nreceivers- number of receivers per shot.nchannel- number of recorded components (1 for pressure, 2/3 for elastic, ...).
For convenience every loss also accepts a plain (nt,) or (nt, nrec) tensor
(treated as a single trace / single shot).
Quick start
import torch
from sweep_loss import L2Loss
syn = torch.randn(2, 1024, 64, 1, requires_grad=True) # (nshots, nt, nrec, nchan)
obs = torch.randn(2, 1024, 64, 1)
loss_fn = L2Loss(reduction="mean")
loss = loss_fn(syn, obs)
loss.backward()
Implemented losses
See docs/report.md (also rendered on the mkdocs site,
see below) for the full list of misfit formulas with DOI-linked
references. Each loss also has its own page under
docs/losses/.
Documentation site
The repository ships with an MkDocs + Material site:
pip install mkdocs mkdocs-material
mkdocs serve # http://127.0.0.1:8000
# or
mkdocs build # outputs to ./site
The site is configured in mkdocs.yml; pages live under docs/.
Installation
pip install sweep-loss
From a clone, with the test extras: pip install -e ".[test]".
Running the tests
pytest -q
License
MIT
Metadata
Release files for sweep-loss 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sweep_loss-0.1.0.tar.gz | 63.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sweep_loss-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 123.1 kB
Release files / sweep_loss-0.1.0.tar.gz
| Download URL | sweep_loss-0.1.0.tar.gz |
|---|---|
| Size | 63.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e51061979dde32a4fefc1b54f0ac9f348e8552801220ee18c5fa2716c59505f1
|
|
BLAKE2b-256 checksum How to use checksums |
9ab80bd0a3bae64b6e6ff8a773baa3f5ee4bf6ebb98db0209e0b26030cfac08e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.5
|
Release files / sweep_loss-0.1.0-py3-none-any.whl
| Download URL | sweep_loss-0.1.0-py3-none-any.whl |
|---|---|
| Size | 60.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
126d976c05395038583cb6f1f277811089d4175a94e1fba517547a368e0439a9
|
|
BLAKE2b-256 checksum How to use checksums |
1ce4196994ff9b53336579f9c5c77134c9ac6fabf3f601dafc72fce13d693049
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.5
|