Client selection methods, systems, apparatus, and storage media in federated learning

By calculating the difference between the local and global models in federated learning and introducing a time factor, clients that conform to the convergence trend of the global model are selected for model aggregation. This solves the problems of slow model convergence and insufficient data security in federated learning, and achieves faster convergence and higher model performance.

CN115600691BActive Publication Date: 2026-04-10SHENZHEN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-22
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing client selection methods in federated learning result in problems such as slow model convergence, uneven performance of the global model across different clients, and insufficient user data security.

Method used

At the start of each training round, the global model is distributed from the server. After training, the client calculates the difference between the local model and the global model from the previous round. The client weights are calculated by combining hyperparameters and time factors. The k clients with the largest weights are selected to upload their local models for aggregation, and the global model is updated.

Benefits of technology

It improves the convergence speed and performance of the model, enhances the security of user data, reduces performance degradation in heterogeneous data scenarios, and improves the fairness of client selection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115600691B_ABST
    Figure CN115600691B_ABST
Patent Text Reader

Abstract

The application discloses a client selection method, system, electronic device and storage medium in federated learning, and the method comprises the following steps: at the beginning of each training round, a global model is issued to all clients from a server end; the global model is saved at the client, a local model is generated after the global model is trained using local data, and the difference degree of the local model of the current training round and the global model of the last round saved is calculated; the weight of all clients is calculated using the difference degree, a first preset hyperparameter, a second preset hyperparameter and a time factor; the local model of the k clients with the largest weight is selected and uploaded to the server, and all local models are aggregated on the server to update the global model; the application can improve the security of local data, improve the fairness of client selection in a data heterogeneous scene, and reduce the performance decline caused by data heterogeneity in federated learning.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of deep learning, and in particular to a client selection method, system and device in federated learning and a storage medium. BACKGROUND

[0002] With the rapid growth of the number of intelligent devices worldwide, the ability of devices themselves to collect and process data has been continuously improved with the progress of technology, which enables intelligent devices to collect data at an unprecedented speed and scale. In recent years, the breakthroughs of deep learning in image recognition, speech recognition and other fields benefit from these increasingly large data sets, however, most of the data collected on devices are user's private data, for the consideration of data security, we cannot directly use these private data to train the model, therefore, Google proposed the concept of federated learning based on model averaging in 2016.

[0003] Federated learning saves data locally for training, uploads the trained model to the server for aggregation, and the server then distributes the new model formed by aggregation to each client, and the client trains the model using local data. Repeat this process until the model converges. During this process, the client data is always kept locally. However, in the actual scenario of federated learning, most of the clients are smart phones, bracelets and other devices. Due to the differences in gender, age, hobbies and other factors of users, the data collected by the client devices have obvious structural differences. Part of the client data may adversely affect the convergence of the global model. In order to reduce the adverse effects of part of the client data on the aggregation of the overall model, researchers select the client that uploads the local model during the model aggregation stage, and use the local model uploaded by the client that is beneficial to the aggregation of the global model as the set of local models to be aggregated in the current round, and abandon the client model that is not beneficial to the aggregation of the global model to participate in the aggregation of the global model.

[0004] In the research process, the selection of the client that uploads the local model is generally based on the calculation and communication ability of the client, or based on the data heterogeneity of the client, or using CSFedAvg to select the client. CSFedAvg is an improvement on FedAvg based on client selection, but these methods may have one or more problems, such as the willingness of the client to participate in federated learning is reduced, and the global model cannot obtain effective information from these clients, resulting in slow convergence, some clients cannot participate in model aggregation for a long time, causing the global model trained to be extremely unbalanced on different clients, the need to collect user data may lead to insecure user data, etc. SUMMARY

[0005] The main purpose of the present application is to provide a client selection method, system, device and storage medium in federated learning, aiming to solve the problems that the existing method of selecting clients causes slow convergence of the model in federated learning, some clients cannot participate in model aggregation for a long time, causes the global model trained to be extremely unbalanced on different clients, needs to collect user data, may cause user data to be insecure and the like.

[0006] To achieve the above-mentioned purpose, the first aspect of the present application provides a client selection method, comprising: at the beginning of each training round, issuing a global model from a server to all clients; saving the global model at the client, generating a local model after training the global model using local data, and calculating the difference degree of the local model of the current training round and the global model of the last round saved; using the difference degree, a first hyperparameter, a second hyperparameter and a time factor to calculate the weight of all clients, the time factor is used to increase the probability of selecting the client which has not participated in aggregation for a long time; uploading the local model trained by the k clients with the largest weight to the server, and aggregating all local models on the server to update the global model.

