Federated machine learning method, device, storage medium and processor

By calculating the contribution of client nodes and dynamically adjusting the nodes participating in training, the federated machine learning method is optimized, which solves the problem of low model performance in traditional methods and improves the training effect and performance.

CN117521783BActive Publication Date: 2024-08-30BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311576433.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-23
Publication Date
2024-08-30
Estimated Expiration
2043-11-23

AI Technical Summary

Technical Problem

Traditional federated machine learning methods may lead to low model performance while protecting user privacy. Especially when blindly selecting client nodes or using all nodes for training, the training effect will be reduced.

Method used

By calculating the historical contribution and cumulative contribution of each client node, dynamically adjust the number of client nodes participating in the current training round, and determine the participation probability of each client node based on its current cumulative contribution, thereby optimizing model training. , improve the performance of federated machine learning.

Benefits of technology

By dynamically adjusting the participation of client nodes and making full use of effective nodes, the training effect and model performance of federated machine learning are optimized, unnecessary negative effects are avoided, and the training effect of the global model is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117521783B
    Figure CN117521783B
Patent Text Reader

Abstract

The embodiment of the present application provides a federated machine learning method, device, storage medium and processor. The method includes: determining the model parameters of the global model in the current training round; obtaining the historical single contribution and historical cumulative contribution of the local model of each client node in the previous training round; determining the current cumulative contribution of each client node according to the total number of historical training times of the global model, the historical single contribution and historical cumulative contribution of each client node; determining the number of client nodes participating in the current training round and the current random selection probability of each client node according to the current cumulative contribution of each client node; selecting the number of client nodes participating in the current training round according to the current random selection probability of each client node; sending the model parameters to each client node participating in this round of training to train the local model, so as to improve the model performance of the federated machine learning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and specifically to a federated machine learning method, apparatus, storage medium, processor, and computer device. Background Art

[0002] At present, with the rapid development of artificial intelligence technology, the application of artificial intelligence technology is becoming more and more extensive. It has been applied to many fields such as image analysis, speech recognition, text processing, intelligent recommendation, security detection, etc. Privacy computing technology represented by federated machine learning has become a new frontier technology hotspot. Federated machine learning can effectively help multiple institutions use data and conduct machine learning modeling while meeting the requirements of user privacy protection, data security and government regulations.

[0003] However, under the condition of protecting user privacy, traditional federated machine learning conducts federated machine learning training based on each client node, but for some client nodes, it may not have a certain advantage in improving the performance of federated machine learning. If certain client nodes are blindly selected or all client nodes are used for federated machine learning, the training effect of federated machine learning will be reduced, resulting in poor model performance. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a federated machine learning method, apparatus, storage medium, processor, and computer device to solve the problem of poor performance of federated machine learning in the prior art.

[0005] In order to achieve the above-mentioned object, the first aspect of the present application provides a federated machine learning method, which is applied to a server node, comprising:

[0006] The final model parameters obtained by the global model on the server node after the previous round of training are determined as the model parameters issued by the global model in the current training round;

[0007] Obtain the historical single contribution and historical cumulative contribution of the local model of each client node after training based on the model parameters issued by the global model in the previous round of training;

[0008] Determine the current cumulative contribution of each client node based on the total number of historical trainings of the global model and the historical single contribution and historical cumulative contribution of each client node;

[0009] Determine the number of client nodes participating in the current training round based on the current cumulative contribution of each client node, as well as the current probability of each client node being randomly selected;

[0010] Selecting the number of client nodes participating in the current training round from multiple client nodes according to the current random selection probability of each client node;

[0011] The model parameters are sent to each client node participating in this round of training, so that each client node participating in this round of training trains the corresponding local model by sending the model parameters.

[0012] In an embodiment of the present application, determining the number of client nodes participating in the current training round based on the current cumulative contribution of each client node and the current probability of each client node being randomly selected includes: determining the total number of client nodes whose current cumulative contribution is greater than a first preset value; determining the smaller value between the total number of nodes and the planned number of client nodes participating in the current training round as the number of client nodes participating in the current training round; selecting any one client node from a plurality of client nodes as the selected client node, and determining the sum of the current cumulative contributions of the plurality of client nodes; determining the ratio between the current cumulative contribution of the selected client node and the sum of the current cumulative contributions as the current probability of the selected client node being randomly selected; removing the selected client node from the plurality of client nodes, and returning to the step of selecting any one client node from the plurality of client nodes as the selected client node, until the current probability of each client node being randomly selected is determined.

[0013] In an embodiment of the present application, the method also includes: after sending the model parameters to each client node participating in this round of training, receiving the local update gradient of the local model sent by each client node participating in this round of training; determining the current single contribution of each client node participating in this round of training relative to the target client node according to the local update gradient of each local model, and the target client node is selected from multiple client nodes according to preset business requirements; updating the model parameters according to all current single contributions to obtain the final model parameters of the global model in the current training round; when it is determined that the final model parameters of the current training round and / or the total number of training of the global model do not meet the termination training conditions, return to the step of obtaining the historical single contribution and historical cumulative contribution of the local model of each client node after training based on the model parameters sent by the global model in the previous round of training, until the re-determined final model parameters and / or the total number of training times meet the termination training conditions.

