Cardiovascular diseases (CVDs) are the primary cause of death. Every year, many people die due to heart attacks. The electrocardiogram (ECG) signal plays a vital role in diagnosing CVDs. ECG signals provide us with information about the heartbeat. ECGs can detect cardiac arrhythmia. In this article, a novel deep-learning-based approach is proposed to classify ECG signals as normal and into sixteen arrhythmia classes. The ECG signal is preprocessed and converted into a 2D signal using continuous wavelet transform (CWT). The time–frequency domain representation of the CWT is given to the deep convolutional neural network (D-CNN) with an attention block to extract the spatial features vector (SFV). The attention block is proposed to capture global features. For dimensionality reduction in SFV, a novel clump of features (CoF) framework is proposed. The k-fold cross-validation is applied to obtain the reduced feature vector (RFV), and the RFV is given to the classifier to classify the arrhythmia class. The proposed framework achieves 99.84% accuracy with 100% sensitivity and 99.6% specificity. The proposed algorithm outperforms the state-of-the-art accuracy, F1-score, and sensitivity techniques.