## 1 Introduction  
Electrocardiogram (ECG) analysis for arrhythmia classification is crucial for the early detection and timely intervention of cardiac abnormalities, significantly reducing morbidity and mortality risks [1]. Recent advances in deep learning have substantially improved arrhythmia detection performance; however, the practical applicability of these models remains limited due to their inability to generalize well across heterogeneous datasets [2, 3]. Variations among ECG datasets, including differences in patient demographics, recording devices, clinical environments, and annotation granularities, significantly degrade the generalization capability of conventional ECG classification models [4, 5, 6]. Traditional ECG arrhythmia classification methods typically rely on fully supervised learning paradigms, necessitating extensive datasets with fine-grained, beat-level annotations [7; 8; 9; 10]. While these methods achieve strong performance in well-controlled scenarios, their dependency on precise annotations restricts scalability and applicability to new, coarsely annotated databases. Consequently, domain adaptation (DA) techniques have emerged to address these challenges by aligning data distributions across different domains [11; 12; 13]. Although these approaches, including adversarial learning and explicit feature alignment, can mitigate cross-database discrepancies, they often require complex procedures and detailed labels from target databases [14; 15]. Recent deep learning approaches, including CNN-based [16], attention-based [17], and transformer-based models [18], have shown promising results in arrhythmia classification tasks. With advances in deep learning-based ECG classification, some works have also explored on-device arrhythmia monitoring using ultra-low-power, single-chip integrated circuits [19; 20]. These systems integrate ECG acquisition, arrhythmia detection, and cardiovascular signal analysis into compact and energy-efficient platforms, underscoring the growing interest in mobile and wearable deployment scenarios. However, most studies still rely on single-database evaluation settings, and their generalizability across heterogeneous ECG datasets remains underexplored. Lately, weakly supervised learning (WSL) has been proposed to reduce reliance on fine-grained annotations by utilizing coarse-grained, record-level labels [21; 22]. Despite the success of WSL in other fields, the existing WSL-based ECG classification approaches have not explicitly addressed cross-database generalization challenges. They have primarily focused on single-database scenarios without adequately accounting for dataset variability, limiting their applicability to broader clinical practice [23]. To address these limitations, we propose a novel two-stage cross-database learning framework for ECG arrhythmia classification that simultaneously utilizes both fine-grained and coarse-grained annotations. Our framework initially pretrains a beat-level classifier using fine-grained labels from a well-annotated dataset and then adapts the classifier to new datasets via weakly supervised learning with coarse-grained, record-level annotations. In contrast to traditional domain adaptation methods--such as adversarial learning or explicit feature alignment--which often require intricate procedures and detailed annotations, our approach effectively handles domain variability through weak supervision. This method is designed to improve the model's robustness and generalization performance across a variety of ECG databases. The objective of this study is to improve cross-database arrhythmia classification by utilizing both fine-grained and coarse-grained annotations together within a unified framework, while developing ECG classification models that are more adaptable to real-world clinical data conditions. The main contributions of our work can be summarized as follows:  
1.