neural-emd
N-EMD: Neural Empirical Mode Decomposition. A differentiable replacement for the iterative sifting in Empirical Mode Decomposition (EMD), written in PyTorch.
Classical EMD splits a signal into intrinsic mode functions (IMFs) by repeated envelope fitting. It works without assumptions about the signal, but it is not differentiable, the number of IMFs is whatever the sifting produces, and it is prone to mode mixing. N-EMD learns the decomposition instead:
- take the signal's spectrum (rFFT),
- a small 1-D CNN reads magnitude and phase and predicts K filter responses,
- a softmax across the K filters turns them into a partition of unity,
- each filter is applied to the spectrum and inverted back to the time domain.
That construction gives three guarantees by design, not by training:
- Exact reconstruction. The IMFs always sum back to the input.
- Band-limited IMFs. Every filter is non-negative, so each IMF is a bandpass of the input.
- No energy inflation. The IMFs' total energy can never exceed the signal's.
Training only has to make the filters sharp, ordered by frequency and orthogonal. Because the whole pipeline is differentiable, N-EMD can sit inside a larger model and be trained end to end with a downstream loss.
Install
pip install neural-emd # the library: torch, numpy, scipy
pip install "neural-emd[baselines]" # adds classical EMD / EEMD / VMD for comparison
The import name is nemd. Python 3.11 or newer.
Quick start
examples/quickstart.py fits N-EMD to a single noisy signal
made of three AM-FM tones (50, 15 and 3 Hz) and compares it with classical EMD:
import numpy as np
import torch
from nemd.classical import ClassicalEMD
from nemd.train import overfit_single_signal
from nemd.utils import generate_synthetic_signal, mode_mixing_index, reconstruction_error
t, x, truth = generate_synthetic_signal(
n_samples=1000,
components=[
{"f0": 50.0, "f_mod": 2.0, "a_mod": 0.5},
{"f0": 15.0, "f_mod": 0.5, "a_mod": 0.3},
{"f0": 3.0, "f_mod": 0.1, "a_mod": 0.2},
],
noise_std=0.05,
seed=42,
)
out = overfit_single_signal(torch.tensor(x, dtype=torch.float32),
num_imfs=3, num_steps=1500, fs=1000.0, verbose=False)
imfs = out["imfs"].detach().numpy() # (3, 1000)
Output on a laptop CPU (about 30 seconds):
N-EMD IMF dominant frequencies (Hz): [58.0, 16.0, 3.0]
N-EMD reconstruction error: 1.96e-07
N-EMD mode-mixing index: 0.241
EMD mode-mixing index: 0.236 (6 IMFs)
EMD first 3 IMF dominant frequencies (Hz): [58.0, 42.0, 15.0]
N-EMD returns exactly the three components asked for, one per tone, and reconstructs the signal to float precision. Classical EMD splits the same signal into six IMFs, including a spurious 42 Hz mode.
Training on a dataset
For signals from one family, train a model once and reuse it rather than fitting each signal:
from nemd.train import TrainConfig, train
result = train(TrainConfig(num_imfs=3, signal_length=1024, sample_rate=1000.0, num_epochs=100))
model = result["model"] # nemd.model.NEMD
imfs, residual, meta = model(batch) # batch: (B, T) tensor -> imfs: (B, K, T)
train generates synthetic training data by default. Pass dataset_fn to train on
your own signals. Best and final weights are saved to TrainConfig.save_dir.
What's in the package
| Module | Contents |
|---|---|
nemd.model |
NEMD, the filter-bank model; NEMDSifting, the earlier iterative variant kept for ablations |
nemd.losses |
Filter sharpness, frequency ordering, orthogonality, balance and the combined NEMDLoss |
nemd.train |
TrainConfig, train, overfit_single_signal |
nemd.utils |
Synthetic AM-FM, chirp and nonstationary signal generators; reconstruction error, orthogonality index, mode-mixing index, IF tracking error |
nemd.classical |
Thin wrappers for EMD, EEMD (PyEMD) and VMD (vmdpy), with the [baselines] extra |
Status
Research code, alpha. The API may change before 1.0. A paper describing the method and its evaluation is in preparation. Until then, please cite this repository if you use it.
Development
pip install -e ".[dev]"
pytest
License
MIT. Copyright (c) 2026 Aous Abdo.
Metadata
Release files for neural-emd 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 | Provenance | Actions |
|---|---|---|---|---|
| neural_emd-0.1.0.tar.gz | 37.2 kB | With provenance | Details for neural_emd-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| neural_emd-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for neural_emd-0.1.0-py3-none-any.whl |
Total release size: 69.8 kB
Release files / neural_emd-0.1.0.tar.gz
| Download URL | neural_emd-0.1.0.tar.gz |
|---|---|
| Size | 37.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
795e0cfd119c41a189447b4f637066442789b9900eaae1de96dcc6ca690a6414
|
|
BLAKE2b-256 checksum How to use checksums |
ea5fc8ea6070f70e97cedf8e1e87b2070befb84614fabdb20ffa38c5b8532afe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 21, 2026.
Transparency logRelease files / neural_emd-0.1.0-py3-none-any.whl
| Download URL | neural_emd-0.1.0-py3-none-any.whl |
|---|---|
| Size | 32.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4900e13b93c1ddc47db67fd28dd2a4a643ba45a2df43b85ea94ace5d639b9b5a
|
|
BLAKE2b-256 checksum How to use checksums |
433df632379baa40ad854a4e908282cad1701d8ebfd658a00e1a2608325c2f03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 21, 2026.
Transparency logSecurity for neural-emd 0.1.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 neural_emd-0.1.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 Nov 21, 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.