DOI: 10.3390/modelling7060231 ISSN: 2673-3951

A Multihead Self-Attention and Adaptive Multiscale Dilated Convolution Model for Generalizable Arrhythmia Classification from ECG Signals

Leihan Gao, Zhiqiang Wu, Yuting Li, Xiaoyu Yang, Yuechen Pan, Lin Wei, Yunfan Chen

Electrocardiogram (ECG) signals exhibit distribution shifts across recording devices, populations, sampling rates, and lead configurations, impairing generalization and long-term feature extraction. To address these issues, this paper proposes a multihead self-attention and adaptive multiscale dilated convolution model (MHA-MSD). First, a multihead encoder projects ECG features into a high-dimensional space to encode both temporal dynamics and inter-lead correlations. A subsequent self-attention mechanism then enhances cross-dataset generalization. Next, an adaptive multiscale dilated convolution module constructs a multibranch network with different dilation rates and uses a gating network to dynamically adjust branch weights according to signal length and feature distribution. Finally, a spatial attention module fuses multibranch features and refines features during dimensionality reduction to enhance global feature learning. On CPSC2018, the model classifies nine categories (Normal, AF, I-AVB, LBBB, RBBB, PAC, PVC, STD, and STE), achieving 93.6% accuracy and a 92.9% mean F1 score in the best-performing fold among the 10 cross-validation iterations. On the MIT-BIH-to-INCART transfer, the model classifies normal (N), supraventricular ectopic (S), and ventricular ectopic (V) beats and achieves 97.38% accuracy and 97.41% mean F1 score, while class-discriminative attention maps align with clinically relevant waveform segments. Cross-dataset classification of N, LBBB, and RBBB among CPSC2018, PTB-XL, and CODE-15% yields respective F1 scores of 0.87, 0.96, and 0.86 for CPSC2018-to-PTB-XL transfer.

More from our Archive