A method and system for detecting anomaly in power grid data based on LSTM-VAE network

By constructing the LSTM-VAE network model, the existing smart grid data anomaly detection methods have solved the problems of high complexity and low detection performance in high-dimensional data processing, and achieved more accurate and stable abnormal detection effects.

CN118861961BActive Publication Date: 2025-02-28YANTAI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411354085.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-27
Publication Date
2025-02-28
Estimated Expiration
2044-09-27

AI Technical Summary

Technical Problem

The existing cluster-based and reconstruction-based smart grid data anomaly detection methods have problems of high complexity and low detection performance when processing high-dimensional grid data.

Method used

The grid data anomaly detection method based on the LSTM-VAE network is adopted to train and detect smart grid data by constructing a LSTM-VAE network model of a long and short-term memory network and a variational autoencoder (VAE).

Benefits of technology

This method can effectively process the timing of power grid data, capture the changing trends and rules of data at different time points before and after the failure, and improve the accuracy of abnormal detection, the stability and generalization ability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

The present invention relates to the field of data processing technology, and in particular to a method and system for detecting anomalies in power grid data based on an LSTM-VAE network. The method comprises obtaining smart grid data; constructing an LSTM-VAE network model of a long short-term memory network and VAE; performing network training on the LSTM-VAE network model using smart grid data; and performing power grid anomaly detection using the trained model. The present invention combines the advantages of LSTM and VAE. LSTM can effectively process the temporal nature of power grid data and capture the changing trends and laws of data at different time points before and after a fault; while VAE can better reconstruct data and detect anomalies by learning the potential distribution of data. The combination of the two can more accurately identify anomalies in power grid data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a method and system for detecting anomaly in power grid data based on an LSTM-VAE network. Background Art

[0002] Traditional power grid systems have drawbacks such as aging infrastructure, reliability issues, lack of consumer participation in power distribution, and limited support for distributed energy. In the information age, more and more power grid data can be used, and practitioners hope to extract effective information from these data to improve or detect smart grid operations. With the development of artificial intelligence and deep learning technologies, neural networks are used in smart grids to detect data anomalies in smart grid systems. The amount of power grid data is huge, so it is a challenge to build supervised learning data. Therefore, anomaly detection of smart grid data based on unsupervised neural networks is very critical. Existing unsupervised smart grid data anomaly detection methods are divided into traditional clustering methods and reconstruction-based unsupervised anomaly detection methods. As the dimension of power grid data gradually increases, the distance calculation complexity between data relied on by clustering methods is high, so ordinary clustering methods are difficult to apply to real scenarios. There are also some problems based on reconstruction methods. Reconstructed data points usually rely on autoencoders (AEs), which can extract common factors of variation from normal samples, but cannot do the same for abnormal samples because they have never seen abnormal examples during training, which leads to reduced detection performance. Therefore, solving these problems is crucial to improving the performance of smart grid data anomaly detection. Summary of the invention

[0003] In order to solve the defects of the above-mentioned clustering-based and reconstruction-based smart grid data anomaly detection methods, the present invention provides a power grid data anomaly detection method and system based on LSTM-VAE network.

[0004] In the first aspect, the present invention provides a method for detecting anomalies in power grid data based on an LSTM-VAE network, which adopts the following technical solution:

[0005] A method for detecting anomaly in power grid data based on LSTM-VAE network, comprising:

[0006] Access smart grid data;

[0007] Construct a LSTM-VAE network model of long short-term memory network and VAE;

[0008] Use smart grid data to train the LSTM-VAE network model;

[0009] Use the trained model to detect power grid anomalies.

[0010] Furthermore, the acquisition of smart grid data includes collecting voltage amplitude, voltage angle and voltage frequency data in the smart grid before, during and after a fault as a data set; wherein the ratios of voltage amplitude, voltage angle and voltage frequency are 40%, 10% and 40%, totaling 10,000 items, 80% of the data set is used as a training set, and 20% is used as a validation set.

[0011] Furthermore, the LSTM-VAE network model of constructing the long short-term memory network and VAE includes constructing a long short-term memory network model, wherein for the input time series , passes through the LSTM unit and outputs a hidden state , where the LSTM unit contains three gating units: input gating, output gating and forgetting gating.

[0012] Furthermore, the LSTM-VAE network model of constructing the long short-term memory network and VAE also includes constructing a VAE module, wherein the VAE module is composed of an encoder and a decoder, and the objective function of the VAE module is the variational lower bound of the marginal likelihood of the data, expressed as:

[0013]

[0014] in, is a neural network used to approximate, It is a decoder. is the encoder, is to calculate the KL divergence. Since this term is non-negative, the term Known as data The lower bound of the boundary likelihood is expressed as:

