Atrial fibrillation (AF) is a common abnormal heart rhythm disease. Therefore, the development of an AF detection system is of great significance to detect critical illnesses. In this paper, we proposed an automatic recognition method named CNN-LSTM to automatically detect the AF heartbeats based on deep learning. The model combines convolutional neural networks (CNN) to extract local correlation features and uses long short-term memory networks (LSTM) to capture the front-to-back dependencies of electrocardiogram (ECG) sequence data. The CNN-LSTM is feeded by processed data to automatically detect AF signals. Our study uses the MIT-BIH Atrial Fibrillation Database to verify the validity of the model. We achieved a high classification accuracy for the heartbeat data of the test set, with an overall classification accuracy rate of 97.21%, sensitivity of 97.34%, and specificity of 97.08%. The experimental results show that our model can robustly detect the onset of AF through ECG signals and achieve stable classification performance, thereby providing a suitable candidate for the automatic classification of AF.