[0014] In an embodiment of the present application, determining the current single contribution of each client node participating in the current round of training relative to the target client node based on the local update gradient of each client node participating in the current round of training includes: determining the global update gradient of the global model and the first test parameter of each client node participating in the current round of training based on the local update gradient of each client node participating in the current round of training; determining the second test parameter for the global model based on the global update gradient; sending the first test parameter and the second test parameter of each client node participating in the current round of training to the target client node; obtaining the first prediction loss and the second prediction loss corresponding to each first test parameter and the second test parameter, respectively, sent by the target client node; determining the current single contribution of each client node participating in the current round of training relative to the target client node based on the first prediction loss and the second prediction loss of each client node participating in the current round of training.

[0015] In an embodiment of the present application, determining the current single contribution of each client node participating in the current round of training relative to the target client node based on the first predicted loss and the second predicted loss of each client node participating in the current round of training includes: for each client node participating in the current round of training, determining the loss difference between the first predicted loss and the second predicted loss of the client node participating in the current round of training; for each client node participating in the current round of training, determining the ratio between the loss difference and the second predicted loss as the current single contribution of the client node participating in the current round of training relative to the target client node.

[0016] In the embodiment of the present application, the first test parameter is determined by formula (1):

[0017]

[0018] Among them, w i ' k It refers to the first test parameter of the i-th client node participating in this round of training during the k-th training. k-1 refers to the final model parameters of the global model during the k-1th training, η refers to the learning rate, m refers to the total number of client nodes participating in this round of training during the kth training, |D j | refers to the total amount of data in the sample data set of the jth client node participating in this round of training during the kth training. The jth client node participating in this round of training refers to the client node participating in this round of training that is different from the i-th client node participating in this round of training among the m client nodes participating in this round of training. It refers to the local update gradient of the jth client node participating in this round of training during the kth training.

[0019] In an embodiment of the present application, updating and sending model parameters based on all current single contributions to obtain the final model parameters of the global model in the current training round includes: selecting client nodes participating in this round of training whose current single contribution is greater than a second preset value as candidate client nodes; updating and sending model parameters based on the local update gradient of the candidate client node to obtain the final model parameters of the global model in the current training round.

[0020] In the embodiment of the present application, the final model parameters of the global model in the current training round are determined by formula (2):

[0021]

[0022] Among them, w k refers to the final model parameters of the global model during the kth training, w k-1 refers to the final model parameters of the global model during the k-1th training, η refers to the learning rate, O k refers to the total number of candidate client nodes during the kth training, |D i | refers to the total amount of data in the sample data set of the i-th client node participating in this round of training, It refers to the local update gradient of the i-th client node participating in this round of training during the k-th training.

[0023] In an embodiment of the present application, determining the current cumulative contribution of each client node based on the total number of historical training times of the global model and the historical single contribution and historical cumulative contribution of each client node includes: for each client node, when the total number of historical training times is equal to the preset number of times, determining the current cumulative contribution of the client node to be a third preset value; for each client node, when the total number of historical training times is greater than the preset number of times, respectively determining a first weight coefficient of the historical single contribution of the client node and a second weight coefficient of the historical cumulative contribution; for each client node, performing a weighted summation of the historical single contribution and the historical cumulative contribution of the client node based on the first weight coefficient and the second weight coefficient to obtain the current cumulative contribution of the client node.

[0024] A second aspect of the present application provides a processor configured to execute the above-mentioned federated machine learning method.

[0025] A third aspect of the present application provides a machine-readable storage medium having instructions stored thereon, the instructions being used to enable a machine to execute the above-mentioned federated machine learning method.

[0026] A fourth aspect of the present application provides a federated machine learning device, comprising the above-mentioned processor.

[0027] A fifth aspect of the present application provides a computer device, including:

[0028] a memory configured to store instructions; and

[0029] The federated machine learning apparatus described above.

[0030] Through the above technical scheme, the participation probability of each client node in the current training round is determined according to the current cumulative contribution of each client node in the current training round, so as to dynamically adjust the client nodes participating in the current training round, and train the local models of the client nodes participating in the current training round through the model parameters issued by the global model in the current training round, so as to make full use of the effective client node optimization to enhance the federated machine learning, and improve the training effect and model performance of the federated machine learning.

[0031] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present application, but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings:

[0033] Figure 1 A schematic diagram of an application environment of a federated machine learning method according to an embodiment of the present application is schematically shown;

[0034] Figure 2 The flowchart of the federated machine learning method according to the embodiment of the present application is schematically shown;

[0035] Figure 3 The flowchart of the federated machine learning method according to another embodiment of the present application is schematically shown;

[0036] Figure 4 A timing diagram of a federated machine learning method according to an embodiment of the present application is schematically shown;

[0037] Figure 5 The internal structure diagram of a computer device according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION

[0038] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application, and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0039] It should be noted that if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0040] The federated machine learning method provided in this application can be applied to Figure 1 In the application environment shown in the figure, the server node 101 communicates with the client node 102 through the network. The client node 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices, and the number of client nodes 102 is multiple. The server node 101 can be implemented by an independent server or a server cluster composed of multiple servers.

[0041] Figure 2 The flowchart of the federated machine learning method according to the embodiment of the present application is schematically shown. Figure 2 As shown, in one embodiment of the present application, a federated machine learning method is provided. This embodiment mainly applies this method to the above Figure 1 Taking the server node 101 in FIG. 1 as an example, the following steps are included:

[0042] Step 201: The final model parameters obtained by the global model on the server node after the previous round of training are determined as the model parameters issued by the global model in the current training round.

