Received January 29, 2020, accepted February 11, 2020, date of publication February 17, 2020, date of current version February 28, 2020. Digital Object Identifier 10.1109/ACCESS.2020.2974712 Generalization of Convolutional Neural Networks for ECG Classification Using Generative Adversarial Networks ABDELRAHMAN M. SHAKER , MANAL TANTAWI , HOWIDA A. SHEDEED , AND MOHAMED F. TOLBA , (Senior Member, IEEE) Department of Scientific Computing, Ain Shams University, Cairo 11566, Egypt Corresponding author: Abdelrahman M. Shaker (abdelrahman.shaker@cis.asu.edu.eg) ABSTRACT Electrocardiograms (ECGs) play a vital role in the clinical diagnosis of heart diseases. An ECG record of the heart signal over time can be used to discover numerous arrhythmias. Our work is based on 15 different classes from the MIT-BIH arrhythmia dataset. But the MIT-BIH dataset is strongly imbalanced, which impairs the accuracy of deep learning models. We propose a novel data-augmentation technique using generative adversarial networks (GANs) to restore the balance of the dataset. Two deep learning approaches—an end-to-end approach and a two-stage hierarchical approach—based on deep convolutional neural networks (CNNs) are used to eliminate hand-engineering features by combining feature extraction, feature reduction, and classification into a single learning method. Results show that augmenting the original imbalanced dataset with generated heartbeats by using the proposed techniques more effectively improves the performance of ECG classification than using the same techniques trained only with the original dataset. Furthermore, we demonstrate that augmenting the heartbeats using GANs outperforms other common data augmentation techniques. Our experiments with these techniques achieved overall accuracy above 98.0%, precision above 90.0%, specificity above 97.4%, and sensitivity above 97.7% after the dataset had been balanced using GANs, results that outperform several other ECG classification methods. INDEX TERMS Class imbalance, convolution neural networks (CNNs), ECG classification, generative adversarial networks (GANs). I. INTRODUCTION An ECG is a standard tool for measuring the electrical activity of the heart and for diagnosing cardiac arrhythmias. Using an ECG involves placing electrodes on the surface of the body—such as the chest, neck, and arms—in order to detect electrical changes in the heart. An ECG record primarily consists of several distinctive wave forms, such as the P wave, the QRS complex, the T wave, and other wave forms. The P wave shows atrial contractions; the QRS complex shows ventricular contractions; the T wave shows the electrical activity produced as the ventricles are recharged for the next contraction [1]. Study of these complex waves and the car- diac activities they represent is vital for diagnosis of various arrhythmias [2]. It is difficult for a cardiologist to correctly analyze a large number of ECG records given their com- plexity and the amount of time required to analyze them [3]. The associate editor coordinating the review of this manuscript and approving it for publication was Yizhang Jiang . Yet life-threatening arrhythmias need to be detected early and accurately [4]. Arrhythmias can be grouped into two main categories, life-threating and non-life threating. Life-threatening arrhyth- mias such as tachycardia and ventricular fibrillation cause heart attacks and sudden death [5], [6]. Non-life-threatening arrhythmias, which is our interest in this study, require atten- tion in order to prevent deterioration of the heart muscle [3]. The category of the arrhythmia can be determined by rec- ognizing the classes of consecutive heartbeats [7]. Manual beat-by-beat classification can be very time-consuming and too difficult in many scenarios. It is crucial to automate ECG analysis so that cardiac disorders can be discovered and treated as quickly as possible in clinical situations where speed in providing medical aid is essential. Medical datasets like the MIT-BIH arrhythmia dataset are often very limited. They usually have data imbalance prob- lem; they over-represent normal classes and common diseases and only sparsely represent rare diseases. Collecting medical 35592 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see http://creativecommons.org/licenses/by/4.0/ VOLUME 8, 2020