Method and system for defending gradient attacks in federal learning process of power system
By clustering and matching user equipment in federated learning of power systems and using encrypted exchange strategies, the problem of gradient information being easily attacked during transmission is solved, and the system's security and data privacy protection is improved.
Patent Information
- Application Number
- CN202510085859.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-20
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2045-01-20
AI Technical Summary
During the federated learning process of the power system, gradient information is easily stolen by attackers during the upload process, resulting in the leakage of user data and reducing the security and reliability of the system.
By clustering and matching user equipment, and using step-skipping random strategy to filter and encrypt and exchange gradient information, the security of gradient information during transmission is ensured.
It effectively prevents gradient attacks, improves data privacy protection and system security in the federated learning process of power system, and ensures the reliability of data transmission.
Smart Images

Figure CN119989412A_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 a federated learning process of an electric 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 the 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 become popular in recent years. It can effectively protect data privacy in the process of model training for multiple clients. In the process of federated learning, each user can participate in model training locally while ensuring that their data is not shared with other users or central servers. Therefore, in recent years, federated learning solutions have been widely used in power systems.
[0004] However, during the federated learning process, users need to upload the gradient information obtained during their own training process to the server to update the overall model at the server. In the process of uploading gradient information, the gradient information can be stolen by attackers. At the same time, there are studies that have shown that attackers can recover the local data of users participating in federated learning through stolen gradient information, thereby achieving the purpose of stealing user data. Therefore, the security and reliability of the existing federated learning scheme for power systems have been greatly reduced. Summary of the invention
[0005] One of the purposes 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 objective of the present invention is to provide a system for implementing a method for defending against gradient attacks in the process of federated learning of the power system.
[0007] The method for defending against gradient attacks in the power system federated learning process 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 according to the data information obtained in step S1 to complete the clustering of users;
[0010] S3. Based on the data information of each user, calculate the cost matrix of each user, and perform bipartite graph matching on the users in 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 gradient of the global model based on the received data information 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 includes 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 distances between the user's device addresses are 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 devices S1 to S m It is divided into a left set and a right set, where the left set is the sender device and the right set is the receiver device;
[0027] Use the following formula to calculate the user equipment S in the left set: i and the user equipment S in the right set j The cost between 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 The computing power of CP(S j ) is S j The computing power of Bw(S i ) is S i The 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 costs constitute 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 matching in any cluster, the following step-hopping random strategy is used to screen 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] Each user and the corresponding matching party in step S6 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 Sending to a 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 described in step S7 performs gradient update on the global model according to 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 screens 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 aggregation of gradient information;
[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 the 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 updating 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 updating 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 clustering analysis on each user according to 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 according to 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 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 process of federated learning of the power system.
[0057] The method and system for defending against gradient attacks in the process of federated learning of a power system provided by the present invention not only realizes defense against gradient attacks in the process of federated learning of a power system by clustering and matching user devices, and encrypting, exchanging, decrypting and uploading gradient information generated in the local training process of the user devices according to the clustering and matching results, but also has higher reliability and better security. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 The figure is a schematic diagram of the method flow of the present invention.
[0059] Figure 2 Schematic diagram for comparing the effects of the method embodiments 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 method flow chart of the method of the present invention is shown as follows: The method for defending against gradient attacks in the power system federated learning process 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 of each user participating in the federated learning process of the power system; among them, the participating users, for the power system, are generally various types of power equipment and corresponding smart terminals (such as smart phones, tablet computers, 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 power, 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 user is clustered according to the clustering results;
[0071] S3. Based on the data information of each user, the cost matrix of each user is calculated, and bipartite graph matching is performed on the users in each cluster; specifically, the steps include:
[0072] Based on the data information of each user, the user devices S1 to S m It is divided into a left set and a right set, where the left set is the sender device and the right set is the receiver device;
[0073] Use the following formula to calculate the user equipment S in the left set: i and the user equipment S in the right set j The cost between 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 The computing power of CP(S j ) is S j The computing power of Bw(S i ) is S i The 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 costs constitute the cost matrix C;
[0077] 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. The Hungarian algorithm can be used to pair the participants after clustering 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 matching in any cluster, the following step-hopping random strategy is used to screen 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 filtered gradient information obtained in step S5, and upload the obtained data information to the central server; specifically, the following steps are included:
[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 Sending to a 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 can effectively prevent the leakage of gradients during exchange and transmission while maintaining computational efficiency, which is very suitable for the actual scenario of federated learning.
[0093] S7. The central server updates the global model based on the received data information to complete this round of federated learning. The specific steps include:
[0094] The data information received by the central server is the plaintext superposition gradient uploaded by each cluster;
[0095] The central server screens 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 aggregation of gradient information;
[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 As the updated gradient, it is sent to each cluster and the corresponding user device to complete this round of federated learning;
[0103] Since the exchange of gradients between 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] By adopting the defense method of the present invention, the server does not need to directly access the local sample data of any participant, and the participants do not need to share sample data. This mechanism protects data privacy to the greatest extent while realizing distributed collaborative learning. In addition, by introducing encryption technology in the statistical information transmission and processing stage, the security of the system is effectively improved, and the risk of data leakage or malicious attack is prevented. Therefore, the method of the present invention is particularly suitable for occasions such as power systems with multiple types of data and multiple sensitive data.
[0106] The method of the present invention is further described below in conjunction with an embodiment:
[0107] The federated learning task uses an image recognition task, and the data set 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 contents as shown in Table 1:
[0109] Table 1 Equipment information diagram
[0110]
[0111] Then, the defense method of the present invention is used to perform federated learning; wherein, the central federated learning model adopts 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 method. 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 the figure. When the training iteration reaches 300, we observe that the original data has been leaked and the attacker can 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, which seriously threatens the privacy of data in the federated learning system.
[0119] Then we introduced our gradient defense mechanism, which essentially adds strong perturbations to the gradient information during the gradient upload process, aiming to destroy the original data structure in the gradient, making it impossible for attackers to recover sensitive information from it. After using the gradient defense mechanism, the risk of gradient leakage is effectively reduced and privacy protection is significantly enhanced. Therefore, 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 proceed during federated learning training, with and without defense enabled.
[0121] Table 4 Reconstruction loss diagram
[0122]
[0123] From Table 4, we can see that when the defense is not enabled, the gradient information provides enough clues, and the attacker can complete data reconstruction in a shorter time. Moreover, as the number of iterations increases, the reconstruction loss gradually decreases, indicating that the attacker can recover more data. When the defense is enabled, due to the perturbation and encryption of the gradient, it is difficult for the attacker to extract useful information from the uploaded gradient, and the reconstruction loss is maintained at a high level throughout the training process, indicating that the defense mechanism effectively destroys the predictability and recovery of the gradient.
[0124] like Figure 3The functional module schematic diagram of the system of the present invention is shown as follows: the system disclosed in 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 updating 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 updating 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 clustering analysis on each user according to the received data information and the acquired data information, so as 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 according to 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 is used to upload the received data information to the local training module; 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 according to the data information obtained in step S1 to complete the clustering of users; S3. Based on the data information of each user, calculate the cost matrix of each user, and perform bipartite graph matching on the users in 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 gradient of the global model based on the received data information 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 includes 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 distances between the user's device addresses are 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 devices S1 to S m It is divided into a left set and a right set, where the left set is the sender device and the right set is the receiver device; Use the following formula to calculate the user equipment S in the left set: i and the user equipment S in the right set j The cost between 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 The computing power of CP(S j ) is S j The computing power of Bw(S i ) is S i The 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 costs constitute 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 matching in any cluster, the following step-hopping random strategy is used to screen 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 Each user and the corresponding matching party in step S6 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 Sending to a 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 described in step S7 performs gradient update on the global model according to 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 screens 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 The number of samples for each participant; For cluster T i The plaintext superposition gradients that participate in the aggregation of gradient information; 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 as claimed in 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 federated learning process 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 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, and 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, 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 use a step-hopping 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 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
Federal learning member reasoning attack defense method and device based on block chain decentration
CN113467928A
Defense method for federated learning neuron gradient attack
CN115333825A
Defense method for cluster federated learning attack, terminal and storage medium
CN117424754A
Defense method for federal learning depth gradient leakage attack
CN119004537A
Federated learning methods and apparatuses, readable storage media, and electronic devices
US20250097265A1