[0043] The server node may determine the final model parameters obtained by the global model on the server node after the last round of training as the model parameters issued by the global model in the current training round. The final model parameters refer to the global model parameters obtained by the global model after the last round of training.

[0044] Step 202: Obtain the historical single contribution and historical cumulative contribution of the local model of each client node after training based on the model parameters issued by the global model in the previous round of training.

[0045] The local model of each client node can be trained based on the model parameters issued by the global model in the previous round of training, and obtain the corresponding historical single contribution and historical cumulative contribution. The server node can obtain the historical single contribution and historical cumulative contribution of the local model of each client node.

[0046] Step 203: Determine the current cumulative contribution of each client node according to the total number of historical training times of the global model and the historical single contribution and historical cumulative contribution of each client node.

[0047] The server node can determine the current cumulative contribution of each client node based on the total number of historical training times of the global model and the historical single contribution and historical cumulative contribution of each client node.

[0048] In an embodiment of the present application, determining the current cumulative contribution of each client node based on the total number of historical training times of the global model and the historical single contribution and historical cumulative contribution of each client node includes: for each client node, when the total number of historical training times is equal to the preset number of times, determining the current cumulative contribution of the client node to be a third preset value; for each client node, when the total number of historical training times is greater than the preset number of times, respectively determining a first weight coefficient of the historical single contribution of the client node and a second weight coefficient of the historical cumulative contribution; for each client node, performing a weighted summation of the historical single contribution and the historical cumulative contribution of the client node based on the first weight coefficient and the second weight coefficient to obtain the current cumulative contribution of the client node.

[0049] When the total number of historical training times of the global model is equal to the preset number of times, the server node can determine that the current cumulative contribution of the client node is a third preset value. Wherein, the preset number of times and the third preset value can be customized according to actual conditions. For example, the preset number of times can be 1, and the third preset value can be 0. When the total number of historical training times of the global model is greater than the preset number of times, the server node can respectively determine the first weight coefficient of the historical single contribution of the client node and the second weight coefficient of the historical cumulative contribution. The server node can perform weighted summation of the historical single contribution and the historical cumulative contribution of the client node based on the first weight coefficient and the second weight coefficient to obtain the current cumulative contribution of the client node.

[0050] In an embodiment of the present application, the current cumulative contribution of each client node may be determined by the following formula:

[0051]

[0052] in, It refers to the current cumulative contribution of the jth client node during the kth training. It refers to the historical cumulative contribution of the j-th client node during the k-1-th training. It refers to the historical single contribution of the jth client node during the k-1th training, α refers to the first weight coefficient of the historical single contribution of the client node, 1-α refers to the second weight coefficient of the historical cumulative contribution of the client node, k refers to the total number of historical trainings of the global model, α is a constant, k and j are both positive integers, 0<j≤N c , N c Refers to the total number of federated learning client nodes.

[0053] Step 204: Determine the number of client nodes participating in the current training round and the current probability of each client node being randomly selected according to the current cumulative contribution of each client node.

[0054] The server node can determine the number of client nodes participating in the current training round and the current probability of each client node being randomly selected based on the current cumulative contribution of each client node.

[0055] In an embodiment of the present application, determining the number of client nodes participating in the current training round based on the current cumulative contribution of each client node and the current probability of each client node being randomly selected includes: determining the total number of client nodes whose current cumulative contribution is greater than a first preset value; determining the smaller value between the total number of nodes and the planned number of client nodes participating in the current training round as the number of client nodes participating in the current training round; selecting any one client node from a plurality of client nodes as the selected client node, and determining the sum of the current cumulative contributions of the plurality of client nodes; determining the ratio between the current cumulative contribution of the selected client node and the sum of the current cumulative contributions as the current probability of the selected client node being randomly selected; removing the selected client node from the plurality of client nodes, and returning to the step of selecting any one client node from the plurality of client nodes as the selected client node, until the current probability of each client node being randomly selected is determined.

[0056] The server node may determine, from among multiple client nodes, client nodes whose current cumulative contribution is greater than a first preset value based on the current cumulative contribution of each client, and determine the total number of client nodes whose current cumulative contribution is greater than the first preset value. The server node may obtain the planned number of client nodes participating in the current training round, and may determine the smaller value between the total number of nodes and the planned number of participants as the number of client nodes participating in the current training round, i.e., the actual number of client nodes participating in the current training round.

[0057] In an embodiment of the present application, the number of client nodes participating in the current training round can be determined according to the following formula:

[0058] m=min{N fc ,|S k |}

[0059] Among them, m refers to the number of client nodes participating in the current training round, N fc Refers to the planned number of client nodes participating in the current training round, |S k | refers to the total number of client nodes whose current cumulative contribution is greater than the first preset value.

[0060] The server node can determine the probability of each client being randomly selected based on independent random sampling without replacement. The server node can select any one client node from multiple client nodes as the selected client node, and determine the current cumulative contribution sum of multiple client nodes. The server node can determine the ratio between the current cumulative contribution of the selected client node and the current cumulative contribution sum, and determine the ratio as the probability of the selected client node being randomly selected. Then, the server node can remove the selected client node from multiple client nodes, and return to the step of selecting any one client node from multiple client nodes as the selected client node. At this point, the server node can select any one client node from multiple client nodes that remove the selected client node as the new selected client node, and determine the new current cumulative contribution sum of multiple client nodes that remove the selected client node, and determine the probability of the new selected client node being randomly selected at present, until the probability of each client node being randomly selected at present is determined.

