ECG-NAT: A Self-supervised Neighborhood Attention Transformer for Multi-lead Electrocardiogram Classification

Mahsa Gazeran, Sayvan Soleymanbaigi, Fatemeh Daneshfar, Amjad Seyedi, Fardin Akhlaghian Tab
5/13/2026
1 citation
cs.LGcs.AI
transformer-attentioncontrastive-ssl

Official code: Mahsagazeran/ECG-NAT (6 stars, last commit 2026-02-24).

Abstract

Electrocardiogram (ECG) arrhythmia classification remains challenging due to signal variability, noise, limited labeled data, and the difficulty in achieving both accuracy and efficiency in models. While self-supervised learning reduces label dependency, most methods target either global contextual features or local morphological patterns, but rarely implement hierarchical multi-scale feature extraction.

Show full abstract

ECG signals require architectures that simultaneously capture fine-grained beat-level morphology and broader rhythm-level dependencies with computational efficiency. To overcome this limitation, this paper proposes the Electrocardiogram Neighborhood Attention Transformer (ECG-NAT), a novel self-supervised learning approach tailored for multi-lead ECG classification. Our two-stage approach begins with generative pretraining, using a masked autoencoder to reconstruct partially masked ECG signals across multiple diverse datasets, enabling the model to learn robust, domain-invariant representations from unlabeled data. This is followed by discriminative fine-tuning with a dual-loss function that combines supervised contrastive and cross-entropy losses, aligning representation learning with label prediction. The hierarchical attention mechanism efficiently captures multi-scale temporal features from localized beat morphology to broader rhythm patterns at low computational cost. ECG-NAT achieves robust performance on benchmark datasets, with 88.1\% accuracy using only 1\% labeled data, demonstrating strong efficacy in low-resource settings. The framework combines superior classification performance with computational efficiency, making it practical for real-time ECG diagnosis. The code will be made available upon acceptance at: https://github.com/Mahsagazeran/ECG-NAT.

View on arXivView PDF

Code Implementations(1)

ECG-classification | self-supervised-learning | Transformer | Deep-learning

60Jul 22, 20259 months ago

Similar Papers

Cite this paper

@article{gazeran2026ecgnat,
  title  = {ECG-NAT: A Self-supervised Neighborhood Attention Transformer for Multi-lead Electrocardiogram Classification},
  author = {Mahsa Gazeran and Sayvan Soleymanbaigi and Fatemeh Daneshfar and Amjad Seyedi and Fardin Akhlaghian Tab},
  year   = {2026},
  eprint = {2605.13194},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2605.13194v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2605.13194.svg)](https://codeofpaper.com/paper/2605.13194)

Discussion