# Design and Application of BP Neural Network Optimization Method Based on SIWSPSO Algorithm

Authors: Lina Chu
Journal: Security and Communication Networks
 (2022)

---

## Abstract

BP neural network method can deal with nonlinear and uncertain problems well and is widely used in the construction of classification, clustering, prediction, and other models. However, BP neural network method has some limitations in fitting nonlinear functions, such as slow convergence speed and easy local optimal convergence rather than global optimal convergence. In order to solve the insufficiency, the optimization approach applying BP neural networks is discussed. This paper proposes a simplified PSO algorithm based on stochastic inertia weight (SIWSPSO) algorithm to optimize BP neural network. In order to test the effect and applicability of the method, this paper established a quality safety risk warning based on SIWSPSO-BP network and selected the detection data of intelligent door lock products for risk warning experiment. The experimental results show that the convergence speed of SIWSPSO-BP model was increased by two times and the accuracy of product quality risk warning reached 85%, which significantly improves the accuracy and learning efficiency of risk warning.


---

## Body

## 1. Introduction

ANN is a computational model which simulates biological neural network. ANN approaches the target function through repeated training, which has the characteristics of parallel processing, discreteness, and self-learning. This algorithm can carry out large-scale nonlinear operations on big data and is suitable for building learning and prediction models [1–3]. At present, the more mature neural networks include convolutional neural network and BP neural network. Due to the complexity of convolutional neural network, the advantages of BP neural network have been highlighted. It is widely used in many fields such as artificial intelligence, signal processing, and automation. It is the most widely studied and applied artificial neural network at present.In recent years, many scholars have carried out extensive research on the application of neural network. The optimization of BP network [4] is also in progress. The main optimization is to find the algorithm of optimal network error, optimize network input and network parameters, etc. The methods of the global optimal solution to find the optimal error of the network include PSO algorithm [5], GA algorithm [6], and compression mapping genetics [7]. The input of network optimization is in the aspect of data feature extraction [8, 9], such as principal component analysis (PCA) method [10], 13-point feature extraction algorithm [11], and four-angle feature extraction method [12]. The optimization of network parameters includes the addition of error momentum term [13], the use of adaptive learning rate [14], and the use of adjustable activation function [15]. Literature [16] studied the BP neural network model based on the end echo reflection method, taking the probe K value and the sound path difference of the reflected wave corresponding to the highly cracked end as the input vector for network training. In literature [17], the improved genetic algorithm was used to conduct global search for the optimal weights and thresholds of the network, and BP algorithm was used for local optimization to obtain the predicted wind speed. Literature [18] introduced the double-layer evolution mechanism of cultural algorithm into particle swarm optimization algorithm and updated its own speed and position by learning the optimal particle. In literature [19], the adaptive chaotic particle swarm optimization algorithm is used to optimize the objective function. When the function solution falls into the local optimum, the chaotic search is used to guide the particle to search again.BP network has some problems, such as slow convergence speed, sensitivity to initial value, local minimum, hidden layer number, and neuron number. A simplified particle swarm optimization (SIWSPSO) algorithm based on random inertia weight is proposed to explore the optimization method of BP neural network application. The backpropagation neural network is optimized. An experimental model was established to verify the method.This paper mainly has the following innovations:(1)
The inertia weight is described by random variables, and the learning factor adopts asynchronous change strategy to replace the individual extreme value of each particle with the average value of the individual extreme value of all particles.(2)
The simplified particle swarm optimization algorithm based on random inertia weight is used to optimize and solve the global optimal value.This paper consists of five main sections: Section 1 gives an introduction, Section 2 discusses related research, Section 3 presents the model design, Section 4 provides case application and analysis, and Section 5 concludes the paper.


## 2. Related Work

### 2.1. BP Neural Network

BP neural network consists of input node layer, hidden node layer, and output node layer. When information is propagated forward, input data is passed in from the input layer [20]. If the actual output of the output layer in the neural network does not conform to the expected output, the direction of reverse propagation of the steering error is reversed, and the weight of each node layer is correctly modified according to the error [21]. The operating principle of BP neural network is that the information is propagating forward and the error is propagating backward. The error signal is used as the basis for correcting the weights of each unit. Its network topology is shown in Figure 1.Figure 1
BP neural network structure model.Myx represents the weights of the input node layer and the hidden node layer. Mxl represents the weights of the implicit node layer and the output node layer. pxN represents the input of the x-th neuron in the hidden node layer. qxN represents the output of excitation from x-th neuron. The current sample set is I, and Iz = [Iz1, Iz2,... Izt] for any sample.The actual output isZt, and the mathematical expectation Dz is the number of iterations of T.(1)
Network inputs sampleIz, which can be obtained from forward information transmission:(1)pxN=∑w−1WMyxIzw,qxN=fpxN=f∑w−1WMyxIzw,pyY=∑x−1XMxlQxX,qxY=∮pxN=∮∑x−1XMylIxX,Zt=qxY==∮∑x−1XMylIxX,outputting node-layer neural network error signal:(2)ezt=dzt−jzt.The sum of errors at the output node layer is as follows:(3)Et=12∑l−1Lez2.The information is always passed forward from the first input node layer and ended at the output node layer, and the learning errorE(t) is calculated.(2)
Error reverse transmission process is carried out when errors are generated. Error information is reversely transmitted from the output node layer backward to the input node layer. The weight and threshold of each layer are modified. Now, the partial derivative of the error to the weight in the algorithm is directly proportional to the correction of the weight in the output node layer and the hidden node layer [22]; that is,(4)△Mxlt∝∂Et∂Mxlt.Among them,(5)∂Et∂Mxlt=∂Et∂plLt×∂plL∂Mxlt=∂Et∂ezt×∂ezt∂Zzt×∂Zzt∂PyYt×∂PyYt∂Mxlt.Then, after the next iteration, the weight is adjusted to(6)Mxyt+1=Mxlt+ΔMxlt.At this time, the network error feedback propagation is completed, and the weight between each node layer is worth an iterative update. BP neural network algorithm needs repeated iterations to make the error generated by learning converge to the expected accuracy [23].


