# Fault Diagnosis Algorithm of Beam Pumping Unit Based on Transfer Learning and DenseNet Model
## 3 Dynamometer Classification Model Based on the Transfer Learning Method
### Training Results and Discussion
#### 3.3.2 Comparative Experiments of Different Depth Convolutional Network Models
In Figure 13c, it can be seen that most of the test data can be accurately identified, but the recognition rate of the case types with a small number of samples is low, which is consistent with the data loss. The Xception model extracts the graphic features by dividing them into several channels, as shown in Figure 14, which not only ensures that the image features can be fully extracted, but also effectively reduces the amounts of parameters and computation [21]. The basic model is established according to the Xception model structure. After pretraining on ImageNet, the convolutional layer is reserved as the feature extraction structure, and the fully connected layer is added as a classifier at the bottom of the Xception model. The dropout function is added to the fully connected layer, as shown in Equation (5). To train the transfer learning model based on the Xception model, the initial learning rate is 0.01, the loss function is the same as Equation (7), and the learning rate decreases with the increase of training time. In this paper, using TensorFlow as the machine learning development platform, the classification experiment of the transfer learning model based on the Xception model is carried out. The experimental environment was the NVIDIA Tesla K80 computing platform, and the training set and model were tested simultaneously. Figure 15a,b record the output of the training set and test set, and the test results are shown in Figure 15c. The recognition accuracy of the test set is 95.3%, the output loss of the test set is 0.245, and the single training time of the model is 7.048 s.  
In Figure 15a,b, the abscissa represents the number of training times, the ordinate represents the training accuracy and output error of the model, respectively, and the two curves represent the training set and test set data, respectively. The experimental results show that the transfer learning model based on the Xception model can basically complete the indicator diagram classification task. The experimental model has been trained a total of 140 times. In Figure 15a, it can be seen that the accuracy rate curve increases rapidly at the beginning of the training, and the accuracy rate curve enters a flat interval after 80 times of training; in the growth interval, the test set curve and the training set curve partially intersect; the test set curve is slightly lower than the training set after entering the flat interval. As can be seen in Figure 15b, the data loss in the initial stage of training is large but decreases rapidly, and then the overall level tends to be flat, and the model reaches a better state at this time. Compared with the test results in Figure 15c, although the accuracy of the test set is generally good, the recognition rate of the model is not high for a single working condition. From the data in the figure, it can be seen that a small number of working condition types have better accuracy. The basic unit of the MobileNet model is separable convolution (DW Conv). Compared with traditional convolution operations, it can be divided into two parts: firstly, the corresponding convolution kernels are applied in different channels to extract information,  
Figure 14: Basic structure of the Xception model. and then \(1\times 1\) convolution kernels are applied in each classification channel to change the shape of feature maps. The process is shown in Figure 16[22]. The basic model is established according to the above structure, and after pretraining on ImageNet, the convolutional layer is reserved as the feature extraction structure. A typical MobileNet model does not contain a fully connected layer at the bottom. In this paper, a fully connected layer is added as a classifier at the bottom of the feature extraction layer, and a dropout layer is added to the fully connected layer. The transfer learning  
Figure 16: MobileNet model. Figure 15: Training results of the transfer learning model based on the Xception model. model based on the MobileNet model is trained and the initial learning rate is 0.01.