Power anomaly detection method based on federated learning and generative adversarial network

By adopting federated learning and generative adversarial network methods in power abnormal detection, the problems of low efficiency and poor accuracy of traditional detection methods are solved, and the effects of improving data timing, mitigation of data imbalance and user privacy protection are achieved.

CN119760595APending Publication Date: 2025-04-04NANJING UNIV OF SCI & TECH +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411796356.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

Traditional power abnormality detection methods are inefficient and have poor accuracy, making it difficult to effectively deal with the problems of sparseness, sample imbalance and complex timing characteristics of power data. Moreover, centralized data processing methods cannot meet the sensitivity and privacy requirements of power data.

Method used

Power anomaly detection methods based on federated learning and generative adversarial networks are adopted, and data preprocessing and model training are carried out locally by client, and more minority samples are generated using generative adversarial networks. Combined with the energy consumption prediction network supervision generator, we ensure that the generated data has accurate timing dynamic characteristics and protect user privacy through federated learning framework.

Benefits of technology

It effectively improves data timing, alleviates data imbalance problem, improves the accuracy and robustness of power abnormality detection, and protects user privacy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119760595A_ABST
    Figure CN119760595A_ABST
Patent Text Reader

Abstract

The invention discloses a federated learning and generative adversarial network-based power anomaly detection method, which belongs to the field of power systems, and comprises the following steps: S1, data collection and preprocessing, and local model initialization; s2, supervising training of a network auxiliary generator; s3, carrying out cooperative training on the generator and the classifier; s4, federal learning and model aggregation; and S5, carrying out model convergence and monitoring. According to the electric power anomaly detection method based on federated learning and generative adversarial network, the data time sequence is effectively improved, the problem of data imbalance is relieved, the detection precision and robustness are improved, and the user privacy is protected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of power systems, and in particular relates to a power anomaly detection method based on federated learning and generative adversarial networks. Background Art

[0002] With the rapid development of modern smart grids, the deployment of a large number of distributed sensors and data acquisition equipment has provided rich data support for power consumption and load analysis. However, the phenomenon of non-technical loss (NTL), especially in high-power consumption areas, is still one of the main problems affecting the safety and economic benefits of the power system. Traditional power anomaly detection methods rely on manual review and simple rule judgment, resulting in low detection efficiency and poor accuracy. In recent years, machine learning methods have been widely used in power anomaly detection, identifying abnormal power consumption patterns by analyzing the historical power consumption behavior of power users. However, power anomaly data usually has the characteristics of sparsity, sample imbalance, and complex time series characteristics, which brings many challenges to traditional detection methods.

[0003] Generative adversarial networks (GANs) are used in data augmentation and data imbalance because of their ability to generate realistic data samples, improving the performance of minority class samples. However, standard generative adversarial networks have limitations in dealing with high temporal correlation and data diversity, making it difficult to effectively capture the temporal characteristics of power data. In addition, the sensitivity and privacy of power data require strict protection during data use, so centralized data processing methods are not suitable for power anomaly detection scenarios. Existing federated learning methods have not fully combined the advantages of generative adversarial networks in data generation and imbalance processing, so a new technical solution is urgently needed. Summary of the invention

[0004] The purpose of the present invention is to provide a method for power anomaly detection based on federated learning and generative adversarial networks, which effectively improves data timing, alleviates the problem of data imbalance, improves detection accuracy and robustness, and protects user privacy.

[0005] To achieve the above object, the present invention provides a method for detecting power anomalies based on federated learning and generative adversarial networks, comprising the following steps:

[0006] S1. The client performs data preprocessing on the local data to obtain local training data. Data preprocessing includes data cleaning, missing value filling and data normalization. The client uses the local training data to initialize the local model. The local model includes a supervised network, a generative adversarial network and a classifier.

