Aiming at solving the problems of fault diagnosis based on machine learning model, such as relying on manual feature extraction quality, dimension disaster, lack of selfadaptation of convolutional neural network (CNN) model construction,a fault diagnosis method of adaptive CNN based on particle swarm optimization (PSO) was proposed and applied to fault diagnosis of rotating machinery. Firstly, onedimensional timedomain signal was transformed into twodimensional timefrequency image; Then, the PSO algorithm was employed to optimize the seven key parameters in the CNN model to construct a deep learning model. Finally, the twodimensional timefrequency image was input into the optimized model to diagnose rotating machinery faults. The results show that the proposed method has high accuracy, stability and adaptability.