# Partial Discharge Pattern-Recognition Method Based on Embedded Artificial Intelligence
## 3 CNN Building and Porting
### CNN Model Construction  
Studies have shown that CNN classification performance and CNN neural network size have a large correlation with the number of network layers [41]. A complete convolutional neural network consists of the following layers: input layer, convolutional layer, pooling layer, fully connected layer, and output layer [29]. The layer structure is shown in Figure 9.  
By pressurizing the three PD models, we collected 4000 sets of discharge data in the laboratory. These datasets were processed using the methods described in the previous section to obtain 260 grayscale maps in PNG format. Subsequently, these maps were used for training and testing using CNN.  
\begin{table}
\begin{tabular}{c c} \hline \hline Pixel size & 50 \(\times\) 60 \\ Space occupied & 769 KB \\ Color channels & Grayscale single channel \\ \hline \hline \end{tabular}
\end{table}
Table 1: Image information table.  
Figure 8: Grayscale diagram of different discharge model features. (**a**) Grayscale map of tip discharge characteristics; (**b**) grayscale map of ball-plate discharge characteristics; (**c**) grayscale map of board-board discharge characteristics.  
Figure 9: The basic structure of CNN.  
From the obtained 260 grayscale images, 200 were selected as the training set of the model, and the network model was obtained through 1000 iterations of training using 10-fold cross-validation. Specifically, the training was repeated 10 times, and, for each training, nine subsets of data from the dataset were selected as the training set of the model, while the remaining 20 grayscale images were used as the test set of the model. The network model was tested every time the network weights were updated twice. Based on the above method, the number of convolutional layers that the convolutional neural network was set to were three, four, five, and six layers for training, respectively. After each training, 10 evaluation results were obtained, and then the accuracy of the network model was calculated as the average of these evaluation results. The experiments compared and analyzed the recognition effect of convolutional neural networks with different convolutional layers under different iteration numbers, as shown in Figure 10.  
From the figure, the following can be seen: the recognition accuracy fluctuated more in the early stage; the model's response to the data was relatively sensitive; the model could quickly learn some basic features; and the model's convergence speed was faster. When the number of network layers was small, the CNN's ability to fit the sample data was poor, the loss function value of the model was high, and the recognition effect was poor. With the increase in the number of convolutional layers, the complexity of the network model increased, with more parameters and more powerful feature-extraction ability, and the recognition accuracy of the network model could reach over 95% stably when the number of convolutional layers was four and five. However, due to less training data, when six convolutional layers were used, the convolutional neural network was deeper, generating the risk of overfitting [29; 42], and the model learnt some useless feature information, which reduced the generalization performance of the model. In summary, when the number of convolutional layers is four and five, the recognition effect of the convolutional neural network model is better. Taking into account the need to transplant the network model into the microprocessor to run, the more complex the model, the more it occupies processor resources, and the more time consuming it is. Therefore, in this paper, the network model with four layers of convolutional layers was selected for training recognition.  
Figure 10: Variation of neural network recognition accuracy with number of iterations for different number of convolutional layers.