A federated learning method based on device training time fairness
By introducing device selection and model aggregation methods with training time fairness constraints, the problems of volatile device computing resources and unbalanced datasets in federated learning are solved, achieving balanced device training and improved model robustness.
Patent Information
- Application Number
- CN202211422679.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2042-11-15
AI Technical Summary
In federated learning, the computational resources of devices are volatile and the datasets are not independent and identically distributed, resulting in uneven training time and affecting training efficiency. Furthermore, device selection and model aggregation methods have failed to effectively address these issues.
A device selection method with training time fairness constraints is introduced. Devices are selected through virtual queues and predicted training time, and the weight of devices that are selected less often is increased during model aggregation, ensuring that all devices have a chance to participate in training and improving their contribution to model aggregation.
This achieves fairness in device training time, reduces the participation of devices with long training times, increases the contribution of devices that are selected less often in the model, and improves the robustness and training efficiency of the model.
Smart Images

Figure CN115713128B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of federated learning, and particularly to a federated learning method based on device training time fairness. BACKGROUND
[0002] In recent years, the number of mobile devices has grown rapidly, and their sensing and computing capabilities have become increasingly powerful, and the amount of data they carry has also increased. If these dispersed data can be fully utilized, it can promote the further development of machine learning applications. However, traditional centralized machine learning requires data to be centralized in cloud servers or data centers, which has attracted widespread public attention due to the potential for privacy leakage. Therefore, a new machine learning paradigm called federated learning has been introduced to try to solve this problem. In federated learning, the server selects devices to participate in training each round, the selected devices download the global model from the server, then train on local data, and upload the model to the server after training is completed. The server collects all the models uploaded by the selected devices and performs model aggregation to generate a new global model, and this cycle continues until the requirements of the federated learning task are met. Federated learning ensures that data remains on the terminal device during training, which can ensure user privacy and security and obtain an efficient model.
[0003] However, in actual federated learning scenarios, the computing resources of devices do not always remain in the best state, and the data sets on each device are non-identically distributed and unbalanced, which will affect the local training time. Moreover, users usually do not want to provide information about the computing power and network environment of their devices. At the same time, due to the large number of devices in the Internet of Things, in order to reduce the impact of unstable network environment and device dropout, federated learning usually selects only a part of devices to participate in training each round, and the device selection method will affect the training time. In addition, the role of model aggregation in federated learning cannot be ignored. Recently, some research has begun to focus on the problem of non-identically distributed and unbalanced data sets on devices in federated learning, but they ignore the influence of variable computing resources of devices. Therefore, a device selection and model aggregation method that takes into account the non-identically distributed and unbalanced data sets on devices and the variable computing resources of devices is the demand of federated learning in actual scenarios. SUMMARY
[0004] The present application aims to overcome the shortcomings and deficiencies of the prior art, and proposes a federated learning method based on device training time fairness, which includes a device selection method that ensures training time fairness from a long-term perspective, and a model aggregation method that cooperates with the device selection method. For the device selection method, the goal is to minimize the total training time of federated learning, and a training time fairness constraint is introduced for device selection. For the model aggregation method, the main purpose is to cooperate with the device selection method and increase the weight of devices that are selected less frequently in the model aggregation formula during model aggregation.
[0005] To achieve the above objectives, the technical solution provided by this invention is: a federated learning method based on device training time fairness, comprising the following steps:
[0006] 1) System initialization: The federated server determines the federated learning task, generates the global model and system parameters, registers all devices and notifies them of the training task and system parameters;
[0007] 2) Equipment selection: The federated server selects a subset of devices to participate in training based on the equipment selection method;
[0008] 3) Local model training: The selected device downloads the global model from the federation server, trains the global model on local data, and sends the trained global model back to the federation server after training is complete.
[0009] 4) Model aggregation: After receiving the global models sent back by all the selected devices, the federation server aggregates these global models according to the model aggregation method to obtain a new global model;
[0010] 5) Determine if the task is completed: The federated server determines whether the current federated learning task is completed. If not, it returns to step 2) to continue the task. If completed, the current federated learning task ends.
[0011] Furthermore, in step 1), the detailed process of system initialization is as follows:
[0012] 1.1) The federated server determines the federated learning task and basic settings: First, the federated server determines the training task for this federated learning; then, the federated server selects a suitable machine learning model based on the task. The federated server serves as the initial global model and determines the model-related hyperparameters; finally, it determines the system parameters (T, acc). g ,K,α,β), where T is the preset number of training rounds, acc g α is the target accuracy of the global model, K is the proportion of devices selected in each round, α is the fairness constraint parameter for training time, specifically the average training time allocated to each device per round, β is a parameter that can be set in the device selection method, and T and acc are also relevant. g Used to determine whether a federated learning task has been completed;
[0013] 1.2) Device registration via the federated server: All devices register with the federated server, which stores a set of device information for each device. There is a total of I devices, of which D i It is the dataset of device i, |D i | is the size of the dataset for device i, s iThis represents the number of times device i has been selected to participate in training, and t is used to index the round, t = 1, 2, 3, ..., T. It is the set of actual training times for device i in each round. This is the current training time of device i as predicted by the federated server. It is a set of virtual queue lengths for each round, used to assist the federated server in achieving fair device selection based on device training time; among them, This is the initial training time for device i. This is the training time for device i in the Tth round. This is the initial virtual queue value for device i. It is the virtual queue value of device i in the Tth round. and The initial values are all 0; at the same time, all devices receive training tasks and system parameters from the federated server.
[0014] Furthermore, in step 2), the federated server selects a subset of devices to participate in this round of training, including the following steps:
[0015] 2.1) Assuming this round is round t, for all devices, the federated server... Update the virtual queue value of device i for this round, according to The score of the computing device in this round i Value, of which, and These are the virtual queue values for device i in round (t-1) and round t, respectively, and score. i This is the metric used by the federal server to evaluate whether device i is selected in each round;
[0016] 2.2) The federated server initializes an empty priority queue PQ. The priority queue is sorted in descending order of the score value of each device. The score is the metric used by the federated server to evaluate whether each device is selected in each round. The maximum training time of the devices in the priority queue is denoted as... The sum of the scores of all devices in the priority queue is denoted as score. pq The goal is to find K devices such that their sum is minimized, where sum is determined by... To calculate;
[0017] 2.3) Arrange all devices according to the predicted training time. Sort by size from smallest to largest;
[0018] 2.4) Traverse the sorted devices. For each device, the detailed processing procedure is as follows: First, save a copy of PQ as PQ. old ,save The copy is Next, push the currently processed device i into the priority queue PQ, and simultaneously use... renew Then, check if the number of devices in the priority queue PQ exceeds K. If it does not exceed K, end the operation; if it exceeds K, remove the head device of PQ and calculate the current sum value, denoted as sum. tmp Next, determine whether the removed device is the current device i or sum. tmp If the value is greater than sum, then the device is not suitable for selection; use a copy of PQ. old Restore PQ, use a copy recover If not, no recovery operation will be performed; finally, use sum. tmp Update sum; follow the detailed processing steps described above until all devices have been traversed;
[0019] 2.5) All devices in the priority queue PQ are the devices selected in this round; the set of devices selected in this round is denoted as A. t The number of times the selected device i is selected to participate in training (s) i Add 1.
[0020] Furthermore, in step 3), the selected device performs model training locally, including the following steps:
[0021] 3.1) Assuming this round is round t, the selected device i downloads the global model from the federated server.
[0022] 3.2) Device i uses a global model Machine learning training is performed on a local dataset;
[0023] 3.3) Device i will train the global model. Uploaded to the federal server.
[0024] Furthermore, in step 4), the federated server performs model aggregation, including the following steps:
[0025] 4.1) Assume this round is round t, and the federated server is waiting for the set of devices A to be selected. t When device i submits its model to the global server, the federated server records the total time spent by device i in this round. In addition, the total time spent by the unselected devices is recorded as -1;
[0026] 4.2) After receiving all the global models, the federated server performs model aggregation, first based on... Selection coefficient of computing device i Among them, s maxis the selected times of the largest device, is the average of the selected times of all devices; then according to Calculate the new global model
[0027] 4.3) The federal server also needs the predicted training time of each device and the virtual queue value The and are the same as the previous round; for the predicted training time The federal server updates the predicted training time of device i by taking the average of the last M non-1 historical training times, and if there are less than M, it calculates the average of the corresponding number; for the virtual queue value The federal server updates the virtual queue value of device i according to .
[0028] Further, in step 5), assuming this round is the t-th round, the federal server judges whether the current federal learning task is completed, which can be achieved by judging whether the preset training round T is reached, or judging whether the global model reaches the target accuracy acc of the federal learning task g If not, return to step 2) to continue training; if it is reached, the federal learning task is completed.
[0029] Compared with the prior art, the present application has the following advantages and beneficial effects:
[0030] 1. The present application introduces a training time fairness constraint to design a device selection method, which ensures that each device has a certain training time from a long-term perspective, allowing each device to participate in training, while limiting the participation of devices with long training times, preventing excessive training time.
[0031] 2. The present application considers the number of times a device is selected to improve the model aggregation method, which is compatible with the device selection method of the present application. Specifically, the weight of devices with fewer selection times is increased in model aggregation, indirectly improving the participation of devices with fewer selection times, making the final model more robust.
[0032] 3. The present application estimates the training time of a device by the last M training times, making the predicted training time closer to the current cycle device usage, while not requiring the device to submit its own network information and computing information, making it more secure and easier to implement. BRIEF DESCRIPTION OF DRAWINGS
[0033] Figure 1 is the logical flowchart of the method of the present application.
[0034] Figure 2 An application architecture diagram of the method of the present application. DETAILED DESCRIPTION
[0035] The present application will be further described in conjunction with the embodiments and the accompanying drawings, but the embodiments of the present application are not limited thereto.
[0036] The embodiment provides a federated learning method based on device training time fairness, which includes a device selection method and a model aggregation method. For the device selection method, the device selection is performed with the objective of minimizing the total training time of the federated learning, and the total training time of all participating devices is also considered to be close, so that a fairness constraint of device training time is introduced to assist in realizing the device selection; for the model aggregation method, the contribution of the device with less selection times to the global model is considered to be increased, so that the aggregation weight of the device with less selection times in the model aggregation formula is improved. In addition, considering that the device may not be willing to provide its computing power and network environment and other privacy information, the mean of the historical training time is used as the prediction of the training time.
[0037] As shown in Figure 1 , first, the federated server initializes the system, determines the federated learning task, generates the global model, and determines the system parameters; the devices participating in the federated learning are registered to the federated server, and the federated learning task and the system parameters are obtained.
[0038] Secondly, the federated server selects the devices by means of the virtual queue and the predicted device training time, selects the appropriate devices to participate in each round of federated learning training; the selected devices download the global model from the federated server, train on the local data, and send the model back to the federated server after the training is completed; after the federated server receives the models sent back by all the selected devices in this round, the model aggregation method is used to aggregate the models to obtain a new global model.
[0039] Finally, the federated server judges whether the federated learning task is completed, if not, the above process is cycled until the federated learning task is completed, if yes, the present federated learning is ended.
[0040] As shown in Figures 1-2 , the above federated learning method based on device training time fairness includes the following steps:
[0041] 1) System initialization: the federated server determines the federated learning task, generates the global model and the system parameters, registers all the devices and notifies the training task and the system parameters; wherein, the detailed process of the system initialization is as follows:
[0042] 1.1) The federated server determines the federated learning task and basic settings: First, the federated server determines the training task for this federated learning; then, the federated server selects a suitable machine learning model based on the task. The federated server serves as the initial global model and determines the model-related hyperparameters; finally, it determines the system parameters (T, acc). g ,K,α,β), where T is the preset number of training rounds, acc g The target accuracy of the global model is given by K, the proportion of devices selected in each round is given by α, the fairness constraint parameter for training time refers to the average training time allocated to each device per round, β is a parameter that can be set in the device selection method of this invention, and T and acc are also given. g Used to determine whether a federated learning task has been completed;
[0043] 1.2) Device registration via the federated server: All devices register with the federated server, which stores a set of device information for each device. There is a total of I devices, of which D i It is the dataset of device i, |D i | is the size of the dataset for device i, s i This represents the number of times device i has been selected to participate in training, and t is used to index the round, t = 1, 2, 3, ..., T. It is the set of actual training times for device i in each round. This is the current training time of device i as predicted by the federated server. It is a set of virtual queue lengths for each round, used to assist the federated server in achieving fair device selection based on device training time; among them, This is the initial training time for device i. This is the training time for device i in the Tth round. This is the initial virtual queue value for device i. It is the virtual queue value of device i in the Tth round. and The initial values are all 0; at the same time, all devices receive training tasks and system parameters from the federated server.
[0044] 2) Device Selection: The federated server selects a subset of devices to participate in training according to the device selection method; the selection of devices by the federated server for this round of training includes the following steps:
[0045] 2.1) Assuming this round is round t, for all devices, the federated server... Update the virtual queue value of device i for this round, according to The score of the computing device in this round i Value, of which, and These are the virtual queue values for device i in round (t-1) and round t, respectively, and score. i This is the metric used by the federal server to evaluate whether device i is selected in each round;
[0046] 2.2) First, the federated server initializes an empty priority queue PQ. The priority queue is sorted in descending order of the score value of each device. The score is the metric used by the federated server to evaluate whether each device is selected in each round. The maximum training time of the devices in the priority queue is denoted as... The sum of the scores of all devices in the priority queue is denoted as score. pq Our goal is to find K devices that minimize their sum, where sum is determined by... To calculate;
[0047] 2.3) Next, all devices will be trained according to the predicted time. Sort by size from smallest to largest;
[0048] 2.4) Then, we iterate through the sorted devices. For each device, our detailed processing procedure is as follows: First, we save a copy of PQ as PQ. old ,save The copy is Next, push the currently processed device i into the priority queue PQ, and simultaneously use... renew Then, check if the number of devices in the priority queue PQ exceeds K. If it does not exceed K, end the operation; if it exceeds K, remove the head device of PQ and calculate the current sum value, denoted as sum. tmp Next, determine whether the removed device is the current device i or sum. tmp If the value is greater than sum, then the device is not suitable for selection; use a copy of PQ. old Restore PQ, use a copy recover If not, no recovery operation will be performed. Finally, use sum. tmp Update sum; follow the detailed processing steps described above until all devices have been traversed;
[0049] 2.5) Finally, all devices in the priority queue PQ are the devices selected in this round; the set of devices selected in this round is denoted as A. t The number of times the selected device i is selected to participate in training (s) i Add 1.
[0050] 3) Local model training: The selected device performs local model training, including the following steps:
[0051] 3.1) Assume that this round is the tth round, the selected device i downloads the global model from the federal server
[0052] 3.2) Device i uses the global model Conduct machine learning training on the local data set;
[0053] 3.3) Device i uploads the trained global model to the federal server.
[0054] 4) Model aggregation: after the federal server receives the models sent back by all selected devices, the models are aggregated according to the model aggregation method to obtain a new global model; wherein the model aggregation includes the following steps:
[0055] 4.1) Assume that this round is the tth round, the federal server waits for the devices in the selected device set A t Upload the global model, when device i submits the model, the federal server records the total time spent by device i in this round In addition, the total time spent by the unselected devices is recorded as -1;
[0056] 4.2) After the federal server receives all the global models, it performs model aggregation, first calculates the selection frequency coefficient of device i according to Where s max is the maximum selection frequency of the device, is the average selection frequency of all devices; then calculate the new global model
[0057] 4.3) The federal server also needs the predicted training time and the virtual queue value of each device and of the unselected devices in this round are the same as those in the previous round; for the predicted training time The federal server takes the average of the last M non-1 historical training times of device i to update the predicted training time, and calculates the average of the corresponding number if there are less than M; for the virtual queue value The federal server updates the virtual queue value of device i according to
[0058] 5) Determine whether to end the task: the federal server determines whether to complete this federated learning task, the detailed process is as follows:
[0059] Assuming that the current round is the t-th round, the federal server determines whether the current federated learning task is completed, which can be determined by judging whether the preset training round T is reached or whether the global model reaches the target accuracy acc of the federated learning task g If the requirement is not reached, return to step 2) to continue training; if the requirement is reached, the federated learning task is completed.
[0060] Federal server: determine the federated learning task, determine the global model and related hyperparameters, generate system necessary parameters, determine the devices participating in federated learning, and send the relevant information of the federated learning task to each device.
[0061] Device: has certain data and computing power, the selected device in each round downloads the global model from the federal server, trains on the local data set, and sends the model back to the federal server after training.
[0062] In summary, the present application is a federated learning method based on device training time fairness. The federal server initializes the system, determines the federated learning task, determines the global model and related hyperparameters, and determines the system parameters; the devices participating in federated learning register with the federal server and obtain the relevant information of the federated learning task; the federal server selects devices by means of a virtual queue and predicted device training time to select appropriate devices to participate in each round of federated learning training; the selected devices download the global model from the federal server, train on the local data, and send the model back to the federal server after training; the federal server receives the models sent back by all selected devices in the current round, and uses a model aggregation method to aggregate the models to obtain a new global model; the federal server determines whether the federated learning task is completed, and if not, the above process is repeated until the federated learning task is completed; if the federated learning task is completed, the current federated learning is ended.
[0063] The above embodiments are the preferred embodiments of the present application, but the embodiments of the present application are not limited by the above embodiments, and any changes, modifications, substitutions, combinations, simplifications made without departing from the spirit and principles of the present application are equivalent replacement methods and are included in the protection scope of the present application.
Claims
1. A federated learning method based on device training time fairness, characterized in that, Comprising the following steps: 1) System initialization: the federal server determines the federal learning task, generates a global model and system parameters, registers all devices and informs them of the training task and system parameters; 2) Device selection: the federal server selects part of the devices to participate in training according to a device selection method, comprising the following steps: 2.1) Assuming this round is round t, for all devices, the federated server... Update the virtual queue value for device i in this round. α is the fairness constraint parameter for training time, specifically referring to the average training time allocated to each device per round, based on... The score of the computing device in this round i Value, of which, This is the current training time of device i as predicted by the federated server. and These are the virtual queue values for device i in round (t-1) and round t, respectively, and score. i This is the metric used by the federal server to evaluate whether device i is selected in each round; 2.2) The federation server initializes an empty priority queue PQ, which is ordered by the score of each device from large to small, score is a metric that the federation server evaluates whether each device is selected in each round, the maximum training time of the devices in the priority queue is recorded as The sum of the scores of all devices in the priority queue is recorded as score pq The goal is to find K' devices so that their sum value is the smallest, where sum is calculated according to β is a parameter that can be set in the device selection method; 2.3) Train all devices for the predicted training time Sort from small to large; 2.4) Traverse the sorted devices, for each device, the detailed process is as follows: first, save a copy of PQ as PQ old , save a copy of as Next, push the current processing device i into the priority queue PQ, and update using Then, judge whether the devices in the priority queue PQ exceed K' or not, if not, end this operation; if yes, remove the head device of PQ and calculate the current sum value as sum tmp , then judge whether the removed device is the current device i or sum tmp is greater than sum, if yes, it means that the device is not suitable to be selected, use the copy PQ old to restore PQ, use the copy to restore If not, do not restore; finally, update sum using sum tmp ; according to the above detailed processing process until all devices are traversed; 2.5) All devices in the priority queue PQ are selected in this round; the set of selected devices in this round is denoted as A t The number of times the selected device i is selected to participate in training s i Increment 1; 3) Local model training: the selected devices download the global model from the federal server, then train the global model on local data, and send the trained global model back to the federal server after training is completed; 4) Model aggregation: after the federal server receives the global models sent back by all selected devices, it aggregates these global models according to a model aggregation method to obtain a new global model; 5) Determine whether the task is completed: the federal server determines whether the current federal learning task is completed, if not, return to step 2) to continue the task, if yes, end the current federal learning task.
2. The federated learning method based on device training time fairness according to claim 1, characterized in that, In step 1), the detailed process of system initialization is as follows: 1.1) The federal server determines the federal learning task and basic settings: first, the federal server determines the training task of this federal learning; then, the federal server selects a suitable machine learning model according to the task as the initial global model and determines the model-related hyperparameters; finally, the federal server determines the system parameters (T, acc g , K, a, b), wherein T is the preset training round, acc g is the target accuracy of the global model, K is the proportion of devices selected per round, and T and acc g are used to determine whether the federal learning task is completed; 1.2) Federal server performs device registration: all devices register to the federal server, which saves a set of device information for each device i There are I devices, where, D i is the data set of device i, |D i | is the data set size of device i, s i is the number of times device i is currently selected to participate in training, t is used to index the round, t = 1, 2, 3,..., T, is the real training time set of device i per round, is the set of virtual queue lengths per round, the virtual queue is used to assist the federal server to realize the device selection based on the training time fairness of the device; wherein, is the initial training time of device i, is the training time of device i in the Tth round, is the initial virtual queue value of device i, is the virtual queue value of device i in the Tth round, and The initial values of and are 0; at the same time, all devices receive training tasks and system parameters from the federal server.
3. The federated learning method based on device training time fairness according to claim 2, characterized in that, In step 3), the selected devices perform local model training, comprising the following steps: 3.1) Assume this round is the t-th round, the selected device i downloads the global model from the federated server 3.2) Device i uses global model Machine learning training on local dataset; 3.3) Device i uploads the trained global model to the federation server. 4. The federated learning method based on device training time fairness according to claim 3, characterized in that, In step 4), the federal server performs model aggregation, comprising the following steps: 4.1) Assume this round is the t-th round, the federated server waits for the selected device set A t to upload the global model, when device i submits the model, the federated server records the total time spent by device i in this round Moreover, the total time spent by the unselected devices is recorded as -1; 4.2) After the federal server receives all the global models, it proceeds to model aggregation, first according to The selection frequency coefficient of the computing device i where s max is the selection frequency of the largest device, is the average selection frequency of all devices; then according to The new global model is calculated 4.3) The federal server also needs to re-compute the predicted training time for each device and the virtual queue value The devices that are not selected in this round and are the same as in the previous round; for the predicted training time The federal server updates the predicted training time for device i by taking the average of the last M non-1 historical training times for device i, and if there are less than M, then take the average of the corresponding number; for the virtual queue value The federal server updates the virtual queue value for device i according to .
5. The federated learning method based on device training time fairness according to claim 4, characterized in that, In step 5), assuming that the current round is the t-th round, the federal server judges whether the current federated learning task is completed, which can be achieved by judging whether the preset training round T is reached or whether the global model reaches the target accuracy acc of the federated learning task g If the requirement is not reached, return to step 2) to continue training; if the requirement is reached, the federated learning task is completed.