Cancer is still one of the most life threatening disease and by far it is still difficult to prevent, prone to recurrence and metastasis and high in mortality. Lots of studies indicate that early cancer diagnosis can effectively increase the survival rate of patients. But early stage cancer is difficult to be detected because of its inconspicuous features. Hence, convenient and effective cancer detection methods are urgently needed. In this paper, we propose to utilize deep autoencoder to learn latent representation of high-dimensional mass spectrometry data. Meanwhile, as a contrast, traditional particle swarm optimization (PSO) optimization algorithm are also used to select optimized features from mass spectrometry data. The learned features are further evaluated on three cancer datasets. The experimental results demonstrate that the cancer detection accuracy by learned features is as high as 100%. As our main contribution, the deep autoencoder method used in this study is a feasible and powerful instrument for mass spectrometry feature learning and also cancer diagnosis.