### 2.2. Basic Principle of Gradient Descent Algorithm

Gradient descent method is also known as the fastest descent method, which searches for the weight and threshold of the optimal state along the direction of negative gradient. Now, the gradient descent algorithm is designed, and its strong local search ability makes up for the local search dilemma of BP neural network [24]. The operation is as follows.For a sample oft features, it is expressed as a function.(7)bi1,i2,…,it=θ0+θ1i1+θ2i2+⋯+θtit.θx (x = 0, 1, 2, ..., t) represents the coefficient on the model, and ix (x = 0, 1, 2, ..., t) represents t variable parameters for each sample. Its loss function can be expressed as(8)yθ=12w∑l=0wbi0y,i1y,…,iwy−zy2.The smaller the loss function is, the better the fitting degree is.The negative gradient of the loss function is calculated by(9)−∂∂θxyθ=−1w∑l=0wbi0y,i1y,…,iwy−zyixy.Multiply the step sizeα by the negative gradient of the loss function to get the current correction, which is −α∂/∂θxyθ, and update the current correction, which is θnew=θx−α∂/∂θxyθ.At this point, an iteration of gradient descent is completed, and the above process is repeated until the loss function tends to the minimum and the gradient descent iteration ends.


### 2.3. PSO Algorithm

Inspired by the foraging behavior of birds, particle swarm optimization (PSO) is a random optimization algorithm based on swarm intelligence. The main idea is to solve the problem through the learning behavior of individual particles and the cooperative interaction between groups. Due to its advantages of simple structure, strong parallelism, and fast convergence, PSO algorithm is mostly applied to solve multiobjective optimization, neural network training, image processing, and other problems [25]. However, PSO is also prone to premature convergence and local optima. In view of these problems, many scholars have put forward improvement methods from various aspects, that is, parameter adjustment, elite selection, algorithm mixing, and other strategies. Literature [26] had proposed a linear decreasing rule of inertia weight. On this basis, literature [27] improved the convergence and convergence speed of the algorithm by dynamically adjusting the strategy. In addition, some scholars made similar improvements on the acceleration factor of PSO and proposed the time-varying self-organizing PSO algorithm (HPSO-TVAC) [28]. In order to further improve the particle optimization ability, literature [29] applied the neighborhood optimal solution to the velocity updating formula and determined the learning intensity through the iterative process. In recent years, good results have been obtained by using topological structure changes to select learning models. As shown in literature [30], a new two-layer population structure was designed by using the double-difference mutation strategy, and elite particles were generated by inference mutation operation with two different control parameters to ensure population diversity. A particle swarm optimization algorithm with heterogeneous clustering (APSO-C) was proposed in literature [31]. K-means clustering was used to dynamically cluster the population, information was exchanged among clusters through ring structure, and learning samples were selected. Many studies have shown that both dynamic multipopulation structure [32] and adaptive learning framework can effectively improve the global search ability of the algorithm. It can overcome the precocious phenomenon of PSO to some extent. In terms of hybrid algorithm, some scholars also use genetic operator and simulated annealing operation to deepen local optimization, and combine differential evolution algorithms to modify the global optimal particle.


#### 2.3.1. Basic Ideas of Particle Swarm Optimization