[0015]

[0016] in, is the likelihood of data x given the latent variable z,

[0017] is the KL divergence between the approximate posterior and prior of the latent variable z.

[0018] Furthermore, the LSTM-VAE network model of constructing a long short-term memory network and VAE also includes forming a decoder and an encoder of the LSTM-VAE network model with two LSTM layers and one linear layer, which are used to extract time series information of power grid data, and the number of hidden units of the two LSTM layers of the encoder network is 128 and 256 units, and the number of hidden units of the two LSTM layers of the decoder network is 256.

[0019] Furthermore, the LSTM-VAE network model of constructing the long short-term memory network and VAE also includes for potential samples ,in, is the vector index, is the number of network layers, ,here , using the diagonal matrix replace ,Right now ,in is a diagonal matrix consisting of the two largest eigenvalues ​​found in the singular value decomposition (SVD) of the wavelet coefficients of the high- and medium-frequency representations of the training data.

[0020] Furthermore, the LSTM-VAE network model is trained using smart grid data, including time series grid data. Transformed into hidden state through encoder network , and obtain the mean of its distribution and covariance , calculate the diagonal matrix , and reparameterize the hidden state, , and then decoded by the decoder network to obtain the final output , calculate the loss function, the calculation method is ,Finally, back propagation updates the network structure parameters.

[0021] In the second aspect, a power grid data anomaly detection system based on LSTM-VAE network includes:

[0022] The data acquisition module is configured to acquire smart grid data;

[0023] The model building module is configured to build a LSTM-VAE network model of a long short-term memory network and VAE;

[0024] The model training module is configured to perform network training on the LSTM-VAE network model using smart grid data;

[0025] The prediction module is configured to use the trained model to perform power grid anomaly detection.

[0026] In a third aspect, the present invention provides a computer-readable storage medium storing a plurality of instructions, wherein the instructions are suitable for being loaded and executed by a processor of a terminal device, for example, a method for detecting anomalies in power grid data based on an LSTM-VAE network.

[0027] In a fourth aspect, the present invention provides a terminal device comprising a processor and a computer-readable storage medium, the processor being used to implement various instructions; the computer-readable storage medium being used to store a plurality of instructions, the instructions being suitable for being loaded by the processor and executing the method for detecting anomalies in power grid data based on an LSTM-VAE network.

[0028] In summary, the present invention has the following beneficial technical effects:

[0029] 1. This invention combines the advantages of LSTM and VAE. LSTM can effectively process the temporal nature of power grid data and capture the changing trends and laws of data at different time points before and after a fault. VAE can better reconstruct data and detect anomalies by learning the potential distribution of data. The combination of the two can more accurately identify anomalies in power grid data.

[0030] 2. When using smart grid data to train the LSTM-VAE network model, the loss function is calculated and the network structure parameters are updated through back propagation, so that the model can be continuously optimized and adjusted, thereby improving the stability and generalization ability of the model.

[0031] 3. Collect and analyze data in different states before, during and after a fault in the smart grid, so that the model can adapt to the data characteristics under various operating conditions of the power grid, enhancing the adaptability and reliability of the model in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 is a schematic diagram of a power grid data anomaly detection method based on an LSTM-VAE network according to Embodiment 1 of the present invention;

[0033] Figure 2 This is an architecture diagram of the LSTM-VAE network model of Example 1 of the present invention. DETAILED DESCRIPTION

[0034] The present invention is further described in detail below in conjunction with the accompanying drawings.

[0035] Example 1

[0036] Reference Figure 1 , a power grid data anomaly detection method based on LSTM-VAE network in this embodiment includes:

[0037] Access smart grid data;

[0038] Construct a LSTM-VAE network model of long short-term memory network and VAE;

[0039] Use smart grid data to train the LSTM-VAE network model;

[0040] Use the trained model to detect power grid anomalies.

[0041] Specifically:

[0042] 1. Long short-term memory network construction, for input time series , passes through the LSTM unit and outputs a hidden state , where the LSTM unit contains three gating units: input gating, output gating and forget gating. The specific processing process of input gating and forget gating is:

[0043]

[0044]

[0045]

[0046] in, represents the forgetting unit, represents the input unit, is the weight matrix, and its superscript first symbol indicates that it processes time series Still hidden ,The second symbol indicates which gating unit the weight matrix belongs to. It is an offset item, and its meaning in the above table is the same as above.

[0047] After input gating and forget gating processing, the cell state of the LSTM cell at that moment can be obtained ,The specific processing process is:

[0048]

[0049] in, It is Hadamard.

