A Federated Learning Method for Smart Grid Data Protection
By generating a data sample with a distance of less than the threshold from the local electricity consumption data for local training, and using the aggregation model to detect abnormal smart meters, the problems of privacy leakage and low learning efficiency in smart grid data protection are solved, and more efficient privacy protection and learning efficiency are achieved.
Patent Information
- Application Number
- CN202510349287.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2045-03-24
AI Technical Summary
In the existing smart grid data protection, the traditional federated learning framework has problems such as user privacy leakage risks, reduced model accuracy and malicious smart meter attacks, resulting in insufficient privacy protection capabilities and low learning efficiency.
Generative models are used to generate data samples whose distance from local electricity consumption data is less than the threshold for local training, and abnormal smart meters are detected through the aggregation model, and global models are generated using attention dynamic aggregation technology to improve privacy protection capabilities and learning efficiency.
Effectively prevent malicious smart meter attacks, improve the privacy protection capability of smart grid data, and accelerate the convergence speed of global models through attention dynamic aggregation, improving the efficiency of federated learning.
Smart Images

Figure CN119862942B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power grid data protection, and particularly to a federated learning method for smart grid data protection. Background Art
[0002] A smart grid is based on the physical power grid of various power generation devices, power transmission and distribution networks, power consumption devices, and energy storage devices, and is a new type of power grid that highly integrates advanced sensing and measurement technologies, network technologies, communication technologies, computing technologies, automation, and intelligent control technologies. The precise control of power resources is mainly based on training models with the collected power data to effectively predict power consumption and energy consumption, so as to control the power generation strategy at the power generation end to achieve the supply balance of the power system.
[0003] Existing smart grid data is protected by using a traditional federated learning framework, but the traditional federated learning framework still has the following limitations under the joint learning of all parties:
[0004] (1) A large amount of user power consumption data will be collected and processed during operation. These data involve personal privacy such as users' power consumption habits and living patterns. An attacker can bypass the traditional privacy protection mechanism through a model inversion attack or infer some information of the original data by analyzing the model refinement results. If these data are leaked or misused, it will cause serious infringement of users' privacy rights;
[0005] (2) If too many privacy protection mechanisms are added, such as differential privacy or homomorphic encryption, etc., it will lead to problems such as a decrease in the accuracy of the model, a reduction in communication efficiency, and an increase in computational complexity;
[0006] (3) Malicious smart meters do not comply with the protocol for poisoning attacks, greatly reducing the efficiency of the global model. If the accuracy of the detection system is not high, it may lead to false alarms and missed alarms. Summary of the Invention
[0007] The present invention provides a federated learning method for smart grid data protection, and its purpose is to improve the efficiency of federated learning while enhancing the privacy protection ability of smart grid data.
[0008] To achieve the above purpose, the present invention provides a federated learning method for smart grid data protection, including:
[0009] Step 1, the central server distributes the initialized neural network model to multiple smart meters;
[0010] Step 2, each smart meter uses the generative model to generate data samples, and trains the initialized neural network model with the data samples or local power consumption data, and uploads the trained model parameters and scoring metrics to the central server;
[0011] Step 3: The central server performs aggregation detection on the trained model parameters and scoring metrics through an aggregation model to identify abnormal smart meters.
[0012] Step 4: The central server performs attention dynamic aggregation on all model parameters except those uploaded by the abnormal smart meters to obtain a global model, and determines whether the global model meets the preset training termination condition. If so, the training ends, and the global model is used to predict the electricity consumption. Otherwise, the global model is sent as an initialized neural network model to multiple smart meters, and Step 2 is executed again.
[0013] Furthermore, the generative model includes a generator and a discriminator.
[0014] The generator transforms noise and class labels to synthesize data samples.
[0015] The discriminator discriminates the distance between the data samples and the local electricity consumption data. If the distance is greater than the preset threshold, the generator is used to synthesize data samples again until the distance is less than the preset threshold, and the data samples are regarded as data samples.
[0016] Furthermore, the calculation expression for the distance between the data samples and the local electricity consumption data is:
[0017]
[0018] where represents the distribution of the data samples and the distribution of the local electricity consumption data the distance between them, represents the infimum, that is, the smallest upper bound, represents the distribution of the data samples and the distribution of the local electricity consumption data all possible joint distributions, represents the joint distribution of, represents that under the joint distribution randomly select a pair of samples the expected value of the distance, represents the local electricity consumption data, represents the data samples.
[0019] Furthermore, Step 3 includes:
[0020] The central server regards all the model parameters uploaded in each round as a point through the trimmed DBScan model and sets the clustering radius.
[0021] Determine whether the distance between every two adjacent points is less than the clustering radius. When all distances are less than the clustering radius, it is determined that there are no abnormal smart meters in this training. When the distance is greater than the clustering radius, the smart meter corresponding to the point with a distance greater than the clustering radius is regarded as an abnormal smart meter.
[0022] Furthermore, the calculation expression for the clustering radius is:
[0023]
[0024] Among them, represents the clustering radius, represents the number of smart meters, represents the th model parameter trained by the th smart meter and the model parameter trained by the th smart meter
[0025] Furthermore, the central server performs attention dynamic aggregation on all model parameters except those uploaded by abnormal smart meters to obtain a global model, including:
[0026] When performing attention dynamic aggregation on model parameters except those uploaded by abnormal smart meters for the first time, average all model parameters except those uploaded by abnormal smart meters to generate a global model;
[0027] When performing attention dynamic aggregation on all model parameters except those uploaded by abnormal smart meters for non - first time, weighted aggregation is performed on all model parameters except those uploaded by abnormal smart meters by calculating the improvement ratio percentage and reciprocal weight of each smart meter to obtain a global model.
[0028] Furthermore, the calculation expression for the improvement ratio percentage of each smart meter is:
[0029]
[0030] Among them, represents the improvement ratio percentage of the th smart meter in the th round, represents the model improvement of the th smart meter in the th round.
[0031] Furthermore, the calculation expression for the reciprocal weight of each smart meter is:
[0032]
[0033] Among them, Represents the reciprocal weight of the th smart meter, Represents the average distance between the model parameters uploaded by the th smart meter and all model parameters in the previous round.
[0034] Furthermore, the calculation expression for weighted aggregation of all model parameters except those uploaded by abnormal smart meters is:
[0035]
[0036] Among them, Represents the model parameters of the global model obtained in the th round, Represents the attention weight, Represents the number of abnormal smart meters, Represents the newly added smart meters, Represents the th smart meter's model parameters trained in the th round.
[0037] Furthermore, the preset training termination conditions include:
[0038] When the number of training rounds reaches the maximum number of rounds, stop training;
[0039] When the data samples are used in the th round of training, and the local electricity consumption data is used in the th round of training, and the evaluation index after the th round of training is greater than the evaluation index after the th round of training, stop training;
[0040] When the global model converges to the expected degree, stop training;
[0041] When the local electricity consumption data is used in several consecutive rounds of training, stop training.
[0042] The above solution of the present invention has the following beneficial effects:
[0043] The present invention distributes an initialized neural network model to multiple smart meters through a central server; each smart meter uses a generation model to generate data samples, and trains the initialized neural network model with the data samples or local electricity consumption data, and uploads the trained model parameters and scoring metrics to the central server; the central server performs aggregation detection on the trained model parameters and scoring metrics through an aggregation model to determine abnormal smart meters; the central server performs attention dynamic aggregation on all model parameters except those uploaded by the abnormal smart meters to obtain a global model, and determines whether the global model meets a preset training termination condition; if so, the training ends, and the global model is used to predict electricity consumption; otherwise, the global model is used as the initialized neural network model and distributed to multiple smart meters, and step 2 is returned for execution; compared with the prior art, the present invention generates data samples with a distance from the local electricity consumption data less than a threshold through a generation model for local training, and determines abnormal smart meters through aggregation detection of the trained model parameters and scoring metrics, preventing malicious smart meters from attacking local electricity consumption data, effectively improving the privacy protection ability of smart grid data; at the same time, it also improves the convergence speed of the global model through attention dynamic aggregation of all model parameters, thereby improving the efficiency of federated learning.
[0044] Other beneficial effects of the present invention will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 is a schematic flowchart of an embodiment of the present invention;
[0046] Figure 2 is a schematic structural diagram of a federated learning framework in an embodiment of the present invention;
[0047] Figure 3 is a schematic structural diagram of a generation model in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0048] To make the technical problems, technical solutions and advantages to be solved by the present invention clearer, the following will be described in detail with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of them. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0049] In the description of the present invention, it should be noted that the orientation or positional relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings. It is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be construed as a limitation to the present invention. In addition, the terms "first", "second", "third" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance.
[0050] In the description of the present invention, it should be noted that unless otherwise clearly specified and limited, the terms "installed", "connected", "connected" should be understood in a broad sense. For example, it can be a locking connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium, and it can be the communication inside two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific situations.
[0051] In addition, the technical features involved in different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0052] The present invention provides a federated learning method for smart grid data protection in view of existing problems.
[0053] In an embodiment of the present invention, the framework of federated learning includes: a central server and multiple local clients;
[0054] The federated learning process is as follows: taking the local smart meter as the local client in the federated learning. In the embodiment of the present invention, the smart meter is used to collect local electricity consumption data or generate data samples using a generative model, training the initialized neural network model sent by the central server using the local electricity consumption data or data samples to obtain a local model, and uploading the model parameters of the local model to the central server;
[0055] In the embodiment of the present invention, the central server in the federated learning can be a computing device such as a desktop computer, a notebook, a palm computer, a server, a server cluster, and a cloud server, etc., which is used to construct an initialized neural network model, perform aggregation detection on the trained model parameters and scoring metrics, and perform attention dynamic aggregation on all model parameters except those uploaded by abnormal smart meters to obtain a global model;
[0056] Finally, the global model is used to predict the electricity consumption of the user, and the prediction result can be the electricity consumption of the user in a future period of time, or the electricity consumption of the user during peak or off-peak electricity consumption.
[0057] As Figure 1 and Figure 2 shown, an embodiment of the present invention provides a federated learning method for smart grid data protection, including:
[0058] Step 1, the central server distributes the initialized neural network model to multiple smart meters;
[0059] Step 2, each smart meter uses the generation model to generate data samples, and trains the initialized neural network model with the data samples or local electricity consumption data, and uploads the trained model parameters and scoring metrics to the central server;
[0060] Step 3, the central server performs aggregation detection on the trained model parameters and scoring metrics through the aggregation model to determine abnormal smart meters;
[0061] Step 4, the central server performs attention dynamic aggregation on all model parameters except the model parameters uploaded by the abnormal smart meters to obtain a global model, and determines whether the global model meets the preset training termination condition; if so, the training ends, and the global model is used to predict the electricity consumption; otherwise, the global model is used as the initialized neural network model and distributed to multiple smart meters, and returns to execute Step 2.
[0062] Most preferably, as Figure 3 shown, the generation model includes a generator and a discriminator;
[0063] The generator transforms noise and class labels to synthesize data samples;
[0064] The discriminator discriminates the distance between the data sample and the local electricity consumption data. If the distance is greater than the preset threshold, the generator is used to synthesize the data sample again until the distance is less than the preset threshold, and the data sample is used as the data sample.
[0065] In the embodiment of the present invention, during the process of the generation model generating data samples, there are the following constraint limitations:
[0066] Data generation efficiency limitation: Although there will be hardware heterogeneity among smart meters, the data generation efficiency cannot be too low to affect the model training and the aggregation efficiency of the central server;
[0067] Data generation quantity limitation: In traditional federated learning, the data volumes owned by different clients are very different. At this time, different weights need to be assigned according to the different data volumes owned by each client, which increases the calculation amount. Therefore, it is necessary to limit the data volumes generated by each smart meter to be the same, so that the weight allocation problem caused by different data volumes can be considered differently, and the calculation pressure on the central server can be reduced;
[0068] Local electricity consumption data usage quantity limit: Limit the usage quantity of local electricity consumption data of each smart meter to not be too low, so that the information contained in the data sample is insufficient.
[0069] In the embodiment of the present invention, the distance between the data sample and the local electricity consumption data is discriminated according to the objective function, and the expression of the objective function is:
[0070]
[0071] Among them, represents the discriminator, represents the generator, represents the expected value under the true data distribution below, represents the discriminator under the parameter for the discrimination of the authenticity of the input data below, represents the expected value under the noise distribution below, represents the discriminator under the parameter for the functional form below, represents the data sample, represents the generator under the parameter for the functional form below.
[0072] Specifically, the embodiment of the present invention uses the Earth-Mover distance to measure the distance between the local electricity consumption data and the data sample. Even if the distributions of the two types of data do not overlap or the overlapping part is very small, it can still reflect the distance between the two data distributions. The calculation expression for the distance between the data sample and the local electricity consumption data is:
[0073]
[0074] Among them, represents the distance between the distribution of the data sample and the distribution of the local electricity consumption data, represents the infimum, that is, the smallest upper bound, represents the distribution of the data sample and the distribution of all possible joint distributions of the local electricity consumption data, represents of the joint distribution, represents, under the joint distribution below, the expected value of the distance of a randomly selected pair of samples below, represents the local electricity consumption data, Represents data samples.
[0075] In an embodiment of the present invention, the model parameters received by the central server are denoted as , and the scoring metric is denoted as . Both the model parameters and the scoring metric received by the central server are saved in the parameter space of the central server.
[0076] In order to make the global model more accurate and prevent model attacks from malicious clients, after receiving the model parameters, the central server in the embodiment of the present invention uses the trimmed DBScan model to detect whether there are abnormal model parameters uploaded by smart meters. The specific process includes:
[0077] The central server regards all the model parameters uploaded in each round as a point through the trimmed DBScan model and sets the clustering radius;
[0078] Judge whether the distance between every two adjacent points is less than the clustering radius. When the distances are all less than the clustering radius, it is determined that there is no abnormal smart meter in this training. When the distance is greater than the clustering radius, the smart meter corresponding to the point with a distance greater than the clustering radius is regarded as an abnormal smart meter.
[0079] It should be noted that the DBScan algorithm is a density-based clustering algorithm, and the trimmed DBScan model eliminates the initialization of the minimum number of points required to form a cluster and only considers whether the newly uploaded parameters can be within the clustering radius of other parameters.
[0080] Specifically, the calculation expression of the clustering radius is:
[0081]
[0082] Where represents the clustering radius, represents the number of smart meters, represents the th model parameter trained by the th smart meter and the th model parameter trained by the
[0083] In an embodiment of the present invention, when multiple smart meters first upload model parameters to the central server, the clustering radius is equal to the average value of the distances between any two model parameters in the parameter space. After that, the clustering radius remains unchanged all the time, which can reduce the computational amount of the central server. Secondly, each time a new model parameter is added to the parameter space, the range of the parameter space will become larger and larger, so there is no need to change the value of the clustering radius.
[0084] Specifically, the central server performs attention dynamic aggregation on all model parameters except those uploaded by abnormal smart meters to obtain a global model, including:
[0085] When performing attention dynamic aggregation on model parameters except those uploaded by abnormal smart meters for the first time, average all model parameters except those uploaded by abnormal smart meters to generate a global model;
[0086] When performing attention dynamic aggregation on all model parameters except those uploaded by abnormal smart meters non-first time, perform weighted aggregation on all model parameters except those uploaded by abnormal smart meters by calculating the proportion of improvement degree and reciprocal weight of each smart meter to obtain a global model.
[0087] In the embodiment of the present invention, when the central server performs attention dynamic aggregation on all model parameters except those uploaded by abnormal smart meters for the first time, simply average the model parameters from each smart meter to generate new model parameters, and use these model parameters as the model parameters of the global model to obtain the global model;
[0088] When the central server performs attention dynamic aggregation on all model parameters except those uploaded by abnormal smart meters non-first time, use the attention mechanism to aggregate the model parameters. The specific process is as follows:
[0089] Assume that there are currently k smart meters performing the t-th round of aggregation;
[0090] For the model parameters and scoring metrics uploaded in the previous run, they are respectively denoted as and , and the model parameters and scoring metrics uploaded by the -th smart meter in the -th round are denoted as and
[0091] ; In the -th round, for the -th smart meter, the model parameters in the previous round are
[0092] , the scoring metric is , the model parameters in this round are , and the scoring metric is ;
[0093]
[0094] As can be seen from the above formula, for the th smart meter, if is greater than 1, it indicates that in this round of update, it is positive for the overall effect, otherwise it is negative; at the same time, in order to reflect the model improvement degree of this smart meter and the relationship with the model improvement degrees of other smart meters, the concept of improvement degree ratio is defined. In the t-th round, the expression for calculating the improvement degree ratio of each smart meter is:
[0095]
[0096] where represents the improvement degree ratio of the th smart meter in the th round, represents the model improvement degree of the th smart meter in the th round;
[0097] The proportion of the total model improvement degree of all smart meters can be calculated through the above formula ;
[0098] Next, calculate the average distance between the parameters uploaded by the th smart meter and all model parameters in the parameter space of the previous rounds. Suppose rounds in total make there be parameters in the parameter space. The calculation method of the average distance is: For
[0099]
[0100] Calculate the average distance for smart meters simultaneously to obtain , and then calculate the weight of each smart meter based on all average distances.
[0101] Different from the normal weight calculation method, the smaller the average distance, the smaller the gap between the uploaded parameters and the aggregated model parameters, that is, more weights should be allocated. Therefore, the reciprocal weight is adopted. Based on , obtain the reciprocal of the average distance calculated for
[0102]
[0103] Among them, represents the reciprocal weight of the th smart meter, represents the average distance between the model parameters uploaded by the th smart meter and all the model parameters in the previous round.
[0104] After calculating the improvement ratio and reciprocal weight of k smart meters in the t-th round and reciprocal weight , weighted aggregation starts. The calculation expression for the aggregation method in the t-th round is:
[0105]
[0106] In the above formula, the summation of is based on the aggregation of evaluation criteria, 's summation is the summation based on the average distance, where 's value represents the weights given by the two aggregation methods, takes values from 0 to 1. When , it means that the two aggregation methods have the same weight. In practical applications, if more emphasis is placed on the improvement of model efficiency, a larger value can be adopted; if more emphasis is placed on the convergence speed, a smaller value can be adopted.
[0107] After completing the aggregation, the number of parameters in the parameter space needs to be changed , because a total of normal model parameters are uploaded in this round, and all rounds .
[0108] The model parameters are aggregated by means of dynamic attention weighted aggregation. While not denying the role of any smart meter that transmits normal model parameters, it takes into account the exclusion of the influence of malicious smart meters, and also examines the accuracy rate of each smart meter and the average distance from the previous parameters, which is more flexible. It not only gives more weight to smart meters with good effects and less weight to smart meters with poor effects, but also allows for selection between model accuracy and convergence speed.
[0109] When uploading model parameters, there may be abnormal smart meters uploading model parameters and smart meters that did not participate in the previous round. At this time, the aggregation method will change. Suppose there are currently abnormal smart meters uploading model parameters, smart meters re-joining or joining the training for the first time. For An abnormal smart meter that has uploaded model parameters, set their Model Lift Degree (MLD) and average distance to 0, and calculate the proportion of the lift degree obtained and the weight to 0, so that it will not be considered in the calculation the role of the abnormal smart meter. For the smart meters that are re-added, in the calculation of the Model Lift Degree (MLD), replace it with the value in the previous round of participation, and the average distance and the weight will not change in the calculation method. Thus, the calculation expression for weighted aggregation of all model parameters except those uploaded by abnormal smart meters in the t-th round is:
[0110]
[0111] where, represents the model parameters of the global model obtained in the t-th round, represents the attention weight, represents the number of abnormal smart meters, represents the newly added smart meters, represents the i-th smart meter's model parameters in the t-th round of training.
[0112] In the embodiment of the present invention, after each aggregation, the central server will compare the current model with the previously saved optimal global model. If the performance of this model is better than the previously saved optimal global model, then use this model to replace the optimal global model and save the model parameters and model evaluation indicators.
[0113] After completing one round of learning, start the next round of learning. The following are the complete steps in one round of the federated learning system:
[0114] Each smart meter receives the global model sent by the central server;
[0115] Each smart meter uses data samples or local electricity consumption data to train the global model to obtain new model parameters and evaluation indicators;
[0116] The smart meters upload the model parameters and evaluation indicators to the parameter space, and the central server receives them;
[0117] The central server uses the trimmed DBScan model to detect whether there are outliers in the model parameters. If there are outliers, the role of this smart meter will not be considered during aggregation;
[0118] The central server calculates the model lift degree MLD of each smart meter in this round of training, and the proportion of the lift degree , average distance , weight ;
[0119] Perform attention dynamic aggregation according to the above formula to obtain the global model;
[0120] In the federated learning system, the above process will be repeated for multiple rounds of iteration until the global model reaches the predetermined training termination condition.
[0121] Specifically, the preset training termination conditions include:
[0122] The central server will send the data volume batch used in each round of training to each smart meter, and the smart meter will calculate the maximum number of rounds it can accept based on this data volume. Assume that the th smart meter has the number of local electricity consumption data as Max, then the maximum number of rounds it can accept is , the central server receives the maximum number of rounds of each smart meter and selects the final number of running rounds as , so when the training round reaches the maximum number of rounds, stop training;
[0123] Secondly, in order to save computing resources and prevent privacy leakage, when the following conditions are met, the model stops running in advance:
[0124] When the th round of training uses data samples, the th round of training uses local electricity consumption data, and the evaluation index after the th round of training is greater than the evaluation index after the th round of training, stop training. This result shows that the effect of using data samples is better than that of local electricity consumption data. In order to avoid privacy leakage caused by using local electricity consumption data in subsequent training, terminate the operation in advance;
[0125] When the global model converges to the expected degree, stop training, and the expected degree is jointly determined by all smart meters;
[0126] Introduce the concept of privacy budget Pr. When the local electricity consumption data is used in consecutive several rounds of training, stop training; assume Pr = 0.2, then when consecutive When all rounds of training use local electricity consumption data, the operation is stopped in advance. The advantage of this setting is that it can protect privacy as expected, avoid excessive use of local electricity consumption data, and prevent excessive leakage of user information. At the same time, the introduction of the privacy budget Pr can make federated learning more flexible. If higher accuracy is required, a larger Pr value can be set; if the accuracy is already relatively satisfied, a smaller Pr value can be set to reduce the degree of privacy leakage.
[0127] In the embodiment of the present invention, the smart meter determines whether to use local electricity consumption data for training according to the data transmitted back by the central server. The determination process is as follows:
[0128] In the first round of training, each smart meter is set to use a generative model and noise to generate data samples. In the second round of training, the generative model is still used to generate data samples. Different from the first round of training, the discriminator in the generative model at this time uses the optimal model learned in the federated learning system. The advantages of doing so are as follows:
[0129] 1. Improve the discrimination efficiency and accuracy: As a discriminator, the global model can make full use of the global knowledge in federated learning, learn and extract features from the data collected from multiple smart meters, and thus have stronger discrimination ability. Compared with the discriminator of a single smart meter, the global model can process more diverse data, improving the discrimination efficiency and accuracy;
[0130] 2. Optimize the training process: As a discriminator, the global model can interact and conduct adversarial training more efficiently with the generators of other smart meters;
[0131] 3. Improve the generalization ability of the model: The global model learns from the data of multiple smart meters, and the generated data is more diverse, has better adaptability in different scenarios, and has stronger generalization ability.
[0132] In addition, in order to further improve the effect of the generator, when deciding to use data samples in the follow-up, the discriminator in the generative model needs to be replaced with the optimal model in the federated learning system of the previous round.
[0133] Although the data samples contain a lot of content in the original data, there are more or less differences from the local electricity consumption data. Then, a mechanism is needed to determine when to use the local electricity consumption data and when to use the data samples.
[0134] To further combine federated learning and the generative model, the following mechanism is proposed:
[0135] In the federated learning of the first round of training, when obtaining the optimal global model, the central server can record the scoring metrics of the smart meters, denoted as Meanwhile, the scoring metric of the global model is set to , and since this is the first round of training, the here is just a simple average of .
[0136] In the second round of training, data samples are still used. At this time, the discriminator in the generative model is the global model. In the federated learning of the second round of training, the optimal global model is obtained. The central server can record the scoring metrics of the smart meters, denoted as . The scoring metric of the global model is set to .
[0137] The mechanism is set as follows:
[0138] It can be determined whether to use local electricity consumption data or data samples by comparing the with . Different from the calculation method, the is calculated from the scoring metrics of each smart meter;
[0139] Calculate the relative change of the smart meters compared to the local scoring metric in the previous round, denoted as , where the scoring metric increment and algorithm of the th smart meter are:
[0140]
[0141] From the above formula, the relative change of the smart meters can be obtained, denoted as , and then the proportion of the change of each smart meter is calculated through the following method : :
[0142]
[0143] Finally, by weighted aggregation of the values of the smart meters, the scoring metric of the global model in the second round of training is calculated, and the calculation method is: :
[0144]
[0145] is the threshold for determining whether to use local electricity consumption data or data samples.
[0146] The judgment process is as follows:
[0147] If > , it indicates that the model effect obtained by using the data sample has been improved, and the data sample is still used in the next round of training.
[0148] If < , it indicates that the model effect obtained by using the data sample has not been improved. To improve the model effect, local electricity consumption data is used in the next round of training.
[0149] Similarly, in the 4th round of training, the corresponding to the optimal model in the federated learning system of the 2nd round of training, and the corresponding to the optimal model in the federated learning system of the 3rd round of training can be used to calculate the global model evaluation index . And by comparing the with the size relationship to determine what data to use.
[0150] In the embodiment of the present invention, the central server distributes the initialized neural network model to multiple smart meters; each smart meter uses the generation model to generate data samples, and trains the initialized neural network model with the data samples or local electricity consumption data, and uploads the trained model parameters and scoring metrics to the central server; the central server performs aggregation detection on the trained model parameters and scoring metrics through the aggregation model to determine abnormal smart meters; the central server performs attention dynamic aggregation on all model parameters except the model parameters uploaded by the abnormal smart meters to obtain a global model, and determines whether the global model meets the preset training termination condition; if so, the training ends, and the global model is used to predict the electricity consumption; otherwise, the global model is used as the initialized neural network model and distributed to multiple smart meters, and returns to execute step 2; compared with the prior art, in the embodiment of the present invention, the generation model is used to generate data samples whose distance from the local electricity consumption data is less than the threshold for local training, and the aggregation model is used to perform aggregation detection on the trained model parameters and scoring metrics to determine abnormal smart meters, preventing malicious smart meters from attacking local electricity consumption data, effectively improving the privacy protection ability of smart grid data; at the same time, the attention dynamic aggregation of all model parameters is also used to improve the convergence speed of the global model, thereby improving the efficiency of federated learning.
[0151] The above is the preferred embodiment of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle described in the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.
Claims
1. A federated learning method for smart grid data protection, characterized in that, Including: Step 1, the central server distributes the initialized neural network model to multiple smart meters; Step 2, each smart meter uses the generation model to generate data samples, and trains the initialized neural network model with the data samples or local electricity consumption data, and uploads the trained model parameters and scoring metrics to the central server; Step 3, the central server performs aggregated detection on the trained model parameters and scoring metrics through the aggregation model to determine abnormal smart meters; Step 4, the central server performs attention dynamic aggregation on all model parameters except the model parameters uploaded by the abnormal smart meters to obtain a global model, and determines whether the global model meets the preset training termination condition; if so, the training ends, and the global model is used to predict electricity consumption; otherwise, the global model is used as the initialized neural network model and distributed to multiple smart meters, and returns to execute Step 2; The central server performs attention dynamic aggregation on all model parameters except the model parameters uploaded by the abnormal smart meters to obtain a global model, including: When performing attention dynamic aggregation on the model parameters except the model parameters uploaded by the abnormal smart meters for the first time, average all model parameters except the model parameters uploaded by the abnormal smart meters to generate a global model; When performing attention dynamic aggregation on all model parameters except the model parameters uploaded by the abnormal smart meters for non-first time, perform weighted aggregation on all model parameters except the model parameters uploaded by the abnormal smart meters by calculating the improvement ratio and reciprocal weight of each smart meter to obtain a global model; The expression for calculating the improvement ratio of each smart meter is: Among them, represents the proportion of the improvement degree of the th smart meter in the th round, represents the model improvement degree of the th smart meter in the th round, represents the number of smart meters; The expression for calculating the reciprocal weight of each smart meter is: Among them, represents the reciprocal weight of the th smart meter, represents the average distance between the model parameters uploaded by the th smart meter and all the model parameters in the previous round.
2. The federated learning method for smart grid data protection according to claim 1, wherein The generation model includes a generator and a discriminator; Use the generator to transform noise and class labels to synthesize data samples; The discriminator discriminates the distance between the data sample and the local electricity consumption data. If the distance is greater than the preset threshold, the generator is used to synthesize the data sample again until the distance is less than the preset threshold, and the data sample is used as the data sample.
3. The federated learning method for smart grid data protection according to claim 2, wherein, The calculation expression for the distance between the data sample and the local electricity consumption data is: Among them, represents the distribution of data samples and the distribution of local electricity consumption data the distance between represents the infimum, that is, the smallest upper bound, represents the distribution of data samples and the distribution of local electricity consumption data all possible joint distributions, represents the joint distribution of represents that under the joint distribution a pair of samples is randomly selected the expected value of the distance, represents local electricity consumption data, represents data samples.
4. The federated learning method for smart grid data protection according to claim 3, characterized in that, The said Step 3 includes: The central server regards all model parameters uploaded in each round as a point through the trimmed DBScan model and sets the clustering radius; Judge whether the distance between every two adjacent points is less than the clustering radius. When the distances are all less than the clustering radius, it is determined that there are no abnormal smart meters in this training. When the distance is greater than the clustering radius, the smart meter corresponding to the point with a distance greater than the clustering radius is used as the abnormal smart meter.
5. The federated learning method for smart grid data protection according to claim 4, wherein The calculation expression for the clustering radius is: Among them, represents the clustering radius, represents the number of smart meters, represents the model parameters trained by the th smart meter model parameters trained by the th smart meter distance between them.
6. The federated learning method for smart grid data protection according to claim 5, wherein The calculation expression for weighted aggregation of all model parameters except the model parameters uploaded by the abnormal smart meters is: Among them, represents the model parameters of the global model obtained in the round, represents the attention weight, represents the number of abnormal smart meters, represents the newly added smart meters, represents the th smart meter's model parameters during the round of training.
7. The federated learning method for smart grid data protection according to claim 1, characterized in that The said preset training termination conditions include: When the number of training rounds reaches the maximum number of rounds, stop training; When the round of training uses data samples, and the round of training uses local electricity consumption data, and when the evaluation index after the round of training is greater than the evaluation index after the round of training, stop training; When the global model converges to the expected degree, stop training; When local electricity consumption data is used in consecutive several rounds of training, stop training.
Citation Information
Patent Citations
Power grid industrial control protocol intrusion detection method and system based on federated learning
CN116260617A
Cluster federated learning method and system for DER power generation and load prediction
CN118656858A