Fault Diagnosis of Photovoltaic Array Based on Deep Belief Network Optimized by Genetic Algorithm

: When using deep belief networks (DBN) to establish a fault diagnosis model, the objective function easily falls into a local optimum during the learning and training process due to random initialization of the DBN network bias and weights, thereby affecting the computational efficiency. To address the problem, a fault diagnosis method based on a deep belief network optimized by genetic algorithm (GA-DBN) is proposed. The method uses the restricted Boltzmann machine reconstruction error to structure the fitness function, and uses the genetic algorithm to optimize the network bias and weight, thus improving the network accuracy and convergence speed. In the experiment, the performance of the model is analyzed from the aspects of reconstruction error, classification accuracy, and time-consuming size. The results are compared with those of back propagation optimized by the genetic algorithm, support vector machines, and DBN. It shows that the proposed method improves the generalization ability of traditional DBN, and has higher recognition accuracy of photovoltaic array faults.


Introduction
Photovoltaic (PV) arrays are the core of PV power generation systems. Due to their large area and long-term exposure in an outdoor environment, it is easy to cause short circuits, open circuits, partial shadow, abnormal aging, and other faults during operation. Effective detection of the operating state of the PV array can improve the power generation efficiency of the PV system. Based on different focuses, the current PV array fault diagnosis methods include the circuit structure method, mathematical model method, electrical measurement method, infrared image analysis method, and intelligent detection method [1] . Among them, the intelligent detection method is a hotspot in the research field of PV array fault diagnosis. Many scholars use neural network [2][3] , clustering [4] , correlation Manuscript  vector machine [5] , fuzzy inference [6] , and other methods to extract feature values. Based on data mining, pattern recognition, data fusion for fault diagnosis of PV arrays achieved certain results. As these methods usually only have obvious advantages in processing small sample training, and there are problems such as easy to fall into local optimal solution, weak selflearning ability, and difficulty in multi-layer feature extraction, limits the accuracy of fault diagnosis to a certain range.
With the development of deep learning, deep belief network (DBN) achieved an excellent feature learning ability, and can deeply mine sample feature information through hierarchical learning to achieve efficient data processing [7] . In recent years, it has shown greater adaptability in fault diagnosis modeling problems, including roller bearings [8] , power transformers [9] , aero engines [10] , power system transient stability assessment [11] , generators [12] , and aircraft [13] .
The field is extensive. Although the DBN model has strong feature extraction and high intelligence, it is also a mechanical learning architecture. In the training process, it has its own inevitable parameter selection problems, such as network connection weights and initialization of neuron bias obtained by random assignment, which leads to some uncontrollable factors in the diagnostic model, thereby limiting its full advantage in the field of fault diagnosis.
In the literature, the cuckoo search algorithm is used to optimize the DBN network and applied to lung tumor image recognition [14] . Additionally, the improved particle swarm optimization algorithm is also used to optimize the DBN network and applied to power system load forecasting [15] . However, these algorithms are optimized for network weights without considering neuron bias. The choice of optimization algorithm is very important for the merits of the DBN model [16] . As the genetic algorithm (GA) can encode the network weight and bias simultaneously, the effect is significant when optimizing the back propagation (BP) neural network [17][18] . Therefore, In order to improve the stability of the DBN network, this study uses GA to optimize the weight and bias of the DBN network, and constructs a fitness function with reconstruction error for PV array fault diagnosis.
First, a Matlab simulation is used to obtain a large number of PV array characteristic parameter data samples. Then, the deep belief network optimized by genetic algorithm (GA-DBN) is used to learn the feature information autonomously, and the hidden features are mined to realize the fault type identification. Finally, the feature data is entered into the traditional DBN, back propagation optimized by genetic algorithm (GA-BP), and support vector machines (SVM) for identification. The results are compared with GA-DBN diagnosis results, which verified the effectiveness of the proposed method.

DBN structure
The DBN is a network learning model consisting of multiple stacked restricted Boltzmann machines (RBMs) and a reverse BP network. By training the connection weights between the neurons, layer by layer, the probability of generating samples for the entire model is maximized, and its basic structure is shown in Fig. 1. The original data of the input layer has N feature numbers, the output layer has M data categories, and θ represents the parameters that the entire DBN model needs to learn.

