Objective.Automatic detection of premature beats on long electrocardiogram (ECG) recordings is of great significance for clinical diagnosis. In this paper, we propose a novel deep learning model, the ECGDet, to detect premature beats, including premature ventricular contractions (PVCs) and supraventricular premature beats (SPBs) on single-lead long-term ECGs.Approach.The ECGDet is proposed based on a convolutional neural network and squeeze-and-excitation network. It outputs the probabilities that the ECG samples belong to a premature contraction. Non-max suppression was used to select the most appropriate locations for the premature beats. The ECGDet was trained and tested on the MIT-BIH arrhythmia database (MITDB) using a five-fold cross-validation approach. A novel loss calculation method was introduced in the model training process. Then it was tuned and further tested on the China Physiological Signal Challenge (2020) database (CPSCDB).Main results.The results showed that the average F1 value of PVC detection was 92.6%, while that of SPB detection was 72.2% on MITDB. The ECGDet bagged the 2nd place for PVC detection and ranked 7th place of SPB detection in the China Physiological Signal Challenge (2020).Significance.The proposed ECGDet can automatically detect premature heartbeats without manually extracting the features. This technique can be used for long-term ECG signal analysis and has potential for clinical applications.