A method for power quality analysis and identification based on deep learning
By using long and short-term memory networks to train and test the electrical energy signals, the problem of incomplete feature extraction caused by artificial intervention in the prior art is solved, and efficient classification of time-sequential electrical energy signals is achieved, and the recognition accuracy and application scope are improved.
Patent Information
- Application Number
- CN202110763356.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-06
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2041-07-06
AI Technical Summary
The existing power quality analysis and identification methods require artificial intervention in feature extraction, resulting in incomplete feature extraction, affecting classification results, and it is difficult to directly process the time-sequential power signals.
The deep learning-based method is adopted, and the electrical energy signals are trained and tested using the long and short-term memory network (LSTM) model, and classified through the Softmax function and backpropagation algorithm to avoid human intervention and directly realize the classification of electrical energy quality signals.
It improves the recognition accuracy of power quality signals, reduces errors, expands the scope of application, and is highly practical.
Smart Images

Figure CN113657149B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of power system power quality analysis and identification, and relates to a power quality analysis and identification method based on deep learning. Background Art
[0002] With the continuous development of society and economy, the complexity and diversity of modern power systems are also increasing. Under the influence of loads including impact, volatility, nonlinearity, etc., power quality issues are becoming more and more prominent. For example, some nonlinear devices will inject various interference signals into the power system during use. These disturbance signals are likely to cause serious consequences such as equipment overheating, motor stoppage, protection failure, and inaccurate measurement, causing serious economic losses and social impacts, and have many adverse effects on the normal operation of the power grid.
[0003] Traditional power quality analysis and identification mainly divides the classification of power quality into two steps: power signal feature extraction and classification based on the extracted features.
[0004] At present, the methods of feature extraction include: Fourier transform, short-time Fourier transform, wavelet transform, S transform and other digital signal processing methods. In recent years, some new technologies have emerged, such as Hilbert Huang transform and ensemble empirical mode decomposition. Fourier transform is the most basic and most commonly used method for extracting features from electric energy signals, but because Fourier transform is a global transform, the specific location of the electric energy disturbance cannot be determined. Short-time Fourier transform selects a window function in the time domain and analyzes the signal by shifting the window, but it requires manual selection of the time window, and the size of the time window is greatly related to the effect of feature extraction. When using the wavelet transform method for feature extraction, it is necessary to manually select the most appropriate wavelet basis. If an inappropriate wavelet basis is selected, the efficiency of feature extraction will be greatly reduced. That is, a certain amount of human intervention is required in the extraction process to extract features, which will inevitably cause incomplete feature extraction, affect the subsequent classification process, and have a greater impact on the classification results. However, the Hilbert Huang transform is not suitable for wide-band signals, and the ensemble empirical mode decomposition increases the running time of the algorithm in order to reduce the error caused by white noise.
[0005] In the classification stage, current methods include expert systems, artificial neural networks, decision trees, and convolutional neural networks. Expert systems rely on human experience, which is objectively limited, and their efficiency is limited. When this method is used for classification, feature extraction is difficult. Artificial neural networks may fall into local extreme values during the training of small samples, resulting in unsuccessful training, and the training time is long. Decision trees are prone to overfitting during training. Convolutional neural networks are mainly used in the field of image recognition. Therefore, in the identification of power quality disturbances, previous studies have converted power signals into two-dimensional images in a certain way and passed them into the network for learning.
[0006] The above situation shows that the current power quality analysis and identification methods all require preprocessing of power signals and certain human intervention for feature extraction, which inevitably leads to incomplete feature extraction and affects the subsequent classification process. Summary of the invention
[0007] The purpose of the present invention is to provide a power quality analysis and identification method based on deep learning, which solves the problems that the existing power quality analysis and identification methods require human intervention to extract features, have large errors and cannot directly process time-series power signals.
[0008] The technical solution adopted by the present invention is a power quality analysis and identification method based on deep learning, which includes collecting power signals to be detected, randomly dividing the power signals to be detected into a training sample set and a test sample set, inputting the training sample set into a long short-term memory network LSTM model for training, obtaining the trained LSTM model, and inputting the test sample set into the trained LSTM model to test the classification of power quality disturbances.
[0009] The specific steps include:
[0010] Step 1, collecting the electric energy signals to be detected in multiple time periods, randomly dividing the collected signals into a training sample set and a test sample set, splicing the signals in the training sample set into a large signal in chronological order, i.e., the training set signal, and splicing the signals in the test sample set into a large signal in chronological order, i.e., the test set signal;
[0011] Step 2, constructing a long short-term memory neural network LSTM model, wherein the LSTM model includes an input layer, a hidden layer and an output layer;
[0012] Step 3, training the LSTM model, selecting sampling points from the training set signal and inputting them into the LSTM model for training, correcting the weights of the matrix in the LSTM model, and using the difference between the sample output value and the target value to update the parameters in the LSTM model. When the number of training times reaches the preset value, the trained LSTM model is obtained;
[0013] Step 4: Input the test set signal into the trained LSTM model for testing, and the LSTM model outputs the power quality disturbance classification result.
[0014] Step 3 includes the following steps:
[0015] Step 3.1, initialize the hidden layer and state layer in the constructed LSTM model to random numbers;
[0016] Step 3.2: Select a sampling point (X,Y label) is input to the input layer of the LSTM model, and after being calculated by the hidden layer, it is output to the output layer to obtain Y out ;;
[0017] Step 3.3, use the Softmax function to process the output layer results, and output multiple neuron outputs. After obtaining the outputs of multiple neurons, the softmax classifier maps the outputs to the (0,1) interval, assigning a probability value to each output classification result. When selecting the output node at the end, select the node with the maximum probability as the prediction target;
[0018] Step 3.4, Y label and Y out The error term is obtained by comparison, and the error term is input into the back propagation algorithm for back propagation training. The LSTM model is optimized, and an output is performed at each time step to calculate the error E between the sample output value and the target value. d , and use the error to update the weights of the neural network to obtain the trained LSTM model.
[0019] In step 3.4, in the back propagation algorithm, the model is divided into input layer, hidden layer, and output layer. The error term of node j in the output layer is:
[0020] δ j =y j (1-y j )(t j -y j )
[0021] Among them, δ j is the error term of output layer node j, y j is the output value of node j in the output layer, t j is the target value of output layer node j;
[0022] The error term of hidden layer node i is:
[0023] δ i =a i (1-a i )∑ k∈output w ji δ j
[0024] Among them, a i is the output value of hidden layer node i, w ji is the weight from hidden layer node i to output layer node j, δ j is the error term of output layer node j, δ i is the error term of hidden layer node i;
[0025] After obtaining the node error term, update the weight:
[0026] w ji ←w ji +ηδ j x ji
[0027] Among them, w ji is the weight from hidden layer node i to output layer node j, η is the learning rate, δ j is the error term of output layer node j, x ji It is the output of hidden layer node i and also the input of output layer node j. The input bias is always 1.
[0028] In step 3.4, when training the neural network, the back propagation algorithm is combined with the gradient descent method to use the error E between the sample output value and the target value. d Update the parameters of the neural network:
[0029]
[0030] In the formula, E d is the error of sample d, y i is the output value of the node, ti is the target value of the node;
[0031] After obtaining the sample error, the weights are updated by gradient descent:
[0032]
[0033] In the formula, w ji is the weight from node i to the next layer node j, η is the learning rate;
[0034] Using the transfer derivation rule, the weight correction of the neural network is obtained as follows:
[0035]
[0036] net j It is the output of the j-th layer network. After calculating the errors of all nodes once, the weights of the entire network are updated.
[0037] In step 1, a mutual inductor or a Hall sensor is used to collect the electric energy signal to be detected, and a mark of the electric energy signal is outputted while outputting the electric energy signal.
[0038] The beneficial effect of the present invention is that a long short-term memory network is used as a model for classifying electric energy signals, and the model is trained through a Softmax function and a back propagation algorithm so that it can quickly reach convergence, thereby avoiding human intervention in feature extraction, directly realizing the classification of electric energy quality signals, reducing errors, improving recognition accuracy, having a wide range of applications, and having high practicality. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is a flow chart of the power quality analysis and identification method based on deep learning of the present invention;
[0040] Figure 2 is a flow chart of electric energy signal collection in an embodiment of the present invention;
[0041] Figure 3 It is a schematic diagram of the time sequence expansion of the long short-term memory network in the present invention;
[0042] Figure 4 It is a schematic diagram of a long short-term memory network unit in the present invention;
[0043] Figure 5 It is a flow chart of long short-term memory network training in the present invention;
[0044] Figure 6 is a schematic diagram of cost function values and signal types after the first training in an embodiment of the present invention;
[0045] Figure 7 This is a test result diagram of the 10th input power signal in an embodiment of the present invention. DETAILED DESCRIPTION
[0046] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0047] The present invention provides a power quality analysis and identification method based on deep learning, referring to Figure 1 , including the following steps:
[0048] Step 1: Collect power signals
[0049] When collecting power signals, in order to detect the accuracy of the power quality analysis and identification method based on deep learning of the present invention, the power signals collected in this embodiment are simulated power signals. According to the relevant documents of IEEE1159-2019, the definition of power quality and the classification and standards of disturbances, six different power quality disturbance models are established, and Python is used to simulate and output the power signals, such as Figure 2 As shown, voltage sag, voltage swell, voltage interruption, voltage pulse, voltage fluctuation, and harmonic disturbance power signals are randomly generated. The time length of any generated signal is 0.22 seconds, which can better describe the power disturbance signal with a long duration, and output the mark of the power signal at the same time as the power signal is output.
[0050] Among them, the power signal output by simulation is as follows:
[0051] Normal voltage signal: v t = sin(ωx)
[0052] Where x is the sampling time point, ω is the fundamental angular frequency, ω=2πf, and f is the alternating voltage frequency, which is 50Hz in my country.
[0053] Voltage swell signal: v t ={1+a[u(x-t1)-u(x-t2)]}sin(ωx)
[0054] In the formula t1 is the starting time point, t2 is the ending time point, x is the sampling time point, the unit of the time point is milliseconds, and u is the unit step function;
[0055] Voltage sag signal: v t ={1-a[u(x-t1)-u(x-t2)]}sin(ωx)
[0056] In the formula t1 is the starting time point, t2 is the ending time point, x is the sampling time point, the unit of the time point is milliseconds, and u is the unit step function;
[0057] Voltage interruption signal: v t =1-a[u(x-t1)-u(x-t2)]}sin(ωx)
[0058] In the formula t1 is the starting time point, t2 is the ending time point, x is the sampling time point, the unit of the time point is milliseconds, and u is the unit step function;
[0059] Transient impulse signal: v t =sin(ωx)+a[u(x-t1)-u(x-t2)]
[0060] In the formula t1 is the starting time point, t2 is the ending time point, x is the sampling time point, the unit of the time point is milliseconds, and u is the unit step function;
[0061] Transient oscillation signal:
[0062]
[0063] in, t1 is the starting time point, t2 is the ending time point, x is the sampling time point, the unit of the time point is milliseconds, and u is the unit step function;
[0064] Harmonic signal:
[0065]
[0066] in, t1 is the starting time point, t2 is the ending time point, x is the sampling time point, the unit of the time point is milliseconds, and u is the unit step function;
[0067] The collected electric energy signals are randomly divided into a training sample set and a test sample set;
[0068] Step 2, construct a long short-term memory network LSTM model. The entire network structure includes an input layer, a hidden layer, and an output layer. The input layer is responsible for directly receiving the sampled data. In the hidden layer, each layer of neurons is fully connected to the neurons in the next layer, and the neurons belonging to the same layer are not connected to each other. The input of each layer is the output of the previous layer and takes a certain weight to obtain the output. The size of the output layer is determined by the task to be completed.
[0069] In this method, the input power signal needs to be classified into one of seven categories, namely, six disturbances and normal signals;
[0070] like Figure 3 As shown in , there are three inputs in the LSTM network: unit state, hidden layer, and input data. Figure 4 As shown, LSTM uses the forget gate and input gate to control the content of the cell state c. The forget gate determines the cell state c at the previous moment. t-1 At the current moment c t How much will be retained, the input gate determines how much network input x is currently t Save to current cell state c t , the output gate controls the output value. The calculations of the forget gate, input gate, and output gate are shown in the following formulas:
[0071]
[0072] In the formula, f t is the result of the current state operation of the forget gate, i t is the result of the current state operation of the input gate, o t is the result of the current state operation of the output gate; W f is the weight matrix of the forget gate, W i is the weight matrix of the input gate, W o is the weight matrix of the output gate; b f is the bias term of the forget gate, b i is the bias term of the input gate, b o is the bias term of the output gate, X t is the current input, h t is the current output value.
[0073] In the entire LSTM network, the unit state output and the output of the hidden layer are expressed by the following formula:
[0074]
[0075] Among them, c′ t is the unit state input at time t, b c is the bias term of the input unit state, W c is the weight matrix of the input unit state, the hollow circle ° is the matrix multiplication according to the element, h t is the current output value, c t The current unit status.
[0076] Step 3: Train the constructed long short-term memory network LSTM model, refer to Figure 5 , specifically including the following steps:
[0077] Step 3.1, initialize the hidden layer and state layer of the long short-term memory network to random numbers to ensure the network learning effect and avoid premature saturation;
[0078] Step 3.2: Select a sampling point (X, Y label ) is input into the input layer of the long short-term memory network, and after being calculated by two hidden layers of 32 neurons, it is output to the output layer to obtain Y out ;
[0079] Step 3.3, use the Softmax function as the algorithm to process the output layer results, and process the output of multiple neurons. After obtaining the output of multiple neurons, the softmax classifier maps the output to the (0,1) interval. When selecting the output node at the end, select the node with the largest probability (that is, the largest corresponding value) as the prediction target; the final classification result is represented by probability, which indicates the possibility that the input signal belongs to each category, and also indicates the credibility of the corresponding category. In order to determine which type the disturbance signal belongs to, the model selects the category with the largest probability. When the conditional probability of the category to which each sample belongs is the largest, the recognition rate of Softmax is the highest, so the trained model is more accurate;
[0080] The Softmax function expression is:
[0081]
[0082] Among them, P(y=j|z)∈(0,1),∑ j P(y=j|z)=(0,1), j=7, corresponding to the six power quality disturbance phenomena defined in this algorithm and the normal power quality signal.
[0083] Step 3.4, Y label and Y outCompare and get the error, so as to perform back propagation training and optimize the model, such as Figure 6 As shown, an output is performed at each time step, the error of the output value is calculated, and the weights of the matrix in the network are corrected during the back propagation algorithm training;
[0084] In the back propagation algorithm, the model is divided into input layer, hidden layer, and output layer. The error term of node j in the output layer is:
[0085] δ j =y j (1-y j )(t j -y j )
[0086] Among them, δ j is the error term of output layer node j, y j is the output value of node j in the output layer, t j is the target value of output layer node j.
[0087] The error term of hidden layer node i is:
[0088] δ i =a i (1-a i )∑ k∈output w ji δ j
[0089] Among them, a i is the output value of hidden layer node i, w ji is the weight from hidden layer node i to output layer node j, δ j is the error term of output layer node j, δ i is the error term of hidden layer node i.
[0090] The error terms of all hidden layer nodes are calculated using the error terms of the output layer nodes.
[0091] After obtaining the node error term, update the weight:
[0092] w ji ←w ji +ηδ j x ji
[0093] Among them, node i is the hidden layer node, node j is the output layer node, and w ji is the weight from node i to node j, η is the learning rate, δ j is the error term of node j, x ji It is the output of node i and the input of node j. The input bias is always 1.
[0094] When training a neural network, the back propagation algorithm is combined with the gradient descent method to use the error E between the sample output value and the target value. d Update the parameters of the neural network:
[0095]
[0096] E d is the error of sample d, y i is the output value of the node, t i is the target value of the node, where It is a constant parameter set for the convenience of subsequent calculations.
[0097] After calculating the sample error, the weights are updated using the gradient descent method:
[0098]
[0099] Using the transfer derivation rule, the weight correction of the neural network is obtained as follows:
[0100]
[0101] After calculating the errors of all nodes once, the weights of the entire network are updated.
[0102] In step 3.5, the input of the electric energy signal is changed to an electric energy disturbance signal, where the disturbance signal accounts for a larger proportion than the normal signal. Steps 3.1, 3.2, 3.3, and 3.4 are repeated to allow the model to learn the duration of the electric energy disturbance signal more quickly and fully.
[0103] Step 4: Input the test sample set into the trained LSTM model for testing. The results are as follows: Figure 6 As shown, the accuracy is recorded as the number of accurate predictions of the model divided by the total number of samples. The model is further tested by inputting an electric energy signal containing a large number of disturbances. The test results are shown in Figure 7 As shown, the accuracy is high and the loss function is low, indicating that the trained model has a good level of classification of electrical energy signals.
Claims
1. A method for analyzing and identifying power quality based on deep learning, characterized in that: The method includes collecting an electric energy signal to be detected, randomly dividing the electric energy signal to be detected into a training sample set and a test sample set, inputting the training sample set into a long short-term memory network LSTM model for training, obtaining a trained LSTM model, and inputting the test sample set into the trained LSTM model to test the classification of power quality disturbances; The specific steps include: Step 1, collecting the electric energy signals to be detected in multiple time periods, randomly dividing the collected signals into a training sample set and a test sample set, splicing the signals in the training sample set into a large signal in chronological order, i.e., the training set signal, and splicing the signals in the test sample set into a large signal in chronological order, i.e., the test set signal; Step 2, constructing a long short-term memory neural network LSTM model, wherein the LSTM model includes an input layer, a hidden layer and an output layer; Step 3, training the LSTM model, selecting sampling points from the training set signal and inputting them into the LSTM model for training, correcting the weights of the matrix in the LSTM model, and using the difference between the sample output value and the target value to update the parameters in the LSTM model. When the number of training times reaches the preset value, the trained LSTM model is obtained; The step 3 comprises the following steps: Step 3.1, initialize the hidden layer and state layer in the constructed LSTM model to random numbers; Step 3.2: Select a sampling point (X,Y label ) is input to the input layer of the LSTM model, and after being calculated by the hidden layer, it is output to the output layer to obtain Y out ; Step 3.3, use the Softmax function to process the output layer results, and output multiple neuron outputs. After obtaining the outputs of multiple neurons, the softmax classifier maps the outputs to the (0,1) interval, assigning a probability value to each output classification result. When selecting the output node at the end, select the node with the maximum probability as the prediction target; Step 3.4, Y label and Y out The error term is obtained by comparison, and the error term is input into the back propagation algorithm for back propagation training. The LSTM model is optimized, and an output is performed at each time step to calculate the error E between the sample output value and the target value. d , use the error to update the weights of the neural network and obtain the trained LSTM model; Step 4: Input the test set signal into the trained LSTM model for testing, and the LSTM model outputs the power quality disturbance classification result.
2. The power quality analysis and identification method based on deep learning according to claim 1, characterized in that: In step 3.4, in the back propagation algorithm, the model is divided into an input layer, a hidden layer, and an output layer. The error term of the output layer node j is: δ j =and j (1-and j )(t j -and j ) Among them, δ j is the error term of output layer node j, y j is the output value of node j in the output layer, t j is the target value of output layer node j; The error term of hidden layer node i is: d i =a i (1-a i )S k∈output w ji d j Among them, a i is the output value of hidden layer node i, w ji is the weight from hidden layer node i to output layer node j, δ j is the error term of output layer node j, δ i is the error term of hidden layer node i; After obtaining the node error term, update the weight: w ji ←w ji +id j x ji Among them, w ji is the weight from hidden layer node i to output layer node j, η is the learning rate, δ j is the error term of output layer node j, x ji It is the output of hidden layer node i and also the input of output layer node j. The input bias is always 1.
3. The power quality analysis and identification method based on deep learning according to claim 2 is characterized in that: In step 3.4, when training the neural network, the back propagation algorithm is combined with the gradient descent method to use the error E between the sample output value and the target value. d Update the parameters of the neural network: In the formula, E d is the error of sample d, y i is the output value of the node, ti is the target value of the node; After obtaining the sample error, the weights are updated by gradient descent: In the formula, w ji is the weight from node i to the next layer node j, η is the learning rate; Using the transfer derivation rule, the weight correction of the neural network is obtained as follows: net j It is the output of the j-th layer network. After calculating the errors of all nodes once, the weights of the entire network are updated.
4. The method for analyzing and identifying power quality based on deep learning according to claim 1, characterized in that: In the step 1, a mutual inductor or a Hall sensor is used to collect the electric energy signal to be detected, and a mark of the electric energy signal is outputted while outputting the electric energy signal.
