Recommender systems are known as intelligent systems which have many applications in enormous domains such as social networks, e-commerce services, and online shopping. Deep neural networks have shown significant improvement in the performance of recommender systems by learning the latent features of users/items based on input data. However, it is a challenging issue to how to apply deep neural networks on different resources and how to integrate their results. In this regard, we propose a recommender system in this paper based on deep sparse autoencoder and particle swarm optimization. In particular, a deep sparse autoencoder is utilized to learn latent features based on the ratings matrix, trust relationships, and tag information. Then, particle swarm optimization is used to find the optimal weights of these latent features in calculating unknown ratings. Experiments on two datasets show the superiority of the proposed method in comparison with state of the art recommender algorithms.