In this study, a novel machine learning algorithm, restricted Boltzmann machine, is introduced. The algorithm is applied for the spectral classification in astronomy. Restricted Boltzmann machine is a bipartite generative graphical model with two separate layers (one visible layer and one hidden layer), which can extract higher level features to represent the original data. Despite generative, restricted Boltzmann machine can be used for classification when modified with a free energy and a soft-max function. Before spectral classification, the original data are binarised according to some rule. Then, we resort to the binary restricted Boltzmann machine to classify cataclysmic variables and non-cataclysmic variables (one half of all the given data for training and the other half for testing). The experiment result shows state-of-the-art accuracy of 100%, which indicates the efficiency of the binary restricted Boltzmann machine algorithm.