Federated Learning Method, Electronic Device, and Storage Medium for Global Optimization
By dynamically adjusting client nodes in federated learning, evaluating and filtering the average loss, the problem that model training is prone to fall into local optimal solutions, and improves the probability and speed of the model jumping out of local optimal solutions and finding global optimal solutions.
Patent Information
- Application Number
- CN202410735257.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2044-06-07
AI Technical Summary
In federated learning, since the client node data does not meet the independent and same distribution conditions, model training is prone to fall into local optimal solutions, resulting in poor generalization performance of the final model.
By obtaining the pause training set generated during the previous round of model training, model parameters are sent to the client nodes, and the average loss of each client node is evaluated. Put nodes with an average loss equal to the historical minimum value into one group, and put nodes with a greater than the historical minimum value into another group, and dynamically adjust the nodes participating in the training to improve the probability and speed of the model jumping out of the local optimal solution.
By evaluating and filtering nodes participating in gradient aggregation, the nodes that hinder the model from jumping out of the local optimal solution will be eliminated, and the probability and speed of the model from jumping out of the local optimal solution and finding the global optimal solution will be improved.
Smart Images

Figure CN118504713B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of federated learning, and particularly relates to a federated learning method for global optimization, an electronic device, and a corresponding storage medium. Background Art
[0002] Currently, with the rapid development of artificial intelligence technology, the application of artificial intelligence technology is becoming more and more extensive, and it has been applied to many fields such as image analysis, speech recognition, text processing, intelligent recommendation, and security detection. Federated learning and large model technology have become the forefront hotspots of artificial intelligence technology. In the model training scenario based on federated learning, since the client node data generally does not satisfy the independent and identically distributed condition, the model training process often falls into a local optimum, resulting in poor generalization performance of the final model.
[0003] Although there are already some methods in the prior art to jump out of the local optimum in federated learning. For example, when adopting a global optimization method based on momentum, it is still restricted by the size of the momentum and may not necessarily be able to jump out of the local optimum. Summary of the Invention
[0004] The purpose of the embodiments of the present invention is to provide a federated learning method, an electronic device, and a storage medium for global optimization, which can help the model training jump out of the local optimum, improve the probability of the model finding the global optimum, and the speed of jumping out of the local optimum, so as to at least solve some problems in the background art.
[0005] To achieve the above purpose, the present invention provides a federated learning method for global optimization, the method includes: obtaining a pause training set composed of client nodes generated during the previous round of model training; sending the model parameters of this round to the client node set including the pause training set, and then obtaining the average loss of each client node in the client node set based on the sent model parameters on the local sample data as the test data set; for each average loss, comparing the average loss with the historical minimum value of all average losses of the client node corresponding to this average loss; putting the client nodes with the average loss equal to the historical minimum value of the average loss into the first set, and putting the client nodes with the average loss greater than the historical minimum value of the average loss into the second set as the pause training set of this round; obtaining the updated gradients of each client node in the first set based on the sent model parameters on the local sample data as the training data set; aggregating the obtained updated gradients to generate a global model updated gradient, and updating the global model in combination with the model parameters.
[0006] Optionally, the method further includes: if there is no previous round of model training, the pause training set is an empty set.
[0007] Optionally, the method includes a model initialization step; the model initialization step includes: setting initialization parameters and setting a counting variable.
[0008] Optionally, the set of client nodes including the paused training set is generated through the following steps: calculating the difference set between the entire set composed of all client nodes of the federated learning system and the paused training set; randomly selecting several client nodes from the difference set, and obtaining the set of client nodes including the paused training set after performing a union operation with the paused training set.
[0009] Optionally, the number of client nodes selected from the difference set is a fixed value; when the sum of the fixed value and the number of client nodes in the previous round's paused training set is greater than the total number of client nodes in the federated learning system, the number of client nodes selected from the difference set is not the fixed value, but is equal to the total number of client nodes included in the difference set.
[0010] Optionally, obtaining the average loss of each client node in the set of client nodes based on the issued model parameters on the local sample data as the test data set includes: each client node using all the sample data stored locally as the test data set; inputting each sample data in the test data set into the local model containing the issued model parameters to obtain the corresponding loss; calculating the average value of all the losses corresponding to the test data set as the average loss; and obtaining the average loss from each client node in the set of client nodes.
[0011] Optionally, the client node is further configured to: store the average loss during each round of model training of this client node including the current round; determine the historical minimum value of the average loss from the stored average losses; compare the average loss of the current round with the historical minimum value of the average loss; when the average loss is equal to the historical minimum value of the average loss, use all the sample data stored locally as the training data set, and train the local model containing the issued model parameters using the stochastic gradient descent algorithm to generate updated gradients; when the average loss is greater than the historical minimum value of the average loss, pause the local model training of the current round.
[0012] Optionally, obtaining the updated gradients of each client node in the first set based on the issued model parameters on the local sample data as the training data set includes: each client node using all the sample data stored locally as the training data set; training the local model containing the issued model parameters using the stochastic gradient descent algorithm to generate updated gradients; and obtaining the updated gradients from each client node in the set of client nodes.
[0013] Optionally, the obtained updated gradients are aggregated to generate global model update gradients, and the global model is updated in combination with the model parameters, including: determining a weight value based on the local sample data of the client node corresponding to each updated gradient; calculating a weighted average based on the updated gradient and the corresponding weight value to obtain the global model update gradient; and calculating the updated parameters of the global model based on the global model update gradient using the Adam algorithm.
[0014] In the present invention, a federated learning device for global optimization is further provided. The device includes: a set acquisition module for acquiring a paused training set composed of client nodes generated during the previous round of model training; a data interaction module for sending the model parameters of this round to the client node set including the paused training set, and then acquiring the average loss of each client node in the client node set based on the sent model parameters using the local sample data as the test data set; a loss classification module for, for each average loss, comparing the average loss with the historical minimum value of all average losses of the client node corresponding to the average loss; putting the client nodes with the average loss equal to the historical minimum value of the average loss into a first set, and putting the client nodes with the average loss greater than the historical minimum value of the average loss into a second set as the paused training set of this round; a gradient acquisition module for acquiring the updated gradients of each client node in the first set based on the sent model parameters using the local sample data as the training data set; and a parameter update module for aggregating the obtained updated gradients to generate global model update gradients, and updating the global model in combination with the model parameters.
[0015] In the present invention, an electronic device is further provided, including: at least one processor; a memory connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the at least one processor implements the aforementioned federated learning method for global optimization by executing the instructions stored in the memory.
[0016] In the present invention, a machine-readable storage medium is further provided. Instructions are stored on the machine-readable storage medium, and when the instructions are executed by a processor, the processor is configured to execute and implement the aforementioned federated learning method for global optimization.
[0017] In the present invention, a computer program product is further provided, including a computer program, and when the computer program is executed by a processor, it implements the aforementioned federated learning method for global optimization.
[0018] The above technical solutions have the following beneficial effects:
[0019] By evaluating and screening the nodes participating in gradient aggregation, eliminating the nodes that hinder the model from jumping out of the local optimal solution, the probability and speed of the model jumping out of the local optimal solution and finding the global optimal solution are improved.
[0020] Other features and advantages of the embodiments of the present invention will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings are used to provide a further understanding of the embodiments of the present invention, and constitute a part of the specification, and are used to explain the embodiments of the present invention together with the following specific implementation manners, but do not constitute a limitation to the embodiments of the present invention. In the drawings:
[0022] Figure 1 Schematically shows a schematic diagram of the steps of the federated learning method for global optimization according to an embodiment of the present invention;
[0023] Figure 2 Schematically shows a schematic diagram of the implementation process of the federated learning method for global optimization according to an embodiment of the present invention;
[0024] Figure 3 Schematically shows a schematic diagram of the structure of the federated learning device for global optimization according to an embodiment of the present invention;
[0025] Figure 4 Schematically shows an internal structure diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0026] The following will describe in detail the specific implementation manners of the embodiments of the present invention with reference to the drawings. It should be understood that the specific implementation manners described herein are only used to illustrate and explain the embodiments of the present invention, and are not used to limit the embodiments of the present invention.
[0027] Figure 1 Schematically shows a schematic diagram of the steps of the federated learning method for global optimization according to an embodiment of the present invention. As Figure 1 shown, a federated learning method for global optimization, the method includes:
[0028] S01. Obtain a suspension training set composed of client nodes generated during the previous round of model training;
[0029] S02. Send the model parameters of this round to the client node set including the suspension training set, and then obtain the average loss of each client node in the client node set based on the sent model parameters on the local sample data as the test data set;
[0030] S03. For each average loss, compare the average loss with the historical minimum of all average losses of the client node corresponding to this average loss; put the client nodes with the average loss equal to the historical minimum of the average losses into the first set, and put the client nodes with the average loss greater than the historical minimum of the average losses into the second set, which is the set of paused training for this round; all the average losses here include the average loss of this round and all historical average losses before this round.
[0031] S04. Obtain the updated gradients of each client node in the first set based on the distributed model parameters on the local sample data as the training data set.
[0032] S05. Aggregate the obtained updated gradients to generate global model updated gradients, and update the global model in combination with the model parameters.
[0033] Through the above implementation manners, by updating and selecting the set of paused training, the participating nodes are dynamically adjusted, and the number of beneficial nodes participating in the training is increased. Moreover, based on the average loss, the client nodes participating in the gradient aggregation are evaluated and screened, and the nodes that hinder the model from jumping out of the local optimal solution are removed. In this way, the probability and speed of the model jumping out of the local optimal solution are improved.
[0034] In some implementation manners of the present application, the method includes a model initialization step; the model initialization step includes: setting initialization parameters and setting a counting variable. If the federated learning system is in the state before the first round of training, it may be necessary to perform model initialization on the federated learning system. In this federated learning system, assume that the federated learning parameter server is S, and all federated learning client nodes form a set , and the total number of all federated learning client nodes is . The specific steps of model initialization are: the parameter server S initializes the parameters of the adopted deep neural network model, and the initialization parameters are , where , is the total number of parameter dimensions of the global model. Set the counting variable , and initialize . At this time, there is no such previous round of model training, and the set of paused training is an empty set. In subsequent model training, the set of paused training may also be an empty set. However, it should be reminded that this model initialization is not necessary. For example, after the federated learning system starts the second round and subsequent training, the aforementioned federated learning method for global optimization can be applied, but it is no longer necessary to perform this initialization before the federated learning method for global optimization.
[0035] In some embodiments of the present application, the set of client nodes containing the paused training set is generated through the following steps: calculating the difference set between the entire set composed of all client nodes of the federated learning system and the paused training set; randomly selecting several client nodes from the difference set, and performing a union operation with the paused training set to obtain the set of client nodes containing the paused training set. In the round of model parameter distribution, the parameter server S will randomly select client nodes from the set , where is the paused training set in the round, is the difference set between the two, 0 < ≤ . Select all nodes from the set , and the selected federated learning client nodes are , where i is the client node serial number, 0 < ≤ . Where and are both positive integers, and are the cardinalities of the sets and respectively. Exemplarily, when , can be preferably selected.
[0036] Further optionally, the number of client nodes selected from the difference set is a fixed value; when the sum of the fixed value and the number of client nodes in the previous round's paused training set is greater than the total number of client nodes in the federated learning system, the number of client nodes selected from the difference set is not the fixed value, but equal to the total number of client nodes contained in the difference set. In the early stage of entering the local optimal solution neighborhood or when jumping out of the local optimal solution neighborhood, satisfies , and the in each round can be of a fixed size. At this time, the number of nodes participating in the training is dynamically adjusted through the change of . As the time of entering the local optimal solution neighborhood becomes longer, may gradually increase. At this time, the fixed may cause ﹥ . At this time, the number of nodes selected in each round becomes = , that is, the total number of client nodes contained in the difference set. When the time of entering the local optimal solution neighborhood becomes longer, the cardinality of the second set may gradually increase. When remains unchanged or = In this case, the total number of nodes participating in training may be larger compared to the early stage of entering the local optimal solution neighborhood or the stage after jumping out of the local optimal solution neighborhood. Consequently, the cardinality of the first set and the number of beneficial nodes in the next round may increase. Evidently, in this embodiment, by dynamically adjusting the number of nodes participating in training, when the model training process has not jumped out of the local optimal solution for a long time, the parameter server may gradually increase the number of beneficial nodes participating in training, further enhancing the probability and speed of jumping out of the local optimal solution and finding the global optimal solution.
[0037] In some embodiments of the present application, obtaining the average loss of each client node in the client node set based on the issued model parameters on the local sample data as the test data set includes: each client node uses all the sample data stored locally as the test data set; inputs each sample data in the test data set into the local model containing the issued model parameters to obtain the corresponding loss; calculates the average value of all the losses corresponding to the test data set as the average loss; and obtains the average loss from each client node in the client node set. Exemplarily, the parameters of the global model of the deep neural network model are sent to the selected federated learning client nodes to start the round of local model training and model parameter update. When all the sample data is used as the test data set, the local model calculates the loss between the calculated value and the actual value according to the loss function to obtain the loss of each sample data. After averaging all the losses in the test data set, the average loss is obtained. At this time, training has not been carried out yet, and whether to perform local model training needs to be further determined.
[0038] In some embodiments of the present application, the client node is further configured to: store the average loss of each round of model training including this round of the client node; determine the historical minimum value of the average loss from the stored average losses; compare the average loss of this round with the historical minimum value of the average loss; when the average loss is equal to the historical minimum value of the average loss, use all the sample data stored locally as the training data set and train the local model containing the issued model parameters using the stochastic gradient descent algorithm to generate updated gradients; when the average loss is greater than the historical minimum value of the average loss, pause the local model training of this round. Exemplarily, the local model training performed by the client node in this embodiment mainly includes two steps: parameter evaluation and model training. Among them, the parameter evaluation step includes: in the round of local model training, each uses all the sample data stored locally as the test data set to test the average loss of the model parameters on the test data set , calculate the historical minimum value of Among them is an integer variable
[0039]
[0040] Specifically, the specific steps of model training are as follows: In the th round of local model training, if , then each uses all the sample data stored locally as the training data set, trains the local model using the stochastic gradient descent algorithm, and calculates the updated gradient of the local model , and sends the updated gradient of the local model and the average loss to the parameter server S; if , then each pauses the local model training in this round and only sends the average loss to the parameter server S
[0041] In some embodiments of the present application, obtaining the updated gradient of each client node in the first set based on the downloaded model parameters on the training data set with the local sample data includes: Each client node uses all the sample data stored locally as the training data set; trains the local model containing the downloaded model parameters using the stochastic gradient descent algorithm to generate an updated gradient; obtains the updated gradient from each client node in the client node set. This implementation step corresponds to the foregoing embodiment. This embodiment is only executed on the federated learning parameter server to obtain the updated gradient from the client node. The generation of this updated gradient refers to the previous embodiment and will not be repeated here
[0042] In some embodiments of the present application, on the side of the federated learning parameter server, in the th round of model parameter update, the parameter server S first receives the update data uploaded by each client node, calculates the historical minimum value of each , puts the client nodes with into the first set , puts the client nodes with into the second set , and uses the second set as the pause training set for this round, that is, the pause training set for the th round
[0043] In some embodiments of the present application, the obtained updated gradients are aggregated to generate global model updated gradients, and the global model is updated in combination with model parameters, including: determining weight values based on the local sample data of the client nodes corresponding to each updated gradient; performing weighted average calculation based on the updated gradients and the corresponding weight values to obtain global model updated gradients; and calculating the updated parameters of the global model by using the Adam algorithm based on the global model updated gradients. Exemplarily, at the round of model parameter update, the parameter server S aggregates the updated gradients of the client nodes in the set to generate global model updated gradients , and generates the updated parameters of the global model based on by using the Adam algorithm .
[0044]
[0045] Wherein, is the local stored sample data set of the client node , and is the number of elements included in the set . is the sum of the sample numbers of the client nodes in the set .
[0046] In some embodiments of the present application, the method is configured to loop and execute when the following preset conditions are met; the preset conditions include: after updating the global model in combination with the trained model parameters, determining that the current state of the federated learning system does not meet the training stop conditions of the federated learning. The training stop conditions herein include convergence or . If converges or , the training process is terminated, otherwise the value of is incremented by 1, and all the sub-steps of the foregoing model parameter distribution, local model training, and model parameter update are repeatedly executed, and the next round of model parameter distribution, local model training, and model parameter update is started. is a preset training cycle threshold constant, is a positive integer greater than 1.
[0047] Through the above embodiments, by evaluating and screening the nodes participating in gradient aggregation, the nodes that hinder the model from jumping out of the local optimal solution are removed, and when the model training process has not jumped out of the local optimal solution for a long time, the parameter server will gradually increase the number of beneficial nodes participating in the training, so as to increase the probability and speed of jumping out of the local optimal solution.
[0048] Figure 2Schematically shows a schematic diagram of the implementation process of the federated learning method for global optimization according to an embodiment of the present invention. As Figure 2 shown, it includes the following implementation steps: The parameter server initializes the model parameters. The parameter server randomly selects a number of client nodes and distributes the model parameters. The client nodes decide whether to perform local model training based on the parameter evaluation results and upload the local update data. If it is decided to perform local model training, the local update data includes local update gradients. The parameter server evaluates and filters each local update gradient to generate the parameters after the global model is updated. The parameter server judges the training termination condition.
[0049] Based on the same inventive concept, the present invention also provides a federated learning device for global optimization, Figure 3 schematically showing a schematic diagram of the structure of the federated learning device for global optimization according to an embodiment of the present invention. As Figure 3 shown, the device includes: a set acquisition module, configured to acquire a pause training set composed of client nodes generated during the previous round of model training; a data interaction module, configured to distribute the model parameters of this round to the set of client nodes including the pause training set, and then acquire the average loss of each client node in the set of client nodes based on the distributed model parameters on the local sample data as the test data set; a loss classification module, configured to, for each average loss, compare the average loss with the historical minimum value of all average losses of the client node corresponding to the average loss; put the client nodes with the average loss equal to the historical minimum value of the average loss into the first set, and put the client nodes with the average loss greater than the historical minimum value of the average loss into the second set as the pause training set of this round; a gradient acquisition module, configured to acquire the update gradients of each client node in the first set based on the distributed model parameters on the local sample data as the training data set; and a parameter update module, configured to aggregate the acquired update gradients to generate a global model update gradient, and update the global model in combination with the model parameters.
[0050] In some alternative embodiments of the present application, the method further includes: if there is no previous round of model training, the pause training set is an empty set.
[0051] In some alternative embodiments of the present application, the method includes a model initialization step; the model initialization step includes: setting initialization parameters and setting a counting variable.
[0052] In some alternative embodiments of the present application, the set of client nodes containing the paused training set is generated through the following steps: calculating the difference set between the entire set composed of all client nodes of the federated learning system and the paused training set; randomly selecting several client nodes from the difference set, and performing a union operation with the paused training set to obtain the set of client nodes containing the paused training set.
[0053] In some alternative embodiments of the present application, the number of client nodes selected from the difference set is a fixed value; when the sum of the fixed value and the number of client nodes in the previous round's paused training set is greater than the total number of client nodes in the federated learning system, the number of client nodes selected from the difference set is not the fixed value, but equal to the total number of client nodes contained in the difference set.
[0054] In some alternative embodiments of the present application, obtaining the average loss of each client node in the set of client nodes based on the issued model parameters on the local sample data as the test data set includes: each client node taking all the sample data stored locally as the test data set; inputting each sample data in the test data set into the local model containing the issued model parameters to obtain the corresponding loss; calculating the average value of all the losses corresponding to the test data set as the average loss; and obtaining the average loss from each client node in the set of client nodes.
[0055] In some alternative embodiments of the present application, the client node is further configured to: store the average loss during each round of model training of this client node including the current round; determine the historical minimum value of the average loss from the stored average losses; compare the average loss of the current round with the historical minimum value of the average loss; when the average loss is equal to the historical minimum value of the average loss, taking all the sample data stored locally as the training data set, and training the local model containing the issued model parameters using the stochastic gradient descent algorithm to generate updated gradients; when the average loss is greater than the historical minimum value of the average loss, pausing the local model training of the current round.
[0056] In some alternative embodiments of the present application, obtaining the updated gradients of each client node in the first set based on the issued model parameters on the local sample data as the training data set includes: each client node taking all the sample data stored locally as the training data set; training the local model containing the issued model parameters using the stochastic gradient descent algorithm to generate updated gradients; and obtaining the updated gradients from each client node in the set of client nodes.
[0057] In some alternative embodiments of the present application, the obtained updated gradients are aggregated to generate global model updated gradients, and the global model is updated in combination with model parameters, including: determining a weight value based on the local sample data of the client node corresponding to each updated gradient; calculating a weighted average based on the updated gradient and the corresponding weight value to obtain the global model updated gradient; and calculating the updated parameters of the global model by using the Adam algorithm based on the global model updated gradient.
[0058] The specific limitations of each functional module in the above-mentioned federated learning device for global optimization can refer to the limitations of the federated learning method for global optimization in the foregoing text, and will not be elaborated herein. Each module in the above system can be implemented in whole or in part by software, hardware, and their combination. Each of the above modules can be embedded in or independent of the processor in the electronic device in the form of hardware, or stored in the memory of the electronic device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules. It also realizes the advantages of evaluating the training loss values of each client node, eliminating the nodes that hinder the model from jumping out of the local optimal solution, and dynamically adjusting the number of training nodes to accelerate the speed at which the model jumps out of the local optimal solution and increase the probability of the model finding the global optimal solution.
[0059] In some embodiments of the present invention, there is also provided an electronic device, including: at least one processor; a memory connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the at least one processor executes the foregoing federated learning method for global optimization. Its internal structure diagram can be as Figure 4 shown. Figure 4 Schematically shows the internal structure diagram of the electronic device according to the embodiment of the present invention. The electronic device includes a processor A01, a network interface A02, a memory (not shown in the figure), and a database (not shown in the figure) connected through a system bus. Among them, the processor A01 of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes an internal memory A03 and a non-volatile storage medium A04. The non-volatile storage medium A04 stores an operating system B01, a computer program B02, and a database (not shown in the figure). The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 in the non-volatile storage medium A04. The network interface A02 of the electronic device is used to communicate with an external terminal through a network. When the computer program B02 is executed by the processor A01, it implements a federated learning method for global optimization.
[0060] Those skilled in the art can understand, Figure 4The structure shown is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the electronic device to which the solution of this application is applied. The specific electronic device may include more or fewer components than those shown in the figure, or combine some components, or have a different component layout.
[0061] In an embodiment provided by the present invention, a machine-readable storage medium is provided. Instructions are stored on the machine-readable storage medium, and when the instructions are executed by a processor, the processor is configured to execute the aforementioned federated learning method for global optimization.
[0062] In an embodiment provided by the present invention, a computer program product is provided, including a computer program that implements the aforementioned federated learning method for global optimization when executed by a processor.
[0063] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0064] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate for implementing in the process Figure 1 one process or multiple processes and / or blocks Figure 1 a device for the functions specified in one block or multiple blocks.
[0065] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device implements in the process Figure 1 one process or multiple processes and / or blocks Figure 1 a device for the functions specified in one block or multiple blocks.
[0066] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 steps for the functions specified in one block or multiple blocks.
[0067] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0068] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM) and / or non-volatile memory such as read-only memory (ROM) or flash memory (flash RAM). The memory is an example of computer-readable media.
[0069] Computer-readable media includes permanent and non-permanent, removable and non-removable media and can store information by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media such as modulated data signals and carrier waves.
[0070] It should also be noted that the term "comprises", "comprising" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, commodity or device comprising the element.
[0071] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
Claims
1. A federated learning method for global optimization, characterized in that: The method includes: Get the paused training set consisting of client nodes generated during the previous round of model training; Calculate the difference between the entire set consisting of all client nodes of the federated learning system and the suspended training set; Randomly select a number of client nodes from the difference set, and perform a union operation with the paused training set to obtain a client node set including the paused training set; Sending the model parameters of this round to the client node set including the suspended training set, and then obtaining the average loss of each client node in the client node set based on the sent model parameters on the test data set with local sample data; For each average loss, compare the average loss with the historical minimum of all average losses of the client nodes corresponding to the average loss; put the client nodes whose average loss is equal to the historical minimum of the average loss into the first set, and put the client nodes whose average loss is greater than the historical minimum of the average loss into the second set, as the paused training set of this round; Obtaining an update gradient of each client node in the first set based on the issued model parameters on the local sample data as a training data set; The acquired update gradients are aggregated to generate global model update gradients, and the global model is updated in combination with the model parameters.
2. The method according to claim 1, characterized in that The method further includes: if the previous round of model training does not exist, the paused training set is an empty set.
3. The method according to claim 1, characterized in that The method comprises a model initialization step; The model initialization step includes: setting initialization parameters and setting counting variables.
4. The method according to claim 1, characterized in that: The number of client nodes selected from the difference set is a fixed value; When the sum of the fixed value and the number of client nodes in the previous round of paused training set is greater than the total number of client nodes in the federated learning system, the number of client nodes selected from the difference set is not the fixed value, but is equal to the total number of client nodes included in the difference set.
5. The method according to claim 1, characterized in that Obtaining the average loss of each client node in the client node set based on the sent model parameters on the test data set using the local sample data, including: Each client node uses all sample data stored locally as a test data set; Input each sample data in the test data set into the local model including the sent model parameters to obtain the corresponding loss; Calculate the average of all losses corresponding to the test data set as the average loss; The average loss is obtained from each client node in the set of client nodes.
6. The method according to claim 5, characterized in that The client node is also configured to: Store the average loss of each round of model training for this client node, including this round; determining a historical minimum average loss from the stored average losses; Compare the average loss of this round with the historical minimum average loss; When the average loss is equal to the historical minimum of the average loss, all sample data stored locally are used as training data sets, and a stochastic gradient descent algorithm is used to train the local model including the issued model parameters to generate an update gradient; When the average loss is greater than the historical minimum average loss, the current round of local model training is paused.
7. The method according to claim 6, characterized in that Obtaining an update gradient of each client node in the first set based on the sent model parameter on the local sample data as a training data set, including: Each client node uses all sample data stored locally as a training data set; Using a stochastic gradient descent algorithm to train a local model including the issued model parameters to generate an update gradient; The update gradient is obtained from each client node in the set of client nodes.
8. The method according to claim 1, characterized in that The acquired update gradients are aggregated to generate global model update gradients, and the global model is updated in combination with the model parameters, including: Determine a weight value based on local sample data of the client node corresponding to each updated gradient; The global model update gradient is obtained by weighted average calculation based on the update gradient and the corresponding weight value; Based on the global model update gradient, the Adam algorithm is used to calculate the model parameters to obtain the updated parameters of the global model.
9. The method according to claim 1, characterized in that: The method is configured to be executed cyclically when the following preset conditions are met; The preset condition includes: after updating the global model in combination with the trained model parameters, determining that the current state of the federated learning system does not meet the training stop condition of the federated learning.
10. An electronic device, characterized in that: include: at least one processor; a memory connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the at least one processor implements the steps of the global optimization-oriented federated learning method described in any one of claims 1 to 9 by executing the instructions stored in the memory.
11. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the steps of the global optimization-oriented federated learning method described in any one of claims 1 to 9 are implemented.
12. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the global optimization-oriented federated learning method described in any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Block chain federal learning method based on turn system updating and client weight optimization
CN116484978A