# Early Detection of Photovoltaic Panel Degradation through Artificial Neural Network
## 5 Configuration of the Proposed Double Level ANN Architecture
### Overfitting and Generalization  
Another common problem of the neural network training process is overfitting. This concept is associated with the way that the neural network learns the process and adjusts a model for representing it. In a training process with overfitting, the neural network finds a model that fits the set of data. Although the error in this process could be set as very small, the neural network builds an overly complex model that is unable to identify the right outputs for new data presented to the input. Therefore, the neural network memorizes the behavior of the training data instead of building a model that generalizes the outputs for testing or validation data.  
A regularization method consists of modifying the performance function. In this case, the default performance function used by the toolbox of Matlab is the mean square error (MSE), defined in (9). This performance function can be tuned for focusing on generalization by using the weights and bias of the neural network. Here, it is necessary to add the mean values of the sum of weights (MSW) of the neural network to the performance function. Equation (11) expresses the way to tune this configuration. The parameter \(\gamma\) (performance ratio) allows the user to define the level of impact of the regularization. This parameter must be defined in the range of [0-1]. In this case, the user must use their expertise to find a trade-off between generalization and performance [38; 39].  
\[\text{MSE}=\frac{1}{N}\sum_{i=1}^{N}e_{i}^{2}=\frac{1}{N}\sum_{i=1}^{N}(t_{i}- a_{i})^{2} \tag{9}\]  
\[\text{MSW}=\frac{1}{n}\sum_{j=1}^{n}w_{j}^{2} \tag{10}\]  
\[\tilde{E}=\gamma*\text{MSW}+(1-\gamma)*\text{MSE} \tag{11}\]  
where \(N\) is the number of trials, and \(n\) is the total number of weights \(w_{i}\) for all the ANN nodes.  
Here, the challenge is to choose the correct value for the performance ratio parameter (\(\gamma\)). If the user uses a parameter that is too large, there is a risk of overfitting. On the contrary, if the performance ratio parameter is too small, the neural network does not fit the training data adequately.  
Bayesian regularization is a neural network training algorithm that updates the weights and bias values. The main characteristic of this algorithm is that it automatically determines the optimal regularization parameters and the correct combination for making up neural networks that generalize well. In the toolbox of Matlab, this function uses the Jacobian for calculation; then, the performance must be the mean or sum of square errors. As a consequence, the training process must be assessed by MSE or by the sum square error (SSE) performance functions [22; 39].  
The Bayesian regularization method does not need to configure a performance ratio parameter. On the contrary, it automatically calculates the best parameters by focusing on generalization.  
In the following, the results concerning the ANN trained with Bayesian regularization is proposed; they exhibit good identification of the SDM parameters in both healthy and degraded conditions.