Examples#

The benchmarks/ directory of the repository contains eight complete, self-contained training examples – one per challenge / database – written against the modern library API. They also serve as the reference usage for the whole package: each one shows reader and dataset usage, model construction, training with the library trainer, and evaluation with the official challenge metrics where applicable.

Each benchmark is runnable as a module with a --smoke debug mode (a few hundred iterations on a subset, no full training):

python -m benchmarks.train_crnn_cinc2021.train --help
python -m benchmarks.train_crnn_cinc2021.train --smoke

The examples#

Benchmark

Task / Database

Architectures

train_crnn_cinc2021

26-class classification, CinC Challenge 2021 (all 6 lead sets)

ECG_CRNN

train_crnn_cinc2020

27-class classification, CinC Challenge 2020 (strict subset of the 2021 data)

ECG_CRNN

train_unet_ludb

ECG waveform delineation, LUDB

ECG_UNET

train_multi_cpsc2019

In-hospital arrhythmia detection, CPSC2019

ECG_SEQ_LAB_NET, ECG_SUBTRACT_UNET, ECG_CRNN

train_hybrid_cpsc2021

LOC/RLOC regression, CPSC2021 (3 sub-tasks)

ECG_UNET_LUDB variants

train_hybrid_cpsc2020

End-to-end + segmentation challenge score, CPSC2020

ECG_CRNN, ECG_SEQ_LAB_NET

train_crnn_cinc2023

24-class classification on ECG + metal-oxide gas sensors, CinC Challenge 2023

CRNN_CINC2023

train_mtl_cinc2022

Multi-task (classification + regression) on circulatory sounds, CinC Challenge 2022

CRNN_CINC2022, Wav2Vec2 variants

Points to note#

  • Determinism: every train.py calls seed_everything() and uses worker_init_fn; a given --seed fully determines the run.

  • Library datasets/readers/metrics: the examples consume torch_ecg.databases readers and datasets instead of local copies, and compute official challenge metrics via the library.

  • Offline preparation: train_hybrid_cpsc2021 runs the (idempotent) offline preparation via persistence() automatically.

  • Checkpoints: written via save() with the full model config, loadable with from_checkpoint().

Tests of the examples#

test/test_pipelines/ contains thin pytest wrappers over the benchmarks (fast lanes run the non-downloading parts; the nightly full suite trains briefly on real data), so the examples are continuously verified against the library.