[0007] Further, the method further comprises: after calculating the weight of the client, sorting the weight of all clients in the list; when uploading the local model trained by the k clients with the largest weight to the server, sequentially selecting the k clients with the largest weight from the list.

[0008] Further, the specific calculation method of the difference degree is:

[0009]

[0010] Wherein, represents the difference degree of the i-th client and the global model of the last round in the current training round t, W t-1 represents the gradient of the global model of the t-1 round, represents the model gradient of the i-th client in the t round.

[0011] Further, the specific calculation method of using the difference degree, the first hyperparameter, the second hyperparameter and the time factor to calculate the weight of the client is:

[0012]

[0013] Wherein, represents the weight of the i-th client in the t round, ω1 and ω2 are the first hyperparameter and the second hyperparameter set in advance, and T is the time factor.

[0014] Further, the local model is trained using a stochastic gradient descent method.

[0015] The second aspect of the application provides a client selection system in federated learning, comprising: a model distribution module configured to distribute a global model from a server to all clients at the beginning of each training round; a local training module configured to save the global model at the client, and generate a local model by training the global model using local data; a data calculation module configured to calculate a difference degree between the local model of the current training round and the global model of the previous training round saved; a weight calculation module configured to calculate the weights of all clients using the difference degree, a first preset hyperparameter, a second preset hyperparameter, and a time factor, the time factor being configured to increase the probability of selecting a client that has not participated in aggregation for a long time; and a model aggregation module configured to select the local models trained by the k clients with the largest weights to upload to the server, aggregate all local models at the server, and update the global model.

[0016] Further, the system further comprises: a sorting module configured to sort the weights of all clients in a list after calculating the weights of the clients; and the model aggregation module is configured to select the k clients with the largest weights from the list in turn when selecting the local models trained by the k clients with the largest weights to upload to the server.

[0017] The third aspect of the application provides an electronic device, comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the client selection method in federated learning according to any one of the above aspects when executing the computer program.

[0018] The fourth aspect of the application provides a computer readable storage medium having a computer program stored thereon, wherein the computer program is executable on a processor to implement the client selection method in federated learning according to any one of the above aspects.

[0019] The application provides a client selection method, system, device and storage medium, and has the beneficial effects that in a federated learning scenario, local data of a client is only used for training a local model, and therefore the local data does not need to be uploaded, thereby improving the security of the local data; meanwhile, in the final model aggregation stage, local models meeting the convergence trend of a global model are selectively filtered out to participate in aggregation, which is conducive to improving the performance and convergence speed of the global model; meanwhile, the client models meeting the convergence trend of the global model can be selected to participate in aggregation through overall evaluation of the convergence directions of the local models and the global model. In order to prevent overfitting, a time factor is introduced in the selection of the weights of the clients, so as to increase the probability of selection of the client models that have not been selected for a long time. In this way, the clients with extremely unbalanced data distribution can also participate in training, thereby improving the fairness of client selection in a data heterogeneous scenario and reducing the performance decline caused by data heterogeneity in federated learning. BRIEF DESCRIPTION OF DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description only constitute some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor.

[0021] Figure 1 The flowchart of the client selection method in the federated learning of the embodiment of the present application;

[0022] Figure 2 The different model accuracy diagram of the client selection method in the federated learning of the embodiment of the present application;

[0023] Figure 3 The architecture diagram of the client selection system in the federated learning of the embodiment of the present application;

[0024] Figure 4 The structural schematic block diagram of the electronic device of the embodiment of the present application. DETAILED DESCRIPTION

[0025] In order to make the application purpose, features and advantages of the present application more obvious and easy to understand, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings of the embodiments of the present application. Obviously, the described embodiments only constitute some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0026] Please refer to Figure 1A client selection method in federated learning includes:

[0027] S101. At the beginning of each training round, the global model is distributed from the server to all clients;

[0028] S102. Save the global model on the client side, train the global model using local data to generate a local model, and calculate the difference between the local model of the current training round and the saved global model of the previous round.

[0029] S103. Calculate the weights of all clients using the difference, the pre-set first hyperparameter, the second hyperparameter, and the time factor. The time factor is used to increase the probability of selecting clients that have not participated in aggregation for a long time.

[0030] S104. Select the k local models trained by the clients with the largest weights and upload them to the server. Then, aggregate all local models on the server and update the global model.

[0031] In federated learning scenarios, local models trained locally on the client side are trained using stochastic gradient descent (SGD), and then the server aggregates these local models to form a new global model. An intuitive inference is that the gradient descent direction of the global model should be continuous; that is, the gradient descent direction of the global model in the previous iteration should largely align with the gradient descent direction of the current iteration. Therefore, the closer the gradient descent direction of the local model matches the gradient descent direction of the global model, the more this local model contributes to the convergence of the global model.

