Federal learning method and device for guaranteeing fairness of heterogeneous data, equipment and medium
By collaboratively calculating fairness metrics and dynamically adjusting weights between the client and server, the system addresses global data distribution bias and data security issues in federated learning, achieving fairness and privacy protection in heterogeneous data environments and enhancing the fairness and credibility of the model.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- STATE GRID HUNAN ELECTRIC POWER CO
- Filing Date
- 2026-04-09
- Publication Date
- 2026-05-08
AI Technical Summary
Existing federated learning techniques cannot capture biases in the global data distribution while ensuring model fairness, leading to data security issues and subjectivity in data quality assessment, which affects the server-side weight aggregation results.
In each round of federated learning, the client calculates the fairness metric and accuracy of the local model, the server calculates the global fairness metric based on global data statistics, and dynamically adjusts the weight parameters of the client model according to the fairness gap. The global model is then updated using a secure aggregation protocol until the set number of training rounds is reached.
It enables the accurate measurement of model performance differences across different sensitive attributes while protecting data privacy, dynamically adjusting weights to adapt to heterogeneous data distribution, reducing unfairness, improving the model's performance balance and social equity across global data, and avoiding the accumulation of bias.
Smart Images

Figure CN121998132A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of power technology, and in particular to federated learning methods, apparatus, devices, and media for ensuring fairness of heterogeneous data. Background Technology
[0002] Currently, with the widespread application of federated learning technology, model fairness and privacy protection have received policy support and widespread attention. How to achieve fairness in models for different groups while protecting privacy has become a focal point and challenge for all stakeholders in the field of artificial intelligence.
[0003] Federated learning, which enables collaborative training of machine learning models among multiple parties while maintaining the privacy of their local data, has been widely used in scenarios such as power and emergency response. However, in the power industry, participants in federated learning often have different data distributions. Reduced model fairness can lead to poorer predictions for certain groups, and significant differences in the contributions of different participants to the model can also occur. Therefore, a federated learning system that achieves fairness among different groups (e.g., specific gender, age, occupation) is indispensable and crucial for ensuring the credibility of federated learning algorithms in the power industry.
[0004] In recent years, several methods for achieving group equity have been implemented in centralized environments. However, these methods are all implemented on the server side and rely on information extracted by the server from each participant, such as node performance and data distribution. This requires centralized access to sensitive information at each data point, reducing the security of each participant's data. Therefore, they are not suitable for application in federated learning.
[0005] Specifically, existing methods for ensuring fairness in federated learning systems fall into two categories: client-side processing and server-side processing. Client-side processing refers to each participant using local bias removal algorithms for training, ensuring that each participant's model is adapted to the corresponding data distribution, thus prioritizing local fairness. Subsequently, the server aggregates the model parameters or gradient information from each participant, bringing the entire federated learning system to a more equitable state.
[0006] However, data from one client may primarily represent a specific group, while data from other clients may represent different groups. In such cases, local debiasing methods may fail to capture biases in the global data distribution. For example, data from the power industry and emergency response data may differ significantly.
[0007] From a server-side perspective, modifications are primarily made in two areas: participant selection and model aggregation, designing various fairness mechanisms. Regarding participant selection, long-term fairness constraints can be introduced to ensure that the probability of each client being selected is not lower than a certain threshold, guaranteeing that even clients with poor performance have an equal chance of being selected. Alternatively, various client parameters (such as data volume, computing power, network performance, and data quality) can be comprehensively considered during the client selection phase, resulting in a richer variety of clients participating in training, thereby improving data diversity and model generalization. From a model aggregation perspective, the data quality of each client can be estimated, ensuring that clients with high-quality data contribute more to the global model, thus achieving aggregation fairness.
[0008] However, both server-side processing methods require the server to obtain additional information from the participating clients, such as task performance, network performance, data volume distribution, data label distribution, and gradient distribution. Since this information may need to be provided by each participant, this approach can lead to the sharing of private data with the server, potentially causing data security issues. Furthermore, the assessment of data quality is somewhat subjective, which can affect the server-side weight aggregation results. Summary of the Invention
[0009] This application provides a federated learning method to ensure fairness in heterogeneous data, addressing the technical problems of existing technologies failing to capture biases in the global data distribution, easily leading to data security issues, and the subjective nature of data quality assessment affecting the server-side weight aggregation results.
[0010] This application is achieved through the following solution: Federated learning methods that ensure fairness across heterogeneous data include the following steps: S1. In each round of federated learning, each client uses local data to train a local model, updates the weight parameters of the local model, and then calculates the fairness index of the local model and the accuracy of the prediction results of the local model. S2. The server calculates the global fairness index based on the global data statistics aggregated from the clients and broadcasts it to each client. S3. Each client updates the weight parameters of its local model based on the difference between the local model's fairness metric and the global fairness metric. Then, according to the secure aggregation protocol, the weighted local models of each client are aggregated and the server's global model weight parameters are updated and broadcast to all clients for the next round of training, until the set number of model training rounds is reached.
[0011] Furthermore, it also includes the following steps: S0. Initialize the parameters of the global model located on the server, the number of training rounds of the model, set the initial weight parameters of the local models located on each client, and use the secure aggregation protocol to aggregate global data statistics from the clients on the server.
[0012] Further, step S0 specifically includes the following steps: S01. Global Model Parameter Initialization: Initialize the global model parameters by randomly sampling from a Gaussian distribution using a random initialization method. Set the number of training rounds for the model. ; S02, Initial Weight Allocation: The server assigns initial weights to each client model. ,in, It is a client The amount of data, K is the total number of clients, and the initial weights are allocated based on the proportion of each client's data volume; S03, Data Statistics Aggregation: The server uses a secure aggregation protocol to aggregate global data statistics from the client. This is used to represent the probability that the majority of sensitive attributes in a client's dataset have positive label values, and the probability that the minority of sensitive attributes have positive label values. Here, Y represents the actual value of the dependent variable, A represents the unevenly distributed sensitive attributes, A=0 represents the category with a smaller proportion, and A=1 represents the category with a larger proportion. It represents probability.
[0013] Further, step S1 specifically includes the following steps: S11, Local Model Update: In each round of federated learning, each client... Use its local data For local models Train the model, update the weight parameters, and obtain the updated local model. ; S12. Calculate the local fairness metric: The client calculates the fairness metric for its local model. Among them, parameters Indicates the client's ID , The fairness index represents the result of the model prediction. It means that the difference between the probability of a wrong prediction and the probability of a right prediction is the data in each class of data with a true prediction value in the sensitive attribute. It measures the difference in the true probability of the model in different sensitive attribute groups. S13. Accuracy Calculation: The client calculates the accuracy of the local model. ,in, TP To correctly predict the number of samples that are classified as positive, TN To correctly predict the number of samples that are negative,FP These are samples that were incorrectly predicted as positive (but were actually negative). FN This represents the number of samples that were incorrectly predicted as negative (but were actually positive).
[0014] Furthermore, step S2 specifically includes the following steps: S21. Calculation of Global Fairness Index: The global fairness index is calculated based on statistical information aggregated from the client. ,in, This means that the overall model prediction is true. This indicates that the actual label value is true; S22, Global Fairness Broadcast: Broadcasts the calculated global fairness index to each client, allowing the client to update the weights of its local model based on the broadcast results.
[0015] Furthermore, step S3 specifically includes the following steps: S31. Fairness Indicator Gap Calculation: Each client calculates its local fairness index. With global fairness indicators The gap ,in, It is the global accuracy. It is the local accuracy of client k. When the fairness metric is calculated, the difference is expressed as the absolute value of the difference between the local and global fairness metrics; otherwise, it is defined as the absolute value of the difference between the local model accuracy and the global model accuracy. S32. Client-side local model update: based on fairness gap Update the weight parameters of the local model on the client. ,in, These are fairness budget parameters that control the impact of fairness constraints on the updates of weight parameters, ultimately resulting in the weight parameters of the client's local model. Through normalization get: ,in, For the number of clients; S33. Update the global model: Aggregate the weighted client-side local model using the secure aggregation protocol, and update the weight parameters of the global model: Then update the global model The program broadcasts to all clients for the next round of training until the set number of training rounds for the model is reached.
[0016] This application also provides, on the other hand, a federal learning apparatus to ensure fairness in heterogeneous data, including: The client-side fairness metric calculation module is used to calculate the fairness metric and the accuracy of the local model's prediction results after each client trains its local model using local data and updates the weight parameters of the local model in each round of federated learning. The server-side fairness measurement calculation module is used by the server to calculate the global fairness index based on the global data statistics information aggregated from the clients and broadcast it to each client; The client-side model and global model iteration update module is used by each client to update the weight parameters of its local model based on the difference between the local model's fairness index and the global fairness index. Then, according to the secure aggregation protocol, the weighted local models of each client are aggregated and the server's global model weight parameters are updated and broadcast to all clients for the next round of training, until the set number of model training rounds is reached.
[0017] Furthermore, the federated learning device for ensuring fairness in heterogeneous data also includes: The system model initialization module is used to initialize the parameters of the global model located on the server, the number of model training rounds, set the initial weight parameters of the local models located on each client, and aggregate global data statistics from the client using a secure aggregation protocol.
[0018] This application also provides an electronic device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the federated learning method for ensuring fairness of heterogeneous data.
[0019] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the federated learning method for ensuring fairness of heterogeneous data.
[0020] This application also provides a computer program product, including a computer program or computer executable instructions, which, when executed by a processor, implement the federated learning method for ensuring fairness of heterogeneous data.
[0021] Compared with the prior art, this application can produce the following beneficial effects: This application uses client-side data statistics to calculate a global fairness index, which has the following advantages: 1) The server does not obtain the specific dataset content of each client, nor does it obtain the performance of each node or the specific distribution of the data. It only obtains a series of probability values, thus maintaining the decentralization of the data and avoiding the leakage of client data privacy; 2) Calculating the global fairness index through client-side data statistics can more accurately measure the performance differences of the model on different sensitive attributes, effectively reducing unfairness to certain groups and ensuring that the model's performance on global data is more balanced. This application employs a fairness-sensitive aggregation algorithm, whose advantages include: 1) In federated learning, client data distribution is typically highly heterogeneous. Dynamically adjusting weights can flexibly allocate aggregation weights according to the characteristics of client data, thus better adapting to this heterogeneity; 2) Dynamic weight adjustment can reduce the risk of unfairness caused by uneven distribution of client data. For clients with small data volumes or uneven data distribution, adjusting weights ensures that their contribution to the global model is not ignored; 3) The dynamic weight adjustment method allows clients to adopt different local debiasing strategies, increasing the flexibility of client users.
[0022] This application adopts a local model weight update method that considers group fairness. Its advantages include: 1) This method dynamically adjusts the weights of client models based on the difference between local and overall fairness, enabling the model to pay more attention to fairness during training, thereby making fairer decisions among different groups or subgroups and improving the social fairness of the model; 2) In actual federated learning, there are cases where the training data of some clients has serious bias or prejudice. This weight update method reduces the weights of these clients, and the system can effectively reduce the negative impact of such unfairness on the global model and avoid the phenomenon of "bias accumulation" during model training.
[0023] In addition to the purposes, features, and advantages described above, this application has other purposes, features, and advantages. A further detailed description of this application will be provided below with reference to the figures. Attached Figure Description
[0024] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0025] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort, wherein: Figure 1 This is a flowchart illustrating a preferred embodiment of the federated learning method for ensuring fairness in heterogeneous data in this application. Figure 2 This is a diagram illustrating the interaction between the client and the server. Figure 3 This is a diagram illustrating collaborative training between the server and multiple clients; Figure 4 This is a flowchart illustrating a federated learning method for ensuring fairness of heterogeneous data, according to another preferred embodiment of this application. Figure 5 This is a schematic diagram of a module of a federated learning device for ensuring fairness of heterogeneous data according to a preferred embodiment of this application; Figure 6 This is a schematic diagram of a module of a federated learning device for ensuring fairness of heterogeneous data according to another preferred embodiment of this application; Figure 7 This is a schematic block diagram of an electronic device according to a preferred embodiment of this application; Figure 8 This is a schematic diagram of the internal structure of a computer device according to a preferred embodiment of this application. Detailed Implementation
[0026] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0027] Terminology Explanation: Federated learning is a multi-party collaborative computing technique that allows multiple clients to jointly model and train a single model without sharing local data, thus protecting user privacy. Federated learning not only fully utilizes data resources distributed across various devices to improve model performance and generalization ability, but also fundamentally protects user privacy and avoids data leakage risks, making it suitable for applications with extremely high privacy protection requirements.
[0028] Group equity: Group equity is a crucial ethical concept in machine learning. It ensures that machine learning models are unbiased in their performance across different sensitive groups (such as gender, race, etc.), maintaining consistent performance and avoiding systemic bias or discrimination against certain groups. Achieving group equity helps improve the credibility and acceptability of models, making them more compliant with ethical and legal standards.
[0029] Secure aggregation protocol: This is a distributed computing technology used to protect privacy. Its core purpose is to allow servers to aggregate information from multiple clients in a federated learning environment, while ensuring that the server cannot access any individual client's specific data or information, thus protecting client data privacy. Even if the server obtains the aggregated global information, it cannot deduce any individual client's original data or model update details. This mechanism provides strong privacy guarantees for federated learning, enabling participants to confidently participate in the joint modeling process while protecting their own data privacy.
[0030] Data debiasing is a technique used to reduce potential biases in data, ensuring that models fairly and accurately reflect real-world conditions during training. Data bias refers to situations where data, due to factors such as collection, sample selection, or labeling errors, fails to fully represent the target group or task requirements, thus affecting model performance and fairness. Data debiasing can more accurately capture the relationships between samples and effectively reduce model bias, improving the model's generalization ability and fairness.
[0031] It should be noted that the executing entity in this embodiment can be a computing service system with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or a federated learning device capable of achieving the above functions and ensuring fairness of heterogeneous data. The following description uses a federated learning device that ensures fairness of heterogeneous data as the executing entity to illustrate this embodiment and the subsequent embodiments.
[0032] like Figure 1 As shown, to address the aforementioned technical problems, a preferred embodiment of this application provides a federated learning method for ensuring fairness in heterogeneous data, comprising the following steps: S1. In each round of federated learning, each client uses local data to train a local model, updates the weight parameters of the local model, and then calculates the fairness index of the local model and the accuracy of the prediction results of the local model. S2. The server calculates the global fairness index based on the global data statistics aggregated from the clients and broadcasts it to each client. S3. Each client updates the weight parameters of its local model based on the difference between the local model's fairness metric and the global fairness metric. Then, according to the secure aggregation protocol, the weighted local models of each client are aggregated and the server's global model weight parameters are updated and broadcast to all clients for the next round of training, until the set number of model training rounds is reached.
[0033] The system model on which this solution applies is as follows: Figure 2As shown, it includes a server and clients. Clients are participants in federated learning, responsible for training the model locally and providing the server with model weights and dataset statistics. The server is responsible for aggregating information from all clients, training a global model, and calculating a global fairness metric for updating the weights of each client's local model.
[0034] like Figure 3 As shown, multiple clients interact and collaborate with the same server. Data between clients is invisible to each other, and each client uses data from different sources with different distributions. The server also cannot obtain detailed client data, but can only obtain several probability values extracted from statistical information within the client dataset.
[0035] This embodiment provides a federated learning method to ensure fairness in heterogeneous data. Compared with existing technologies, this embodiment can produce the following beneficial effects: This embodiment uses client-side data statistics to calculate the global fairness index, which has the following advantages: 1) The server does not obtain the specific dataset content of each client, nor does it obtain the performance of each node or the specific distribution of the data. It only obtains a series of probability values. This process maintains the decentralization of data and avoids the leakage of client data privacy; 2) By calculating the global fairness index through client-side data statistics, the performance differences of the model on different sensitive attributes can be measured more accurately. This can effectively reduce unfairness to certain groups and ensure that the model's performance on global data is more balanced. This embodiment employs a fairness-sensitive aggregation algorithm, whose advantages include: 1) In federated learning, client data distribution is typically highly heterogeneous. Dynamically adjusting weights allows for flexible allocation of aggregation weights based on the characteristics of client data, thus better adapting to this heterogeneity; 2) Dynamic weight adjustment reduces the risk of unfairness caused by uneven client data distribution. For clients with small datasets or uneven data distribution, adjusting weights ensures their contribution to the global model is not ignored; 3) The dynamic weight adjustment method allows clients to adopt different local debiasing strategies, increasing the flexibility for client users.
[0036] This embodiment adopts a local model weight update method that considers group fairness. Its advantages include: 1) This method dynamically adjusts the weights of client models based on the difference between local and overall fairness, so that the model can pay more attention to fairness during training, thereby making fairer decisions among different groups or subgroups and improving the social fairness of the model; 2) In actual federated learning, there are cases where the training data of some clients has serious bias or prejudice. This weight update method reduces the weights of these clients, and the system can effectively reduce the negative impact of such unfairness on the global model and avoid the phenomenon of "bias accumulation" during model training.
[0037] Preferably, such as Figure 4 As shown, the federated learning method for ensuring fairness in heterogeneous data further includes the following steps: S0. Initialize the parameters and training rounds of the global model located on the server. n Set the initial weight parameters for the local models located on each client, and use a secure aggregation protocol on the server to aggregate global data statistics from the clients.
[0038] Specifically, step S0 includes the following steps: S01. Global Model Parameter Initialization: Use random initialization to sample randomly from a Gaussian distribution to initialize the global model parameters θ0 and set the number of training epochs. n ; S02, Initial Weight Allocation: The server assigns initial weights to each client model. ,in, It is a client The amount of data, K is the total number of clients, and the initial weights are allocated based on the proportion of each client's data volume; S03, Data Statistics Aggregation: The server uses a secure aggregation protocol to aggregate global data statistics from the client. This represents the probability that the majority of sensitive attributes in each client's dataset have positive label values, and the probability that the minority of sensitive attributes have positive label values. This statistical information is used to subsequently calculate the global fairness index, where Y represents the actual value of the dependent variable, A represents the unevenly distributed sensitive attributes, A=0 represents the category with a small percentage, and A=1 represents the category with a large percentage. It represents probability.
[0039] This embodiment achieves model initialization through steps S01-S03, which has the following advantages: 1) Protecting data privacy and achieving decentralization: The server only obtains simple statistical information such as the probability values of sensitive attribute labels of clients through a secure aggregation protocol, without obtaining the specific dataset content or data distribution of each client. This step maintains data decentralization from the source and avoids the leakage of client data privacy. 2) Providing a reasonable starting point for training: The initial weights are allocated based on the proportion of data volume of each client, providing a reasonable baseline that takes into account the data scale for subsequent federated learning.
[0040] Preferably, step S1 specifically includes the following steps: S11, Local Model Update: In each round of federated learning, each client... Use its local data For local models Train the model, update the weight parameters, and obtain the updated local model. ; S12. Calculate the local fairness metric: The client calculates the fairness metric for its local model. Among them, parameters Indicates the client's ID , The fairness index represents the result of the model prediction. It means that the difference between the probability of a wrong prediction and the probability of a right prediction is the data in each class of data with a true prediction value in the sensitive attribute. It measures the difference in the true probability of the model in different sensitive attribute groups (such as gender and race). S13. Accuracy Calculation: The client calculates the accuracy of the local model. ,in, TP To correctly predict the number of samples that are classified as positive, TN To correctly predict the number of samples that are negative, FP These are samples that were incorrectly predicted as positive (but were actually negative). FN This represents the number of samples that were incorrectly predicted as negative (but were actually positive).
[0041] This embodiment implements client-side fairness measurement calculation through steps S11-S13, and its beneficial effects include: 1) Local computation ensures privacy: Each client directly uses local data for model training and metric calculation, and the original data does not need to leave the local machine, thus completing an objective evaluation of the local model while protecting user privacy. 2) Accurately quantifies local differences: By calculating the difference between the probability of prediction errors and the probability of prediction correctness (true positive rate difference), the degree of bias of the local model on specific sensitive attribute groups (such as gender and race) can be intuitively and accurately measured, providing a reliable data foundation for subsequent dynamic adjustment of weights.
[0042] Preferably, step S2 specifically includes the following steps: S21. Calculation of Global Fairness Index: The global fairness index is calculated based on statistical information aggregated from the client. This ensures that the model training process is not affected by biases from certain clients, preventing unfair performance of the global model. This means that the overall model prediction is true. This indicates that the actual label value is true; S22, Global Fairness Broadcast: Broadcasts the calculated global fairness index to each client, allowing the client to update the weights of its local model based on the broadcast results.
[0043] This embodiment implements server-side fairness measurement calculation through steps S21-S22. Its beneficial effects include: improving the balance of global performance: by calculating the fairness index at the global level, the performance difference of the model on different sensitive attributes can be measured more accurately, effectively reducing bias in the global data distribution and ensuring that the model's performance on global data is more balanced.
[0044] Preferably, step S3 specifically includes the following steps: S31. Fairness Indicator Gap Calculation: Each client calculates its local fairness index. With global fairness indicators The gap ,in, It is the global accuracy. It is the local accuracy of client k. When the fairness metric is calculated, the difference is expressed as the absolute value of the difference between the local and global fairness metrics; otherwise, it is defined as the absolute value of the difference between the local model accuracy and the global model accuracy. S32. Client-side local model update: based on fairness gap Update the weight parameters of the local model on the client. ,in, These are fairness budget parameters that control the impact of fairness constraints on weight parameter updates. If the client's local fairness is close to global fairness, a higher weight is given; otherwise, a lower weight is given. The final weight parameters are those of the client's local model. Through normalization get: ,in, For the number of clients; S33. Update the global model: Aggregate the weighted client-side local model using the secure aggregation protocol, and update the weight parameters of the global model: Then update the global model The program broadcasts to all clients for the next training round, continuing until the set number of model training rounds is reached. n .
[0045] This embodiment achieves secure iterative collaborative updates between the client-side local model and the server-side global model through steps S31-S33. Its beneficial effects include: 1) Adapting to data heterogeneity and avoiding bias accumulation: This method dynamically adjusts weights based on the difference in fairness between local and global models. For clients with severely biased training data, their weights are reduced, effectively reducing the negative impact of unfairness on the global model and preventing bias accumulation during model training. 2) Improving model fairness: Introducing fairness constraints during weight updates allows the model to pay more attention to fairness metrics during iterative training, enabling fairer decisions among different groups or subgroups and significantly improving the system's fairness and credibility.
[0046] like Figure 5 As shown, another preferred embodiment of this application also provides a federated learning apparatus for ensuring fairness of heterogeneous data, including: The client-side fairness metric calculation module is used to calculate the fairness metric and the accuracy of the local model's prediction results after each client trains its local model using local data and updates the weight parameters of the local model in each round of federated learning. The server-side fairness measurement calculation module is used by the server to calculate the global fairness index based on the global data statistics information aggregated from the clients and broadcast it to each client; The client-side model and global model iteration update module is used by each client to update the weight parameters of its local model based on the difference between the local model's fairness index and the global fairness index. Then, according to the secure aggregation protocol, the weighted local models of each client are aggregated and the server's global model weight parameters are updated and broadcast to all clients for the next round of training, until the set number of model training rounds is reached.
[0047] The federated learning device for ensuring fairness in heterogeneous data provided in this embodiment employs the federated learning method for ensuring fairness in heterogeneous data described in the above embodiments. It addresses the technical problems of existing technologies, such as the inability to capture biases in the global data distribution, the potential for data security issues, and the inherent subjectivity in data quality assessment affecting the server-side weight aggregation results. Compared to existing technologies, the beneficial effects of the federated learning device for ensuring fairness in heterogeneous data provided in this embodiment are the same as those of the federated learning method for ensuring fairness in heterogeneous data provided in the above embodiments. Furthermore, other technical features of the federated learning device for ensuring fairness in heterogeneous data are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0048] Preferably, such as Figure 6As shown, the federated learning device for ensuring fairness in heterogeneous data also includes: The system model initialization module is used to initialize the parameters of the global model located on the server, the number of model training rounds, set the initial weight parameters of the local models located on each client, and aggregate global data statistics from the client using a secure aggregation protocol.
[0049] like Figure 7 As shown, a preferred embodiment of this embodiment also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the federated learning method for ensuring fairness of heterogeneous data in the above embodiments.
[0050] This embodiment also provides an electronic device that employs the federated learning method for ensuring fairness of heterogeneous data as described in the above embodiments. This addresses the technical problems of existing technologies, such as the inability to capture biases in the global data distribution, the potential for data security issues, and the subjectivity in data quality assessment that affects the server-side weight aggregation results. Compared with existing technologies, the beneficial effects of the electronic device provided in this embodiment are the same as those of the federated learning method for ensuring fairness of heterogeneous data provided in the above embodiments. Furthermore, other technical features of the electronic device are the same as those disclosed in the methods of the above embodiments, and will not be elaborated upon here.
[0051] like Figure 8 As shown, a preferred embodiment of this application also provides a computer device, which may be a terminal or a liveness detection server, and its internal structure diagram may be as follows. Figure 8 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with other external computer devices via a network connection. When the computer program is executed by the processor, it implements the steps of the federated learning method described above to ensure fairness in heterogeneous data.
[0052] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the solution of this embodiment, and does not constitute a limitation on the computer device to which the solution of this embodiment is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.
[0053] The computer device provided in this embodiment employs the federated learning method for ensuring fairness of heterogeneous data as described in the above embodiments. This addresses the technical problems of existing technologies, such as the inability to capture biases in the global data distribution, the potential for data security issues, and the subjective nature of data quality assessment, which affects the server-side weight aggregation results. Compared with existing technologies, the beneficial effects of the computer device provided in this embodiment are the same as those of the federated learning method for ensuring fairness of heterogeneous data provided in the above embodiments. Furthermore, other technical features in the electronic device are the same as those disclosed in the methods of the above embodiments, and will not be elaborated upon here.
[0054] A preferred embodiment of this application also provides a storage medium including a stored program that, when the program is executed, controls the device where the storage medium is located to perform the steps of the federated learning method for ensuring fairness of heterogeneous data in the above embodiments.
[0055] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0056] If the functions described in this embodiment are implemented as software functional units and sold or used as independent products, they can be stored in one or more computing device-readable storage media. Based on this understanding, the parts of this embodiment that contribute to the prior art or the technical solution can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a computing device (which may be a personal computer, server, mobile computing device, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this embodiment. The aforementioned storage media include: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.
[0057] Those skilled in the art will understand that the embodiments of this example can be provided as methods, systems, or computer program products. Therefore, this example can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this example can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code. The solutions in this example can be implemented using various computer languages, such as the object-oriented programming language C++ and the embedded programming language C.
[0058] This embodiment is described with reference to flowchart illustrations and / or block diagrams of the method, apparatus (system), and computer program product according to this embodiment. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A system that specifies functions in one or more boxes.
[0059] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including an instruction set implemented in a process. Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0060] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0061] This embodiment also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the federated learning method for ensuring fairness of heterogeneous data as described above.
[0062] The computer program product provided in this embodiment addresses the technical problems of existing technologies, such as the inability to capture biases in global data distribution, the potential for data security issues, and the subjective nature of data quality assessment affecting server-side weight aggregation results. Compared to existing technologies, the beneficial effects of the computer program product provided in this embodiment are the same as those of the federated learning method for ensuring fairness of heterogeneous data provided in the above embodiments, and will not be elaborated upon here.
[0063] Obviously, those skilled in the art can make various modifications and variations to this embodiment without departing from the spirit and scope of this embodiment. Therefore, if these modifications and variations of this embodiment fall within the scope of the claims of this embodiment and their equivalents, this embodiment is also intended to include these modifications and variations.
Claims
1. A federated learning method that ensures fairness for heterogeneous data, characterized in that, Including the following steps: S1. In each round of federated learning, each client uses local data to train a local model, updates the weight parameters of the local model, and then calculates the fairness index of the local model and the accuracy of the prediction results of the local model. S2. The server calculates the global fairness index based on the global data statistics aggregated from the clients and broadcasts it to each client. S3. Each client updates the weight parameters of its local model based on the difference between the local model's fairness metric and the global fairness metric. Then, according to the secure aggregation protocol, the weighted local models of each client are aggregated and the server's global model weight parameters are updated and broadcast to all clients for the next round of training, until the set number of model training rounds is reached.
2. The federated learning method for ensuring fairness of heterogeneous data according to claim 1, characterized in that, It also includes the following steps: S0. Initialize the parameters of the global model located on the server, the number of training rounds of the model, set the initial weight parameters of the local models located on each client, and use the secure aggregation protocol to aggregate global data statistics from the clients on the server.
3. The federated learning method for ensuring fairness of heterogeneous data according to claim 2, characterized in that, Step S0 specifically includes the following steps: S01. Global Model Parameter Initialization: Initialize the global model parameters by randomly sampling from a Gaussian distribution using a random initialization method. Set the number of training rounds for the model. ; S02, Initial Weight Allocation: The server assigns initial weights to each client model. ,in, It is a client The amount of data, K is the total number of clients, and the initial weights are allocated based on the proportion of each client's data volume; S03, Data Statistics Aggregation: The server uses a secure aggregation protocol to aggregate global data statistics from the client. This is used to represent the probability that the majority of sensitive attributes in a client's dataset have positive label values, and the probability that the minority of sensitive attributes have positive label values. Here, Y represents the actual value of the dependent variable, A represents the unevenly distributed sensitive attributes, A=0 represents the category with a smaller proportion, and A=1 represents the category with a larger proportion. It represents probability.
4. The federated learning method for ensuring fairness of heterogeneous data according to claim 3, characterized in that, Step S1 specifically includes the following steps: S11, Local Model Update: In each round of federated learning, each client... Use its local data For local models Train the model, update the weight parameters, and obtain the updated local model. ; S12. Calculate the local fairness metric: The client calculates the fairness metric for its local model. Among them, parameters Indicates the client's ID , The fairness index represents the result of the model prediction. It means that the difference between the probability of a wrong prediction and the probability of a right prediction is the data in each class of data with a true prediction value in the sensitive attribute. It measures the difference in the true probability of the model in different sensitive attribute groups. S13. Accuracy Calculation: The client calculates the accuracy of the local model. ,in, TP To correctly predict the number of samples that are classified as positive, TN To correctly predict the number of samples that are negative, FP For samples that were incorrectly predicted as positive, FN This represents the number of samples that were incorrectly predicted as negative.
5. The federated learning method for ensuring fairness in heterogeneous data according to claim 1, characterized in that, Step S2 specifically includes the following steps: S21. Calculation of Global Fairness Index: The global fairness index is calculated based on statistical information aggregated from the client. ,in, This means that the overall model prediction is true. This indicates that the actual label value is true; S22, Global Fairness Broadcast: Broadcasts the calculated global fairness index to each client, allowing the clients to update the weights of their local models based on the broadcast results.
6. The federated learning method for ensuring fairness of heterogeneous data according to claim 1, characterized in that, Step S3 specifically includes the following steps: S31. Fairness Indicator Gap Calculation: Each client calculates its local fairness index. With global fairness indicators The gap ,in, It is the global accuracy. It is the local accuracy of client k. When the fairness metric is calculated, the difference is expressed as the absolute value of the difference between the local and global fairness metrics; otherwise, it is defined as the absolute value of the difference between the local model accuracy and the global model accuracy. S32. Client-side local model update: based on fairness gap Update the weight parameters of the local model on the client. ,in, These are fairness budget parameters that control the impact of fairness constraints on the updates of weight parameters, ultimately resulting in the weight parameters of the client's local model. Through normalization get: ,in, For the number of clients; S33. Update the global model: Aggregate the weighted client-side local model using the secure aggregation protocol, and update the weight parameters of the global model. Then update the global model The program broadcasts to all clients for the next round of training until the set number of training rounds for the model is reached.
7. A federated learning device that ensures fairness in heterogeneous data, characterized in that, include: The client-side fairness metric calculation module is used to calculate the fairness metric and the accuracy of the local model's prediction results after each client trains its local model using local data and updates the weight parameters of the local model in each round of federated learning. The server-side fairness measurement calculation module is used by the server to calculate the global fairness index based on the global data statistics information aggregated from the clients and broadcast it to each client; The client-side model and global model iteration update module is used by each client to update the weight parameters of its local model based on the difference between the local model's fairness index and the global fairness index. Then, according to the secure aggregation protocol, the weighted local models of each client are aggregated and the server's global model weight parameters are updated and broadcast to all clients for the next round of training, until the set number of model training rounds is reached.
8. The federated learning apparatus for ensuring fairness of heterogeneous data according to claim 7, characterized in that, The federated learning device that ensures fairness for heterogeneous data also includes: The system model initialization module is used to initialize the parameters of the global model located on the server, the number of model training rounds, set the initial weight parameters of the local models located on each client, and aggregate global data statistics from the client using a secure aggregation protocol.
9. An electronic device, the electronic device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, when the processor executes the computer program, it implements a federated learning method for ensuring fairness of heterogeneous data as claimed in any one of claims 1 to 6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the federated learning method for ensuring fairness of heterogeneous data as described in any one of claims 1 to 6.