# Fault Diagnosis Algorithm of Beam Pumping Unit Based on Transfer Learning and DenseNet Model
## 1 Preface
In recent years, machine learning has been widely used in the field of fault diagnosis. For example, [PERSON] et al. [5] designed the original feature vector based on 26 statistical parameters, 72 envelope characteristics, and 32 wavelet envelope characteristics, and then used support vector machines (Support Vector Machine, SVM) to identify the bearing faults. [PERSON] et al. [6] calculated several characteristic parameters and used an artificial neural network for fault diagnosis of the photovoltaic system. [PERSON] et al. [7] proposed a novel fuzzy neural data fusion engine for online monitoring and diagnosis. The above methods have achieved certain results, but due to the limitations of artificial feature extraction, and the fact that there is no authoritative theory to guide the design method of feature functions, such methods are difficult to popularize and use. Deep learning, one of the branches of machine learning, is valued because it can extract features from data automatically and reduce the uncertainty in the process of artificial data extraction effectively. For example, [PERSON] et al. [8] fused the vibration data in the horizontal and vertical directions into a two-dimensional matrix and proposed a deep CNN to identify gearbox operating conditions. [PERSON] et al. [9] identified four rotating mechanical states by a two-dimensional CNN model. Using the discrete Fourier transform of two vibration signals as input to a CNN, faults in rotating machinery are classified and compared with artificially designed faults. The results show that the CNN-based method outperforms traditional methods and does not require any artificial feature extraction with domain expertise. In recent years, fault diagnosis methods based on deep learning have received attention in the petroleum industry. [PERSON] et al. [10] proposed a data-based CNN method and an image-based CNN method for fault diagnosis of a rod oil pumping system and compared them with traditional machine learning algorithms. The results show that the CNN-based method is superior to the traditional method, as it does not need to extract any artificial characteristics of experts in the field. [PERSON] et al. [11] proposed a 14-layer CNN diagnostic model based on big data deep learning to identify the working conditions of rod pumping wells. In 2020, [PERSON] et al. [12] used a combination of transfer learning and SVM to identify operating conditions in indicator diagrams automatically. This kind of method solves the problem that feature extraction is more difficult and has no guaranteed effect. However, the above research is based on the laboratory or a few working conditions, and the various types of data are processed uniformly, which is inconsistent with the actual work situation, which leads to the following problems in practical applications:  
(a) Most of the mechanical fault diagnosis studies are based on balanced data sets, ignoring the fact that the amount of data in different working conditions in the actual production process are often highly unbalanced. In the actual recorded data, as shown in Figure 1, the number of each working condition type is not uniform. In practical applications, mechanical equipment is in a normal state during most of the operation stages, and failures rarely occur during operation [13]. In the actual working environment, there are many kinds of faults, and it is difficult to provide sufficient samples. The rod pump model may automatically ignore some working conditions affecting the actual use. (b) Most of the sample research data for mechanical fault diagnosis come from the experimental environment or from a small amount of equipment operation data. Because of the similarity of the sample data, the classification results are good, but the generalization is poor. Therefore, the performance of the fault diagnosis model is affected in actual use.