[0032] Based on this inference, this embodiment uses a convergence consistency index to describe the degree of gradient descent trend of the local model and the global model. That is, based on the gradients of the global model and the local model in the current training round t, the difference between the i-th client in round t and the global model in round t-1 is calculated. Specifically, the calculation is as follows:

[0033]

[0034] in, W represents the difference between the i-th client in round t and the global model in the previous round. t-1 This represents the gradient of the global model in the (t-1)th round. This represents the model gradient of the i-th client in round t.

[0035] To ensure that clients with extremely imbalanced data distributions can also participate in model aggregation, this embodiment introduces a time factor T to increase the probability of these client models being selected. Finally, this embodiment selects client models for aggregation based on the weight ω calculated using Formula 2. Formula 2 is as follows:

[0036]

[0037] wherein, represents the weight of the i-th client in the t-th round, ω1 and ω2 are the first and second preset hyperparameters, and T is a time factor.

[0038] In one embodiment, after calculating the weights of the clients, the weights of all the clients in the list are sorted; when the k clients with the smallest weights are selected to participate in model aggregation, the k clients with the smallest weights are sequentially selected from the list.

[0039] In this embodiment, the list used can be the weight list.

[0040] In summary, in the federated learning scenario, the data distribution of the client is an important factor affecting the overall model performance. Conditionally filtering the local model that meets the global model convergence trend to participate in aggregation in the model aggregation stage is conducive to the performance improvement and convergence speed of the global model. In this embodiment, the client model that meets the global model convergence trend is selected to participate in aggregation through overall evaluation of the convergence direction of the local model and the global model. However, this may cause some excellent models to always participate in aggregation, resulting in overfitting. In order to prevent the occurrence of overfitting, a time factor is introduced in the selection of the weight of the client to increase the probability of selection of the client model that has not been selected for a long time. In this way, the client with extremely unbalanced data distribution can also participate in training, which is not considered in other federated learning client selection algorithms.

[0041] Therefore, the client selection method in federated learning provided by the embodiment of the present application has the following advantages: in the federated learning scenario, the local data of the client is only used for training the local model by the client, so the local data does not need to be uploaded, thereby improving the security of the local data; meanwhile, the local model that meets the global model convergence trend is conditionally filtered to participate in aggregation in the final model aggregation stage, which is conducive to the performance improvement and convergence speed of the global model; meanwhile, the client model that meets the global model convergence trend can be selected to participate in aggregation through overall evaluation of the convergence direction of the local model and the global model. In order to prevent the occurrence of overfitting, a time factor is introduced in the selection of the weight of the client to increase the probability of selection of the client model that has not been selected for a long time. In this way, the client with extremely unbalanced data distribution can also participate in training, thereby improving the fairness of client selection in the data heterogeneous scenario and reducing the performance decline caused by data heterogeneity in federated learning.

[0042] In this embodiment, in order to verify the performance of the client selection method in federated learning in the data heterogeneous scene of federated learning, the CIFAR10 dataset is used, the dataset is manually divided onto the clients, it is ensured that the data distribution on each client is non-identically distributed, the overall training round is 700 rounds, and the experimental results are as shown in Figure 2 FIG. 1, wherein model 1 is a FedAvg algorithm, model 2 is a CSFedAvg algorithm, and model 3 is a C-T CS algorithm.

[0043] Because the model performance of federated learning fluctuates greatly in the non-identically distributed scene, the model performance cannot be intuitively evaluated from the figure, so this embodiment gives the experimental data in Table 1. As shown in the following table:

[0044] Table 1: Experimental results in the non-identically distributed scene

[0045] Algorithm Top 1 accuracy Top 5 average accuracy Accuracy average of last 200 rounds Accuracy variance of last 200 rounds FedAvg 68.6% 68.4% 61.16% 1.24 CSFedAvg 67.9% 67.36% 62.53% 4.16 CT-CS 72.7% 72.08% 68.75% 0.21

[0046] It can be seen from the data in Table 1 that the performance of the algorithm proposed in this embodiment is 4.1% higher than that of the FedAvg algorithm and 4.8% higher than that of the CSFedAvg algorithm in Top1 accuracy on the CIFAR10 dataset. It is 3.68% higher than the FedAvg algorithm and 4.72% higher than the CSFedAvg algorithm in Top5 average accuracy. In order to describe the experimental results of different algorithms on the model, the average value and variance of the accuracy of the last 200 rounds are used to evaluate the algorithm performance, and it can be seen from Figure 2 After 500 rounds of iteration, the model has converged, so the model performance of the last 200 rounds is compared. It can be seen from Table 1 that the algorithm used in this embodiment is superior to the FedAvg and CSFedAvg algorithms in terms of accuracy and stability. The experiment on the CIFAR10 dataset verifies the effectiveness of the algorithm proposed in this embodiment.

