A sample paper for presentation at ANZIIS 2001 Copyright © the author(s). This work is licensed under a Creative Commons Attribution 4.0 International License. DOI: 10.14800/IOGR.453 Received July 11, 2019; revised August 18, 2019; accepted September 8, 2019. *Corresponding author: xiangwang@cczu.edu.cn 1 Well Production Real-Time Intelligent Monitoring Based On Convolutional Neural Network Zhen Wang, Luming Oil and Gas Exploration and Development Co., LTD, Shengli Oilfield, Dongying, China; Xiang Wang*, Changzhou University, Changzhou, China; Weigang Duan, Fajun Li and Fei Chen, Luming Oil and Gas Exploration and Development Co., LTD, Shengli Oilfield, Dongying, China Abstract Based on the theory of deep learning, this paper proposes the use of convolution neural network (CNN) method to identify the working condition of pumping unit of an oil well by indicator diagram. The structure and principle of CNN are introduced, and the CNN-based indicator diagram identification model is established. Over 180,000 pieces of indicator diagram data from a real oilfield are collected and the working conditions corresponding to each indicator diagram are manually labeled as the training set for CNN model. Using this training set, the CNN-based indicator diagram identification model is trained and tested. The training and test results show that the accuracy of the CNN-based indicator diagram identification model is more than 90%. Compared with the traditional neural network models, CNN model can learn from the image directly and avoid the complex process of artificial extraction of features, hence lead to a better performance. The CNN-based indicator diagram classification and recognition model can be combined with the real-time data acquisition system of the well to realize the real-time intelligent monitoring of the oil well working condition. Introduction Rod pumping is the most commonly used method in oil production. Monitoring the working conditions in real time is very important to avoid the inefficient production, reduce the production cost, and improve the oil production capacity. The working conditions diagnose is mainly conducted by using the indicator diagram of pumping well (Wang et al. 2001). With the continuous improvement of information construction in the oilfield, real-time online measurement of well indicator diagram has been achieved. The sensors installed in the wells can collect the indicator diagram data by a certain frequency and upload the data to the management terminal (Wang 2006). If the data is collected every 30 minutes, for a management region of an oilfield which has 100 wells, 144,000 pieces of data will be collected within one month. For such a large number of data, the traditional indicator diagram identification method, which identifies each diagram manually, will bring a huge workload, and the identification accuracy is affected by the experience and knowledge of the field engineer. There are also many automatic methods were introduced for indicator diagram identification, such as the decision tree method (Gong 2016), gray correlation analysis (Xu and Yang 2013), pattern recognition method (Schirmer et al. 2013), etc. However, these methods also have the issues of low accuracy. In recent years, with the development of machine learning technology, researchers start to apply the machine learning methods to identify the indicator diagram automatically (Nazi et al. 2013; Martinez et al. 1993; Pan and Ge 1996; Yue et al. 1999; Li et al. 2014; Meng 2012). The main ideas of these methods are: firstly, extract the feature vectors (e.g. area of the indicator diagram, the maximum/minimum value, etc.) from the indicator diagram. Then, use the traditional neural network method to identify the working mailto:xiangwang@cczu.edu.cn 2 conditions of the indicator diagram according to the feature vectors. The selection of features and the quality of these features have a significant influence on the identification results. Too many features lead to a large computation budget and noise may involve. But if we consider too few features, the indicator diagram cannot be fully reflected and leads to a low identification accuracy. Moreover, lots of useful information is lost during the feature extraction process (Li 2015). To address these problems, the convolution neural network was introduced. The convolution neural network (CNN) model animal visual perception and avoid the explicit feature extract process. This makes CNN a great success in many visual recognition tasks. In this paper, a CNN based identification model is proposed and is used in indicator diagram identification. Results show that CNN method can identify the working conditions by the indicator diagram with over 95% accuracy and high efficient. Convolution Neural Network Convolution neural network (CNN) is a type of feed-forward artificial neural network in which the connectivity pattern between its neurons is inspired by the organization of the animal visual cortex (LISA Lab 2017; Matsugu et al. 2003). It is a variation of a multilayer perceptron (MLR). CNN has wide applications in image and video recognition, recommender systems (Aaron et al. 2013), and natural language processing (Collobert and Weston 2008). In this section, we introduce the structure of CNN and its training method. Structure of CNN. CNN includes several feature extraction stages and a classifier in structure. In each feature extraction stage, a higher level of features is obtained through convolution operations. Each feature extraction stage includes a convolution layer and a sub-sampling layer. The output of each layer is a series of feature maps. The output of feature maps obtained in the last feature extraction stage is used as input to the classifier. The classifier of CNN generally uses back propagation (BP) network (Cun et al. 1990; Simard et al. 2003) and radial basis function (RBF) network (LeCun et al. 1998), etc. Figure 1 shows a typical structure of CNN with two feature extraction stages. Figure 1—A typical structure of CNN with two feature extraction stages. Convolution Layer. A convolution layer contains a series of feature maps, each of which is connected to one or more of the feature maps in the previous layer by a convolutional kernel. The convolutional kernel of K×K size defines the connection weight. For CNN in Figure 1, a feature map in layer C3 can be connected to multiple feature maps in layer S2. All neurons in the same feature map share the same convolutional kernel and bias, and the convolution kernel and bias are determined by training/learning method. Each neuron in the convolution layer extracts the local features at the same position in the previous part of the feature map by convolution. Taking the element of the jth feature map of the ith convolution layer as an example, the convolution operation is calculated as, Input 6464 C1 4@6060 S2 4@3030 C3 14@2626 S4 14@1313 C5 120 F6 84 Output 8 Convolutions Subsampling Convolutions Subsampling Full connection 3 𝑜𝑖𝑗(𝑥, 𝑦) = tanh [ 𝑏𝑖𝑗 + ∑ ∑ ∑ 𝑤𝑖𝑗𝑘(𝑟, 𝑐)𝑜(𝑖−1)𝑘(𝑥 + 𝑟, 𝑦 + 𝑐) 𝐶𝑖 𝑐=0 𝑅𝑖−1 𝑟=0 𝑘∈𝐾𝑖𝑗 ] ,………………(1) where tanh denotes the hyperbolic tangent activation function; bij denotes the bias parameter of the feature map; Kij denotes the set of feature maps in the (i-1)th layer connected to oij; wijk denotes the convolution kernel between the feature map oij and the feature map o(i-1,k); Ri and Ci denote the number of rows and the number of columns of the convolution kernel correspondingly. Assuming that the size of the feature map in (i-1)th layer is n1×n2. If we do convolution operation to the feature map using a l1×l2 convolution kernel, the size of feature map obtained for the ith layer is (n1- l1+1)×(n2-l2+1). We can see that the convolution operation can reduce the dimension of the data. Generally, the size of the convolution kernel is 5×5. If the size of the convolution kernel is too small, it cannot obtain the local characteristics between the adjacent regions of the image. But if the size is too large, the calculation budget of the convolution operation will be increased and the calculation speed will be slow. Sub-sampling Layer. The sub-sampling layer uses the region filter to reduce the resolution of the feature map in the convolution layer. The sub-sampling operation can extract the important features for classification, and ignore the useless details and noise. This gives CNN a good noise resistance ability. The feature maps of the sub-sampling layer are one-to-one corresponding to the feature maps of the previous convolution layer. Assuming the resolution of the sub-sampling operation is N, the resolution of feature map in sub-sampling layer becomes the 1/N2 of the original map. The sub-sampling operation can decrease the number of data significantly. There are two main sub-sampling methods, the mean sampling, and the maximum sampling. The sub-sampling operation makes the output of the convolution neural network invariance in spatial. Taking the element of the jth feature map of the ith layer as an example, the sub- sampling operation is calculated as follows. 𝑜𝑖𝑗(𝑥, 𝑦) = tanh [𝑏𝑖𝑗 + 𝑔𝑖𝑗 ∑ ∑ 𝑜(𝑖−1)𝑗(𝑥𝑁𝑖 + 𝑟, 𝑦𝑁𝑖 + 𝑐) 𝑁𝑖−1 𝑐=0 𝑁𝑖−1 𝑟=0 ] ,………………………........(2) where gij denotes the gain parameter of the feature map oij; Ni denotes the sub-sampling rate of the ith layer. The step size of the feature combination is equal to the side length of the sub-sampling operation, and Ni>1. Assuming that the size of the feature map of the (i-1)th layer is n1×n2, the ith layer is obtained through a sub-sampling operation with a l×l sub-sampling rate. Then the size of the ith layer should be n1/l×n2/l, where   denotes rounded down operation. Classifier. CNN extracts the feature of the input image and reduces the dimension of data through the convolution operation and sub-sampling operation in its hidden layers. That makes CNN can obtain the effective features and filtering the interference information for identification and classification. Because CNN uses the backpropagation algorithm to train the weight of the entire network, so the classifier for CNN usually chooses the fully connected BP network classifier (Cun et al. 1990; Simard et al. 2003), polynomial logic regression classifier (Jarrett et al. 2010), radial basis function network classifier (LeCun et al. 1998), and so on. Training of CNN. The CNN obtains the mapping relationship between input and output through learning. This mapping relationship is finally reflected in the network weight, which makes CNN have the ability to extract features of input data layer by layer. In this paper, a supervised error backpropagation algorithm is used to train the CNN network. The sum of squared the output errors is used as the system error function. The weights are updated according to the error backpropagation algorithm during the training process. The training process can be divided into two stages, they are, the forward propagation of the input signal and the backpropagation of the output error. In the process of forward propagation, the sample image data is input directly into the input layer of CNN, and the result is extracted and transformed by layer-by-layer of the middle hidden layer, and finally to the output layer. In the backpropagation process, the error between 4 the sample label and the forward propagated output is calculated, and the weights of the entire network are adjusted by the backpropagation algorithm to achieve the best performance. The detailed training process of CNN is as follows: (1) Forward propagation process a. Take a sample from the training set (X, Dp) and put the sample data X into CNN; b. Forward propagation the input data according to the convolution operation calculation Eq. 1, the sub-sampling operation calculation Eq. 2 and the classifier, and obtains the actual output Yp of the input data X. (2) Backpropagation process a. Calculate the error E from the actual output Yp and the ideal output Dp; b. Back propagate the error E to update the weight of the entire network. In practical application, the training process usually uses the batch training technology, which weights and biases are updated after multiple of the inputs and targets are presented. The detailed descriptions of the error estimate method and the weights update method can be found in Li (2015). CNN Based Indicator Diagram Identification Model The process of indicator diagram identification based on CNN is shown in Figure 2. Figure 2—The process of indicator diagram identification based on CNN. Pretreatment of Indicator Diagram. In order to keep the quality of the training and learning of the CNN network, it is necessary to standardize the input data of the network. Standardized Indicator Diagram Drawing. In order to reduce the training time and improve the convergence speed of learning, the original indicator diagram is pre-processed to a normalized binary image as the input of CNN. In our model, the displacement vector S and the load vector F measured from the pumping unit are plotted as 64×64 binary image. The plot uses displacement vector as the x-axis and the bound is set to [min(S), max(S)]; and uses load vector as the y-axis and the bound is set to [min(F), max(F)]. CNN Output Definition. In this paper, all the samples are classified into eight categories of working conditions of pumping unit, of which seven are the most common types of working conditions, and the rest of the conditions is classified as unknown. Figure 3 shows the typical indicator diagram of the well and the corresponding working conditions. 5 Figure 3—The typical indicator diagram. The number of neurons in the output layer of CNN equals the number of categories of working conditions we defined. When we input an indicator diagram to CNN, only one of all the neurons in the output layer obtain value 1, and the remaining neuron output is 0. The ideal output mode for CNN is shown in Table 1. Table 1—Ideal output mode for CNN model. Index Working condition Output vector 1 Unknown [1 0 0 0 0 0 0 0] 2 Normal [0 1 0 0 0 0 0 0] 3 Insufficient liquid [0 0 1 0 0 0 0 0] 4 Gas influence [0 0 0 1 0 0 0 0] 5 Travelling valve loss [0 0 0 0 1 0 0 0] 6 Standing valve loss [0 0 0 0 0 1 0 0] 7 Piston out [0 0 0 0 0 0 1 0] 8 Gas locking [0 0 0 0 0 0 0 1] Model Description. In this study, we use LeNet-5 (Elsawy et al. 2016), the most commonly used structure of CNN, as the CNN structure of indicator diagram identification model. LeNet-5 contains two feature extraction stages and a neural network classifier (Figure 1). The input for our CNN model is a normalized 64×64 binary image of indicator diagram, and output is an 8×1 column vector. The first feature extraction stage of CNN consists a convolution layer C1 and a sub-sampling layer S2. The C1 layer is obtained by convolution of the original image through four 5×5 convolution kernels. That makes C1 layer contains four 60×60 feature maps. There are one 5×5 convolution kernel and one bias NormalUnknown Piston out Insufficient liquid Gas locking Gas influence Standing valve lossTravelling valve loss 6 between the original image and each feature map in the C1 layer. The number of weights needs training is 4×(5×5+1)=104. The S2 layer is obtained by one-to-one sub-sampling operation on the feature maps of the C1 layer. The sub-sampling resolution is set to 2×2. Hence the size of feature maps in the S2 layer is 30×30, and the number of the maps is 4. Each sub-sampling operation contains two training parameters, which are multiplicative bias and additive bias. The S2 layer has 4×(1+1)=8 weights. The second feature extraction stage of CNN consists of convolution layer C3 and subsampling layer S4. The convolution layer C3 contains 14 feature maps, corresponding to the size of 14 convolution kernels is 5×5, so the layer of the feature map resolution of 26×26. Each of the feature maps in the C3 layer is connected to one or more maps of the S2 layers. This not only reduces the number of connections between the C3 and S2 layers but more importantly, it can destroy the symmetry of the network connection. The connection between the C3 layer and the S2 layer is shown in Figure 4. The number of weights required for the C3 layer is 5×5×14+14×1=364. Figure 4—The connection between the C3 layer and S2 layer. The sub-sampling resolution of the subsampling layer S4 is still 2×2, so S4 outputs 14 13×13 feature maps. Each sub-sampling operation requires two training parameters. The number of weights required in the S4 layer is 14×2=28. The C5 layer is a convolution layer, and each feature map is connected to all the feature maps of the S4 layer. This connection type usually is called as full connections. C5 layer contains 120 1×1 feature maps, which can also be seen as a 120-dimensional column vector. The convolutional kernel size for this layer is 13*13. The number of connections between the S4 layer and C5 layer is 120×(13×13×14+1)=284,040, i.e. the number of weights is 284,040. The F6 layer is a hidden layer of BP neural network with 84 nodes. There are 84×(120+1) = 10164 weights for this layer. The output layer contains 8 nodes, and a 1×8 output column vector is obtained. The position of the element with the largest value in the vector corresponds to the classification result of the network. Experimental Results The indicator diagram set collected from a real oilfield are used to training our proposed CNN model and verify its effectiveness. The data set includes 180,000 indicator diagram from 39 wells. All indicator diagrams are labelled by means of manual identification and can be divided into 8 categories. 2/3 of each category are randomly selected as training set and the rest as the test set. The total number of training 1 2 3 4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 7 samples is 120,000 and the number of test samples is 60,000. The number of samples for each type of working condition is shown in Figure 5. Figure 5—Distribution of experiment samples. The structure of CNN used in our model is LeNet-5, which shows good performance in the experiments of image recognition and speech recognition. The detail description of the CNN is given in section 3. Before training our CNN model, we need to determine the learning rate η and the training times s. For the learning rate η, a too large training rate may lead to an unstable training process, and a too small rate will slow down the convergence rate of training, hence make the training cycle too long and is easy to fall into local optima. According to Li’s work (2015), we choose the learning rate η=0.5 in our model. For the training times s, the training times should be decided carefully to make sure CNN will be trained adequately without overfitting. According to Li’s work (2015), we choose the training times s=20 in our model. The training time for our CNN model is 6,235s. When training process is completed, the test samples and training samples are used to verify the identification accuracy of the model, results show that the recognition error of the training sample is 1.79%, and the recognition error of the test sample is 2.00%. The accuracy of the CNN-based indicator diagram recognition model is more than 90%. The average time required for our CNN model to identify an indicator diagram is 3.0 ms. From the result, we can see that the performance of CNN model is excellent. The CNN-based indicator diagram classification and recognition model can be combined with the real-time data acquisition system of the well to realize the real-time intelligent monitoring of the oil well working condition. Conclusions Based on the theory of deep learning, this paper proposes the use of convolution neural network method to study the massive indicator diagram collected in the pumping unit of oil well, and identify the working conditions of the oil well. The structure and principle of CNN are introduced and the CNN based indicator diagram recognition model is established. The accuracy of the CNN-based indicator diagram recognition 0 10000 20000 30000 40000 50000 Unknown Normal Insufficient liquid Gas influence Travelling valve loss Standing valve loss Piston out Gas locking Number of training samples Number of test samples 8 model is more than 90%. The efficiency of the identification process is excellent. The CNN based indicator diagram recognition model can be combined with the real-time data acquisition system of the well to realize the real-time intelligent monitoring of the oil well working condition. Acknowledgments This work is supported by Open Fund (PLC20190803) of State Key Laboratory of Oil and Gas Reservoir Geology and Exploitation (Chengdu university of Technology) and the Natural Science Research Project of Higher Education of Jiangsu, China (No. 17KJB440001). We would like to thank Luming oil and gas exploration and development Co., Ltd, Shengli oilfield which provides experimental data. Conflicts of Interest The author(s) declare that they have no conflicting interests. References Aaron, V.D.O., Dieleman, S., and Schrauwen, B. 2013. Deep Content-Based Music Recommendation. Advances in Neural Information Processing Systems 2013(26): 2643-2651. Collobert, R. and Weston, J. 2008. A Unified Architecture for Natural Language Processing: Deep Neural Networks With Multitask Learning. Paper presented at 25th International Conference on Machine Learning, New York, United States, 23-25 July. Cun, Y.L., Boser, B., Denker, J.S., et al. 1990. Handwritten Digit Recognition with a Back-Propagation Network. Advances in Neural Information Processing Systems 2(2): 396–404. Elsawy, A., Elbakry, H., and Loey, M. 2016. CNN for Handwritten Arabic Digits Recognition Based on LeNet-5. Paper presented at International Conference on Advanced Intelligent Systems and Informatics, Cairo, Egypt, 20-23 October. Gong, J. 2006. Fault Diagnosis of Sucker Oil Well Based on Expert System. Master thesis, China University of Petroleum (East China), Qingdao, China. Jarrett, K., Kavukcuoglu, K., Ranzato, M., et al. 2010. What Is the Best Multi-Stage Architecture for Object Recognition? Paper presented at IEEE International Conference on Computer Vision, Kyoto, Japan, 12-15 May. LeCun, Y., Bottou, L., Bengio, Y., et al. 1998. Gradient-Based Learning Applied to Document Recognition. Proceedings of the IEEE 86(11): 2278–2324. Li, C., Su, X., Wei, J., et al. 2014. Research on Diagrams Identification of Pumping Unit Based on Support Vector Machine. Computer Technology and Development 24(8): 215–222. Li, P. 2015. Pump Indicator Diagram Intelligent Identification Based on Deep Learning Network. Master thesis, Henan University of Science and Technology, Luoyang, China. LISA Lab. Convolutional Neural Networks. http://deeplearning.net/tutorial/lenet.html. Downloaded in April 2017. Matsugu, M., Mori, K., Mitari, Y., et al. 2003. Subject Independent Facial Expression Recognition with Robust Face Detection Using a Convolutional Neural Network. Neural Networks 16(5): 555-558. Martinez, E.R., Moreno, W.J., Castillo, V.J., et al. 1993. Rod Pumping Expert System. Paper presented at Petroleum Computer Conference, New Orleans, United States, 7-9 January. Meng, Q. 2012. Theoretical Research on Recognition of Rod Pumped Well Working Condition Through Dynamometer Card Based on Cellular Neural Network Theory. Master thesis, China University of Petroleum (East China), Qingdao, China. Nazi, G. M., Ashenayi, K., Lea, J. F., et al. 2013. Application of Artificial Neural Network to Pump Card Diagnosis. SPE Computer Applications 6(6): 9-14. Pan, Z. J., and Ge, J. L. 1996. An Adaptive Neural Networks for Identification of Dynamometer Card. Acta Petrolei Sinica 17(3): 104–109. Schirmer, P., Gay, J. C., and Toutain, P. 2013. Use of Advanced Pattern-recognition and Knowledge-based System in Analyzing Dynamometer Cards. SPE Computer Applications 3(6): 21-24. Simard, P. Y., Steinkraus, D., and Platt, J. C. 2003. Best Practices for Convolutional Neural Networks Applied To Visual Document Analysis. Paper presented at International Conference on Document Analysis and Recognition, Edinburgh, UK, 2-5 August. http://deeplearning.net/tutorial/lenet.html 9 Wang, Z., Xue, G., Jin, Z., et al. 2001. Using Human Nerve Network for Indicator Diagram Identification. Petroleum Drilling Techniques 29(2): 56–57. Wang, Y. 2006. Remote Monitoring and Fault Diagnosis System of Sucker Road Oil Well. Master thesis, Wuhan University of Technology, Wuhan, China. Xu, G. and Yang, S. 2013. Application of Grey Theory in Fault Diagnosis of Rod-pumped Well. Journal of Hefei University of Technology (Natural Science) 36(10): 1265–1268. Yue, J., Zuo, J., and Li, H. 1999. Distinguishing Method to Characteristics of Dynamometer Diagram Moment of Pumping Wells. Oil-Gas field Surface Engineering 18(3): 15–16. Zhen Wang is an engineer at Luming Oil and Gas Exploration and Development Co., LTD, Shengli Oilfield. He holds a master’s degree in oil and gas field development engineering from China University of Petroleum (East China). His expertise is oil well production management and smart oilfield. Xiang Wang is an assistant professor at School of Petroleum Engineering, Changzhou University. He got his PhD degree from China University of Petroleum (East China). His research interests are the interface of mathematics, computer science, and engineering to better understand and optimize the development of oil and gas reservoirs. Weigang Duan is a senior engineer at Luming Oil and Gas Exploration and Development Co., LTD, Shengli Oilfield. He has over 20 years of experience in oil and gas production and management. Fajun Li is a senior engineer at Luming Oil and Gas Exploration and Development Co., LTD, Shengli Oilfield. He has long been engaged in research and management of oil well production technology and has rich experience. Fei Chen is an engineer at Luming Oil and Gas Exploration and Development Co., LTD, Shengli Oilfield. He is currently engaged in research and management of oilfield information construction.