Sleep apnea is defined as a breathing disorder that affects sleep. Early detection of sleep apnea helps doctors to take intervention for patients to prevent sleep apnea. Manually making this determination is a time-consuming and subjectivity problem. Therefore, many different methods based on polysomnography (PSG) have been proposed and applied to detect this disorder. In this study, a unique two-layer method is proposed, in which there are four different deep learning models in the deep neural network (DNN), gated recurrent unit (GRU), recurrent neural network (RNN), RNN-based-long term short term memory (LSTM) architecture in the first layer, and a machine learning-based meta-learner (decision-layer) in the second layer. The strategy of making a preliminary decision in the first layer and verifying/correcting the results in the second layer is adopted. In the training of this architecture, a vector consisting of 23 features consisting of snore, oxygen saturation, arousal and sleep score data is used together with PSG data. A dataset consisting of 50 patients, both children and adults, is prepared. A number of pre-processing and under-sampling applications have been made to eliminate the problem of unbalanced classes. Proposed method has an accuracy of 95.74% and 99.4% in accuracy of apnea detection (apnea, hypopnea and normal) and apnea types detection (central, mixed and obstructive), respectively. Experimental results demonstrate that patient-independent consistent results can be produced with high accuracy. This robust model can be considered as a system that will help in the decisions of sleep clinics where it is expected to detect sleep disorders in detail with high performance.