[0007] S2. Generative adversarial networks include generators and discriminators. The generator uses random noise to generate pseudo data samples and uses a supervised network to assist in generator training. The discriminator is used to distinguish between real data samples and pseudo data samples in data samples, and the classifier is used to distinguish between normal samples and abnormal samples in data samples.

[0008] S3, the client adopts the generation and classification synchronization mechanism to jointly train the generator and classifier;

[0009] S4. The client uploads the local model parameters to the server. The server aggregates the model parameters using the federated average algorithm to obtain the global model. The server sends the global model to the client and replaces the local model parameters with the global model parameters.

[0010] S5. Repeat S2 to S4 until the local model converges, and use the classifier to detect power anomalies.

[0011] Preferably, in S2, supervised network assisted generator training means that the supervised network guides the generator to generate pseudo data samples that conform to the temporal dynamic characteristics of real data samples, and the supervised network is an energy consumption prediction network pre-trained using real data samples, and the energy consumption prediction network is constructed using a long short-term memory network.

[0012] Preferably, the supervised network is trained using the following loss function:

[0013]

[0014] in, represents the pseudo data sample generated by the generator at time step t, represents the predicted value of the supervised network for the pseudo data sample generated by the generator at time step t, Represents the expected value of the pseudo data sample generated by the generator at time step t, that is, under a given distribution p, for x 1:T expectations.

[0015] Preferably, in S2, the step of the generator generating a pseudo data sample comprises:

[0016] S201, the generator generates pseudo data samples at time step t

[0017] S202, use the supervised network to simulate the pseudo data samples Make predictions and get predicted values

[0018] S203, according to the predicted value For fake data samples Make adjustments.

[0019] Preferably, the classifier is constructed using a convolutional neural network, and the classifier feeds the classification loss back to the generator.

[0020] Preferably, the loss function of the classifier is:

[0021]

[0022] in, Represents the classification loss of real data samples, represents the classification loss of pseudo data samples, x represents real data samples, θ c represents the parameters of the classifier, λ o and λ g Represents the weighting coefficient of control loss.

[0023] Preferably, in S3, the generation and classification synchronization mechanism means that during the model training process, the generator not only receives feedback from the discriminator, but also combines feedback from the classifier, and the feature extraction module weights of the classifier and the discriminator are shared.

[0024] Preferably, the generator is trained using the following loss function:

[0025]

[0026] in, Denotes the noise distribution p z The random variable z sampled in (z) takes the expectation, L S represents the loss of the supervision network, represents the classification loss of the classifier for pseudo data samples, and α and β represent weight coefficients.

[0027] Preferably, the discriminator is trained using the following loss function:

[0028]

[0029] in, represents the expectation of the generated data G(z), represents the expectation of the real data sample x, Represents the classification loss of the classifier for real data samples, and γ represents the weight coefficient.

[0030] Preferably, the aggregation formula of the federated average algorithm is:

[0031]

[0032] in, represents the model parameters of client j in the i-th round of training, J represents the total number of clients, Represents the model parameters after aggregation.

[0033] Therefore, the present invention adopts the above-mentioned power anomaly detection method based on federated learning and generative adversarial network. Compared with the prior art, the present invention has the following significant beneficial effects:

[0034] (1) The present invention adopts a federated learning framework, and each client only processes and trains data locally, avoiding the sharing of sensitive data and effectively protecting user privacy;

[0035] (2) The present invention introduces an energy consumption prediction network (supervision network) to supervise the generator, ensuring that the generated data has accurate time series dynamic characteristics and is more in line with the actual change law of power data;

[0036] (3) The present invention generates more minority class samples by generating adversarial networks, effectively alleviating the data imbalance problem existing in power abnormal data;

[0037] (4) The present invention adopts a collaborative training mechanism of the generator and the classifier, thereby ensuring the quality of the generated data and improving the classification accuracy and robustness of the power anomaly detection system.

[0038] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 This is an architecture diagram of an embodiment of a method for detecting power anomalies based on federated learning and generative adversarial networks according to the present invention;

