# 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
The loss function is the same as above. The learning rate decreases with the increase of training time. This paper uses the TensorFlow machine learning development platform to conduct the dynamometer classification experiment of the transfer learning model based on the MobileNet model. The experimental environment is the NVIDIA Tesla K80 computing platform. The model is tested while the training set is being trained, and the output of the training set and test set are recorded as shown in Figure 16(a),b, and the test results are shown in Figure 16(c). The recognition accuracy of the test set is 97.3%, the output loss of the test set is 0.211, and the single training time of the model is 5.003 s.  
In Figure 16(a),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 MobileNet model can complete the indicator diagram classification task. The experimental model is trained a total of 100 times. In Figure 16(a), it can be seen that the accuracy curve increases rapidly in the early stage of training. After 40 times of training, the curve enters a flat range, and the training set curve converges to around 99%; in the growth range, the test set curve has is a partial intersection with the training set curve, so it can be seen that there is no overfitting phenomenon. As can be seen in Figure 16(b), the overall trend of the loss curve and the accuracy rate curve basically correspond one-to-one; the loss rate curve shows a logarithmic trend of decline, and enters a flat range after 60 training sessions. The curve of the test set is stable in the flat range, and the overall curve is slightly higher than that of the training set,  
Figure 16: Training results of the transfer learning model based on the MobileNet model. which proves that the MobileNet model deviates from reality. Comparing the test results in Figure 17c, it can be seen from the data in the figure that the accuracy of a small number of working condition types is better, and the recognition rate of the model for a single working condition type is not high. The performance of the model on the test atlas shows that the transfer learning model based on the MobileNet model can accurately identify the characteristics of some types of working conditions but cannot identify all characteristics of the 15 types of working conditions. Table 3 shows the comparison results of the ResNet, MobileNet, Xception, and DenseNet models. Each comparison model performs very well in the training set and test set, but due to the serious uneven distribution of the number of samples, the recognition rate of a single type of indicator diagram varies greatly. From the analysis of the training curve, the initial loss value of the Xception model is high, but the convergence speed is fast and the curve is stable. At the same time, it can better identify the fault types with sufficient samples, which can be applied in the case of a small number of classifications. The loss data of the test set of the ResNet model still fluctuates significantly when the training set enters the stable range, and the accuracy of the test set is significantly lower than that of the training set, which proves that there is a certain degree of overfitting. The final training result of the MobileNet model is only 42.8 MB, which is the smallest of all the models, and the overall accuracy of the model is good, but the recognition rate for some working conditions is poor  
The recognition rate of the DenseNet model is generally at a good level. Except for the influence of heavy oil, the recognition rate of various working conditions is higher than 90%; in a single type of fault type, the recognition rate is lower than that of the fault type, such as the broken rod. The off-time is lower than ResNet and Xception, but its average