PSO algorithm originated from the study of foraging behavior of birds. There are some similarities between swarm foraging and optimization problem solving. Therefore, people simulate the biological principle of bird swarm foraging to make optimization decisions and find the optimal solution of the problem. The implementation process of the standard PSO algorithm is as follows.Supposet particles form a population in the W-dimension (that is, there are W function independent variables) search domain and t represents the population size. If the population is too small, the diversity of particle population cannot be guaranteed and the algorithm performance is poor. Although too large population can increase the efficiency of optimization and prevent premature convergence, it will undoubtedly increase the amount of calculation, resulting in too long convergence time, which is manifested as slow convergence. Ix=(ix1, ix2,...,ixW) (x = 1, 2,..., t) is the position vector of particle I, and the particle dimension depends on the number of variables of the function to be optimized. Here, ixz∈[L,P] represents the value of particle X on the Z-th independent variable. In practical application, the value of each dimension of I is guaranteed to be within a certain range. This is equivalent to the domain of independent variables in function optimization problems. L represents the lower limit of the Z-th independent variable, and U represents the upper limit of the k-th independent variable. Qx=(qx1,qx2,...,qxW) is the velocity vector of particle X, and they are all W dimensions. Qxz∈[qmin, qmax], where qmin represents the minimum velocity of the particle in the z-dimension direction and qmax represents the maximum velocity of the particle in the z-th dimension. In each generation of optimization, the particle will adjust its flight direction and orientation according to the historical optimal position found by itself and the colony.Remember thatUx = (ux1, ux2,...,uxW) is the position with the best adaptive value found by particle X itself. Remember that Ua= (ua1, ua2,...,uaW) is the optimal position searched by the whole particle swarm.Letf(i) be the fitness function, and the individual optimal position of particle I is as follows:(10)uxz=uxz−1,fuxz≥fuxz−1,ixz,fuxz<fuxz−1.The global optimal position found by all particles in the group is as follows:(11)ua∈u1z,u2z,…,uWz|fua=minfu1z,u2z,…,uWz.When thex-th particle of the n-th generation evolves to the (n +1)-th generation, the velocity and position of the y-th dimension are calculated by the following evolution equation:(12)qxyn+1=m×qxyn+c1×r1×uxyn−ixyn+c2×r2×uayn−ixynixyn+1=ixyn+qxyn+1.where m is the inertial weight, C1 and C2 are acceleration factors, and r1 and r2 are random quantities.The velocity and position of each one-dimensional particle will be constrained within a range. In order to prevent the particle from escaping out of the solution space, if the boundary condition is exceeded, the following methods are adopted:whenqxy>qmax,ixy>imax, qxy=qmax,ixy=imax,orwhenqxy<−qmax,ixy<−imax, qxy=−qmax,ixy=−imax.


#### 2.3.2. Influence of Parameters on Particle Swarm Optimization

The search performance of the algorithm is highly dependent on parameters. The algorithm involves three parameters: inertia weightm and acceleration factors c1 and c2. If the three parameters are set to constant values or linear changes, this will adversely affect the optimization and efficiency of the algorithm. Improper setting of the three parameters may cause the particle swarm optimization algorithm to evolve into a local optimization algorithm, or the particle swarm will lose its diversity at an early stage, resulting in premature convergence of the algorithm. In addition, in the early stage of optimization, it can improve the ability of particles to search the global optimal solution and make particles have higher velocity. However, when approaching the optimal solution in the later stage, in order not to make the particle velocity too high and deviate from the optimal location region, the particle misses the global optimal solution and falls into the local optimal solution. Therefore, when approaching the global optimal region in the later stage, the position updating amplitude should not be too large, and the particle velocity should be effectively adjusted and constrained. We should not ignore the fact that the particle may move out of the global optimal region due to excessive velocity in the later stage, which may lead to immature convergence of the algorithm. In view of the above reasons, the nonlinear shrinkage factor ρ(n) is introduced into the PSO calculation.In the process of algorithm search, the change of inertia weight value should meet the following requirements: the speed of early reduction is relatively slow, the inertia weight value is large, and the reduction is small, which is conducive to global exploration. The later stage is small, and the reduction speed is fast, which is conducive to the particle carrying out fine local search and effectively avoiding falling into local optimum. In addition, the changes of the two acceleration factors of the algorithm should meet the requirements thatc1 first becomes large and then small, and c2 first becomes small and then large, so that the algorithm can give consideration to both local and global search.


## 2.1. BP Neural Network

BP neural network consists of input node layer, hidden node layer, and output node layer. When information is propagated forward, input data is passed in from the input layer [20]. If the actual output of the output layer in the neural network does not conform to the expected output, the direction of reverse propagation of the steering error is reversed, and the weight of each node layer is correctly modified according to the error [21]. The operating principle of BP neural network is that the information is propagating forward and the error is propagating backward. The error signal is used as the basis for correcting the weights of each unit. Its network topology is shown in Figure 1.Figure 1
BP neural network structure model.Myx represents the weights of the input node layer and the hidden node layer. Mxl represents the weights of the implicit node layer and the output node layer. pxN represents the input of the x-th neuron in the hidden node layer. qxN represents the output of excitation from x-th neuron. The current sample set is I, and Iz = [Iz1, Iz2,... Izt] for any sample.The actual output isZt, and the mathematical expectation Dz is the number of iterations of T.(1)
Network inputs sampleIz, which can be obtained from forward information transmission:(1)pxN=∑w−1WMyxIzw,qxN=fpxN=f∑w−1WMyxIzw,pyY=∑x−1XMxlQxX,qxY=∮pxN=∮∑x−1XMylIxX,Zt=qxY==∮∑x−1XMylIxX,outputting node-layer neural network error signal:(2)ezt=dzt−jzt.The sum of errors at the output node layer is as follows:(3)Et=12∑l−1Lez2.The information is always passed forward from the first input node layer and ended at the output node layer, and the learning errorE(t) is calculated.(2)
Error reverse transmission process is carried out when errors are generated. Error information is reversely transmitted from the output node layer backward to the input node layer. The weight and threshold of each layer are modified. Now, the partial derivative of the error to the weight in the algorithm is directly proportional to the correction of the weight in the output node layer and the hidden node layer [22]; that is,(4)△Mxlt∝∂Et∂Mxlt.Among them,(5)∂Et∂Mxlt=∂Et∂plLt×∂plL∂Mxlt=∂Et∂ezt×∂ezt∂Zzt×∂Zzt∂PyYt×∂PyYt∂Mxlt.Then, after the next iteration, the weight is adjusted to(6)Mxyt+1=Mxlt+ΔMxlt.At this time, the network error feedback propagation is completed, and the weight between each node layer is worth an iterative update. BP neural network algorithm needs repeated iterations to make the error generated by learning converge to the expected accuracy [23].


