Abstract:To address the limitations of existing automatic atrial fibrillation (AF) detection algorithms in distinguishing persistent/paroxysmal AF, localizing abnormal episodes, resisting noise and avoiding error accumulation, a Multi-level Multi-task Attention-based Convolutional Neural Network (MMA-CNN) is proposed for simultaneous electrocardiogram (ECG) rhythm classification and AF episode localization. With a hierarchical feature extraction structure and a dual-head classifier, the model fuses one-dimensional convolution and bidirectional long short-term memory network to extract multi-scale features, and completes end-to-end training with weighted joint loss and adaptive preprocessing. Experimental results on the CPSC2021 dataset show that the model achieves a rhythm discrimination accuracy over 0.99 and an optimal comprehensive score of 2.2844, outperforming mainstream baseline models. With good generalization and robustness, it is suitable for real-time single-lead AF monitoring on wearable devices.