One of the solutions used to create security in computer networks is the use of intrusion detection systems. Today’s architectures detecting intrusion have made it difficult for the designers of these systems to select an efficient architecture that can be more reliable in detecting intrusions. One of the solutions that has been developed to secure computer systems and networks is the emergence of intrusion detection systems. In the present study, a method for combining deep learning and observer learning in detecting intrusion patterns is presented with the aim of increasing the security of computer networks. Observer learning is provided to teach the parameters of a deep neural network algorithm that uses linear combinations and representations of effective features. This method is based on a learning algorithm with supervision and a deep neural network that optimizes the appropriate number of hidden layers and the number of neurons in each layer according to a threshold value. The results of experiments on NSL-KDD data set show the superiority of the proposed method with 97.64% accuracy over MARS and DLNN methods.