[0040] Figure 2 This is a time series prediction supervision module architecture diagram of a power anomaly detection method based on federated learning and generative adversarial networks in the present invention;

[0041] Figure 3 This is a data generation effect diagram of a timing prediction supervision module control generator of an electric power anomaly detection method based on federated learning and generative adversarial networks in the present invention, wherein A-1 and B-1 represent distribution diagrams of two groups of data randomly selected from real data samples, A-2 and B-2 represent data distribution diagrams generated without using a supervision network, and A-3 and B-3 represent data distribution diagrams generated using a supervision network. DETAILED DESCRIPTION

[0042] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0043] Unless otherwise defined, technical or scientific terms used in the present invention shall have the common meanings understood by one having ordinary skills in the field to which the present invention belongs.

[0044] Embodiment 1

[0045] like Figure 1 As shown, a method for detecting power anomalies based on federated learning and generative adversarial networks of the present invention comprises the following steps:

[0046] S1. Data collection, preprocessing and model initialization:

[0047] Since the power data collected by each client has data imbalance and time series characteristics, each client needs to preprocess the local data. Data preprocessing includes data cleaning, missing value filling, data normalization and other operations to eliminate data noise and unify data scale to ensure effective training of the generative adversarial network. After data preprocessing, local training data is obtained;

[0048] Each client initializes the model based on the preprocessed data, including the generator (G), discriminator (D), supervision network (S), and classifier (C). Each client initializes the local model, prepares for local training, and lays the foundation for subsequent local generative adversarial network training;

[0049] S2. Supervised network assisted generator training:

[0050] Each client uses its own local training data to independently train the generator (G). The loss function of the generator (G) is expressed as:

[0051]

[0052] in, Denotes the noise distribution p z The random variable z sampled in (z) takes the expectation, L S represents the supervision network loss, represents the classification loss of generated data of the classifier, α and β are weight coefficients, indicating the relative importance of controlling the loss of each part.

[0053] The generator (G) generates pseudo power data samples similar to the real power data distribution by inputting random noise (z). Let the pseudo data sample be X G , expressed as:

[0054] X G =G(X,z);

[0055] Where X represents the real data sample and z represents the random noise sampled from the standard normal distribution N(0,1). The fake data samples are used to expand the imbalanced dataset.

[0056] The energy consumption prediction network is constructed using a long short-term memory network (LSTM). The energy consumption prediction network trained with real data samples is used as a supervisory network (S) to provide temporal supervision for pseudo data samples. The optimization goal of the supervisory network (S) is to minimize the difference between the generated data and the predicted data, and its loss function is:

[0057]

[0058] in, represents the pseudo data sample generated by the generator at time step t, represents the predicted value of the supervised network (S) for the pseudo data sample generated by the generator at time step t, Represents the expected value of the pseudo data sample generated by the generator at time step t, that is, under a given distribution p, for x 1:T expectations. S represents the loss function of the supervisory network (S), which is used to measure the difference between the generated data and the predicted data.

[0059] When generating data, the generator (G) relies on the time series prediction information of the supervisory network (S) to continuously optimize the generated samples to make them more consistent with the classification criteria. The supervisory network (S) provides feedback by predicting time by time. The generator (G) gradually corrects the generation process based on whether the generated data at each moment meets the predicted actual value to ensure that the generated data meets the time series requirements at each time step. The prediction of the supervisory network (S) for the pseudo data sample is expressed as:

[0060]

[0061] Among them, X t-1 Represents the input data at the previous moment, Represents the predicted energy consumption data for the next moment. The generator (G) adjusts the data generation process according to the feedback from the supervisory network (S) to ensure that the pseudo data samples at each moment conform to the time series pattern.

[0062] The steps for the generator to generate fake data samples include:

[0063] S201, the generator generates pseudo data samples at time step t

