Federal learning method and device based on dynamic sub-model, medium and equipment
By constructing sub-models with different neuron sizes in federated learning and allocating them based on user reputation and neuron importance, the problems of user unfairness and model inconsistency are solved, thus improving both fairness and performance.
Patent Information
- Application Number
- CN202511130046.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-13
- Publication Date
- 2025-11-11
AI Technical Summary
In existing federated learning methods, the reward distribution among users is not differentiated enough, resulting in unfairness for high-contribution users. Furthermore, as the number of communication rounds increases, the inconsistency between local models intensifies, affecting the performance of the global model.
By constructing multiple sub-models with different neuron sizes and allocating them based on the user's reputation and neuron importance score, the local model is dynamically adjusted to ensure fairness and model consistency.
It effectively reduces inconsistency between local models, improves fairness among users, and enhances the overall performance and training stability of the global model.
Smart Images

Figure CN120930731A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of federated learning technology, and in particular to a federated learning method, apparatus, computer-readable storage medium, and electronic device based on dynamic sub-models. Background Technology
[0002] In federated learning systems, ensuring fairness in collaboration among users is crucial. Existing methods primarily aim to achieve fairness by allocating an appropriate number of gradient updates as rewards based on the contributions of different users. However, these methods still suffer from the following technical shortcomings: firstly, they do not sufficiently differentiate the reward allocation among users, leading to persistent unfairness for high-contributing users; secondly, since local models are updated solely through gradient distribution, inconsistencies between users' local models intensify with increasing communication rounds, potentially negatively impacting the overall performance of the global model. Summary of the Invention
[0003] The purpose of this invention is to provide a federated learning method, apparatus, computer-readable storage medium, and electronic device based on dynamic sub-models. By constructing multiple sub-models with different neuron scales through a global model and distributing them to corresponding users, the inconsistency between local models can be effectively reduced, and the fairness among users can be significantly improved.
[0004] A first aspect of this invention provides a federated learning method based on dynamic sub-models, executed by a central server, comprising:
[0005] The parameters of the local model uploaded by the user are aggregated to obtain the updated global model;
[0006] Determine whether the next round of communication has reached the preset cycle number;
[0007] If the preset cycle number is reached, then based on the global model and the importance score of each neuron, multiple sub-models with different neuron sizes are reconstructed, and based on the user's reputation, the corresponding sub-model is assigned as a local model.
[0008] If the preset cycle number is not reached, the parameters of each sub-model are updated according to the global model and sent to the corresponding user as a local model.
[0009] Optionally, the importance score is obtained by the following steps:
[0010] When the communication round reaches the preset cycle round, Q neuron removal operations are performed on the global model, and the corresponding loss change of the global model is calculated; wherein, the neuron removal operation is to remove only one neuron from the global model; Q is the total number of neurons;
[0011] Based on each change in loss, the importance score of the corresponding neuron is obtained.
[0012] Optionally, the step of reconstructing multiple sub-models with different neuron sizes based on the global model and the importance score of each neuron includes:
[0013] Based on the descending order of the importance scores, corresponding neurons are gradually removed from the global model to obtain multiple sub-models with different neuron sizes; wherein, the global model is the sub-model with the largest neuron size.
[0014] Optionally, the user's reputation is calculated using the following formula:
[0015]
[0016] Where, r i For the reputation of the i-th user; C i β represents the contribution of the i-th user; β is a hyperparameter.
[0017] Optionally, based on the user's reputation, assigning a corresponding sub-model as a local model includes:
[0018] Sort all the reputations and all the sub-models according to a preset order to obtain the reputation sorting order and the sub-model sequence;
[0019] Based on the reputation ranking order, the corresponding sub-models are extracted from the sub-model sequence and sent to the user as local models.
[0020] Optionally, the aggregation of user-uploaded local model parameters to obtain the updated global model includes:
[0021] Based on the user's local data volume and the number of parameters in the local model, a weighted average is calculated for all the local model parameters to obtain the updated global model.
[0022] Optionally, the global model is updated using the following formula:
[0023]
[0024] in, The global model is pre-distributed in the (t+1)th communication round; M is the total number of parameters in the global model; m i P represents the number of parameters in the i-th local model; P represents the total amount of data; p i Let i be the amount of local data for the i-th user; Let be the i-th local model trained in the t-th communication round; N is the number of users.
[0025] A second aspect of the present invention provides a federated learning device based on dynamic sub-models, comprising:
[0026] The global model update module is used to aggregate the local model parameters uploaded by users to obtain the updated global model;
[0027] The communication round determination module is used to determine whether the next communication round has reached the preset cycle round.
[0028] The sub-model reconstruction module is used to reconstruct multiple sub-models with different neuron sizes based on the global model and the importance score of each neuron if the preset cycle number is reached, and to assign the corresponding sub-model as a local model based on the user's reputation.
[0029] The sub-model update module is used to update the parameters of each sub-model according to the global model and send them to the corresponding user as a local model if the preset cycle number has not been reached.
[0030] A third aspect of the present invention provides a computer-readable storage medium, characterized in that the computer-readable storage medium includes a stored computer program; wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the federated learning method based on dynamic sub-models as described in any of the first aspects.
[0031] A fourth aspect of the present invention provides an electronic device, characterized in that it includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements the federated learning method based on dynamic sub-models as described in any of the first aspects above.
[0032] Compared with existing technologies, embodiments of the present invention provide a federated learning method, apparatus, computer-readable storage medium, and electronic device based on dynamic sub-models. The method includes: aggregating local model parameters uploaded by users to obtain an updated global model; determining whether the next round of communication has reached a preset cycle number of rounds; if the preset cycle number of rounds has been reached, reconstructing multiple sub-models with different neuron scales based on the global model and the importance score of each neuron, and assigning the corresponding sub-model as a local model based on the user's reputation; if the preset cycle number of rounds has not been reached, updating the parameters of each sub-model based on the global model and distributing it to the corresponding user as a local model. The present invention constructs multiple sub-models with different neuron scales through a global model and distributes them to the corresponding users, which can effectively reduce inconsistencies between local models and significantly improve fairness among users. Attached Figure Description
[0033] Figure 1 This is a flowchart illustrating an embodiment of the federated learning method based on dynamic sub-models provided by the present invention.
[0034] Figure 2 This is a flowchart illustrating another embodiment of the federated learning method based on dynamic sub-models provided by the present invention.
[0035] Figure 3 This is a schematic diagram of the structure of an embodiment of the federated learning device based on dynamic sub-models provided by the present invention;
[0036] Figure 4 This is a schematic diagram of the structure of an embodiment of an electronic device provided by the present invention. Detailed Implementation
[0037] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0038] See Figure 1 This is a flowchart illustrating an embodiment of the federated learning method based on dynamic sub-models provided by the present invention.
[0039] The first aspect of this invention provides a federated learning method based on dynamic sub-models, executed by a central server, including steps S1 to S4, as follows:
[0040] Step S1: Aggregate the local model parameters uploaded by the user to obtain the updated global model;
[0041] Step S2: Determine whether the next round of communication has reached the preset cycle number;
[0042] Step S3: If the preset cycle number is reached, then based on the global model and the importance score of each neuron, reconstruct multiple sub-models with different neuron sizes, and based on the user's reputation, assign the corresponding sub-model as a local model;
[0043] Step S4: If the preset cycle number has not been reached, then according to the global model, update the parameters of each sub-model and send them to the corresponding user as a local model.
[0044] It should be noted that the preset periodic rounds (within the range of positive integers) in this embodiment of the invention are used to periodically evaluate the importance score of each neuron (e.g., every 10 communication rounds) and reconstruct sub-models with different neuron sizes (i.e., perform structural adjustments). Periodically reconstructing the sub-models, while ensuring the prediction accuracy of the global model, can effectively reduce the framework training time and computational resource consumption, such as... Figure 2 As shown.
[0045] In practice, when the current communication round reaches a preset cycle number, the server will reconstruct the sub-model and assign corresponding sub-models to users with different reputations. Specifically, users with higher reputations will receive sub-models with better performance, i.e., sub-models containing more neurons. In other words, sub-models assigned to high-reputation users have fewer important neurons removed, thereby ensuring the maximization of their model performance.
[0046] When the current communication round has not reached the preset cycle round, the server does not adjust the internal structure of the sub-model, but directly adjusts the parameters of each sub-model according to the global model. This can improve the continuity and stability of the global model training.
[0047] It's worth noting that since the sub-models in each communication round are obtained from the global model and distributed to users as local models, the inconsistencies between local models do not worsen with increasing communication rounds. Furthermore, allocating sub-models based on user reputation effectively ensures fairness among users.
[0048] In an optional embodiment, the importance score is obtained by the following steps:
[0049] When the communication round reaches the preset cycle round, Q neuron removal operations are performed on the global model, and the corresponding loss change of the global model is calculated; wherein, the neuron removal operation is to remove only one neuron from the global model; Q is the total number of neurons;
[0050] Based on each change in loss, the importance score of the corresponding neuron is obtained.
[0051] It should be noted that the importance of each neuron varies within the global model, depending on its role in the global model and its contribution to the final prediction result. This embodiment of the invention evaluates the importance of neurons by assessing the impact of removing each neuron on the model loss (i.e., the amount of change in loss). For example, the greater the increase in model loss after removing a neuron from the global model, the greater the neuron's contribution to model performance, and the higher its importance score.
[0052] It is worth noting that the training objective of the global model is to minimize the cross-entropy loss function L. ec ,Right now
[0053]
[0054] Where, x i Let θ represent the i-th training sample, and L represent the global model. ec (x i ,θ) represents the loss function for the classification task.
[0055] Each neuron in the global model corresponds to multiple parameters, and each parameter contributes differently to the overall model performance. The importance (score) of a neuron can be determined by the increase in loss (i.e., the change in loss) after removing a particular neuron (ni). Right now
[0056]
[0057] Where V represents the validation dataset (e.g., constructed by uniformly selecting 10% of the data from the original training samples); This means that all parameters corresponding to the i-th neuron in the global model are set to 0.
[0058] Of course, the importance score of a neuron can also be calculated based on the sum of the importance scores of all neurons. Normalization is performed. In other words, the importance score of the neuron is calculated. This is converted to a percentage of its importance in the global model:
[0059]
[0060] in, is the normalized importance score of neuron i; S is the set of all neurons in the global model.
[0061] This invention determines the importance score of a neuron by measuring the change in loss after removing neurons from the global model. This accurately measures the contribution of each neuron to the overall model performance, providing important guidance for building personalized sub-models. Of course, in other embodiments, changes in other representative model performance metrics (such as changes in accuracy) can also be collected to determine the importance score of a neuron; this invention does not limit this approach.
[0062] In an optional embodiment, the user's reputation is calculated using the following formula:
[0063]
[0064] Where, r i For the reputation of the i-th user; C i β represents the contribution of the i-th user; β is a hyperparameter.
[0065] It should be noted that β is a hyperparameter used to adjust the impact of a contribution. A user's reputation is directly proportional to their contribution, meaning that users who contribute more will receive a higher reputation.
[0066] Of course, it can also affect the user's reputation. i Perform normalization processing, that is Here, max(r) is the maximum value among all user reputations.
[0067] In an optional embodiment, the step of reconstructing multiple sub-models with different neuron sizes based on the global model and the importance score of each neuron includes:
[0068] Based on the descending order of the importance scores, corresponding neurons are gradually removed from the global model to obtain multiple sub-models with different neuron sizes; wherein, the global model is the sub-model with the largest neuron size.
[0069] It's important to note that sub-models with different neuron sizes will produce different model performance. The sub-models assigned to users will also vary depending on their contribution. To ensure fairness among users, the greater a user's contribution, the larger and better the sub-model they will be assigned, thus fulfilling the goal of rewarding high-contributing users with higher returns.
[0070] This invention proposes a pruning mechanism (pruning strategy) that extracts sub-models with different performance levels from the global model based on user contributions. Specifically, starting with the most important neurons (i.e., in descending order of importance scores), neurons that contribute significantly to the global model are gradually removed. This pruning strategy ensures that sub-models of users with low contributions also obtain as many neurons as possible, thereby providing more information when training the global model. This is beneficial for the training of the global model (e.g., enhancing the performance of corresponding local model updates).
[0071] In an optional embodiment, assigning a corresponding sub-model as a local model based on the user's reputation includes:
[0072] Sort all the reputations and all the sub-models according to a preset order to obtain the reputation sorting order and the sub-model sequence;
[0073] Based on the reputation ranking order, the corresponding sub-models are extracted from the sub-model sequence and sent to the user as local models.
[0074] It's important to note that users with better reputations receive sub-models with larger neuron sizes (and thus better model performance). Clearly, users with the best reputations are assigned the largest sub-model (i.e., the global model).
[0075] In addition, when the communication round is 1 to (preset cycle round - 1), the sub-models issued by the central server to all users are global models.
[0076] In conjunction with the above embodiments, the present invention, on the one hand, promotes fair cooperation among users, ensuring that each user receives impartial treatment during the federated learning process; on the other hand, it maximizes the overall performance of the aggregated model, i.e., by including as many neurons as possible in each sub-model, to better optimize the training of the global model. In other words, the embodiments of the present invention achieve a balance between fairness and performance, thereby optimizing the federated learning system.
[0077] In an optional embodiment, the aggregation of user-uploaded local model parameters to obtain the updated global model includes:
[0078] Based on the user's local data volume and the number of parameters in the local model, a weighted average is calculated for all the local model parameters to obtain the updated global model.
[0079] Specifically, the global model is updated using the following formula:
[0080]
[0081] in, The global model is pre-distributed in the (t+1)th communication round; M is the total number of parameters in the global model; m i P represents the number of parameters in the i-th local model; P represents the total amount of data; p i Let i be the amount of local data for the i-th user; Let be the i-th local model trained in the t-th communication round; N is the number of users.
[0082] It should be noted that, considering the different numbers of neurons in the sub-models of different users (clients) and the different amounts of local data for different users, a weighted average algorithm is used to aggregate all sub-models. This weighted average algorithm ensures that the impact of sub-models from different contributing users on the global model is fairly considered. That is, by suppressing the influence (weight) of sub-models corresponding to high-contributing users, all sub-models can contribute to the global model more fairly, and the contribution of low-frequency parameters to the global model is guaranteed. This is because over-reliance on certain large sub-models may cause sub-models corresponding to users with low contributions to be "overwhelmed," thereby weakening diversity and global learning ability.
[0083] See Figure 3 This is a schematic diagram of an embodiment of the federated learning device based on dynamic sub-models provided by the present invention.
[0084] A second aspect of the present invention provides a federated learning apparatus based on dynamic sub-models for implementing the federated learning method based on dynamic sub-models described in any of the embodiments of the first aspect above. The apparatus includes:
[0085] The global model update module 11 is used to aggregate the local model parameters uploaded by the user to obtain the updated global model.
[0086] The communication round determination module 12 is used to determine whether the next communication round has reached the preset cycle round.
[0087] The sub-model reconstruction module 13 is used to reconstruct multiple sub-models with different neuron sizes based on the global model and the importance score of each neuron if the preset cycle number is reached, and to assign the corresponding sub-model as a local model based on the user's reputation 14.
[0088] The sub-model update module 15 is used to update the parameters of each sub-model according to the global model and send them to the corresponding user as a local model if the preset cycle number has not been reached.
[0089] It should be noted that the federated learning device based on dynamic sub-models provided in the second aspect embodiment of the present invention can realize all the processes of the federated learning method based on dynamic sub-models described in the first aspect embodiment. The functions and technical effects of each module in the device are the same as the functions and technical effects of the federated learning method based on dynamic sub-models described in the first aspect embodiment, and will not be repeated here.
[0090] A third aspect of the present invention provides a computer-readable storage medium comprising a stored computer program; wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium is located to perform the federated learning method based on dynamic sub-models as described in any of the first aspects of the present invention.
[0091] See Figure 4 This is a schematic diagram of an embodiment of an electronic device provided by the present invention.
[0092] A fourth aspect of the present invention provides an electronic device including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements the federated learning method based on dynamic sub-models as described in any of the first aspects of the present invention.
[0093] Preferably, the computer program can be divided into one or more modules / units (such as computer program 1, computer program 2, ...), and the one or more modules / units are stored in the memory 22 and executed by the processor 21 to complete the present invention. The one or more modules / units can be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device.
[0094] The processor 21 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor, or the processor 21 may be any conventional processor. The processor 21 is the control center of the electronic device, connecting various parts of the electronic device through various interfaces and lines.
[0095] The memory 22 mainly includes a program storage area and a data storage area. The program storage area can store the operating system, applications required for at least one function, etc., and the data storage area can store related data, etc. In addition, the memory 22 can be a high-speed random access memory, or a non-volatile memory, such as a plug-in hard disk, a smart media card (SMC), a secure digital card (SD), and a flash card, etc., or the memory 22 can also be other volatile solid-state storage devices.
[0096] It should be noted that the aforementioned electronic devices may include, but are not limited to, processors and memory, as will be understood by those skilled in the art. Figure 4 The schematic diagram shown is merely an example of the structure of the above-described electronic device and does not constitute a limitation on the structure of the above-described electronic device. The above-described electronic device may include more or fewer components than shown, or combine certain components, or different components.
[0097] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A federated learning method based on dynamic sub-models, characterized in that, Executed by the central server, including: The parameters of the local model uploaded by the user are aggregated to obtain the updated global model; Determine whether the next round of communication has reached the preset cycle number; If the preset cycle number is reached, then based on the global model and the importance score of each neuron, multiple sub-models with different neuron sizes are reconstructed, and based on the user's reputation, the corresponding sub-model is assigned as a local model. If the preset cycle number is not reached, the parameters of each sub-model are updated according to the global model and sent to the corresponding user as a local model.
2. The federated learning method based on dynamic sub-models as described in claim 1, characterized in that, The importance score is obtained through the following steps: When the communication round reaches the preset cycle round, Q neuron removal operations are performed on the global model, and the corresponding loss change of the global model is calculated; wherein, the neuron removal operation is to remove only one neuron from the global model; Q is the total number of neurons; Based on each change in loss, the importance score of the corresponding neuron is obtained.
3. The cooperative fair federated learning method based on dynamic sub-models as described in claim 1, characterized in that, The process involves reconstructing multiple sub-models with different neuron sizes based on the global model and the importance score of each neuron, including: Based on the descending order of the importance scores, corresponding neurons are gradually removed from the global model to obtain multiple sub-models with different neuron sizes; wherein, the global model is the sub-model with the largest neuron size.
4. The federated learning method based on dynamic sub-models as described in claim 1, characterized in that, The user's reputation is calculated using the following formula: Where, r i For the reputation of the i-th user; C i β represents the contribution of the i-th user; β is a hyperparameter.
5. The federated learning method based on dynamic sub-models as described in claim 1, characterized in that, Based on the user's reputation, the corresponding sub-model is assigned as the local model, including: Sort all the reputations and all the sub-models according to a preset order to obtain the reputation sorting order and the sub-model sequence; Based on the reputation ranking order, the corresponding sub-models are extracted from the sub-model sequence and sent to the user as local models.
6. The federated learning method based on dynamic sub-models as described in claim 1, characterized in that, The process of aggregating the local model parameters uploaded by the user to obtain the updated global model includes: Based on the user's local data volume and the number of parameters in the local model, a weighted average is calculated for all the local model parameters to obtain the updated global model.
7. The federated learning method based on dynamic sub-models as described in claim 1, characterized in that, The global model is updated using the following formula: in, The global model is pre-distributed in the (t+1)th communication round; M is the total number of parameters in the global model; m i P represents the number of parameters in the i-th local model; P represents the total amount of data; p i Let i be the amount of local data for the i-th user; Let be the i-th local model trained in the t-th communication round; N is the number of users.
8. A federated learning device based on dynamic sub-models, characterized in that, include: The global model update module is used to aggregate the local model parameters uploaded by users to obtain the updated global model; The communication round determination module is used to determine whether the next communication round has reached the preset cycle round. The sub-model reconstruction module is used to reconstruct multiple sub-models with different neuron sizes based on the global model and the importance score of each neuron if the preset cycle number is reached, and to assign the corresponding sub-model as a local model based on the user's reputation. The sub-model update module is used to update the parameters of each sub-model according to the global model and send them to the corresponding user as a local model if the preset cycle number has not been reached.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program; wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium is located to perform the federated learning method based on dynamic sub-models as described in any one of claims 1 to 7.
10. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements the federated learning method based on dynamic sub-models as described in any one of claims 1 to 7.