Wavelet Loss
A Python library for wavelet-based loss calculations in machine learning.
Installation
pip install git+https://github.com/rockerBOO/wavelet-loss.git
Usage
Quick Start
import torch
from wavelet_loss import WaveletLoss
# Frequency-aware loss for VAE latents [B, C, H, W]
loss_fn = WaveletLoss(wavelet="db4", level=2, transform_type="dwt")
prediction = torch.randn(2, 4, 32, 32, requires_grad=True)
target = torch.randn(2, 4, 32, 32)
loss, metrics = loss_fn(prediction, target) # scalar loss (reduce=True default)
loss.backward()
Diffusion / flow-matching training
Pass the current timestep to fade out high-frequency loss at high noise levels:
# Flow-matching sigmas in [0, 1] (default convention)
loss_fn = WaveletLoss(wavelet="db4", level=2)
loss, metrics = loss_fn(prediction, target, timestep=timesteps)
# DDPM-style integer timesteps require max_timestep=1000
loss_fn = WaveletLoss(wavelet="db4", level=2, max_timestep=1000)
See docs/configurations.md for timestep_cutoff,
timestep_transition_width, and other options.
Features
- Discrete Wavelet Transform (DWT)
- Quadrature Wavelet Transform (QWT)
- Stationary Wavelet Transform (SWT)
- Wavelet-based loss calculations
- Timestep-aware loss weighting for diffusion / flow-matching training
Upgrading to 2.0
See CHANGELOG.md for breaking changes: normalize_bands now
defaults to False, forward returns a scalar by default (reduce=True),
metrics are opt-in (metrics=True), and timesteps are validated against
max_timestep (default 1.0, flow-matching convention).
Development
- Run tests:
uv run pytest - Python 3.10+ required
Metadata
Release files for wavelet-loss 2.0.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 | Provenance | Actions |
|---|---|---|---|---|
| wavelet_loss-2.0.0.tar.gz | 157.5 kB | With provenance | Details for wavelet_loss-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wavelet_loss-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for wavelet_loss-2.0.0-py3-none-any.whl |
Total release size: 175.9 kB
Release files / wavelet_loss-2.0.0.tar.gz
| Download URL | wavelet_loss-2.0.0.tar.gz |
|---|---|
| Size | 157.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1043b55f50e7dc52e089e77be7cb19c143b21f288c509cb1749b20fdf642cd30
|
|
BLAKE2b-256 checksum How to use checksums |
39b3d86ad721703fa654024ee7d420620a652d0d64e97445f507a6141fa1e3b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 1, 2026.
Transparency logRelease files / wavelet_loss-2.0.0-py3-none-any.whl
| Download URL | wavelet_loss-2.0.0-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
08ffec350dbb832e79cbd2cb32e4a54cc85d0e2f473acdb94d969c3301f677e9
|
|
BLAKE2b-256 checksum How to use checksums |
616edeec66135c678f3ae2aa53b3d863042c415c13e259c264b8e1fed7cd8a15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 1, 2026.
Transparency logSecurity for wavelet-loss 2.0.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for wavelet_loss-2.0.0.tar.gz
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 Jul 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.