A new particle swarm optimization algorithm with dynamically changing inertia weight based on chaos particle swarm optimization was proposed, in which the inertia weight of the particle was adjusted adaptively based on the premature convergence degree of the swarm and the fitness of the particle, the diversity of inertia weight made a compromise between the global convergence and convergence speed, so it can effectively alleviate the problem of premature convergence. The algorithm was applied to train neural network and a model of fault diagnosis for rotating machinery was established, compared with particle swarm optimization algorithm and genetic algorithm, the proposed algorithm can effectively improve the training efficiency of neural network and obtain good diagnosis results.