Skip to main content

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, so the split is differentiable and you choose how many components you get:

  1. take the signal's spectrum (rFFT),
  2. a small 1-D CNN reads magnitude and phase and predicts K filter responses,
  3. a softmax across the K filters turns them into a partition of unity,
  4. 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]

What this shows is the structure N-EMD guarantees. It returns exactly the three components asked for, and they add back up to the signal to float precision. Classical EMD returns six.

It does not show better separation. "Dominant frequency" is only each component's strongest peak. In this single-signal fit, most of the 15 Hz tone's energy lands in the same component as the 3 Hz tone, and the mode-mixing index is about the same as EMD's. How cleanly N-EMD separates components depends on the training data and the loss settings. Evaluating that is the subject of the paper in preparation, so test it on signals like yours before relying on it.

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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neural-emd 0.1.1
File Size Uploaded Provenance Actions
neural_emd-0.1.1.tar.gz 37.4 kB With provenance Details for neural_emd-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for neural-emd 0.1.1
File Interpreter ABI Platform Actions
neural_emd-0.1.1-py3-none-any.whl Python 3 none any Details for neural_emd-0.1.1-py3-none-any.whl

Total release size: 70.2 kB

Release files / neural_emd-0.1.1.tar.gz

Download URL neural_emd-0.1.1.tar.gz
Size 37.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d02d5382f2bc46a4ab656910d8db63ca44e3910738a4c4cb113f37fae3575d10
BLAKE2b-256 checksum
How to use checksums
b3063637e9a647aacee19b4e095f8093614c62ece04aa126ab41a82e1307823d
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 22, 2026.

Transparency log

Release files / neural_emd-0.1.1-py3-none-any.whl

Download URL neural_emd-0.1.1-py3-none-any.whl
Size 32.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
75aba371c317d12ee7b69153476e57b43f900d67bfb63684401e6c5ad43f1076
BLAKE2b-256 checksum
How to use checksums
2c63e39c3c8ccee657548a126c7eea38cd7d7e0d16e3b4a7d3cd2348282bcd11
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 22, 2026.

Transparency log

Security for neural-emd 0.1.1

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.

Select from 2 files

Attestation for neural_emd-0.1.1.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 22, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page