RBM structure
The RBM is a kind of generated random neural network, which has undirected connections between the hidden and visible layer through weights. However, there is no connection between the neurons in the layer [19] . A basic RBM structure is shown in Fig. 2. , v h between visible layer unit and hidden layer unit is expressed as where ( , , ) ij i j w a b θ = denotes the parameter values for training RBM, ij w is the connection weight between the i th neural unit in v layer and j th neural unit in the h layer, i a is the bias of the i th neural unit in the v layer, j b is the bias of the j th neural unit in the h layer. According to Eq. (1), the joint probability distribution of ( ) , v h is obtained as The updating criteria of model parameters are obtained by solving Eq.
where ε is the learning rate, <. .> d is the mathematical expectation defined by the training data set, <. .> m is the mathematical expectation defined by the model, whose value is not easy to obtain by direct calculation. However, it can be approximated by the contrastive divergence (CD) algorithm [20] . Several research studies have shown that the CD algorithm can achieve a good effect by iterating once. When the state of the visible layer unit is determined, the activation probability of the hidden layer unit can be obtained because of the independent activation conditions among the nerve units in the RBM layer. At this time, the activation probability of the j th hidden layer unit is shown as follows Correspondingly, when the state of the hidden layer unit is determined, the activation probability of the i th neuron unit in the visible layer is expressed as where ( ) x σ is the activation function.
According to Eqs. (6) and (7), the mathematical expectation defined by the model in Eq. (5) is transformed into the mathematical expectation defined by the reconstructed model through two Gibbs sampling. Therefore, the updating rule of parameters for the whole network model in Eq. (5) transforms as shown in Eq. (9).
where <. .> r is the mathematical expectation defined by the reconstructed model.

DBN training process
The parameter training of DBN includes two stages: pre-training and tuning.
In the pre-training stage, unsupervised greedy learning is used to train the RBM network, layer by layer, from the bottom to the top. The training samples after data preprocessing are used as the input 0 v of the bottom RBM visible layer, and the output 0 h of the hidden layer is used as the input 1 v of the second RBM visible layer, and so on. Therefore, each level of RBM is trained. The underlying original features are transformed into deeper abstract features to initialize the parameters of the whole DBN model. For each layer of RBM, the error is reconstructed by C-1 algorithm according to Eqs. (6) and (7), and the model parameters are updated according to Eq. (9) to ensure that the original feature information is maximized when the feature vector is mapped to the next layer. In the tuning stage, the error between the labeled data samples and expected output after data preprocessing is utilized, and the BP neural network algorithm is used to supervise and fine-tune the parameters of the whole deep architecture from top to bottom, so that the output of the DBN network model can maximize the presentation of the original input.

DBN based on genetic algorithm
The genetic algorithm is mainly used to optimize the initial bias and weight of the DBN network to find the optimal DBN neural unit bias and weight between the layers, so that the DBN network is in a better range from the pre-training stage. To improve nonlinear fitting, GA provides an effective way to solve the initial parameter randomization problem of DBN. Fig. 3 shows a flow chart of GA optimization for DBN networks.
The GA-DBN parameter optimization process is as follows.
(1) Population initialization. The real number method is used to encode the bias of the visible and hidden layers of DBN and the weights between them.
(2) Selection of fitness function. The purpose of using GA to optimize DBN is to minimize the training error. The fitness function is constructed by the mean square error between the reconstructed value and actual value of RBM, which can be used as a reference index to measure the network performance in the unsupervised pre-training stage. (3) Selection operation. The optimal chromosome individuals in the current population are selected according to the fitness ratio method using the best retention strategy. The probability of an individual i being selected in a population is expressed as k is the chromosomal order, and M is the individual population.
(4) Cross operation. The real number crossover method is used, and the crossover operator chooses a simple single point crossover method. Consider the crossover operation of the a-th chromosome X a and b-th chromosome X b at the j-position. The two new individuals generated after the cross operation are expressed as (1 ) (1 ) where η is crossover operator.
(5) Variation operation. Mutated genes are randomly generated with a small probability. The new genetic value after mutation is expressed as where max X is the initial individual maximum, min X is the initial individual minimum, and σ is the mutation operator. (6) When the fitness of an individual reaches the termination condition (training error threshold or the set number of iterations), the optimization is stopped, and the weights and bias of the DBN are assigned. Otherwise, selection, crossover, and mutation operations are continued.
(7) The reverse fine-tuning of the hidden layer parameters θ is performed using the BP algorithm. Then, the GA-DBN diagnostic model is generated for PV array fault diagnosis. The diagnostic accuracy rate can be expressed as where t N is the number of data samples correctly classified, s N is the total number of data samples.

