Recently, many electrocardiogram (ECG) classification algorithms using deep learning have been proposed. The characteristics of ECG vary from dataset to dataset for various reasons (i.e., hospital, race, etc). Therefore, it is important that models have high dataset-wise generalization performance. In this paper, as part of the PhysioNet / Computing in Cardiology Challenge 2021, we developed a model to classify cardiac abnormalities from 12 lead and reduced-lead ECGs. In particular, to select a model with high generalization performance, we applied constant-weighted cross-entropy loss and evaluated the performance using a leave-one-dataset-out cross-validation setting. Our DSAIL_SNU team got challenge scores of 0.61, 0.58, 0.60, 0.59, and 0.59 on 12, 6, 4, 3, 2-lead ECGs respectively. Our model obtained higher dataset-wise generalization performance than the model we submitted last year.