# 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.1 Training Results Based on Transfer Learning
As can be seen from the classification situation shown in Figure 6(c), the dense connection model with a full connection classifier can distinguish various working conditions, but the recognition rate is low for some working conditions (such as two plunger down bumps and 14 pumps and eject). The comparison of training results for densely connected models using fully connected layer separators and global pooling layer classifiers are shown in Table 2:  
From the data in Table 2, it can be seen that the dense connection model built with the global pooling layer classifier generally has a higher recognition rate for a single type of fault than the dense connection model built based on the fully connected layer classifier. However, due to the large difference in the number of indicator diagrams for various types of working conditions, the accuracy rates of the training set and test set of the two classifications are basically the same. By comparing the accuracy curves, it can be seen that the accuracy of the model using the global pooling layer classifier increases rapidly during the training process, but it is easy for it to fall into the local optimum. It can be fine-tuned in advance to speed up the training process. The learning curve of the densely connected model using the fully connected layer classifier has less fluctuation, and the training result is more stable after the learning rate is reduced after fine-tuning. Figure 7: Model training results of the fully connected layer classifier of the densely connected model. A single image is randomly selected for testing; a is the classification result of the fully connected layer classifier recognition model, and b is the classification result of the global pooling layer classifier recognition model. Figure 8 shows the actual test results under the influence of the dense connection model on wax. As can be seen from Figure 8b, the judgment probability of the indicator diagram (Figure 8a) of the influence of the dense connection model of the full-connection classifier on wax is 1, while the probability of other working conditions is lower than \(10^{-10}\) and can be ignored. It can be seen from Figure 8c that the dense connection model of the global pooling layer classifier considers that the probability of the working condition shown in the sample dynamometer diagram is wax effect is 99.66%, and the probability of other working conditions is less than 0.2%. The test results of the sand effect condition are shown in Figure 9. It can be seen from Figure 9a,b that the dense connection model constructed by applying the two classifiers considers that the probability of the indicator diagram working condition type is gas effect is 1, and the probability of other working condition types is negligible. The actual test results of the gas effect condition are shown in Figure 10. It can be seen from Figure 10b that the classification of the densely connected model constructed by applying the fully connected classifier is wrong. It can be seen from Figure 10c that the dense connection model constructed by the global pooling layer classifier is used to judge that the probability that the indicator diagram in Figure 10a is affected by gas is 86.2%, and the probability of insufficient liquid supply is 13.6%. The actual test results under normal conditions are shown in Figure 11. It can be seen from Figure 11b that in the dense connection model constructed by the fully connected classifier, the probability of judging that the indicator diagram in Figure 11a is a normal working condition is 1. It can be seen from Figure 11c that in the dense connection model constructed by applying the global pooling layer classifier, the probability of judging that the indicator diagram in Figure 11a is a normal working condition is 99.9%, and the probability of other working condition types is lower than 0.03%.