[0061] Step 205: selecting a number of client nodes that participate in the current training round from a plurality of client nodes according to the current probability of each client node being randomly selected.

[0062] The server node may select a number of client nodes participating in the current training round from the plurality of client nodes according to the current random selection probability of each client node.

[0063] Step 206: Send the model parameters to each client node participating in this round of training, so that each client node participating in this round of training trains the corresponding local model by sending the model parameters.

[0064] The server node can send the model parameters to each client node participating in this round of training, so that each client node participating in this round of training trains the corresponding local model by sending the model parameters.

[0065] In an embodiment of the present application, the method also includes: after sending the model parameters to each client node participating in this round of training, receiving the local update gradient of the local model sent by each client node participating in this round of training; determining the current single contribution of each client node participating in this round of training relative to the target client node according to the local update gradient of each local model, and the target client node is selected from multiple client nodes according to preset business requirements; updating the model parameters according to all current single contributions to obtain the final model parameters of the global model in the current training round; when it is determined that the final model parameters of the current training round and / or the total number of training of the global model do not meet the termination training conditions, return to the step of obtaining the historical single contribution and historical cumulative contribution of the local model of each client node after training based on the model parameters sent by the global model in the previous round of training, until the re-determined final model parameters and / or the total number of training times meet the termination training conditions.

[0066] After sending the model parameter value to each client node participating in this round of training, each client node participating in this round of training can update the corresponding local model by sending the model parameter, and use the local training data set and the stochastic gradient descent algorithm to train the corresponding local model to obtain the local update gradient of the local model. Each client node participating in this round of training can send the local update gradient of the local model to the server node. The server node can receive the local update gradient of the local model sent by each client node participating in this round of training.

[0067] The server node can determine the current single contribution of each client node participating in this round of training relative to the target client node based on the local update gradient of each local model. Among them, the current single contribution of each client node participating in this round of training refers to the influence of the local update gradient generated by the client node participating in this round of training on the prediction loss of the global model of the current training round on the target client node. The target client node is selected from multiple client nodes based on preset business requirements. The target client node can be any one of the multiple client nodes, which can be selected from multiple client nodes before the initial training round based on preset business requirements.

[0068] The server node can update and send model parameters based on all current single contributions to obtain the final model parameters of the global model in the current training round. When it is determined that the final model parameters of the current training round and / or the total number of trainings of the global model do not meet the conditions for terminating training, return to the step of obtaining the historical single contribution and historical cumulative contribution of the local model of each client node after training based on the model parameters sent by the global model in the previous round of training, until the re-determined final model parameters and / or the total number of trainings meet the conditions for terminating training. Among them, the conditions for terminating training are that the final model parameters of the current training round converge and / or the total number of trainings of the global model is greater than or equal to the preset number of times.

[0069] In an embodiment of the present application, determining the current single contribution of each client node participating in the current round of training relative to the target client node based on the local update gradient of each client node participating in the current round of training includes: determining the global update gradient of the global model and the first test parameter of each client node participating in the current round of training based on the local update gradient of each client node participating in the current round of training; determining the second test parameter for the global model based on the global update gradient; sending the first test parameter and the second test parameter of each client node participating in the current round of training to the target client node; obtaining the first prediction loss and the second prediction loss corresponding to each first test parameter and the second test parameter, respectively, sent by the target client node; determining the current single contribution of each client node participating in the current round of training relative to the target client node based on the first prediction loss and the second prediction loss of each client node participating in the current round of training.

[0070] The server node can determine the global update gradient of the global model and the first test parameter of each client node participating in this round of training based on the local update gradient of each client node participating in this round of training. In an embodiment of the present application, the global update gradient of the global model can be determined by the following formula:

[0071]

[0072] in, It refers to the global update gradient of the global model during the kth training. i | refers to the total amount of data in the sample data set of the i-th client node participating in this round of training during the k-th training. It refers to the local update gradient of the i-th client node participating in this round of training during the k-th training, 0<i≤m, and m refers to the total number of client nodes participating in this round of training during the k-th training.

[0073] In the embodiment of the present application, the first test parameter of each client node participating in the current round of training is determined by formula (1):

[0074]

[0075] Among them, w′ ik It refers to the first test parameter of the i-th client node participating in this round of training during the k-th training. k-1 refers to the final model parameters of the global model during the k-1th training, η refers to the learning rate, m refers to the total number of client nodes participating in this round of training during the kth training, |D j | refers to the total amount of data in the sample data set of the jth client node participating in this round of training during the kth training. The jth client node participating in this round of training refers to the client node participating in this round of training that is different from the i-th client node participating in this round of training among the m client nodes participating in this round of training. It refers to the local update gradient of the jth client node participating in this round of training during the kth training.

[0076] The server node can determine the second test parameter for the global model according to the global update gradient. In an embodiment of the present application, the second test parameter of the global model can be determined by the following formula:

[0077]

[0078] Among them, w′ kk refers to the second test parameter of the global model during the kth training, w k-1 refers to the final model parameters of the global model during the k-1th training, η refers to the learning rate, 0<η<1, It refers to the global update gradient of the global model during the kth training.