## 2.2. Basic Principle of Gradient Descent Algorithm

Gradient descent method is also known as the fastest descent method, which searches for the weight and threshold of the optimal state along the direction of negative gradient. Now, the gradient descent algorithm is designed, and its strong local search ability makes up for the local search dilemma of BP neural network [24]. The operation is as follows.For a sample oft features, it is expressed as a function.(7)bi1,i2,…,it=θ0+θ1i1+θ2i2+⋯+θtit.θx (x = 0, 1, 2, ..., t) represents the coefficient on the model, and ix (x = 0, 1, 2, ..., t) represents t variable parameters for each sample. Its loss function can be expressed as(8)yθ=12w∑l=0wbi0y,i1y,…,iwy−zy2.The smaller the loss function is, the better the fitting degree is.The negative gradient of the loss function is calculated by(9)−∂∂θxyθ=−1w∑l=0wbi0y,i1y,…,iwy−zyixy.Multiply the step sizeα by the negative gradient of the loss function to get the current correction, which is −α∂/∂θxyθ, and update the current correction, which is θnew=θx−α∂/∂θxyθ.At this point, an iteration of gradient descent is completed, and the above process is repeated until the loss function tends to the minimum and the gradient descent iteration ends.


## 2.3. PSO Algorithm

Inspired by the foraging behavior of birds, particle swarm optimization (PSO) is a random optimization algorithm based on swarm intelligence. The main idea is to solve the problem through the learning behavior of individual particles and the cooperative interaction between groups. Due to its advantages of simple structure, strong parallelism, and fast convergence, PSO algorithm is mostly applied to solve multiobjective optimization, neural network training, image processing, and other problems [25]. However, PSO is also prone to premature convergence and local optima. In view of these problems, many scholars have put forward improvement methods from various aspects, that is, parameter adjustment, elite selection, algorithm mixing, and other strategies. Literature [26] had proposed a linear decreasing rule of inertia weight. On this basis, literature [27] improved the convergence and convergence speed of the algorithm by dynamically adjusting the strategy. In addition, some scholars made similar improvements on the acceleration factor of PSO and proposed the time-varying self-organizing PSO algorithm (HPSO-TVAC) [28]. In order to further improve the particle optimization ability, literature [29] applied the neighborhood optimal solution to the velocity updating formula and determined the learning intensity through the iterative process. In recent years, good results have been obtained by using topological structure changes to select learning models. As shown in literature [30], a new two-layer population structure was designed by using the double-difference mutation strategy, and elite particles were generated by inference mutation operation with two different control parameters to ensure population diversity. A particle swarm optimization algorithm with heterogeneous clustering (APSO-C) was proposed in literature [31]. K-means clustering was used to dynamically cluster the population, information was exchanged among clusters through ring structure, and learning samples were selected. Many studies have shown that both dynamic multipopulation structure [32] and adaptive learning framework can effectively improve the global search ability of the algorithm. It can overcome the precocious phenomenon of PSO to some extent. In terms of hybrid algorithm, some scholars also use genetic operator and simulated annealing operation to deepen local optimization, and combine differential evolution algorithms to modify the global optimal particle.


### 2.3.1. Basic Ideas of Particle Swarm Optimization

PSO algorithm originated from the study of foraging behavior of birds. There are some similarities between swarm foraging and optimization problem solving. Therefore, people simulate the biological principle of bird swarm foraging to make optimization decisions and find the optimal solution of the problem. The implementation process of the standard PSO algorithm is as follows.Supposet particles form a population in the W-dimension (that is, there are W function independent variables) search domain and t represents the population size. If the population is too small, the diversity of particle population cannot be guaranteed and the algorithm performance is poor. Although too large population can increase the efficiency of optimization and prevent premature convergence, it will undoubtedly increase the amount of calculation, resulting in too long convergence time, which is manifested as slow convergence. Ix=(ix1, ix2,...,ixW) (x = 1, 2,..., t) is the position vector of particle I, and the particle dimension depends on the number of variables of the function to be optimized. Here, ixz∈[L,P] represents the value of particle X on the Z-th independent variable. In practical application, the value of each dimension of I is guaranteed to be within a certain range. This is equivalent to the domain of independent variables in function optimization problems. L represents the lower limit of the Z-th independent variable, and U represents the upper limit of the k-th independent variable. Qx=(qx1,qx2,...,qxW) is the velocity vector of particle X, and they are all W dimensions. Qxz∈[qmin, qmax], where qmin represents the minimum velocity of the particle in the z-dimension direction and qmax represents the maximum velocity of the particle in the z-th dimension. In each generation of optimization, the particle will adjust its flight direction and orientation according to the historical optimal position found by itself and the colony.Remember thatUx = (ux1, ux2,...,uxW) is the position with the best adaptive value found by particle X itself. Remember that Ua= (ua1, ua2,...,uaW) is the optimal position searched by the whole particle swarm.Letf(i) be the fitness function, and the individual optimal position of particle I is as follows:(10)uxz=uxz−1,fuxz≥fuxz−1,ixz,fuxz<fuxz−1.The global optimal position found by all particles in the group is as follows:(11)ua∈u1z,u2z,…,uWz|fua=minfu1z,u2z,…,uWz.When thex-th particle of the n-th generation evolves to the (n +1)-th generation, the velocity and position of the y-th dimension are calculated by the following evolution equation:(12)qxyn+1=m×qxyn+c1×r1×uxyn−ixyn+c2×r2×uayn−ixynixyn+1=ixyn+qxyn+1.where m is the inertial weight, C1 and C2 are acceleration factors, and r1 and r2 are random quantities.The velocity and position of each one-dimensional particle will be constrained within a range. In order to prevent the particle from escaping out of the solution space, if the boundary condition is exceeded, the following methods are adopted:whenqxy>qmax,ixy>imax, qxy=qmax,ixy=imax,orwhenqxy<−qmax,ixy<−imax, qxy=−qmax,ixy=−imax.


