Objective. Neonates spend most of their time asleep. Sleep of preterm infants evolves rapidly throughout maturation and plays an important role in brain development. Since visual labelling of the sleep stages is a time consuming task, automated analysis of electroencephalography (EEG) to identify sleep stages is of great interest to clinicians. This automated sleep scoring can aid in optimizing neonatal care and assessing brain maturation. Approach. In this study, we designed and implemented an 18-layer convolutional neural network to discriminate quiet sleep from non-quiet sleep in preterm infants. The network is trained on 54 recordings from 13 preterm neonates and the performance is assessed on 43 recordings from 13 independent patients. All neonates had a normal neurodevelopmental outcome and the EEGs were recorded between 27 and 42 weeks postmenstrual age. Main results. The proposed network achieved an area under the mean and median ROC curve equal to 92% and 98%, respectively. Significance. Our findings suggest that CNN is a suitable and fast approach to classify neonatal sleep stages in preterm infants.