[0079] The server node may send the first test parameter and the second test parameter of each client node participating in this round of training to the target client node. The target client node may update the local model respectively through the first test parameter and the second test parameter, and train the corresponding local model respectively using the local test data set to obtain the first prediction loss and the second prediction loss corresponding to each first test parameter and the second test parameter. The target client node may send the first prediction loss and the second prediction loss respectively to the server node, and the server node may obtain the first prediction loss and the second prediction loss respectively corresponding to each first test parameter and the second test parameter sent by the target client node. The server node may determine the current single contribution of each client node participating in this round of training relative to the target client node based on the first prediction loss and the second prediction loss of each client node participating in this round of training.

[0080] In an embodiment of the present application, determining the current single contribution of each client node participating in the current round of training relative to the target client node based on the first predicted loss and the second predicted loss of each client node participating in the current round of training includes: for each client node participating in the current round of training, determining the loss difference between the first predicted loss and the second predicted loss of the client node participating in the current round of training; for each client node participating in the current round of training, determining the ratio between the loss difference and the second predicted loss as the current single contribution of the client node participating in the current round of training relative to the target client node.

[0081] For each client node participating in this round of training, the server node can determine the loss difference between the first prediction loss and the second prediction loss of the client node participating in this round of training. The server node can determine the ratio between the loss difference and the second prediction loss, and determine the ratio as the current single contribution of the client node participating in this round of training relative to the target client node. Among them, the current single contribution of each client node participating in this round of training refers to the influence of the local update gradient generated by the client node participating in this round of training on the prediction loss of the global model of the current training round on the target client node.

[0082] In the embodiment of the present application, the current single contribution of the client node participating in the current round of training relative to the target client node can be determined by the following formula:

[0083]

[0084] in, It refers to the current single contribution of the i-th client node participating in this round of training during the k-th training, L′ ik It refers to the first prediction loss corresponding to the first test parameter of the i-th client node participating in this round of training during the k-th training, L′ k It refers to the second prediction loss corresponding to the second test parameter of the global model during the k-th training.

[0085] In an embodiment of the present application, updating and sending model parameters based on all current single contributions to obtain the final model parameters of the global model in the current training round includes: selecting client nodes participating in this round of training whose current single contribution is greater than a second preset value as candidate client nodes; updating and sending model parameters based on the local update gradient of the candidate client node to obtain the final model parameters of the global model in the current training round.

[0086] The server node may select the client nodes participating in the current round of training whose current single contribution is greater than the second preset value as candidate client nodes. The second preset value may be customized according to actual conditions. For example, the second preset value is 0. The server node may update and distribute the model parameters according to the local update gradient of the candidate client node to obtain the final model parameters of the global model in the current training round.

[0087] In the embodiment of the present application, the final model parameters of the global model in the current training round can be determined by formula (2):

[0088]

[0089] Among them, w k refers to the final model parameters of the global model during the kth training, w k-1 refers to the final model parameters of the global model during the k-1th training, P k It refers to the set of client nodes participating in this round of training whose current single contribution is greater than the second preset value. It refers to the local update gradient of the client node participating in this round of training whose i-th current single contribution is greater than the second preset value during the k-th training. i | refers to the total amount of data in the sample data set of the client node participating in this round of training whose current single contribution is greater than the second preset value.

[0090] Through the above technical solution, the participation probability of each client node in the current training round is determined according to the current cumulative contribution of each client node in the current training round, so as to dynamically adjust the client nodes participating in the current training round, and train the local models of the client nodes participating in the current training round through the model parameters issued by the global model in the current training round, so as to make full use of the effective client node optimization to improve the federated machine learning, and improve the training effect and model performance of the federated machine learning. Moreover, the global model of the current training round is generated by aggregating the local update gradients provided by the client nodes whose contribution in this round is greater than the second preset value, which effectively avoids the negative effect of the client nodes with negative contribution in this round on the global model of the current training round.

[0091] like Figure 3 As shown, a flowchart of another federated machine learning method is provided, including the following steps:

[0092] Step 301: The server node S can initialize the global model parameters. Assume that the total number of federated learning client nodes is N c The server can initialize the global model parameters. The server refers to the server node S. The server node S can initialize the parameters of the adopted deep neural network model, and the initialization parameter is w0.

[0093] Step 302: The server can send global model parameters to some client nodes randomly selected according to the cumulative contribution. The model parameter sending includes the steps of selecting training nodes and synchronizing model parameters. The step of selecting training nodes includes: in the kth round of model training, the server node S can determine each client node C j Cumulative contribution of in, It refers to the historical single contribution of the jth client node during the k-1th training. It refers to the historical cumulative contribution of the jth client node during the k-1th training, k refers to the model training round, α is the weight constant, 0<α<1. The server node S is based on each client node C j Cumulative contribution of From N c m client nodes are randomly selected from the client nodes. In specific implementation, the above selection process can be divided into m independent random sampling processes of single client nodes without replacement. In each sampling, the probability of each client node that has not been selected being selected this time is the ratio of the cumulative contribution of the node to the sum of the cumulative contributions of all nodes that have not been selected.

[0094] If the cumulative contribution of a client node is not greater than 0, the probability of the node being selected is 0. The selected federated learning client node is C i , i is the client node number, 0<i≤m. Among them, m=min{N fc ,|S k |}, m is the number of client nodes actually extracted, N fc Indicates the number of client nodes planned for each round of plan extraction, 0<N fc ≤N c , min{x,y} is a function to find the minimum value of x and y, 0<m≤N c , S k It is the set of all the serial numbers of client nodes whose cumulative contribution is greater than 0. k | represents the set S k The number of elements in. Among them, i, j, k, N fc and N c The steps of model parameter synchronization include: the server node S sets the parameters w of the global model of the deep neural network model to k-1 Sent to the selected federated learning client node C i Among them, w k-1 Refers to the final model parameters of the global model during the k-1th training.