### 2.3.2. Influence of Parameters on Particle Swarm Optimization

The search performance of the algorithm is highly dependent on parameters. The algorithm involves three parameters: inertia weightm and acceleration factors c1 and c2. If the three parameters are set to constant values or linear changes, this will adversely affect the optimization and efficiency of the algorithm. Improper setting of the three parameters may cause the particle swarm optimization algorithm to evolve into a local optimization algorithm, or the particle swarm will lose its diversity at an early stage, resulting in premature convergence of the algorithm. In addition, in the early stage of optimization, it can improve the ability of particles to search the global optimal solution and make particles have higher velocity. However, when approaching the optimal solution in the later stage, in order not to make the particle velocity too high and deviate from the optimal location region, the particle misses the global optimal solution and falls into the local optimal solution. Therefore, when approaching the global optimal region in the later stage, the position updating amplitude should not be too large, and the particle velocity should be effectively adjusted and constrained. We should not ignore the fact that the particle may move out of the global optimal region due to excessive velocity in the later stage, which may lead to immature convergence of the algorithm. In view of the above reasons, the nonlinear shrinkage factor ρ(n) is introduced into the PSO calculation.In the process of algorithm search, the change of inertia weight value should meet the following requirements: the speed of early reduction is relatively slow, the inertia weight value is large, and the reduction is small, which is conducive to global exploration. The later stage is small, and the reduction speed is fast, which is conducive to the particle carrying out fine local search and effectively avoiding falling into local optimum. In addition, the changes of the two acceleration factors of the algorithm should meet the requirements thatc1 first becomes large and then small, and c2 first becomes small and then large, so that the algorithm can give consideration to both local and global search.


## 2.3.1. Basic Ideas of Particle Swarm Optimization

PSO algorithm originated from the study of foraging behavior of birds. There are some similarities between swarm foraging and optimization problem solving. Therefore, people simulate the biological principle of bird swarm foraging to make optimization decisions and find the optimal solution of the problem. The implementation process of the standard PSO algorithm is as follows.Supposet particles form a population in the W-dimension (that is, there are W function independent variables) search domain and t represents the population size. If the population is too small, the diversity of particle population cannot be guaranteed and the algorithm performance is poor. Although too large population can increase the efficiency of optimization and prevent premature convergence, it will undoubtedly increase the amount of calculation, resulting in too long convergence time, which is manifested as slow convergence. Ix=(ix1, ix2,...,ixW) (x = 1, 2,..., t) is the position vector of particle I, and the particle dimension depends on the number of variables of the function to be optimized. Here, ixz∈[L,P] represents the value of particle X on the Z-th independent variable. In practical application, the value of each dimension of I is guaranteed to be within a certain range. This is equivalent to the domain of independent variables in function optimization problems. L represents the lower limit of the Z-th independent variable, and U represents the upper limit of the k-th independent variable. Qx=(qx1,qx2,...,qxW) is the velocity vector of particle X, and they are all W dimensions. Qxz∈[qmin, qmax], where qmin represents the minimum velocity of the particle in the z-dimension direction and qmax represents the maximum velocity of the particle in the z-th dimension. In each generation of optimization, the particle will adjust its flight direction and orientation according to the historical optimal position found by itself and the colony.Remember thatUx = (ux1, ux2,...,uxW) is the position with the best adaptive value found by particle X itself. Remember that Ua= (ua1, ua2,...,uaW) is the optimal position searched by the whole particle swarm.Letf(i) be the fitness function, and the individual optimal position of particle I is as follows:(10)uxz=uxz−1,fuxz≥fuxz−1,ixz,fuxz<fuxz−1.The global optimal position found by all particles in the group is as follows:(11)ua∈u1z,u2z,…,uWz|fua=minfu1z,u2z,…,uWz.When thex-th particle of the n-th generation evolves to the (n +1)-th generation, the velocity and position of the y-th dimension are calculated by the following evolution equation:(12)qxyn+1=m×qxyn+c1×r1×uxyn−ixyn+c2×r2×uayn−ixynixyn+1=ixyn+qxyn+1.where m is the inertial weight, C1 and C2 are acceleration factors, and r1 and r2 are random quantities.The velocity and position of each one-dimensional particle will be constrained within a range. In order to prevent the particle from escaping out of the solution space, if the boundary condition is exceeded, the following methods are adopted:whenqxy>qmax,ixy>imax, qxy=qmax,ixy=imax,orwhenqxy<−qmax,ixy<−imax, qxy=−qmax,ixy=−imax.


