Depression is a common illness worldwide with doubtless severe implications. Due to the absence of early identification and treatment for depression, millions of individuals worldwide suffer from mental illnesses. It might be difficult to identify those who are experiencing mental health illnesses and to provide them with the early help that they need. Additionally, depression may be associated with thoughts of suicide. Currently, there are no clinically specific diagnostic biomarkers that can identify the severity and type of depression. In this research paper, the novel particle swarm-cuckoo search (PS-CS) optimization algorithm is proposed instead of the traditional backpropagation algorithm for training deep neural networks. The backpropagation algorithm is widely used for supervised learning in deep neural networks, but it has limitations in terms of convergence speed and the possibility of getting trapped in local optima. These problems were addressed by using a deep neural network architecture for depression detection tasks along with the PS-CS optimization technique. The PS-CS algorithm combines the strengths of both particle swarm optimization and cuckoo search algorithms, which allows for a more efficient and effective optimization of the network parameters. We also evaluated how well the suggested methods performed against the most widely used classification models, including (K-nearest neighbor) KNN, (support vector regression) SVR, and decision trees, as well as the most widely used deep learning models, including residual neural network (ResNet), visual geometry group (VGG), and simple neural network (LeNet). The findings show that the suggested method, PS-CS, in conjunction with the CNN model, outperformed all other models, achieving the maximum accuracy of 99.5%. Other models, such as the KNN, decision trees, and logistic regression, achieved lower accuracies ranging from 69% to 97%.