[0095] Step 303: The selected client node can train the local model based on the local training data and upload the local update gradient to the server node. The model local training step includes: in the kth round of model training, each selected federated learning client node C i Using the global model parameters w received from the server node S k-1 Update the local model, use the local training data set and the stochastic gradient descent algorithm to train the local model, and calculate the local update gradient of the local model Each federated learning client node C i The local update gradient of the local model Sent to server node S.

[0096] Step 304: The server can synthesize the test parameters and send them to the target client node, calculate the contribution of each client node according to the test results of the target client node, and aggregate to generate the global model parameters. In the kth round of model training, the server node S first receives the update gradients uploaded by each client node. Then according to Determine the global update gradient of the global model in, It refers to the global update gradient of the global model during the kth training. i | refers to the total amount of data in the sample data set of the i-th client node participating in this round of training during the k-th training. It refers to the local update gradient of the i-th client node participating in this round of training during the k-th training, 0<i≤m, and m refers to the total number of client nodes participating in this round of training during the k-th training.

[0097] The server node S can be based on Calculate the parameters w′ of the global model k Among them, w′ k refers to the second test parameter of the global model during the kth training, w k-1 refers to the final model parameters of the global model during the k-1th training, η refers to the learning rate, 0<η<1, It refers to the global update gradient of the global model during the kth training. The server node S can be based on Calculate each client node C i The corresponding test parameter w′ ik Among them, w′ 1k It refers to the first test parameter of the i-th client node participating in this round of training during the k-th training. k-1refers to the final model parameters of the global model during the k-1th training, η refers to the learning rate, m refers to the total number of client nodes participating in this round of training during the kth training, |D j | refers to the total amount of data in the sample data set of the jth client node participating in this round of training during the kth training. The jth client node participating in this round of training refers to the client node participating in this round of training that is different from the i-th client node participating in this round of training among the m client nodes participating in this round of training. It refers to the local update gradient of the jth client node participating in this round of training during the kth training.

[0098] The server node S can k ′ and w i ' k Sent to the target client node. i For client node C i Locally stored sample dataset, |D i | is the set D i The number of elements contained, η is the learning rate, 0<η<1. The target client node uses the local test data set to test w k ′ and w i ' k The prediction loss L′ of the corresponding model k and L′ ik , and sent to the server node S. The server node S can Calculate the time for each client node C during the kth round of model training i Contribution to the target client node in, It refers to the current single contribution of the i-th client node participating in this round of training during the k-th training, L′ ik It refers to the first prediction loss corresponding to the first test parameter of the i-th client node participating in this round of training during the k-th training, L′ k It refers to the second prediction loss corresponding to the second test parameter of the global model during the k-th training.

[0099] The server node S can aggregate the client nodes with positive contribution values ​​uploaded and According to the final global model parameter w k Among them, w k refers to the final model parameters of the global model during the kth training, w k-1 refers to the final model parameters of the global model during the k-1th training. It refers to the set of client nodes participating in this round of training whose current single contribution is greater than 0. It refers to the local update gradient of the client node participating in this round of training whose i-th current single contribution is greater than the second preset value during the k-th training. i | refers to the total amount of data in the sample data set of the client node participating in this round of training whose current single contribution is greater than the second preset value.

[0100] Step 305: The server can determine the training termination condition. If the training termination condition is not met, the global model parameters are sent and the above training process is repeated. k Convergence or k ≥ E TH , then the training process is terminated. TH is a positive integer. If the parameter w of the global model k Not converged or k<E TH , then the execution server returns to the step of sending the model parameters to some client nodes randomly selected according to the cumulative contribution, and the k+1th round of model training process begins.

[0101] In one embodiment, the server node initializes the parameters of the adopted deep neural network model, and the initialization parameter is w0.

[0102] In the kth round of model training, the server node S calculates the j Cumulative contribution of From N c = m = 1000 client nodes are randomly selected from the 10000 client nodes. The server node S sets the parameter w of the global model of the deep neural network model k-1 Sent to the selected federated learning client nodes, each of which stores private user behavior data.

[0103] During the kth round of model training, each selected federated learning client node C i Using the global model parameters w received from the server node S k-1 Update the local model, use the local training data set to train the local model using the stochastic gradient descent algorithm, and calculate the updated gradient of the local model Will Sent to server node S.

[0104] In the kth round of model training, the server node S first receives the update gradients uploaded by each client node Then calculate the parameters w′ of the global model kk and each client node C i The corresponding test parameter w′ ik , and w′ k and w′ ikSent to the target client node. The initial value of η can be 0.05, and gradually decays to 0 with k.

[0105] The target client node tests w′ using the local test dataset k and w′ ik The prediction loss L′ of the corresponding model k and L′ ik , and sent to the server node S. The server node S calculates each client node C during the k-th round of model training. i Contribution to the target client node Server node S aggregates the data uploaded by client nodes with positive contribution Generate the final global model parameters w k .