## 2.3.2. Influence of Parameters on Particle Swarm Optimization

The search performance of the algorithm is highly dependent on parameters. The algorithm involves three parameters: inertia weightm and acceleration factors c1 and c2. If the three parameters are set to constant values or linear changes, this will adversely affect the optimization and efficiency of the algorithm. Improper setting of the three parameters may cause the particle swarm optimization algorithm to evolve into a local optimization algorithm, or the particle swarm will lose its diversity at an early stage, resulting in premature convergence of the algorithm. In addition, in the early stage of optimization, it can improve the ability of particles to search the global optimal solution and make particles have higher velocity. However, when approaching the optimal solution in the later stage, in order not to make the particle velocity too high and deviate from the optimal location region, the particle misses the global optimal solution and falls into the local optimal solution. Therefore, when approaching the global optimal region in the later stage, the position updating amplitude should not be too large, and the particle velocity should be effectively adjusted and constrained. We should not ignore the fact that the particle may move out of the global optimal region due to excessive velocity in the later stage, which may lead to immature convergence of the algorithm. In view of the above reasons, the nonlinear shrinkage factor ρ(n) is introduced into the PSO calculation.In the process of algorithm search, the change of inertia weight value should meet the following requirements: the speed of early reduction is relatively slow, the inertia weight value is large, and the reduction is small, which is conducive to global exploration. The later stage is small, and the reduction speed is fast, which is conducive to the particle carrying out fine local search and effectively avoiding falling into local optimum. In addition, the changes of the two acceleration factors of the algorithm should meet the requirements thatc1 first becomes large and then small, and c2 first becomes small and then large, so that the algorithm can give consideration to both local and global search.


## 3. Model Building

All models in this paper were trained and tested on a computer with Core I5-7500 CPU @3.40 GHz and 64 GB memory. The computer system is 64-bit Windows 10 Professional. All models are implemented with Matlab 2020a Deep Learning Toolbox framework.


### 3.1. SIWSPSO Optimized BP Neural Network

In BP neural networks, random initialization weights and thresholds usually make the network fall into local extremum points, which further affects its nonlinear fitting ability and network operation efficiency. Initial thresholds and weights are equivalent to particles in particle swarm optimization. The test error of BP neural network is taken as the fitness function. The time-domain peak value, center frequency, 3 dB bandwidth in frequency domain, upper limit cut-off frequencyfH, and lower limit cut-off frequency fL of transmitted wave signal are selected as the input of neural network, and the expected value is the output of neural network. In this paper, the random inertia weight value is introduced to improve the PSO algorithm, and the application model of SIWSPSO-BP neural network is established. See Figure 2.Figure 2
SIWSPSO-BP model.


### 3.2. Product Quality Risk Warning Model

Product quality risk early warning model adopts qualitative and quantitative methods to conduct comprehensive risk analysis of products, and the evaluation steps are as follows:(1)
The unqualified test items are taken as risk factors, and the unqualified rate is divided into five levels of 20% each. According to Table1, determine the x value.(2)
The impact of risk factors is divided into 5 levels and assigned to each level, as shown in Table2.(3)
A number of experts in the field of product quality and safety and risk assessment are invited to assess the impact of items on risk occurrence according to expert analysis and evaluation, and the scores are given according to the instructions in Table3. The average score is used as the rating basis to determine the j value.(4)
According to expert analysis and evaluation, determine the values ofw and t ( w +t = 1), divide the risk grade into different grades, and define the corresponding relationship between the risk grade and the quantitative value (K).(13)K=wi2+tj2.In the formula,K is the risk grade value, w is the weight value of the possibility of risk factor, t is the weight value of the influence degree of risk, i is the possibility of the occurrence of risk factor, and j is the influence degree of risk factor.(5)
Calculate the risk level values according to steps 1–4, and build the risk level classification matrix according to the possibility of risk, as shown in Table4.(6)
Select the risk factor with the highest risk grade value, and determine the risk grade of the risk assessment of the product according to the risk grade classification matrix.Table 1
Classification of risk occurrence possibility.
LevelFeature descriptionAssignmentVery low(0～20%)(0～1)Low(20～40%)(1～2)Medium(40～60%)(2～3)High(60～80%)(3～4)Very high(80%～100%)(4～5)Table 2
Description of influence degree of risk factors.
Degree of influenceDescriptionAssignmentKeyRisk factor is the key factor leading to risk(4～5)SeriousThe impact of risk factors is significant(3～4)GeneralThe impact of risk factors is moderate(2～3)SmallRisk factors have little influence(1～2)Can be ignoredThe impact of risk factors can be ignored(0～1)Table 3
Summary analysis table of networked intelligent door lock project detection results (section).
NumberSample numberName of manufacturerProduct informationTest itemSample nameSpecificationsTrade markAnti-violence openingRFID lock safetyAnti-damage alarmPassword entry testSensitive information protectionData encryption transmissionSecurity scanningDecompilingNetwork security1W01814501800Company 1Intelligent lock112RX1QualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualified2W01814501801Company 2Smart door lockH636X2QualifiedUnqualifiedQualifiedQualifiedUnqualifiedQualifiedUnqualifiedUnqualifiedQualified3W01814501802Company 3Smart door lockS400X3QualifiedUnqualifiedQualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualified4W01814501803Company 4Smart fingerprint lockVHSX4QualifiedUnqualifiedQualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualified5W01814501804Company 5Cloud intelligent lockHZ8-R-TX5QualifiedUnqualifiedQualifiedQualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualified6W01814501805Company 6Smart fingerprint lockD2X6QualifiedQualifiedQualifiedQualifiedQualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedTable 4
Risk grade classification matrix.
Risk factor possibilityThe extent of the impact on the riskKeySeriousGeneralSmallIgnoredVery highHighHighHighMediumMediumHighHighHighMediumMediumLowMediumHighMediumMediumLowLowLowMediumMediumLowLowLowVery lowMediumLowLowLowLow


