Objective. This study aims to address the challenges of imbalanced heartbeat classification using electrocardiogram (ECG). In this proposed novel deep-learning method, the focus is on accurately identifying minority classes in conditions characterized by significant imbalances in ECG data. Approach. We propose a feature fusion neural network enhanced by a dynamic minority-biased batch weighting loss function. This network comprises three specialized branches: the complete ECG data branch for a comprehensive view of ECG signals, the local QRS wave branch for detailed features of the QRS complex, and the R wave information branch to analyze R wave characteristics. This structure is designed to extract diverse aspects of ECG data. The dynamic loss function prioritizes minority classes while maintaining the recognition of majority classes, adjusting the network’s learning focus without altering the original data distribution. Together, this fusion structure and adaptive loss function significantly improve the network’s ability to distinguish between various heartbeat classes, enhancing the accuracy of minority class identification. Main results. The proposed method demonstrated balanced performance within the MIT-BIH dataset, especially for minority classes. Under the intra-patient paradigm, the accuracy, sensitivity, specificity, and positive predictive value for Supraventricular ectopic beat were 99.63 % , 93.62 % , 99.81 % , and 92.98 % , respectively, and for Fusion beat were 99.76 % , 85.56 % , 99.87 % , and 84.16 % , respectively. Under the inter-patient paradigm, these metrics were 96.56 % , 89.16 % , 96.84 % , and 51.99 % for Supraventricular ectopic beat, and 96.10 % , 77.06 % , 96.25 % , and 13.92 % for Fusion beat, respectively. Significance. This method effectively addresses the class imbalance in ECG datasets. By leveraging diverse ECG signal information and a novel loss function, this approach offers a promising tool for aiding in the diagnosis and treatment of cardiac conditions.