[0050] The process of output gating is:

[0051]

[0052] in Represents an output gating unit.

[0053] After obtaining the LSTM unit state and output at this moment, the hidden state at the next moment can be obtained :

[0054] .

[0055] 2. (1) Construct a VAE module. VAE consists of an encoder and a decoder. The objective function of VAE is the variational lower bound of the marginal likelihood of the data, which can be expressed as:

[0056]

[0057] in, is a neural network used to approximate, It is a decoder. is the encoder, also constructed from a neural network, is to calculate the KL divergence. Since this term is non-negative, the term Known as data The lower bound of the boundary likelihood is expressed as:

[0058]

[0059] in, is the likelihood of data x given the latent variable z,

[0060] is the KL divergence between the approximate posterior and prior of the latent variable z.

[0061] Assume that the latent variable It obeys Gaussian distribution, that is ,therefore, is re-parameterized into ,in , we can get:

[0062] .

[0063] (2) Improved reparameterization method for latent samples ,in, is the vector index, is the number of network layers, ,here , using the diagonal matrix Replace the identity matrix ,Right now ,in is a diagonal matrix consisting of the two largest eigenvalues ​​found in the singular value decomposition (SVD) of the wavelet coefficients of the high-frequency and medium-frequency representations of the training data. The specific construction method is:

[0064] 1) In order to obtain high-frequency and medium-frequency wavelet coefficients, principal component analysis is performed on the training data set, and a 4-layer db wavelet transform is applied to the first principal component. The specific method is as follows:

[0065]

[0066]

[0067] in, is the low-frequency component (approximate coefficient), is the high frequency component (detail coefficient), is the scaling function used to extract low-frequency components, is the wavelet function used to extract high frequency components. The detail coefficients are stored as column vectors of the matrix. The wavelet coefficients of the lower level are padded with zeros to keep the dimensions of all vectors in each column equal. The purpose of this process is to keep all wavelet coefficients of the same size. Calculate the average of the wavelet coefficient matrix generated by the first two principal components. This resulting matrix is ​​represented as .

[0068] 2) Repeat the same process for the second principal component.

[0069] 3) Calculate the matrix The eigenvalues ​​of The first two eigenvalues ​​of construct a diagonal matrix .

[0070] 3. LSTM-VAE network framework construction. The entire network encoder and decoder are composed of two LSTM layers and one linear layer to extract the time series information of power grid data. The number of hidden units in the two LSTM layers of the encoder network is 128 and 256 units, and the number of hidden units in the two LSTM layers of the decoder network is 256. Each LSTM layer is followed by a ReLU activation function. The number of neurons in the linear layer of the encoder and decoder networks is 2. The batch size of network training is set to 256, and the four-fold cross-validation method is used. The Adam optimizer is used to optimize the entire neural network. The time step value of LSTM is selected as 10. The maximum iteration is 200 times, and the learning rate is , if the validation set loss does not decrease within 50 iterations, early stopping is enabled.

[0071] 4. Collection and construction of training data set: The voltage amplitude, voltage angle and voltage frequency data before, during and after the fault in the smart grid are collected, with the specific ratio of 40%, 10% and 40%, totaling 10,000 data. 80% of the data set is used as the training set and 20% as the validation set.

[0072] 5. Network training process:

[0073] Time series power grid data First, it is converted into a hidden state through the encoder network , and obtain the mean of its distribution and covariance , calculate the diagonal matrix , and reparameterize the hidden state, , and then decoded by the decoder network to obtain the final output , calculate the loss function, the calculation method is ,Finally, back propagation updates the network structure parameters.

[0074] The encoder and decoder are two neural networks, see Figure 2 The neural network will send the original data to the network for training at a time according to the set batch size. The data sent in first passes through the encoder-decoder network and finally obtains an output. This output is compared with the data label, that is, the loss function is calculated. All parameters of the neural network are updated according to the loss back propagation. Once the data set is fully trained, it is an iteration. The hidden state is to put the original data into the network and output it as a new data, such as mapping a triple (A, B, C) into a new data with 128 dimensions through a function.

[0075] 6. Grid data anomaly detection process, setting a confidence threshold , all time-series power grid data passes through the encoder-decoder network to obtain the final output , calculate the confidence level , for values ​​below the confidence threshold The data are regarded as abnormal data.

[0076] Through the technical solution of the present invention, the accuracy of abnormal data recognition can reach 97%, the F1 score exceeds 0.7, and the area under the ROC curve is greater than 0.79.

[0077] Example 2

[0078] This embodiment provides a power grid data anomaly detection system based on an LSTM-VAE network, including:

[0079] The data acquisition module is configured to acquire smart grid data;