### 3.3. Training Warning Model Based on SIWSPSO-BP

The product quality warning model was designed and trained based on SIWSPSO-BP algorithm, and input layer vector, hidden layer node number and weight, output layer vector and activation function were determined.(1)
Input layer vector. Product quality risk warning needs to input a variety of product quality testing items, which have different effects on product quality. Therefore, key testing items affecting product quality are extracted as input vectors.(2)
Hidden layer design. The hidden layer is designed as 1 layer with 4 nodes, which correspond to the risk evaluation of experts (the probability value of the occurrence of risk factori, the influence degree of risk factor j, the weight value of the possibility value of risk factor W, and the weight value of the influence degree of risk factor t).(3)
Output layer vector. Conclusion of quality safety risk assessment: 3 represents high risk, 2 represents medium risk, 1 represents low risk, and 0 represents no risk.(4)
Activate the function. Select the unipolar S-type Sigmoid function [33]. The function is flat on both sides and continuously differentiable in the middle, being suitable for activation function.


## 3.1. SIWSPSO Optimized BP Neural Network

In BP neural networks, random initialization weights and thresholds usually make the network fall into local extremum points, which further affects its nonlinear fitting ability and network operation efficiency. Initial thresholds and weights are equivalent to particles in particle swarm optimization. The test error of BP neural network is taken as the fitness function. The time-domain peak value, center frequency, 3 dB bandwidth in frequency domain, upper limit cut-off frequencyfH, and lower limit cut-off frequency fL of transmitted wave signal are selected as the input of neural network, and the expected value is the output of neural network. In this paper, the random inertia weight value is introduced to improve the PSO algorithm, and the application model of SIWSPSO-BP neural network is established. See Figure 2.Figure 2
SIWSPSO-BP model.


## 3.2. Product Quality Risk Warning Model

Product quality risk early warning model adopts qualitative and quantitative methods to conduct comprehensive risk analysis of products, and the evaluation steps are as follows:(1)
The unqualified test items are taken as risk factors, and the unqualified rate is divided into five levels of 20% each. According to Table1, determine the x value.(2)
The impact of risk factors is divided into 5 levels and assigned to each level, as shown in Table2.(3)
A number of experts in the field of product quality and safety and risk assessment are invited to assess the impact of items on risk occurrence according to expert analysis and evaluation, and the scores are given according to the instructions in Table3. The average score is used as the rating basis to determine the j value.(4)
According to expert analysis and evaluation, determine the values ofw and t ( w +t = 1), divide the risk grade into different grades, and define the corresponding relationship between the risk grade and the quantitative value (K).(13)K=wi2+tj2.In the formula,K is the risk grade value, w is the weight value of the possibility of risk factor, t is the weight value of the influence degree of risk, i is the possibility of the occurrence of risk factor, and j is the influence degree of risk factor.(5)
Calculate the risk level values according to steps 1–4, and build the risk level classification matrix according to the possibility of risk, as shown in Table4.(6)
Select the risk factor with the highest risk grade value, and determine the risk grade of the risk assessment of the product according to the risk grade classification matrix.Table 1
Classification of risk occurrence possibility.
LevelFeature descriptionAssignmentVery low(0～20%)(0～1)Low(20～40%)(1～2)Medium(40～60%)(2～3)High(60～80%)(3～4)Very high(80%～100%)(4～5)Table 2
Description of influence degree of risk factors.
Degree of influenceDescriptionAssignmentKeyRisk factor is the key factor leading to risk(4～5)SeriousThe impact of risk factors is significant(3～4)GeneralThe impact of risk factors is moderate(2～3)SmallRisk factors have little influence(1～2)Can be ignoredThe impact of risk factors can be ignored(0～1)Table 3
Summary analysis table of networked intelligent door lock project detection results (section).
NumberSample numberName of manufacturerProduct informationTest itemSample nameSpecificationsTrade markAnti-violence openingRFID lock safetyAnti-damage alarmPassword entry testSensitive information protectionData encryption transmissionSecurity scanningDecompilingNetwork security1W01814501800Company 1Intelligent lock112RX1QualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualified2W01814501801Company 2Smart door lockH636X2QualifiedUnqualifiedQualifiedQualifiedUnqualifiedQualifiedUnqualifiedUnqualifiedQualified3W01814501802Company 3Smart door lockS400X3QualifiedUnqualifiedQualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualified4W01814501803Company 4Smart fingerprint lockVHSX4QualifiedUnqualifiedQualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualified5W01814501804Company 5Cloud intelligent lockHZ8-R-TX5QualifiedUnqualifiedQualifiedQualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedUnqualified6W01814501805Company 6Smart fingerprint lockD2X6QualifiedQualifiedQualifiedQualifiedQualifiedUnqualifiedUnqualifiedUnqualifiedUnqualifiedTable 4
Risk grade classification matrix.
Risk factor possibilityThe extent of the impact on the riskKeySeriousGeneralSmallIgnoredVery highHighHighHighMediumMediumHighHighHighMediumMediumLowMediumHighMediumMediumLowLowLowMediumMediumLowLowLowVery lowMediumLowLowLowLow


