Defense method and system for gradient attacks in federated learning process of power system
By clustering and matching user devices during the federated learning process of the power system, combined with a step-skipping random strategy and homomorphic encryption technology, the leakage of gradient information during transmission is prevented, the problem of gradient attacks is solved, and the security and reliability of the system are improved.
Patent Information
- Application Number
- CN202510085859.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-20
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2045-01-20
AI Technical Summary
In the federated learning process of the power system, gradient information can be easily stolen by attackers, resulting in user data leakage, and the security and reliability of existing solutions are insufficient.
By clustering and matching user devices, adopting step-hopping randomization strategy and homomorphic encryption technology, gradient information is screened, encrypted, exchanged and decrypted, and gradient updates are performed on the central server to prevent gradient attacks.
It achieves effective defense against gradient attacks in the federated learning process of the power system, improves the reliability and security of the system, and protects data privacy to the greatest extent.
Smart Images

Figure CN119989412B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of electrical automation, and in particular relates to a method and system for defending against gradient attacks in the federated learning process of a power system. Background Art
[0002] With the development of economy and technology and the improvement of people's living standards, electricity has become an indispensable secondary energy source in people's production and life, bringing endless convenience to people's production and life. Therefore, ensuring a stable and reliable supply of electricity has become one of the most important tasks of the power system.
[0003] Federated learning is a distributed learning solution that has emerged and gained popularity in recent years. It effectively protects data privacy during multi-client model training. During federated learning, each user can participate in model training locally while ensuring that their data is not shared with other users or central servers. Consequently, federated learning solutions have been widely used in power systems in recent years.
[0004] However, during federated learning, users must upload the gradient information obtained during their training to the server to update the overall model. During this process, this gradient information can be stolen by attackers. Furthermore, research has demonstrated that attackers can use stolen gradient information to recover the local data of users participating in federated learning, thereby stealing user data. Consequently, the security and reliability of existing federated learning solutions for power systems have been significantly reduced. Summary of the Invention
[0005] One of the objectives of the present invention is to provide a method for defending against gradient attacks in the federated learning process of a power system with high reliability and good security.
[0006] A second object of the present invention is to provide a system for implementing a method for defending against gradient attacks in the federated learning process of the power system.
[0007] The method for defending against gradient attacks in the federated learning process of the power system provided by the present invention comprises the following steps:
[0008] S1. Obtain data information of each user participating in the federated learning process of the power system;
[0009] S2. Perform cluster analysis on each user based on the data information obtained in step S1 to complete the user clustering;
[0010] S3. Calculate the cost matrix of each user based on their data information and perform bipartite graph matching on the users within each cluster.
[0011] S4. Each user performs local training and obtains corresponding gradient information;
[0012] S5. Each user uses a random skipping strategy to filter the gradient information obtained in step S4;
[0013] S6. Each user and the corresponding matching party encrypt, exchange and decrypt the filtered gradient information obtained in step S5, and upload the obtained data information to the central server;
[0014] S7. The central server updates the global model based on the received data to complete this round of federated learning.
[0015] S8. Repeat the above steps to complete the defense against gradient attacks in the federated learning process of the power system.
[0016] The step S1 of obtaining data information of each user participating in the federated learning process of the power system specifically includes the following steps:
[0017] Obtain data information of each user participating in the federated learning process of the power system;
[0018] The data information includes the user's device address, the user's device type, the user's device computing power, the user's power supply power, the user's storage capacity, the user's network bandwidth, the user's IP address and the user's operating system.
[0019] Step S2, based on the data information obtained in step S1, performs cluster analysis on each user to complete the clustering of users, specifically including the following steps:
[0020] Express the user's device address as longitude and latitude;
[0021] Use the following formula to calculate the distance d between the user's devices:
[0022]
[0023] Where r is the radius of the earth; ∅1 is the latitude value of the first device address; ∅2 is the latitude value of the second device address; Δ∅ is the latitude difference between the user's device addresses; Δλ is the longitude difference between the user's device addresses;
[0024] The distance between the user's device addresses is added to the user's data information, and a clustering algorithm is used to perform cluster analysis on each user, and the users are clustered according to the clustering results.
[0025] The step S3 described above calculates the cost matrix of each user based on the data information of each user and performs bipartite graph matching on the users in each cluster, specifically including the following steps:
[0026] Based on the data information of each user, the user equipment S1~S m It is divided into left set and right set, where the left set is the sending device and the right set is the receiving device;
[0027] Use the following formula to calculate the user equipment S in the left set: i and user equipment S in the right set j The cost c(S i ,S j ):
[0028] c(S i ,S j )=α·Dis(S i ,S j )+β·|CP(S i )-CP(S j )|+γ·|Bw(S i )-Bw(S j )|
[0029] Where Dis(S i ,S j ) is S i and S j The distance between CP(S i ) is S i Computing power; CP(S j ) is S j The computing power of Bw(S i ) is S i Network bandwidth; Bw(S j ) is S j The network bandwidth; α is the distance weight; β is the computing power weight; γ is the network bandwidth weight;
[0030] The calculated cost constitutes the cost matrix C;
[0031] In each cluster, the Hungarian algorithm is used to perform bipartite graph matching on the devices of each user according to the obtained cost matrix.
[0032] Each user in step S4 performs local training and obtains corresponding gradient information, which specifically includes the following steps:
[0033] Each user trains the central federated learning model locally and obtains the corresponding gradient information;
[0034] The central federated learning model includes the LeNet model.
[0035] Each user in step S5 uses a random skipping strategy to filter the gradient information obtained in step S4, which specifically includes the following steps:
[0036] For the first device id1 and the second device id2 corresponding to the bipartite graph in any cluster, the following random skipping strategy is used to filter the gradient information:
[0037] All gradient information of the first device id1 Expressed as
[0038] All gradient information of the second device id2 Expressed as n is the total number of gradient information;
[0039] For the first device id1, randomly generate the first device selection vector S id1 ; Among them, S id1 The length and Same, S id1 The element S in id1 [n] means Is it selected, and S id1 [n]=0 means Not selected, S id1 [n]=1 means Selected; Select vector S according to the generated first device id1 , get the first device selection gradient
[0040] For the second device id2, randomly generate the second device selection vector S id2 ; Among them, S id2 The length and Same, S id2 The element S in id2 [n] means Is it selected, and S id2 [n]=0 means Not selected, S id2 [n]=1 means Selected; Select vector S according to the generated second device id1 , get the second device selection gradient
[0041] In step S6, each user and the corresponding matching party encrypt, exchange, and decrypt the filtered gradient information obtained in step S5, which specifically includes the following steps:
[0042] The first device will The elements in are expanded in matrix form, and each element is encrypted using the homomorphic encryption scheme Paillier encryption algorithm to obtain the first device encrypted gradient set Will Send to the second device;
[0043] The second device will The elements in are expanded in matrix form, and each element is encrypted using the homomorphic encryption scheme Paillier encryption algorithm to obtain the second device encrypted gradient set Will Sending to the first device;
[0044] The first device receives and its own Perform gradient addition to obtain the first device superposition gradient right Decrypt to get the first device plaintext superposition gradient And upload to the central server;
[0045] The second device receives and its own Perform gradient addition to obtain the second device superposition gradient right Decrypt to get the second device plaintext superposition gradient And upload to the central server.
[0046] The central server in step S7 performs a gradient update on the global model based on the received data information to complete this round of federated learning, which specifically includes the following steps:
[0047] The data information received by the central server is the plaintext superposition gradient uploaded by each cluster;
[0048] The central server filters the received data information: if any of the matching parties does not upload the corresponding plaintext superposition gradient, the corresponding gradient information of the matching parties will not be used;
[0049] After screening, the gradient information of each cluster is aggregated using the following formula:
[0050]
[0051] In the formula For cluster T i Aggregation gradient; n i For cluster T i The number of users participating in gradient information aggregation; X i The number of samples for each participant; For cluster T iThe plaintext superposition gradients that participate in the gradient information aggregation;
[0052] After aggregating the gradient information, the central server aggregates the gradient information of each cluster to obtain the global model update gradient:
[0053]
[0054] In the formula Update the gradient for the global model; K is the total number of clusters;
[0055] Will As the updated gradient, it is sent to each cluster and the corresponding user device to complete this round of federated learning.
[0056] The present invention also provides a system for implementing a method for defending against gradient attacks in the process of federated learning of the power system, comprising a data acquisition module, a user clustering module, a matching module, a local training module, an information screening module, an information encryption module, a gradient update module and a defense module; the data acquisition module, the user clustering module, the matching module, the local training module, the information screening module, the information encryption module, the gradient update module and the defense module are connected in series in sequence; the data acquisition module is used to acquire data information of each user participating in the process of federated learning of the power system, and upload the data information to the user clustering module; the user clustering module is used to perform cluster analysis on each user based on the received data information and the acquired data information to complete the clustering of the users, and upload the data information to the matching module; the matching module is used to calculate the cost matrix of each user based on the received data information and the data information of each user, and perform bipartite graph matching on the users in each cluster, and upload the data information to the local training module Block; the local training module is used to enable each user to perform local training based on the received data information, and obtain the corresponding gradient information, and upload the data information to the information screening module; the information screening module is used to enable each user to adopt a step-by-step random strategy to screen the obtained gradient information based on the received data information, and upload the data information to the information encryption module; the information encryption module is used to enable each user and the corresponding matching party to encrypt, exchange and decrypt the screened gradient information based on the received data information, and upload the obtained data information to the central server, and upload the data information to the gradient update module; the gradient update module is used to enable the central server to perform gradient update on the global model based on the received data information to complete this round of federated learning, and upload the data information to the defense module; the defense module is used to repeat the work of the above modules based on the received data information to complete the defense against gradient attacks in the federated learning process of the power system.
[0057] The method and system for defending against gradient attacks during federated learning of power systems provided by the present invention cluster and match user devices, and encrypt, exchange, decrypt, and upload gradient information generated during local training of user devices based on the clustering and matching results. This not only achieves defense against gradient attacks during federated learning of power systems, but also provides higher reliability and better security. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 Schematic diagram of the process of the present invention.
[0059] Figure 2 Schematic diagram for comparing the effects of the embodiments of the method of the present invention.
[0060] Figure 3 Schematic diagram of the functional modules of the system of the present invention. DETAILED DESCRIPTION
[0061] like Figure 1 The figure shows a flow chart of the method of the present invention: The method for defending against gradient attacks in the federated learning process of the power system provided by the present invention comprises the following steps:
[0062] S1. Obtain data information of each user participating in the federated learning process of the power system; specifically, the following steps are included:
[0063] Obtain data information from each user participating in the federated learning process of the power system. For the power system, the participating users are generally various types of power equipment and corresponding smart terminals (such as smartphones, tablets, desktop computers, etc.);
[0064] The data information includes the user's device address, the user's device type, the user's device computing power, the user's power supply, the user's storage capacity, the user's network bandwidth, the user's IP address and the user's operating system;
[0065] S2. Based on the data information obtained in step S1, cluster analysis is performed on each user to complete the clustering of users; specifically, the steps include:
[0066] Express the user's device address as longitude and latitude;
[0067] Use the following formula to calculate the distance d between the user's devices:
[0068]
[0069] Where r is the radius of the earth; ∅1 is the latitude value of the first device address; ∅2 is the latitude value of the second device address; Δ∅ is the latitude difference between the user's device addresses; Δλ is the longitude difference between the user's device addresses;
[0070] The distance between the user's device addresses is added to the user's data information, and a clustering algorithm is used to perform cluster analysis on each user, and the users are clustered according to the clustering results;
[0071] S3. Based on the data information of each user, calculate the cost matrix of each user and perform bipartite graph matching on the users within each cluster. This specifically includes the following steps:
[0072] Based on the data information of each user, the user equipment S1~S m It is divided into left set and right set, where the left set is the sending device and the right set is the receiving device;
[0073] Use the following formula to calculate the user equipment S in the left set: i and user equipment S in the right set j The cost c(S i ,S j ):
[0074] c(S i ,S j )=α·Dis(S i ,S j )+β·|CP(S i )-CP(S j )|+γ·|Bw(S i )-Bw(S j )|
[0075] Where Dis(S i ,S j ) is S i and S j The distance between CP(S i ) is S i Computing power; CP(S j ) is S j The computing power of Bw(S i ) is S i Network bandwidth; Bw(S j ) is S j The network bandwidth; α is the distance weight; β is the computing power weight; γ is the network bandwidth weight;
[0076] The calculated cost constitutes the cost matrix C;
[0077] Within each cluster, the Hungarian algorithm is used to perform bipartite graph matching on each user's device based on the obtained cost matrix. The Hungarian algorithm can pair the clustered participants and optimize computing and communication resources.
[0078] S4. Each user performs local training and obtains corresponding gradient information; specifically, the steps include:
[0079] Each user trains the central federated learning model locally and obtains the corresponding gradient information;
[0080] The central federated learning model includes the LeNet model;
[0081] S5. Each user uses a random skipping strategy to filter the gradient information obtained in step S4; specifically, the steps include:
[0082] For the first device id1 and the second device id2 corresponding to the bipartite graph in any cluster, the following random skipping strategy is used to filter the gradient information:
[0083] All gradient information of the first device id1 Expressed as
[0084] All gradient information of the second device id2 Expressed as n is the total number of gradient information;
[0085] For the first device id1, randomly generate the first device selection vector S id1 ; Among them, S id1 The length and Same, S id1 The element S in id1 [n] means Is it selected, and S id1 [n]=0 means Not selected, S id1 [n]=1 means Selected; Select vector S according to the generated first device id1 , get the first device selection gradient
[0086] For the second device id2, randomly generate the second device selection vector S id2 ; Among them, S id2 The length and Same, S id2 The element S in id2 [n] means Is it selected, and S id2 [n]=0 means Not selected, S id2 [n]=1 means Selected; Select vector S according to the generated second device id1 , get the second device selection gradient
[0087] S6. Each user and the corresponding matching party encrypt, exchange and decrypt the gradient information obtained after the screening in step S5, and upload the obtained data information to the central server; specifically comprising the following steps:
[0088] The first device will The elements in are expanded in matrix form, and each element is encrypted using the homomorphic encryption scheme Paillier encryption algorithm to obtain the first device encrypted gradient set Will Send to the second device;
[0089] The second device will The elements in are expanded in matrix form, and each element is encrypted using the homomorphic encryption scheme Paillier encryption algorithm to obtain the second device encrypted gradient set Will Sending to the first device;
[0090] The first device receives and its own Perform gradient addition to obtain the first device superposition gradient right Decrypt to get the first device plaintext superposition gradient And upload to the central server;
[0091] The second device receives and its own Perform gradient addition to obtain the second device superposition gradient right Decrypt to get the second device plaintext superposition gradient And upload to the central server;
[0092] The homomorphic encryption scheme effectively prevents gradient leakage during exchange and transmission while maintaining computational efficiency, making it ideal for practical federated learning scenarios.
[0093] S7. The central server performs a gradient update on the global model based on the received data to complete this round of federated learning. This includes the following steps:
[0094] The data information received by the central server is the plaintext superposition gradient uploaded by each cluster;
[0095] The central server filters the received data information: if any of the matching parties does not upload the corresponding plaintext superposition gradient, the corresponding gradient information of the matching parties will not be used;
[0096] After screening, the gradient information of each cluster is aggregated using the following formula:
[0097]
[0098] In the formula For cluster T i Aggregation gradient; n i For cluster T i The number of users participating in gradient information aggregation; X i The number of samples for each participant; For cluster T i The plaintext superposition gradients that participate in the gradient information aggregation;
[0099] After aggregating the gradient information, the central server aggregates the gradient information of each cluster to obtain the global model update gradient:
[0100]
[0101] In the formula Update the gradient for the global model; K is the total number of clusters;
[0102] Will This is used as the updated gradient and distributed to each cluster and the corresponding user device, completing this round of federated learning.
[0103] Since exchanging the gradients of the two participants does not affect the overall sum, the convergence of federated learning can be guaranteed.
[0104] S8. Repeat the above steps to complete the defense against gradient attacks in the federated learning process of the power system.
[0105] Using this defense method of the present invention, the server does not need to directly access the local sample data of any participant, nor does the participant need to share sample data. This mechanism maximizes data privacy while enabling distributed collaborative learning. Furthermore, by introducing encryption technology during the statistical information transmission and processing stages, the system's security is effectively enhanced, preventing the risk of data leakage or malicious attacks. Therefore, the method of the present invention is particularly suitable for situations such as power systems where multiple types of data and multiple sensitive data are involved.
[0106] The method of the present invention is further described below with reference to an embodiment:
[0107] The federated learning task uses an image recognition task, and the dataset uses CIFAR-10 as an example. The federated learning solution is a horizontal federated learning scenario.
[0108] First, the central server sends the global federation model to all participants, and all participants upload the device information table to the server. The device information table contains the following content:
[0109] Table 1 Schematic diagram of equipment information
[0110]
[0111] Then, the defense method of the present invention is used to perform federated learning. The central federated learning model uses the LeNet model, which has 8 layers. After one round of federated learning, the gradient information of the first device id1 is shown in Table 2:
[0112] Table 2 Gradient information diagram
[0113]
[0114] After the gradient information is encrypted, exchanged, and decrypted, the transformed gradient information is shown in Table 3:
[0115] Table 3 Schematic diagram of gradient information after transformation
[0116]
[0117] First, we tested the gradient leakage without any defense methods. We used the DLG gradient attack method, which uses the uploaded gradient information to reconstruct the gradient and infer the local sensitive data of the participants.
[0118] The results are as follows Figure 2 As shown in Figure 3, after 300 training iterations, we observed that the original data had been leaked, and attackers were able to recover the private data of the participants from the gradient information. This situation shows that unprotected gradient information is extremely vulnerable to malicious attackers during transmission, seriously threatening the privacy of data in federated learning systems.
[0119] We then introduced our gradient defense mechanism. This mechanism essentially perturbs the gradient information during upload, destroying the original data structure of the gradient, making it impossible for attackers to recover sensitive information. With the gradient defense mechanism, the risk of gradient leakage is effectively reduced, significantly enhancing privacy protection. As a result, attackers cannot recover any private information from the gradient, greatly improving the security of the federated learning system.
[0120] Table 4 shows the change in reconstruction loss when the attacker reconstructs the uploaded gradients as training iterations progress during federated learning training, with and without defense enabled.
[0121] Table 4 Schematic diagram of reconstruction loss
[0122]
[0123] Table 4 shows that when the defense is disabled, the gradient information provides sufficient clues, allowing the attacker to complete data reconstruction in a relatively short time. Furthermore, the reconstruction loss decreases as the number of iterations increases, indicating that the attacker can recover more data. However, when the defense is enabled, due to the perturbation and encryption of the gradients, it is difficult for the attacker to extract useful information from the uploaded gradients. The reconstruction loss remains high throughout the training process, indicating that the defense mechanism effectively undermines the predictability and recoverability of the gradients.
[0124] like Figure 3The figure shows a schematic diagram of the functional modules of the system of the present invention: the system disclosed by the present invention for realizing the method for defending against gradient attacks in the process of federated learning of the power system comprises a data acquisition module, a user clustering module, a matching module, a local training module, an information screening module, an information encryption module, a gradient update module and a defense module; the data acquisition module, the user clustering module, the matching module, the local training module, the information screening module, the information encryption module, the gradient update module and the defense module are connected in series in sequence; the data acquisition module is used to acquire the data information of each user participating in the process of federated learning of the power system, and upload the data information to the user clustering module; the user clustering module is used to perform cluster analysis on each user based on the received data information and the acquired data information to complete the clustering of the users, and upload the data information to the matching module; the matching module is used to calculate the cost matrix of each user based on the received data information and the data information of each user, and perform bipartite graph matching on the users in each cluster, and upload the data information to the matching module. The local training module uploads the data information; the local training module is used to enable each user to perform local training according to the received data information, and obtain the corresponding gradient information, and upload the data information to the information screening module; the information screening module is used to enable each user to adopt a step-by-step random strategy to screen the obtained gradient information according to the received data information, and upload the data information to the information encryption module; the information encryption module is used to enable each user and the corresponding matching party to encrypt, exchange and decrypt the screened gradient information according to the received data information, and upload the obtained data information to the central server, and upload the data information to the gradient update module; the gradient update module is used to enable the central server to perform gradient update on the global model according to the received data information to complete this round of federated learning, and upload the data information to the defense module; the defense module is used to repeat the work of the above modules according to the received data information to complete the defense against gradient attacks in the federated learning process of the power system.
Claims
1. A method for defending against gradient attacks in a federated learning process of a power system, comprising the following steps: S1. Obtain data information of each user participating in the federated learning process of the power system; S2. Perform cluster analysis on each user based on the data information obtained in step S1 to complete the user clustering; S3. Calculate the cost matrix of each user based on their data information and perform bipartite graph matching on the users within each cluster. S4. Each user performs local training and obtains corresponding gradient information; S5. Each user uses a random skipping strategy to filter the gradient information obtained in step S4; S6. Each user and the corresponding matching party encrypt, exchange and decrypt the filtered gradient information obtained in step S5, and upload the obtained data information to the central server; S7. The central server updates the global model based on the received data to complete this round of federated learning. S8. Repeat the above steps to complete the defense against gradient attacks in the federated learning process of the power system.
2. The method for defending against gradient attacks in the federated learning process of the power system according to claim 1 is characterized in that The step S1 of obtaining data information of each user participating in the federated learning process of the power system specifically includes the following steps: Obtain data information of each user participating in the federated learning process of the power system; The data information includes the user's device address, the user's device type, the user's device computing power, the user's power supply power, the user's storage capacity, the user's network bandwidth, the user's IP address and the user's operating system.
3. The method for defending against gradient attacks in the federated learning process of the power system according to claim 2 is characterized in that Step S2, based on the data information obtained in step S1, performs cluster analysis on each user to complete the clustering of users, specifically including the following steps: Express the user's device address as longitude and latitude; Use the following formula to calculate the distance d between the user's devices: Where r is the radius of the earth; ∅1 is the latitude value of the first device address; ∅2 is the latitude value of the second device address; Δ∅ is the latitude difference between the user's device addresses; Δλ is the longitude difference between the user's device addresses; The distance between the user's device addresses is added to the user's data information, and a clustering algorithm is used to perform cluster analysis on each user, and the users are clustered according to the clustering results.
4. The method for defending against gradient attacks in the federated learning process of the power system according to claim 3 is characterized in that The step S3 described above calculates the cost matrix of each user based on the data information of each user and performs bipartite graph matching on the users in each cluster, specifically including the following steps: Based on the data information of each user, the user equipment S1~S m It is divided into left set and right set, where the left set is the sending device and the right set is the receiving device; Use the following formula to calculate the user equipment S in the left set: i and user equipment S in the right set j The cost c(S i ,S j ): c(S i ,S j )=α·Dis(S i ,S j )+β·|CP(S i )-CP(S j )|+γ·|Bw(S i )-Bw(S j )| Where Dis(S i ,S j ) is S i and S j The distance between CP(S i ) is S i Computing power; CP(S j ) is S j The computing power of Bw(S i ) is S i Network bandwidth; Bw(S j ) is S j The network bandwidth; α is the distance weight; β is the computing power weight; γ is the network bandwidth weight; The calculated cost constitutes the cost matrix C; In each cluster, the Hungarian algorithm is used to perform bipartite graph matching on the devices of each user according to the obtained cost matrix.
5. The method for defending against gradient attacks in the federated learning process of the power system according to claim 4 is characterized in that Each user in step S4 performs local training and obtains corresponding gradient information, which specifically includes the following steps: Each user trains the central federated learning model locally and obtains the corresponding gradient information; The central federated learning model includes the LeNet model.
6. The method for defending against gradient attacks in the federated learning process of the power system according to claim 5 is characterized in that Each user in step S5 uses a random skipping strategy to filter the gradient information obtained in step S4, which specifically includes the following steps: For the first device id1 and the second device id2 corresponding to the bipartite graph in any cluster, the following random skipping strategy is used to filter the gradient information: All gradient information of the first device id1 Expressed as All gradient information of the second device id2 Expressed as n is the total number of gradient information; For the first device id1, randomly generate the first device selection vector S id1 ; Among them, S id1 The length and Same, S id1 The element S in id1 [n] means Is it selected, and S id1 [n]=0 means Not selected, S id1 [n]=1 means Selected; Select vector S according to the generated first device id1 , get the first device selection gradient For the second device id2, randomly generate the second device selection vector S id2 ; Among them, S id2 The length and Same, S id2 The element S in id2 [n] means Is it selected, and S id2 [n]=0 means Not selected, S id2 [n]=1 means Selected; Select vector S according to the generated second device id1 , get the second device selection gradient 7. The method for defending against gradient attacks in the federated learning process of the power system according to claim 6 is characterized in that In step S6, each user and the corresponding matching party encrypt, exchange, and decrypt the filtered gradient information obtained in step S5, which specifically includes the following steps: The first device will The elements in are expanded in matrix form, and each element is encrypted using the homomorphic encryption scheme Paillier encryption algorithm to obtain the first device encrypted gradient set Will Send to the second device; The second device will The elements in are expanded in matrix form, and each element is encrypted using the homomorphic encryption scheme Paillier encryption algorithm to obtain the second device encrypted gradient set Will Sending to the first device; The first device receives and its own Perform gradient addition to obtain the first device superposition gradient right Decrypt to get the first device plaintext superposition gradient And upload to the central server; The second device receives and its own Perform gradient addition to obtain the second device superposition gradient right Decrypt to get the second device plaintext superposition gradient And upload to the central server.
8. The method for defending against gradient attacks in the federated learning process of the power system according to claim 7 is characterized in that The central server in step S7 performs a gradient update on the global model based on the received data information to complete this round of federated learning, which specifically includes the following steps: The data information received by the central server is the plaintext superposition gradient uploaded by each cluster; The central server filters the received data information: if any of the matching parties does not upload the corresponding plaintext superposition gradient, the corresponding gradient information of the matching parties will not be used; After screening, the gradient information of each cluster is aggregated using the following formula: In the formula For cluster T i Aggregation gradient; n i For cluster T i The number of users participating in gradient information aggregation; X i is the sample size for each participant; For cluster T i The plaintext superposition gradients that participate in the gradient information aggregation; After aggregating the gradient information, the central server aggregates the gradient information of each cluster to obtain the global model update gradient: In the formula Update the gradient for the global model; K is the total number of clusters; Will As the updated gradient, it is sent to each cluster and the corresponding user device to complete this round of federated learning.
9. A system for implementing the method for defending against gradient attacks in the federated learning process of a power system according to any one of claims 1 to 8, characterized in that It includes a data acquisition module, a user clustering module, a matching module, a local training module, an information screening module, an information encryption module, a gradient update module and a defense module; the data acquisition module, the user clustering module, the matching module, the local training module, the information screening module, the information encryption module, the gradient update module and the defense module are connected in series in sequence; the data acquisition module is used to obtain the data information of each user participating in the power system federated learning process, and upload the data information to the user clustering module; The user clustering module is used to perform cluster analysis on each user based on the received data information to complete the clustering of users and upload the data information to the matching module; The matching module is used to calculate the cost matrix of each user based on the received data information and the data information of each user, perform bipartite graph matching on the users in each cluster, and upload the data information to the local training module; The local training module is used to enable each user to perform local training based on the received data information, obtain the corresponding gradient information, and upload the data information to the information screening module; the information screening module is used to enable each user to use a step-by-step random strategy to screen the obtained gradient information based on the received data information, and upload the data information to the information encryption module; the information encryption module is used to enable each user and the corresponding matching party to encrypt, exchange and decrypt the screened gradient information based on the received data information, and upload the obtained data information to the central server, and upload the data information to the gradient update module; the gradient update module is used to enable the central server to perform gradient updates on the global model based on the received data information to complete this round of federated learning, and upload the data information to the defense module; The defense module is used to repeat the work of the above modules according to the received data information to complete the defense against gradient attacks in the federated learning process of the power system.
Citation Information
Patent Citations
Defense method for federated learning neuron gradient attack
CN115333825A
Federated learning methods and apparatuses, readable storage media, and electronic devices
US20250097265A1