[0080] The model building module is configured to build a LSTM-VAE network model of a long short-term memory network and VAE;

[0081] The model training module is configured to perform network training on the LSTM-VAE network model using smart grid data;

[0082] The prediction module is configured to use the trained model to perform power grid anomaly detection.

[0083] A computer-readable storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded and executed by a processor of a terminal device, a method for detecting anomalies in power grid data based on an LSTM-VAE network.

[0084] A terminal device includes a processor and a computer-readable storage medium, wherein the processor is used to implement various instructions; the computer-readable storage medium is used to store multiple instructions, and the instructions are suitable for being loaded and executed by the processor. A power grid data anomaly detection method based on an LSTM-VAE network is described.

[0085] The above are all preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A power grid data anomaly detection method based on LSTM-VAE network, characterized in that: include: Access smart grid data; Construct a LSTM-VAE network model of long short-term memory network and VAE; Use smart grid data to train the LSTM-VAE network model; Use the trained model to detect power grid anomalies; The method of constructing a LSTM-VAE network model of a long short-term memory network and VAE also includes forming a decoder and an encoder of the LSTM-VAE network model with two LSTM layers and one linear layer, which are used to extract time series information of power grid data, the number of hidden units of the two LSTM layers of the encoder network is 128 and 256 units, and the number of hidden units of the two LSTM layers of the decoder network is 256; The LSTM-VAE network model of constructing the long short-term memory network and VAE also includes the following steps for potential samples: ,in, is the vector index, is the number of network layers, ,here , using the diagonal matrix replace ,Right now ,in is a diagonal matrix consisting of the two largest eigenvalues ​​found in the singular value decomposition (SVD) of the wavelet coefficients of the high-frequency and medium-frequency representations of the training data; The LSTM-VAE network model is trained using smart grid data, including time series grid data. Transformed into hidden state through encoder network , and obtain the mean of its distribution and covariance , calculate the diagonal matrix , and reparameterize the hidden state, , and then decoded by the decoder network to obtain the final output , calculate the loss function, the calculation method is ,Finally, back propagation updates the network structure parameters.

2. According to a method for detecting anomaly in power grid data based on LSTM-VAE network according to claim 1, it is characterized in that: The smart grid data acquisition includes collecting voltage amplitude, voltage angle and voltage frequency data before, during and after a fault in the smart grid as a data set; wherein the ratio of voltage amplitude, voltage angle and voltage frequency is 40%, 10% and 40%, totaling 10,000 items, 80% of the data set is used as a training set, and 20% is used as a validation set.

3. According to a method for detecting anomaly in power grid data based on LSTM-VAE network according to claim 2, it is characterized in that: The LSTM-VAE network model of constructing a long short-term memory network and VAE includes constructing a long short-term memory network model, wherein for the input time series , passes through the LSTM unit and outputs a hidden state , where the LSTM unit contains three gating units: input gating, output gating and forgetting gating.

4. According to a method for detecting anomaly in power grid data based on LSTM-VAE network according to claim 3, it is characterized in that: The LSTM-VAE network model of constructing a long short-term memory network and VAE also includes constructing a VAE module, wherein the VAE module is composed of an encoder and a decoder, and the objective function of the VAE module is the variational lower bound of the marginal likelihood of the data, expressed as: in, is a neural network used to approximate, It is a decoder. , is to calculate the KL divergence. Since this term is non-negative, the term Known as data The lower bound of the boundary likelihood is expressed as: in, is the likelihood of data x given the latent variable z, is the KL divergence between the approximate posterior and prior of the latent variable z.

5. A power grid data anomaly detection system based on LSTM-VAE network, executing the method according to any one of claims 1 to 4, characterized in that: include: The data acquisition module is configured to acquire smart grid data; The model building module is configured to build a LSTM-VAE network model of a long short-term memory network and VAE; The model training module is configured to perform network training on the LSTM-VAE network model using smart grid data; The prediction module is configured to use the trained model to perform power grid anomaly detection.

6. A computer-readable storage medium storing a plurality of instructions, characterized in that: The instructions are suitable for being loaded by a processor of a terminal device and executing the method according to claim 1 .

7. A terminal device, comprising a processor and a computer-readable storage medium, wherein the processor is used to implement each instruction; and the computer-readable storage medium is used to store multiple instructions, characterized in that: The instructions are suitable for being loaded by a processor and executing the method as claimed in claim 1 .

Citation Information

Patent Citations

  • Deep hierarchical variational autoencoder

    CN113822437A

  • Optical module fault prediction method based on variational auto-encoder and long and short term memory network hybrid model

    CN115833937A