## 3.3. Training Warning Model Based on SIWSPSO-BP

The product quality warning model was designed and trained based on SIWSPSO-BP algorithm, and input layer vector, hidden layer node number and weight, output layer vector and activation function were determined.(1)
Input layer vector. Product quality risk warning needs to input a variety of product quality testing items, which have different effects on product quality. Therefore, key testing items affecting product quality are extracted as input vectors.(2)
Hidden layer design. The hidden layer is designed as 1 layer with 4 nodes, which correspond to the risk evaluation of experts (the probability value of the occurrence of risk factori, the influence degree of risk factor j, the weight value of the possibility value of risk factor W, and the weight value of the influence degree of risk factor t).(3)
Output layer vector. Conclusion of quality safety risk assessment: 3 represents high risk, 2 represents medium risk, 1 represents low risk, and 0 represents no risk.(4)
Activate the function. Select the unipolar S-type Sigmoid function [33]. The function is flat on both sides and continuously differentiable in the middle, being suitable for activation function.


## 4. Case Application and Analysis

Intelligent door lock is implemented through wireless network, NFC, modern biology or optics, remote control, and other technologies, in product security, user identification, and management of more intelligent and simple products. Smart door locks have security risks such as data leakage risk, replay attack, fingerprint cracking, and communication security. Based on the above SIWSPSO-BP neural network risk warning model, we carry out risk warning experiment for intelligent door locks.We collected 210 product records of risk monitoring data of intelligent door locks from the risk monitoring database of Tianjin Quality Inspection Institute, with a total of 4320 test data items. 200 product records were selected as training samples and 20 as prediction samples. When conducting comprehensive rating, detection items such as antiviolent opening, RFID lockpick security, antidamage alarm, sensitive information protection, data encryption transmission, security scanning, decompilation, and network security are taken as input. The test result of the item is pass or fail. The detection results are shown in Table3.Initial setting of SIWSPSO-BP algorithm parameters was as follows: input: 21; hidden node number: 4; output node: 1; genetic population size: 20; genetic algebra: 40; crossover probability: 0.5; mutation probability: 0.3. The BP neural network model was established on Matlab, and the optimization model based on SIWSPSO-BP neural network was realized by programming. Training samples were used to train the model.As shown in Figures3 and 4, the BP neural network based on genetic algorithm has greatly improved the convergence times of training times, and the convergence speed of SIWSPSO-BP is twice that of BP, which improves the training speed. In terms of prediction error, the accuracy of SIWSPSO-BP in product quality risk warning reached 85%, compared with the accuracy of 75% of BP model before optimization, and SIWSPSO-BP neural network also has obvious advantages. Therefore, product quality risk warning based on SIWSPSO-BP network can give higher warning to product risk.Figure 3
Comparison of training times between SIWSPSO-BP and BP.Figure 4
Comparison of prediction errors between SIWSPSO-BP and BP.


## 5. Conclusions

In order to explore optimization method of BP network application and solve problems of BP neural network such as sensitivity to initial value, slow convergence rate, and local minimum point, this paper proposes the idea of optimizing BP network by PSO algorithm. In view of the disadvantages of the standard PSO algorithm, this paper innovatively proposes to use random variables to describe the inertia weight and adopts the strategy of asynchronous variation of learning factors, which is improved and optimized first. In order to verify and analyze the performance of SWISPSO-BP network, this paper establishes a product quality risk early warning model based on SIWSPSO-BP neural network and applies the optimized neural network algorithm to the quality risk early warning of product quality big data. Experiments show that the performance of SWISPSO-BP network has been obviously improved. The accuracy is increased by 10%, and the convergence speed is doubled. In the next step, we will collect more data used in scenarios and further study how to improve the performance of BP network.



---

*Source: 2960992-2022-04-21.xml*