[0106] If the global model parameter w k Convergence or k ≥ E TH =100, the training process is terminated, otherwise it returns to the execution server node S according to each client node C j Cumulative contribution of From N c =10000 client nodes are randomly selected to start the k+1th round of model training process.

[0107] like Figure 4 As shown, a timing diagram of a federated machine learning method is provided.

[0108] The server node 101 determines the model parameters sent by the global model in the current training round, and obtains the historical single contribution and historical cumulative contribution of the local model of each client node 102 after training based on the model parameters sent by the global model in the previous training round. The server node 101 determines the current cumulative contribution of each client node 102 based on the total number of historical training times of the global model and the historical single contribution and historical cumulative contribution of each client node 102.

[0109] The server node 101 determines the number of client nodes participating in the current training round according to the current cumulative contribution of each client node 102, and the current random selection probability of each client node 102, and selects the client nodes participating in the current training round from multiple client nodes 102 according to the current random selection probability of each client node 102. The server node 101 sends the model parameters to each client node participating in the current training round. Each client node participating in the current training round can update the corresponding local model by sending the model parameters, and use the local training data set and the stochastic gradient descent algorithm to train the corresponding local model to obtain the local update gradient of the local model. Each client node participating in the current training round sends the local update gradient of the local model to the server node 101.

[0110] The server node 101 can determine the global update gradient of the global model and the first test parameter of each client node participating in this round of training according to the local update gradient of each client node participating in this round of training. The server node 101 can determine the second test parameter for the global model according to the global update gradient. The server node 101 can send the first test parameter and the second test parameter of each client node participating in this round of training to the target client node. The target client node can update the local model respectively by the first test parameter and the second test parameter, and train the corresponding local model respectively using the local test data set to obtain the first prediction loss and the second prediction loss corresponding to each first test parameter and the second test parameter. The target client node can send the first prediction loss and the second prediction loss to the server node 101 respectively. The server node 101 can determine the current single contribution of each client node participating in this round of training relative to the target client node according to the first prediction loss and the second prediction loss of each client node participating in this round of training.

[0111] The server node 101 can select the client nodes participating in this round of training whose current single contribution is greater than the second preset value as candidate client nodes. The server node 101 can update and issue model parameters according to the local update gradient of the candidate client node to obtain the final model parameters of the global model in the current training round. The server node 101 can determine whether the final model parameters of the current training round and / or the total number of training of the global model meet the termination training conditions. In the case of determining that the final model parameters of the current training round and / or the total number of training of the global model do not meet the termination training conditions, return to the step of obtaining the historical single contribution and historical cumulative contribution obtained after the local model of each client node 102 is trained based on the model parameters issued by the global model in the previous round of training, until the re-determined final model parameters and / or the total number of trainings meet the termination training conditions. Among them, the termination training condition is that the final model parameters of the current training round converge and / or the total number of trainings of the global model is greater than or equal to the preset number of times.

[0112] Figure 2 and 3 FIG. 1 is a flow chart of a federated machine learning method in one embodiment. It should be understood that although Figure 2 and 3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 and 3 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0113] In one embodiment, a processor is provided, which is configured to execute the above-mentioned federated machine learning method.

[0114] In one embodiment, a machine-readable storage medium is provided, on which instructions are stored, and the instructions are used to enable a machine to execute the above-mentioned federated machine learning method.

[0115] In one embodiment, a federated machine learning device is provided, comprising the above-mentioned processor.

[0116] In one embodiment, a computer device is provided, comprising:

[0117] a memory configured to store instructions; and

[0118] The federated machine learning apparatus described above.

[0119] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 5 As shown. The computer 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 via a system bus. Among them, the processor A01 of the computer device is used to provide computing and control capabilities. The memory of the computer 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 database of the computer device is used to store data such as the model parameters issued for the current training round. The network interface A02 of the computer device is used to communicate with an external terminal through a network connection. When the computer program B02 is executed by the processor A01, a federated machine learning method is implemented.

[0120] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0121] An embodiment of the present application provides a device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, the above-mentioned steps of the federated machine learning method are implemented.

[0122] The present application also provides a computer program product which, when executed on a data processing device, is suitable for executing a program initialized with the above-mentioned federated machine learning method steps.

[0123] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0124] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0125] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0126] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0127] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0128] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0129] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. 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 technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0130] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0131] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A federated machine learning method, characterized in that: Applied to a server node, the method comprises: Determining the final model parameters obtained by the global model on the server node after the last round of training as the model parameters issued by the global model in the current training round; Obtain the historical single contribution and historical cumulative contribution of the local model of each client node after training based on the model parameters issued by the global model during the previous round of training; Determine the current cumulative contribution of each client node according to the total number of historical training times of the global model and the historical single contribution and historical cumulative contribution of each client node, wherein, when the total number of historical training times is greater than a preset number, the current cumulative contribution refers to the weighted sum of the historical single contribution and the historical cumulative contribution of the corresponding client node; Determine the number of client nodes participating in the current training round and the current probability of each client node being randomly selected according to the current cumulative contribution of each client node; Selecting the number of client nodes participating in the current training round from the plurality of client nodes according to the current random selection probability of each client node; Sending the sent model parameters to each client node participating in this round of training, so that each client node participating in this round of training trains a corresponding local model through the sent model parameters; Wherein, the determining the number of client nodes participating in the current training round according to the current cumulative contribution of each client node, and the current probability of each client node being randomly selected includes: Determine the total number of client nodes whose current cumulative contribution is greater than a first preset value; Determine the smaller value between the total number of nodes and the planned number of client nodes participating in the current training round as the number of client nodes participating in the current training round; Selecting one client node from the plurality of client nodes as the selected client node, and determining the sum of current accumulated contributions of the plurality of client nodes; Determine the ratio between the current cumulative contribution of the selected client node and the sum of the current cumulative contributions as the current probability of the selected client node being randomly selected; The selected client node is removed from the multiple client nodes, and the process returns to the step of selecting any one client node from the multiple client nodes as the selected client node, until the current probability of each client node being randomly selected is determined.

