Polysomnography (PSG) monitoring is an important method for clinical diagnosis of diseases such as insomnia, apnea and so on. In order to solve the problem of time-consuming and energy-consuming sleep stage staging of sleep disorder patients using manual frame-by-frame visual judgment PSG, this study proposed a deep learning algorithm model combining convolutional neural networks (CNN) and bidirectional gate recurrent neural networks (Bi GRU). A dynamic sparse self-attention mechanism was designed to solve the problem that gated recurrent neural networks (GRU) is difficult to obtain accurate vector representation of long-distance information. This study collected 143 overnight PSG data of patients from Shanghai Mental Health Center with sleep disorders, which were combined with 153 overnight PSG data of patients from the open-source dataset, and selected 9 electrophysiological channel signals including 6 electroencephalogram (EEG) signal channels, 2 electrooculogram (EOG) signal channels and a single mandibular electromyogram (EMG) signal channel. These data were used for model training, testing and evaluation. After cross validation, the accuracy was (84.0±2.0)%, and Cohen's kappa value was 0.77±0.50. It showed better performance than the Cohen's kappa value of physician score of 0.75±0.11. The experimental results show that the algorithm model in this paper has a high staging effect in different populations and is widely applicable. It is of great significance to assist clinicians in rapid and large-scale PSG sleep automatic staging.