[0047] Please refer to Figure 3The embodiment of the application also provides a client selection system in federated learning, comprising a model issuing module 1, a local training module 2, a data calculation module 3, a weight calculation module 4 and a model aggregation module 5; the model issuing module 1 is used for issuing a global model from a server end to all clients at the beginning of each training round; the local training module 2 is used for saving the global model at the client, and generating a local model after training the global model using local data; the data calculation module 3 is used for calculating the difference degree of the local model of the current training round and the saved global model of the last round; the weight calculation module 4 is used for calculating the weights of all clients using the difference degree, a first preset hyperparameter, a second preset hyperparameter and a time factor, and the time factor is used for increasing the probability of selection of a client that has not participated in aggregation for a long time; and the model aggregation module 5 is used for uploading the local models trained by the k clients with the largest weights to the server, and aggregating all the local models at the server to update the global model.

[0048] In one embodiment, the client selection system in federated learning further comprises a sorting module, which is used for sorting the weights of all clients in a list after calculating the weights of the clients.

[0049] When the model aggregation module 5 selects the local models trained by the k clients with the largest weights to upload to the server, the k clients with the largest weights are sequentially selected from the list.

[0050] When the client selection module 6 selects the k clients with the smallest weights to participate in model aggregation, the k clients with the smallest weights are sequentially selected from the list.

[0051] In one embodiment, the specific calculation method of the data calculation module 3 for calculating the difference degree is as follows:

[0052]

[0053] wherein, represents the difference degree of the i th client and the global model of the last round in the t th training round, W t-1 represents the gradient of the global model of the t-1 th round, represents the model gradient of the i th client in the t th round.

[0054] In one embodiment, the specific calculation method of the weight calculation module 4 is as follows:

[0055]

[0056] wherein, represents the weight of the i th client in the t th round, ω 1 and ω 2 are the first preset hyperparameter and the second preset hyperparameter, and T is the time factor.

[0057] In one embodiment, the local training module 2 trains the local model using a stochastic gradient descent method.

[0058] Therefore, the client selection system in federated learning provided by the embodiments of the present application can improve the security of local data in the federated learning scenario, because the local data of the client is only used for training the local model of the client, and thus the local data does not need to be uploaded. Meanwhile, the performance of the global model is improved and the convergence speed is increased by conditionally selecting the local models that meet the convergence trend of the global model to participate in the aggregation in the final model aggregation stage. In addition, the client models that meet the convergence trend of the global model can be selected to participate in the aggregation by overall evaluation of the convergence directions of the local models and the global model. In order to prevent overfitting, a time factor is introduced in the weight of the selected client, so as to increase the probability of selecting the client model that has not been selected for a long time. In this way, the client with extremely unbalanced data distribution can also participate in the training, so as to improve the fairness of the client selection in the data heterogeneous scenario and reduce the performance decline caused by data heterogeneity in federated learning.

[0059] The embodiments of the present application provide an electronic device, please refer to Figure 4 The electronic device includes a memory 601, a processor 602, and a computer program stored in the memory 601 and executable on the processor 602. When the processor 602 executes the computer program, the client selection method in federated learning described in the foregoing is implemented.

[0060] Further, the electronic device further includes at least one input device 603 and at least one output device 604.

[0061] The memory 601, the processor 602, the input device 603, and the output device 604 are connected through a bus 605.

[0062] The input device 603 can be a camera, a touch panel, a physical button, or a mouse, etc. The output device 604 can be a display screen.

[0063] The memory 601 can be a high-speed random access memory (RAM, Random Access Memory) or a non-volatile memory such as a disk memory. The memory 601 is used to store a set of executable program codes, and the processor 602 is coupled with the memory 601.

[0064] Further, the embodiment of the present application further provides a computer readable storage medium, which can be arranged in the electronic device in the above-mentioned embodiments, and can be the memory 601 in the foregoing. The computer readable storage medium has a computer program stored thereon, and the program is executed by the processor 602 to realize the client selection method in the federated learning described in the foregoing embodiments.

[0065] Further, the computer readable storage medium can also be a U disk, a mobile hard disk, a read-only memory 601 (ROM, Read-Only Memory), a RAM, a magnetic disk or an optical disk, and various media that can store program codes.

