Due to the increasing volume of data, the importance of data analysis systems has become more critical. An intrusion detection system is a type of software that monitors and analyzes the data collected by a network or system. Due to the increasing volume of data collected in the medical field, it has become harder for traditional methods to detect unauthorized access and manipulation of the data. To advance the efficiency of big data analysis, various techniques are used in IDS. This paper proposes a method that combines the deep learning network and proposed optimization algorithm. The goal of this paper is to develop a classification model that takes into account the hidden layer nodes of the DBN and then implement a PSO algorithm to improve its structure. The results of the simulations show that the Spark-DBN-PSO algorithm achieves a 99.04% accuracy rate, which is higher than the accuracy of other deep neural network (DNN) and artificial neural network (ANN) algorithms. The results of the research demonstrate that the proposed methodology performs superior than the existing algorithm.