[0064] S202, supervised network (S) for pseudo data samples Make predictions and get predicted values

[0065] S203, according to the predicted value For fake data samples Make adjustments.

[0066] The role of the supervisory network (S) is to predict the energy consumption at the next moment based on the data at the historical moment, and guide the generator (G) to adjust the pseudo data samples so that the pseudo data samples conform to the timing pattern of the actual power system.

[0067] S3. Generator and classifier collaborative training:

[0068] The client uses a generation and classification synchronization mechanism to jointly train the generator (G) and the classifier (C). The classifier (C) can distinguish between normal samples and abnormal samples in the data samples.

[0069] When the generator (G) generates pseudo data samples, the classifier (C) determines the validity of the pseudo data samples through real-time classification training and feeds back the classification loss to the generator (G). The generator (G) can make timely adjustments in the process of generating data through classification loss feedback to ensure that the pseudo data samples not only have high temporal sequence but also have high accuracy in the classification task. The loss function of the classifier (C) is:

[0070]

[0071] in, Represents the classification loss of real data samples, represents the classification loss of generated data, x represents the real data sample, θ c represents the parameters of the classifier, λ o and λ g represents the weighting coefficient of the control loss to ensure a balanced classification of generated data and real data samples.

[0072] The feature extraction module weights of the discriminator (D) and the classifier (C) are shared. Therefore, the classifier (C) can use the ability of the discriminator (D) to distinguish between real data samples and fake data samples to improve its own classification ability. The loss function for training the discriminator (D) is:

[0073]

[0074] in, represents the expectation of the generated data G(z), represents the expectation of the real data sample x, Represents the classification loss of the classifier for real data samples, and γ represents the weight coefficient.

[0075] Under the dual feedback guidance of the discriminator (D) and the classifier (C), the generator (G) gradually improves the temporal characteristics of the generated data and its classification adaptability by generating data and optimizing the quality of the data.

[0076] S4. Federated Learning and Model Aggregation:

[0077] After each client completes the training of the generator (G), discriminator (D), supervision network (S) and classifier (C) locally, it uploads these model parameters to the server. During the whole process, each client only uploads the model parameters and does not share local training data, which effectively protects user privacy.

[0078] The server uses the Federated Averaging algorithm to perform weighted averaging on the model parameters uploaded by each client to obtain the global model parameters, including the global generator, global discriminator, and global classifier. The specific aggregation formula is:

[0079]

[0080] in, is the model parameter of client j in the i-th round of training, J is the total number of clients, is the model parameter after global aggregation.

[0081] After the model aggregation is completed, the server sends the global model parameters to each client and uses the global model parameters to replace the local model parameters, completing a training cycle and starting the next round of federated learning training.

[0082] S5. Model convergence and power anomaly detection:

[0083] After multiple rounds of federated learning training, the generator (G) and classifier (C) of each client are gradually optimized and converged. The generator (G) can generate pseudo data samples with high temporal and data balance characteristics, and the classifier (C) can accurately distinguish normal power consumption data from abnormal data.

[0084] After the model converges, the classifier (C) performs power anomaly detection on the real power data on the client. The classifier (C) distinguishes the input power data, accurately identifies power abnormal behavior, and improves the intelligent detection capability of the power system.

[0085] like Figure 2-Figure 3 As shown, in this embodiment, actual power usage data from the State Grid Corporation of China (SGCC) is used for the experiment. The data set contains daily power usage data of 42,372 users, spanning from January 2014 to October 2016. 8.55% of the users in the data set were confirmed to have participated in power theft and were marked as abnormal. The specific steps and implementation methods of the experiment are described in detail below.

[0086] In order to ensure the quality of experimental data, the SGCC dataset was first preprocessed. The preprocessing process includes data cleaning, missing value filling and standardization. The specific steps are as follows:

[0087] 1. Data cleaning: Delete the user data with more than half of missing data, retain the users with at least 517 days of valid data, and remove potential noise data to avoid affecting the model training effect.

[0088] 2. Missing value filling: For users with a large number of missing values, we use data interpolation methods to fill them in to ensure the integrity of the training data.

[0089] 3. Data standardization: Standardizing the power data of all users to ensure that the power data of different users have the same scale will help speed up the training process and improve the model convergence speed.

[0090] After data preprocessing is completed, the generative adversarial network is used for data enhancement to solve the problem of data imbalance. The specific process is as follows:

[0091] 1. Training the generator: The generator (G) generates pseudo data samples using random noise (z) to simulate the electricity data of electricity theft users. The pseudo data samples are designed to enhance the abnormal category samples in the original dataset.

[0092] 2. Discriminator training: The task of the discriminator (D) is to distinguish between real data samples and fake data samples. During the training process, the generator (G) and the discriminator (D) compete with each other through the adversarial process. The generator (G) is constantly improved, and the discriminator (D) continuously improves its recognition accuracy. The loss function of the discriminator (D) is expressed as:

[0093]

[0094] in, represents the expectation of the generated data G(z), represents the expectation of the real data sample x, Represents the classification loss of the classifier for real data samples, and γ represents the weight coefficient.

[0095] 3. The loss function of the generator (G) is expressed as:

[0096]

[0097] in, Denotes the noise distribution p z The random variable z sampled in (z) takes the expectation, L S represents the supervision network loss, Represents the classification loss of the generated data of the classifier. This part of the loss is used to ensure that the data generated by the generator has the correct label distribution in the classification task. α and β are weighting coefficients that control the contribution of each loss in training.

[0098] Federated learning and model aggregation, the specific process is as follows:

[0099] 1. Client data distribution: Three clients are set up, and the data of each client comes from different user groups in the SGCC dataset. Because each client can only access local data, data leakage is avoided.

[0100] 2. Model training and uploading: After each client completes the training of the generator (G), discriminator (D) and classifier (C) locally, it uploads the local model parameters to the server for aggregation. F1 represents the output of the original outlier detection network, which is responsible for preliminary analysis and processing of the input one-dimensional data to discover potential abnormal patterns or behaviors. F2 represents the output of the LSTM model. LSTM is used to process two-dimensional data input (input by week) to extract more complex time patterns and features.

[0101] 3. Global model aggregation: Use the federated learning algorithm to perform weighted averaging on the model parameters uploaded by the client to obtain the global model. The specific aggregation formula is:

[0102]

[0103] in, is the model parameter of client j in the i-th round of training, J is the total number of clients, is the model parameter after global aggregation.

[0104] Power theft detection and performance evaluation, the specific process is as follows:

[0105] 1. Detecting power theft: Use the trained classifier to detect power theft on power data. The classifier identifies potential power theft users by determining whether the user's power consumption pattern conforms to normal power consumption behavior.

[0106] 2. Performance evaluation: Use F1-score to evaluate the comprehensive performance of the model's precision and recall, which is particularly important in unbalanced data sets. Compared with existing methods, the detection accuracy of the method provided by the present invention on unbalanced data sets (imbalance ratio of 10:1) is improved by 11.41%, so this method is effective for the problem of power theft detection.

[0107] It is worth noting that the contents not elaborated in detail in the present invention are all prior art and are well known to those skilled in the art.

[0108] Therefore, the present invention adopts the above-mentioned power anomaly detection method based on federated learning and generative adversarial network, which effectively improves data timing, alleviates the problem of data imbalance, improves detection accuracy and robustness, and protects user privacy.

[0109] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that they can still modify or replace the technical solution of the present invention with equivalents, and these modifications or equivalent replacements cannot cause the modified technical solution to deviate from the spirit and scope of the technical solution of the present invention.

Claims