Determination of network input and output nodes
The GA-DBN network model is applied to the fault diagnosis of PV arrays. Four characteristic parameters commonly used in PV modules are selected as network input, namely short circuit current sc I , open circuit voltage oc U , maximum power point output current m I , and maximum power point output voltage U m [3] .
There are many types of faults in PV arrays. The most common operating states selected in this paper correspond to the output of the model. They are normal operation, grounded short circuit, open circuit in series, partial shadow and abnormal aging.

Acquisition of sample data sets
Twelve PV modules are used to build the PV array simulation model in series and parallel, as shown in Fig. 4. The simulation object is Zytech Engineering Technology ZT185S PV module of Sideck Engineering Co., Ltd., which is used to construct the experimental sample database.  In this study, the method of adding series resistance is used to simulate the abnormal aging fault [21] , because the severity of short-circuit, open-circuit, and partial shadow faults depend on the percentage of array mismatch [22] . To avoid the influence of slight proximity of the characteristic values between different faults at a certain percentage, the number of samples for these faults is increasingly demanded, and multiple simulations are required to increase the number of samples and to avoid the influence of diagnostic accuracy of the model due to data samples in subsequent experiments.

Data normalization
The feature data set is normalized by the zeromean normalization method, and the value of a certain feature is obtained as where x is the original data of eigenvalue, mean x is the mean of such features in eigenvalue datasets, std x is the standard deviation of the feature. After normalization, the difference in physical dimension can be eliminated, and the data for different orders of magnitude can be compared to a certain extent.

Example verification
In each experiment, 70% of the data samples in various operating states are randomly selected to remove tags and perform DBN pre-training, 15% of the data is selected for tuning, and the remaining samples are used as test samples.

Characteristic analysis of GA-DBN
(1) Comparison of reconstruction errors. Reconstruction error is the evaluation of training sample likelihood by RBM, and it is an important indicator of the evaluation model. A DBN network composed of 4 layers of RBM is established and the number of neural units in the hidden layers is set to 100. The RBM learning rate is set to 0.01, and the number of iterations of pre-training and fine-tuning is set to 400. The learning rate of weight, visible layer, and hidden layer is 0.1. The initial momentum is 0.5 and the final momentum is 0.9. The parameter settings of the DBN network in GA-DBN model are consistent with those mentioned above. The parameter settings of the GA algorithm are shown in Tab. 2. After the pre-training, the variation of reconstructtion errors of GA-DBN and DBN tail layer RBM with the training epochs are shown in Fig. 6. As observed in Fig. 6, the reconstruction error curve of GA-DBN model is significantly lower than that of the traditional DBN model, i.e., the reconstruction error of GA-DBN network model is smaller than that of the DBN network model. The tail layer reconstruction error of the DBN model training data sample has no downward trend after 36 epochs. However, there are fluctuations and large ranges. The GA-DBN model tends to be basic after 19 epochs. In other words, the convergence speed of the GA-DBN model in the unsupervised training stage is faster than that of the traditional DBN model. It shows that GA has an obvious effect on solving the problem of initial parameter randomization of the DBN network, which makes the GA-DBN model converge the whole network quickly in the pre training stage and ensures the training error to be as small as possible. It also reduces the number of training steps as much as possible, and better assigns the initial parameters of the BP network in the optimization stage.

Tab. 2 Operating parameters of genetic algorithm
(2) Comparison of the hidden layer. The number of hidden layers are set to 2, 3, 4, 5, 6 and 7. The remaining parameters are fixed and the GA-DBN and DBN models are executed, respectively. The experimental results are shown in Tab. 3. As observed from Tab. 3, with the increase in the number of hidden layers, the diagnostic accuracy of the GA-DBN model shows an upward trend. When there are more than 5 hidden layers, the degree of improvement in the diagnostic accuracy of the model is affected by the increase in the number of hidden layers. The impact is basically small, and a downward trend is observed. This means that the diagnostic accuracy increases with the increase in RBM layers. However, too many layers will lead to the accumulation of errors. On the contrary, the accuracy of diagnosis will be reduced. However, under the same number of hidden layers, the recognition effect of GA-DBN is significantly better than that of the DBN network due to the optimization of initial parameters. When the number of hidden layers is 5, DBN achieved a recognition rate of 93.21%. Whereas, GA-DBN achieved the same recognition rate of 93.51% with 4 hidden layers. This shows that the GA-DBN diagnostic model can overcome the defects caused by the randomization of initial parameters in the traditional DBN diagnostic model to a certain extent to improve the performance of the DBN model.