[0066] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and the division of the modules is merely a logical function division, and there can be another division manner in actual implementation, for example, a plurality of modules or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection can be indirect coupling or communication connection through some interfaces, apparatuses or modules, and can be electrical, mechanical or other forms.

[0067] The modules illustrated as separated components can or can not be physically separated, and the components illustrated as modules can or can not be physical modules, that is, can be located in one place, or can be distributed to a plurality of network modules. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment scheme.

[0068] In addition, each functional module in each embodiment of the present application can be integrated in one processing module, or each module can be physically present alone, or two or more modules can be integrated in one module. The integrated module can be realized in the form of hardware or in the form of a software functional module.

[0069] The integrated module, if implemented in the form of a software function module and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art, or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various program code storage media.

[0070] It should be noted that, for the foregoing method embodiments, in order to facilitate description, they are all expressed as a combination of a series of actions, but those skilled in the art should know that the present application is not limited by the order of the described actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily essential to the present application.

[0071] In the above embodiments, the description of each embodiment has its own emphasis, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0072] The above is a description of a client selection in federated learning, a system, an electronic device and a storage medium provided by the present application. For those skilled in the art, according to the idea of the embodiments of the present application, there will be changes in specific implementation and application range. In conclusion, the content of the specification should not be understood as a limitation of the present application.

Claims

1. A method for client selection in federated learning, comprising: The method comprises: at the beginning of each round of training, distributing a global model from the server side to all clients; saving the global model at the client side, generating a local model after training the global model using local data, and calculating the difference between the local model of the current training round and the saved global model of the last round; using the difference, a first pre-set hyperparameter, a second pre-set hyperparameter, and a time factor to calculate the weight of all clients, wherein the time factor is used to increase the probability of selecting a client that has not participated in aggregation for a long time; selecting the local models of the k clients with the largest weights to upload to the server, aggregating all local models on the server, and updating the global model; wherein the specific calculation method of the difference is: wherein, represents the difference degree of the i-th client in the current training round t and the last round global model, represents the gradient of the t-1 round global model, represents the model gradient of the i-th client in the t round; the specific calculation method of using the difference, the first pre-set hyperparameter, the second pre-set hyperparameter, and the time factor to calculate the weight of the client is: wherein, represents the weight of the i-th client in the t-th round, and are a first hyper-parameter and a second hyper-parameter set in advance, and T is a time factor.

2. The client selection method in federated learning according to claim 1, wherein, the method further comprises: after calculating the weight of the client, sorting the weights of all clients in a list; when selecting the local models of the k clients with the largest weights to upload to the server, sequentially selecting the k clients with the largest weights from the list.

3. The client selection method in federated learning according to claim 1, wherein, the local model is trained using the stochastic gradient descent method. 4.A client selection system in federated learning, characterized in that, The method comprises: a model distribution module, configured to distribute a global model from the server side to all clients at the beginning of each round of training; a local training module, configured to save the global model at the client side, and generate a local model after training the global model using local data; a data calculation module, configured to calculate the difference between the local model of the current training round and the saved global model of the last round; wherein the specific calculation method of the difference is: wherein, represents the difference degree of the i-th client and the last round global model in the current training round t, represents the gradient of the t-1 round global model, represents the model gradient of the i-th client in the t round. a weight calculation module, configured to use the difference, a first pre-set hyperparameter, a second pre-set hyperparameter, and a time factor to calculate the weight of all clients, wherein the time factor is used to increase the probability of selecting a client that has not participated in aggregation for a long time; wherein the specific calculation method of using the difference, the first pre-set hyperparameter, the second pre-set hyperparameter, and the time factor to calculate the weight of the client is: wherein, represents the weight of the i-th client in the t-th round, and are a first hyper-parameter and a second hyper-parameter set in advance, and T is a time factor. a model aggregation module, configured to select the local models of the k clients with the largest weights to upload to the server, aggregate all local models on the server, and update the global model.

5. The client selection system in federated learning according to claim 4, wherein, the system further comprises: a sorting module, configured to sort the weights of all clients in a list after calculating the weight of the client; when the model aggregation module selects the local models of the k clients with the largest weights to upload to the server, the model aggregation module sequentially selects the k clients with the largest weights from the list.

6. An electronic device comprising: A memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the computer program, the method of any one of claims 1 to 4 is implemented.

7. A computer-readable storage medium having stored thereon a computer program, characterized in that The computer program, when executed by the processor, implements the method of any one of claims 1 to 4.

Citation Information

Patent Citations

  • Model update amount aggregation method for eliminating dynamic available deviation of terminal

    CN112101568A

  • Federal learning method and system for adaptive client parameter updating and storage medium

    CN114528304A