Particle Swarm Algorithm (PSO) Optimized BP Neural Network Predictive Regression – with code

Time:2024-1-11

catalogs

Abstracts:

1.BP model neural network model

2. Particle Swarm Optimization Algorithm (PSO)

pseudocode implementation

3. Particle swarm algorithm combined with BP neural network (PSO-BP)

4. Results of program operation

5. Matlab code for this paper


Abstracts:

BP neural network is a common multi-layer feed-forward neural network, this article through the particle swarm algorithm (PSO) on the BP neural network network network parameters for optimization, to get the most optimal network parameters, and with no PSO BP network on the same test samples for prediction, comparative analysis and highlight the superiority of the PSO-BP. The code in this article is highly adaptable, detailed comments, replace the inputs and outputs to meet different tasks, to achieve the function you want, suitable for new entrants to the neural network students to learn.

1.BP model neural network model

Particle Swarm Algorithm (PSO) Optimized BP Neural Network Predictive Regression - with code

Particle Swarm Algorithm (PSO) Optimized BP Neural Network Predictive Regression - with code

2. Particle Swarm Optimization Algorithm (PSO)

The idea of the particle swarm algorithm originated from the study of the foraging behavior of bird flocks, which enables the group to find the optimal destination through collective information sharing. As shown in the figure below, envision a scenario in which a flock of birds is randomly searching for food in a forest, and they want to find the location with the largest amount of food. However, all the birds do not know exactly where the food is, but can only sense the approximate direction in which the food is located. Each bird searches in the direction it determines, and as it searches, it records the location where it has found the most food, and all birds share the location and amount of food they have found each time, so that the flock knows where the most food is currently located. During the search, each bird adjusts the direction of its search according to the location it remembers as having the most food and the location where the flock has recorded the most food. After a period of searching, the flock can find out which location in the forest has the most food (global optimal solution).

After finding the twooptimum valueThe particle updates its velocity and new position according to the following equationParticle Swarm Algorithm (PSO) Optimized BP Neural Network Predictive Regression - with code

v[ ] is the velocity of the particle and present[ ] is the current position of the particle. pbest[ ] and gbest[ ] are as defined previously.rand() Is between (0,1)random number. c1, c2 are learning factors. Usually c1=c2=2.

pseudocode implementation

For each particle

____Initialize particle

END

Do

____For each particle

________Calculate fitness value

________If the fitness value is better than the best fitness value (pBest) in history

____________set current value as the new pBest

____End

____Choose the particle with the best fitness value of all the particles as the gBest

____For each particle

________Calculate particle velocity according equation (a)

________Update particle position according equation (b)

____End

While maximum iterations or minimum error criteria is not attained

at eachone-dimensional (math.)The velocities of the particles are all limited to a maximum velocity Vmax, and if the updated velocity of a dimension exceeds the user-set Vmax, then that dimension is limited to Vmax.

3. Particle swarm algorithm combined with BP neural network (PSO-BP)

The hidden nodes of the BP neural network are usually determined by the repetitive forward transmission and back propagation, and by modifying or constructing the number of nodes that are changed to be hidden by the training method, the corresponding initial weights and thresholds will also be changed, thus affecting the convergence and learning efficiency of the network. In order to reduce the impact, the adjustment of weights and thresholds is optimized by using the BP neural network model based on the particle swarm algorithm, so as to accelerate the convergence speed of the network and improve the learning efficiency of the network. The specific calculation process is as follows:

Particle Swarm Algorithm (PSO) Optimized BP Neural Network Predictive Regression - with code

4. Results of program operation

Particle Swarm Algorithm (PSO) Optimized BP Neural Network Predictive Regression - with code

5. Matlab code for this paper

Recommended Today

Resolved the Java. SQL. SQLNonTransientConnectionException: Could not create connection to the database server abnormal correctly solved

Resolved Java. SQL. SQLNonTransientConnectionException: Could not create connection to the database server abnormal correct solution, kiss measuring effective!!!!!! Article Catalog report an error problemSolutionscureexchanges report an error problem java.sql.SQLNonTransientConnectionException:Could not create connection to database server Solutions The error “java.sql.SQLNonTransientConnectionException:Could not create connection to database server” is usually caused by an inability to connect to the […]