Here’s an example of a PSO optimizing the weights of a NN performing XOR.

Each particle is a 9D vector:

Our objective is to minimize the error between the desired and actual outputs of the network. This is done by randomly initializing a group of particles and letting them move in the search space until an acceptable error is reached.