2. The federated machine learning method according to claim 1, characterized in that: The method further comprises: After sending the model parameters to each client node participating in this round of training, receiving the local update gradient of the local model sent by each client node participating in this round of training; Determine the current single contribution of each client node participating in the current round of training relative to a target client node according to the local update gradient of each local model, wherein the target client node is selected from a plurality of client nodes according to preset business requirements; Update the issued model parameters according to all current single contributions to obtain the final model parameters of the global model in the current training round; When it is determined that the final model parameters of the current training round and / or the total number of training times of the global model do not meet the conditions for terminating training, return to the step of obtaining the historical single contribution and historical cumulative contribution of the local model of each client node after training based on the model parameters issued by the global model in the previous round of training, until the re-determined final model parameters and / or the total number of training times meet the conditions for terminating training.

3. The federated machine learning method according to claim 2, characterized in that: Determining the current single contribution of each client node participating in the current round of training relative to the target client node according to the local update gradient of each client node participating in the current round of training includes: Determine the global update gradient of the global model and the first test parameter of each client node participating in the current round of training according to the local update gradient of each client node participating in the current round of training; Determine a second test parameter for the global model according to the global update gradient; Sending the first test parameter and the second test parameter of each client node participating in this round of training to the target client node; Obtaining a first predicted loss and a second predicted loss respectively corresponding to each first test parameter and the second test parameter sent by the target client node; The current single contribution of each client node participating in the current round of training relative to the target client node is determined according to the first prediction loss and the second prediction loss of each client node participating in the current round of training.

4. The federated machine learning method according to claim 3, characterized in that: The determining, according to the first prediction loss and the second prediction loss of each client node participating in the current round of training, the current single contribution of each client node participating in the current round of training relative to the target client node comprises: For each client node participating in this round of training, determine a loss difference between a first predicted loss and a second predicted loss of the client node participating in this round of training; For each client node participating in this round of training, the ratio between the loss difference and the second predicted loss is determined as the current single contribution of the client node participating in this round of training relative to the target client node.

5. The federated machine learning method according to claim 3, characterized in that: The first test parameter is determined by formula (1): Among them, w′ ik It refers to the first test parameter of the i-th client node participating in this round of training during the k-th training. k-1 refers to the final model parameters of the global model during the k-1th training, η refers to the learning rate, m refers to the total number of client nodes participating in this round of training during the kth training, |D j | refers to the total amount of data in the sample data set of the jth client node participating in this round of training during the kth training. The i-th client node participating in this round of training refers to the client node participating in this round of training that is different from the i-th client node participating in this round of training among the m client nodes participating in this round of training. It refers to the local update gradient of the jth client node participating in this round of training during the kth training.

6. The federated machine learning method according to claim 2, characterized in that: The updating of the issued model parameters according to all current single contributions to obtain the final model parameters of the global model in the current training round includes: Selecting the client nodes participating in this round of training whose current single contribution is greater than the second preset value as candidate client nodes; The sent model parameters are updated according to the local update gradient of the candidate client node to obtain the final model parameters of the global model in the current training round.

7. The federated machine learning method according to claim 6, characterized in that: The final model parameters of the global model in the current training round are determined by formula (2): Among them, w k refers to the final model parameters of the global model during the kth training, w k -1 refers to the final model parameters of the global model during the k-1th training, η refers to the learning rate, P k refers to the total number of candidate client nodes during the kth training, |D i | refers to the total amount of data in the sample data set of the i-th client node participating in this round of training, It refers to the local update gradient of the i-th client node participating in this round of training during the k-th training.

8. The federated machine learning method according to claim 1, characterized in that: Determining the current cumulative contribution of each client node according to the total number of historical training times of the global model and the historical single contribution and historical cumulative contribution of each client node includes: For each client node, when the total number of historical training times is equal to the preset number of times, determining the current cumulative contribution of the client node to be a third preset value; For each client node, when the total number of historical training times is greater than the preset number of times, respectively determining a first weight coefficient of the historical single contribution and a second weight coefficient of the historical cumulative contribution of the client node; For each client node, a weighted sum is performed on the historical single contribution and the historical cumulative contribution of the client node based on the first weight coefficient and the second weight coefficient to obtain the current cumulative contribution of the client node.

9. A processor, characterized in that: Configured to perform the federated machine learning method according to any one of claims 1 to 8.

10. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores instructions for causing a machine to execute the federated machine learning method according to any one of claims 1 to 8.

11. A federated machine learning device, characterized in that: The apparatus comprises a processor according to claim 9.

12. A computer device, characterized in that: include: a memory configured to store instructions; and A federated machine learning apparatus according to claim 11.

Citation Information

Patent Citations

  • Tree-based resource distribution method

    CN108416615A

  • Federal learning-based client contribution calculation method and device

    CN112926897A