Performance comparison of fault diagnosis
(1) Accuracy comparison. To verify the superiority of the GA-DBN model in PV array fault diagnosis, GA-DBN and DBN with five-layer RBM structures are selected, and compared with SVM and GA-BP methods. The learning parameters C and gamma of SVM model are optimized by grid search method, and the parameter range is [10,10]. In the GA-BP model, the number of neural units in the hidden layer of the BP neural network is set to 100, learning rate is 0.1, learning goal is 0.01, and the number of iterations is 600 times. The running parameters of the GA algorithm are consistent with Tab. 2.
Each model is executed 10 times to obtain the average classification accuracy of each operation state and the overall process. The results are compared in Fig. 7.
It can be observed from Fig. 7 that the average accuracy of the proposed method (GA-DBN) for PV array fault diagnosis is better than other algorithms. All the aspects are optimal and the overall diagnostic accuracy could reach 95.73%, which indicates good In this experiment, the GA-BP model training chooses the same number of labeled data samples as in the DBN tuning stage. Although it overcomes the shortcomings of randomization of initial values, the BP neural network is based on the empirical risk minimization model and only has the ability of supervisory training. It is superior in processing small data. In the absence of a large number of labeled data samples, the accuracy rate of evaluation is low (85.42%). The objective function of SVM is a convex function that can guarantee the global optimum and avoid the problem of artificial neural network falling into local optimum. Therefore, its diagnostic accuracy is slightly higher than that of GA-BP, which is approximately 86.77%. The pre-training and optimization processes of DBN can achieve higher evaluation accuracy when there are fewer labeled data samples, its average accuracy of the PV array fault diagnosis reached 93.02%, which is significantly higher than that of GA-BP and SVM. However, it is uncertain because of the random initialization of weights and bias parameters, which affects the final model training. GA enables DBN to obtain better initial weights and bias at the beginning of unsupervised training. However, while deep mining data features, it overcomes the shortcomings of random initialization of model training parameters. The evaluation error rate of the model can finally converge to a very low level.
Compared to other algorithm models, GA-DBN can provide a reliable way and effectively improve the accuracy of PV array fault diagnosis.
(2) Time-consumption comparison. To analyze the efficiency of model training corresponding to the accuracy of the experiment, the training time of the three models is recorded 10 times simultaneously, and the average value is calculated. The results are shown in Tab. 4. It can be observed from Tab. 4 that the training time of DBN and SVM is less. However, the accuracy of SVM diagnosis is lower than that of DBN. Although the diagnostic accuracy of GA-DBN is higher, GA-DBN and GA-BP increases the optimization process of initial weight and bias of DBN by GA, which significantly increases the training time of the model compared to that before optimization. GA-DBN has the longest average time, which is approximately 266 s higher than that of DBN. Therefore, GA optimized DBN network is not suitable for occasions with higher time requirements. However, after the initial parameters of the DBN model are optimized by the GA algorithm, the number of iterations required for model convergence is less, which also reduces the number of RBM layers required. Therefore, it can be considered for reducing the iterations or RBM layers, shortening the training time in the pre training stage to a certain extent, and to make up for the time-consuming GA optimization.

Conclusions
In this study, a method for fault diagnosis of PV arrays based on GA is proposed to optimize DBN. Through simulation and comparison with conventional model recognition results, the following conclusions are obtained.
(1) The fitness function of GA is constructed by the DBN training error on sample data. The parameters of DBN are selected effectively, which overcame the shortage of random initialization parameters. By considering the DBN network composed of 4 layers of RBM as an example, the reconstruction error of the optimized network is smaller than that of the simple DBN network and had a significant improvement in convergence ability. This resulted in the reduction of number of training required for convergence and the number of RBM layers is also reduced by one layer for obtaining similar diagnostic accuracy simultaneously.
(2) The method based on GA-DBN can effecttively realize the diagnosis and detection of PV arrays in 5 operating states, and achieve an overall diagnostic accuracy of 95.73%. In the unsupervised training stage, it not only utilizes the unlabeled data for training, but also avoids the problem of randomization of initial parameters. Compared to DBN, SVM, and GA-BP models, it achieved a higher accuracy for overall diagnosis and diagnosis of individual types of fault. However, with GA optimization, the diagnostic time of the entire model increased. Hence, it is a direction that needs further improvement.