1. A method for power anomaly detection based on federated learning and generative adversarial network, characterized in that: The following steps are involved: S1. The client performs data preprocessing on the local data to obtain local training data. The data preprocessing includes data cleaning, missing value filling and data normalization. The client uses the local training data to initialize the local model. The local model includes a supervised network, a generative adversarial network and a classifier. S2. Generative adversarial networks include generators and discriminators. The generator uses random noise to generate pseudo data samples and uses a supervised network to assist in generator training. The discriminator is used to distinguish between real data samples and pseudo data samples in data samples, and the classifier is used to distinguish between normal samples and abnormal samples in data samples. S3, the client adopts the generation and classification synchronization mechanism to jointly train the generator and classifier; S4. The client uploads the local model parameters to the server. The server aggregates the model parameters using the federated average algorithm to obtain the global model. The server sends the global model to the client and replaces the local model parameters with the global model parameters. S5. Repeat S2 to S4 until the local model converges, and use the classifier to detect power anomalies.

2. According to claim 1, a method for detecting power anomalies based on federated learning and generative adversarial networks is characterized in that: In S2, supervised network assisted generator training means that the supervised network guides the generator to generate pseudo data samples that conform to the temporal dynamic characteristics of real data samples. The supervised network is an energy consumption prediction network pre-trained using real data samples, and the energy consumption prediction network is constructed using a long short-term memory network.

3. The power anomaly detection method based on federated learning and generative adversarial network according to claim 1 is characterized in that: The supervised network is trained using the following loss function: in, represents the pseudo data sample generated by the generator at time step t, represents the predicted value of the supervised network for the pseudo data sample generated by the generator at time step t, Represents the expected value of the pseudo data sample generated by the generator at time step t, that is, under a given distribution p, for x 1:T expectations.

4. The power anomaly detection method based on federated learning and generative adversarial network according to claim 1 is characterized in that: In S2, the steps of generating pseudo data samples by the generator include: S201, the generator generates pseudo data samples at time step t S202, use the supervised network to simulate the pseudo data samples Make predictions and get predicted values S203, according to the predicted value For fake data samples Make adjustments.

5. The method for detecting power anomalies based on federated learning and generative adversarial networks according to claim 1, characterized in that: The classifier is built using a convolutional neural network, and the classifier feeds the classification loss back to the generator.

6. The method for detecting power anomalies based on federated learning and generative adversarial networks according to claim 1, characterized in that: The loss function of the classifier is: in, represents the classification loss of real data samples, represents the classification loss of pseudo data samples, x represents real data samples, θ c represents the parameters of the classifier, λ o and λ g Represents the weighting coefficient of control loss.

7. The method for detecting power anomalies based on federated learning and generative adversarial networks according to claim 1, characterized in that: In S3, the generation and classification synchronization mechanism means that during the model training process, the generator not only receives feedback from the discriminator, but also combines the feedback from the classifier, and the feature extraction module weights of the classifier and the discriminator are shared.

8. The method for detecting power anomalies based on federated learning and generative adversarial networks according to claim 1, characterized in that: The generator is trained using the following loss function: in, Denotes the noise distribution p z The random variable z sampled in (z) takes the expectation, L S represents the loss of the supervision network, represents the classification loss of the classifier for pseudo data samples, and α and β represent weight coefficients.

9. The method for detecting power anomalies based on federated learning and generative adversarial networks according to claim 1, characterized in that: The discriminator is trained using the following loss function: in, represents the expectation of the generated data G(z), represents the expectation of the real data sample x, Represents the classification loss of the classifier for real data samples, and γ represents the weight coefficient.

10. The method for power anomaly detection based on federated learning and generative adversarial network according to claim 1, characterized in that: The aggregation formula of the federated average algorithm is: in, represents the model parameters of client j in the i-th round of training, J represents the total number of clients, Represents the model parameters after aggregation.

Citation Information

Cited By

  • Informationized examination room intelligent supervision method and system based on Internet of Things

    CN122367688A