Federated learning method, device, computing device and machine-readable storage medium

By detecting and removing abnormal node devices in federated learning, the impact of Byzantine attacks on model training is solved and the high reliability and quality of the model are ensured.

CN117829269BActive Publication Date: 2024-09-03BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311733982.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-15
Publication Date
2024-09-03
Estimated Expiration
2043-12-15

AI Technical Summary

Technical Problem

In federated learning, Byzantine attacks cause abnormal information sent by node devices to affect the training of the global model, causing the model to converge to suboptimal or divergent, making it impossible to obtain a highly reliable model.

Method used

Abnormal nodes are detected by calculating the distance between the median aggregate gradient and the mean aggregate gradient of node devices, remove abnormal node devices, and update global model parameters to ensure the reliability of model training.

Benefits of technology

It effectively detects and removes the impact of Byzantine attacks, ensures that the model converges to a high-quality global model, avoids model divergence, and achieves a highly reliable model through federated learning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117829269B
    Figure CN117829269B
Patent Text Reader

Abstract

The embodiment of the present application discloses a federated learning method, apparatus, computing device and machine-readable storage medium, which belongs to the field of machine learning. The federated learning method includes: sending the global model parameters of the previous round to a first number of node devices, so that the node devices train the local model according to the global model parameters to obtain the local model update gradient; determining the first median aggregation gradient and the first mean aggregation gradient of the global model according to the local model update gradient corresponding to the first number of node devices; determining the abnormality of each node device respectively when the distance between the first median aggregation gradient and the first mean aggregation gradient is greater than a preset threshold; removing abnormal node devices based on the abnormality of each node device to obtain a second number of node devices; determining the global model parameters of the current round according to the second mean aggregation gradient and the global model parameters of the previous round; updating the global model based on the global model parameters of the current round.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of machine learning, and in particular to a federated learning method, apparatus, computing device and machine-readable storage medium. Background Art

[0002] With the rapid development of machine learning technology, trained machine learning models are widely used in various scenarios such as image analysis, speech recognition, and intelligent recommendation. Federated learning is a distributed learning technology that allows node devices to train models locally. In scenarios with sensitive data such as medical and financial, compared to centralized learning, federated learning does not require node devices to share sensitive local data with central devices. Instead, it only needs to transmit the parameters of the model training back to the central device, which can protect node devices from sensitive local data leakage and protect user privacy.

[0003] However, when using a distributed system for federated learning, there is a situation where the distributed system is subject to Byzantine attacks. Specifically, the node devices disguised by the attacker or the node devices hijacked by the attacker are called Byzantine nodes. Byzantine nodes continuously send misleading information and abnormal information such as malicious information to the central device, affecting the central device's training of the global model. A large number of Byzantine nodes constantly sending abnormal information will cause the trained model to converge only to a suboptimal model, and even cause the model to diverge, making it impossible to obtain a highly reliable model through federated learning. Summary of the invention

[0004] The purpose of the embodiments of the present invention is to provide a federated learning method, apparatus, computing device and machine-readable storage medium. The federated learning method is used to solve the problem of models that cannot be highly reliable through federated learning.

[0005] In order to achieve the above objectives, in a first aspect, the present application provides a federated learning method, which includes:

[0006] Sending the global model parameters of the previous round to the first number of node devices, so that the node devices train the local models according to the global model parameters to obtain the local model update gradients;

[0007] Determine a first median aggregate gradient and a first mean aggregate gradient of a global model according to local model update gradients corresponding to the first number of node devices;

[0008] When the distance between the first median aggregate gradient and the first mean aggregate gradient is greater than a preset threshold, determining the abnormality degree of each node device respectively;

[0009] Removing abnormal node devices based on the abnormality degree of each node device to obtain a second number of node devices, wherein the distance between the second median aggregation gradient and the second mean aggregation gradient corresponding to the second number of node devices is less than or equal to a preset threshold, and the second number is the maximum number of node devices that satisfy the distance between the second median aggregation gradient and the second mean aggregation gradient is less than or equal to the preset threshold;

[0010] Determine the global model parameters of the current round according to the second mean aggregate gradient and the global model parameters of the previous round;

[0011] Based on the global model parameters of the current round, the global model is updated.

[0012] In an embodiment of the present application, the federated learning method further includes:

[0013] Obtain the cumulative abnormality of each node device in the node device set;

[0014] A first number of node devices are selected from the set of node devices according to the accumulated abnormality of each node device, wherein the selection probability of each node device is negatively correlated with the accumulated abnormality.

[0015] In an embodiment of the present application, removing abnormal node devices based on the abnormality degree of each node device to obtain a second number of node devices includes:

[0016] sorting the first number of node devices by abnormality;

[0017] Determine the node device with the highest abnormality as an abnormal node device;

[0018] Remove abnormal node devices to obtain a preset number of node devices;

[0019] When the preset number is not the second number, the step of determining the node device with the highest abnormality as the abnormal node device is repeatedly performed until the second number of node devices is obtained.

[0020] In an embodiment of the present application, the federated learning method further includes:

[0021] When the distance between the first median aggregate gradient and the first mean aggregate gradient is less than or equal to a preset threshold, determining the first mean aggregate gradient as the global aggregate gradient of the global model;

[0022] The global model parameters of the current round are determined according to the global aggregate gradient, the global model parameters of the previous round and the model learning rate of the current round.

[0023] In an embodiment of the present application, when the distance between the first median aggregate gradient and the first mean aggregate gradient is greater than a preset threshold, determining the abnormality of each node device separately includes:

[0024] When the distance between the first median aggregate gradient and the first mean aggregate gradient is greater than a preset threshold, updating the gradient according to the local model corresponding to the node device other than the target node device, and determining the third median aggregate gradient and the third mean aggregate gradient corresponding to the target node device;

[0025] The abnormality of the target node device is determined according to the distance between the first median aggregate gradient and the first mean aggregate gradient, and the distance between the third median aggregate gradient and the third mean aggregate gradient.

[0026] In an embodiment of the present application, the federated learning method further includes:

[0027] In the case where the current round is the first round, initializing the global model, obtaining initial global model parameters of the global model, and sending the initial global model parameters to a first number of node devices;

[0028] Sending the global model parameters of the previous round to the first number of node devices includes:

[0029] When the current round is greater than the first round, the global model parameters of the previous round are sent to the first number of node devices.

[0030] In an embodiment of the present application, updating the global model based on the global model parameters of the current round includes:

[0031] When the global model update of the current round does not meet the termination condition, the global model is updated based on the global model parameters of the current round, and the step of sending the global model parameters of the previous round to the first number of node devices is performed until the global model update of the current round meets the termination condition.

[0032] In a second aspect, the present application provides a federated learning device, the federated learning device comprising:

[0033] A model parameter sending module, used to send the global model parameters of the previous round to a first number of node devices, so that the node devices train local models according to the global model parameters to obtain local model update gradients;

[0034] An aggregate gradient determination module, configured to determine a first median aggregate gradient and a first mean aggregate gradient of a global model according to local model update gradients corresponding to a first number of node devices;

[0035] An abnormality determination module, used to determine the abnormality of each node device respectively when the distance between the first median aggregate gradient and the first mean aggregate gradient is greater than a preset threshold;

[0036] A node device determination module, configured to remove abnormal node devices based on the abnormality degree of each node device, and obtain a second number of node devices, wherein the distance between the second median aggregation gradient and the second mean aggregation gradient corresponding to the second number of node devices is less than or equal to a preset threshold, and the second number is the maximum number of node devices satisfying that the distance between the second median aggregation gradient and the second mean aggregation gradient is less than or equal to the preset threshold;

[0037] A model parameter determination module, used to determine the global model parameters of the current round according to the second mean aggregate gradient and the global model parameters of the previous round;

[0038] The global model updating module is used to update the global model based on the global model parameters of the current round.

[0039] In a third aspect, the present application provides a computing device, including:

[0040] a memory configured to store instructions; and

[0041] The processor is configured to call instructions from the memory and implement the above-mentioned federated learning method when executing the instructions.

[0042] In a fourth aspect, the present application provides a machine-readable storage medium, on which instructions are stored, and the instructions are used to enable a processor to execute the above-mentioned federated learning method.

[0043] The present application provides a federated learning method, which includes: sending the global model parameters of the previous round to a first number of node devices, so that the node devices train local models according to the global model parameters to obtain local model update gradients; determining the first median aggregation gradient and the first mean aggregation gradient of the global model according to the local model update gradients corresponding to the first number of node devices; determining the abnormality of each node device respectively when the distance between the first median aggregation gradient and the first mean aggregation gradient is greater than a preset threshold; removing abnormal node devices based on the abnormality of each node device to obtain a second number of node devices; determining the global model parameters of the current round according to the second mean aggregation gradient and the global model parameters of the previous round; and updating the global model based on the global model parameters of the current round. Since the influence of the abnormal information sent by the abnormal node device on the median aggregation gradient can be ignored, the mean aggregation gradient is detected by the median aggregation gradient, thereby accurately detecting whether it is attacked by Byzantine. At the same time, by removing the abnormal local model update gradient sent by the abnormal node device, and then updating the global model parameters, a high reliability model can be obtained through federated learning.

[0044] Other features and advantages of the embodiments of the present invention will be described in detail in the subsequent detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0046] Figure 1 A flowchart of a federated learning method provided in an embodiment of the present application is shown;

[0047] Figure 2 An example diagram of an application of a node device provided in an embodiment of the present application is shown;

[0048] Figure 3 A schematic diagram of the structure of a federated learning device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0049] The specific implementation of the embodiment of the present invention will be described in detail below in conjunction with the accompanying drawings in the embodiment of the present invention. It should be understood that the specific implementation described here is only used to illustrate and explain the embodiment of the present invention, and is not used to limit the embodiment of the present invention.

[0050] The components of the embodiments of the present invention generally described and shown in the drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0051] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present invention, are intended only to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or adding the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.

[0052] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.

[0053] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present invention belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present invention.

[0054] Example 1

[0055] See also Figure 1 , Figure 1 A flowchart of the federated learning method provided in an embodiment of the present application is shown.

[0056] Figure 1 The federated learning methods in include:

[0057] S110, sending the global model parameters of the previous round to a first number of node devices, so that the node devices train local models according to the global model parameters to obtain local model update gradients.

[0058] See also Figure 2 , Figure 2 An example diagram of an application of a node device provided in an embodiment of the present application is shown.

[0059] The federated learning method in this embodiment is applied to a computing device 210. As shown in the figure, in an actual federated learning scenario, the computing device 210 is connected to a plurality of node devices 220. For ease of understanding, only three node devices 220 are shown in the figure. The computing device 210 includes a global model, and the node device 220 includes a local model. The computing device 210 sends the global model parameters of the previous round to the first number of node devices 220 so that the node device 220 trains the local model according to the global model parameters, obtains the local model update gradient, and then updates the global model through the local model update gradient. The node device 220 performs model training locally, so that the node device 220 does not need to send sensitive data to the computing device 210, protects the user privacy of the node device 220, and avoids the leakage of sensitive data.

[0060] Specifically, the computing device 210 sends the global model parameters of the previous round to the first number of node devices 220. Each node device 220 updates the local model according to the received global model parameters of the previous round. The sample data set stored locally in the node device 220 is used as a training set, and the updated local model is trained using a stochastic gradient descent algorithm to obtain a local model update gradient. When the global model is updated in the current round, the node device 220 sends the local model update gradient to the computing device 210. It should be understood that the value of the first number is set according to actual needs and is not limited here. The types of global models and local models are set according to actual needs and can be any deep neural network, which is not limited here.

[0061] S120: Determine a first median aggregate gradient and a first mean aggregate gradient of a global model according to local model update gradients corresponding to the first number of node devices.

[0062] After receiving the local model update gradient sent by the node device, determine the first median aggregate gradient and the first mean aggregate gradient of the global model according to the local model update gradient corresponding to the first number of node devices. The first median aggregate gradient is the median of the local model update gradient corresponding to the first number of node devices, and the first mean aggregate gradient is the mean of the local model update gradient corresponding to the first number of node devices. Specifically, the first median aggregate gradient is:

[0063]

[0064] in, is the first median aggregate gradient of the global model, N fc is the first quantity, The local model update gradient is sent by the ith node device, where the ith node device is any node device among the first number of node devices.

[0065] The first mean aggregate gradient is:

[0066]

[0067] in, is the first mean aggregate gradient of the global model, N fc is the first quantity, The local model update gradient sent by the i-th node device, D i is the sample data set stored locally on the i-th node device, |D i | is the number of sample data included in the sample data set.

[0068] S130: When the distance between the first median aggregate gradient and the first mean aggregate gradient is greater than a preset threshold, determine the abnormality of each node device respectively.

[0069] The node device disguised by the attacker or hijacked by the attacker causes the node device to become an abnormal node device, that is, the node device becomes a Byzantine node. Since it is impossible to effectively detect whether the information sent by the node device is abnormal information, the abnormal node device can continuously send misleading information and malicious information to the computing device, thereby affecting the high reliability model obtained through federated learning.

[0070] When the number of abnormal node devices in the first number of node devices does not exceed half of the first number, the abnormal information sent by the abnormal node device will affect the first mean aggregation gradient, but the impact of the abnormal information on the first median aggregation gradient can be ignored. Determine whether the distance between the first median aggregation gradient and the first mean aggregation gradient is greater than a preset threshold, where the size of the preset threshold is set according to actual needs and is not limited here. When the distance between the first median aggregation gradient and the first mean aggregation gradient is less than or equal to the preset threshold, it is determined that the current round of update process of the global model is normal.

[0071] When the distance between the first median aggregate gradient and the first mean aggregate gradient is greater than a preset threshold, the current round of update process of the global model is determined to be abnormal, and the abnormality degree of each node device is determined respectively, so as to determine the abnormal node device by the abnormality degree. Since the influence of the abnormal information sent by the abnormal node device on the median aggregate gradient is negligible, the mean aggregate gradient is detected by the median aggregate gradient, so as to accurately detect whether it is subjected to a Byzantine attack.

[0072] In an embodiment of the present application, when the distance between the first median aggregate gradient and the first mean aggregate gradient is greater than a preset threshold, determining the abnormality of each node device includes:

[0073] When the distance between the first median aggregate gradient and the first mean aggregate gradient is greater than a preset threshold, updating the gradient according to the local model corresponding to the node device other than the target node device, and determining the third median aggregate gradient and the third mean aggregate gradient corresponding to the target node device;

[0074] The abnormality of the target node device is determined according to the distance between the first median aggregate gradient and the first mean aggregate gradient, and the distance between the third median aggregate gradient and the third mean aggregate gradient.

[0075] When the distance between the first median aggregate gradient and the first mean aggregate gradient is greater than a preset threshold, the marginal utility evaluation principle is used to determine the abnormality of each node device. Any node device among the first number of node devices is determined as the target node device, and the third median aggregate gradient and the third mean aggregate gradient corresponding to the target node device are determined according to the local model update gradients corresponding to the node devices other than the target node device. Specifically, after removing the target node device, the median of the local model update gradients corresponding to the remaining node devices is determined as the third median aggregate gradient:

[0076]

[0077] in, is the third median aggregate gradient corresponding to the i-th node device, N fc is the first quantity, The local model update gradient sent by the l-th node device, i is the i-th node device. The i-th node device is the target node device, and the l-th node device is the node device other than the target node device.

[0078] After removing the target node device, the mean of the local model update gradients corresponding to the remaining node devices is determined as the third mean aggregate gradient:

[0079]

[0080] in, is the third mean aggregate gradient corresponding to the i-th node device, N fc is the first quantity, is the local model update gradient sent by the lth node device, i is the i-th node device, D l is a sample data set stored locally on the lth node device. The i-th node device is the target node device, and the l-th node device is a node device other than the target node device.

[0081] According to the distance between the first median aggregate gradient and the first mean aggregate gradient, and the distance between the third median aggregate gradient and the third mean aggregate gradient, the abnormality of the target node device is determined:

[0082]

[0083] Among them, E ik is the abnormality degree of the i-th node device, L k is the distance between the first median aggregate gradient and the first mean aggregate gradient, is the third median aggregate gradient corresponding to the i-th node device, is the third mean aggregation gradient corresponding to the i-th node device, and the i-th node device is the target node device.

[0084] S140, removing abnormal node devices based on the abnormality of each node device to obtain a second number of node devices, wherein the distance between the second median aggregation gradient and the second mean aggregation gradient corresponding to the second number of node devices is less than or equal to a preset threshold, and the second number is the maximum number of node devices that satisfy the distance between the second median aggregation gradient and the second mean aggregation gradient is less than or equal to the preset threshold.

[0085] Based on the abnormality of each node device, the node device with high abnormality is determined as an abnormal node device. Based on the distance between the median aggregation gradient and the mean aggregation gradient, the abnormal node devices are removed, and the number of direct node devices is reduced from the first number to the second number. When the number of node devices is the second number, the distance between the second median aggregation gradient and the second mean aggregation gradient determined by the local model update gradient corresponding to the second number of node devices is less than or equal to the preset threshold, and the distance between the second median aggregation gradient and the second mean aggregation gradient corresponding to the second number of node devices is less than or equal to the preset threshold.

[0086] It should be understood that when the number of node devices is reduced from the first number to below the second number by removing abnormal node devices, the distance between the median aggregate gradient and the mean aggregate gradient of the obtained global model is also less than or equal to the preset threshold. The second number is the maximum number of node devices that satisfy the distance between the second median aggregate gradient and the second mean aggregate gradient is less than or equal to the preset threshold, so as to ensure that the second median aggregate gradient and the second mean aggregate gradient are determined according to the local model update gradient corresponding to a sufficient number of node devices.

[0087] In an embodiment of the present application, removing abnormal node devices based on the abnormality degree of each node device to obtain a second number of node devices includes:

[0088] sorting the first number of node devices by abnormality;

[0089] Determine the node device with the highest abnormality as an abnormal node device;

[0090] Remove abnormal node devices to obtain a preset number of node devices;

[0091] When the preset number is not the second number, the step of determining the node device with the highest abnormality as the abnormal node device is repeatedly performed until the second number of node devices is obtained.

[0092] For ease of understanding, the first number in the embodiment of the present application is 300. The 300 node devices are sorted by abnormality to determine the node device with the highest abnormality. Assume that one node device with the highest abnormality is determined from the 300 node devices, the node device with the highest abnormality is determined as an abnormal node device, and the abnormal node device is removed to obtain a preset number of node devices, that is, 299 node devices. According to the local model update gradient corresponding to the remaining 299 node devices, the current median aggregation gradient and the current mean aggregation gradient of the global model are determined.

[0093] When the distance between the current median aggregate gradient and the current mean aggregate gradient is greater than the preset threshold, it is determined that the preset number is not the second number, and the step of determining the node device with the highest abnormality as an abnormal node device is repeated. Specifically, assuming that two node devices with the highest abnormality are determined from the remaining 299 node devices, the two node devices with the highest abnormality are simultaneously determined as abnormal node devices, and the two abnormal node devices are removed at the same time, resulting in 297 nodes. According to the local model update gradient corresponding to the remaining 297 node devices, the current median aggregate gradient and the current mean aggregate gradient of the global model are updated.

[0094] When the distance between the current median aggregate gradient and the current mean aggregate gradient is less than or equal to the preset threshold, the preset number is determined to be the second number, the current median aggregate gradient is determined to be the second median aggregate gradient, and the current mean aggregate gradient is determined to be the second mean aggregate gradient.

[0095] S150, determining the global model parameters of the current round according to the second mean aggregate gradient and the global model parameters of the previous round.

[0096] By removing the abnormal node devices, the abnormal local model update gradients sent by the abnormal node devices are removed to obtain the second mean aggregate gradient. The second mean aggregate gradient is determined as the global aggregate gradient of the current round of the global model. According to the global aggregate gradient, the global model parameters of the previous round and the model learning rate of the current round, the global model parameters of the current round are determined:

[0097]

[0098] Among them, w k is the global model parameter of the kth round, w k-1 is the global model parameter of the k-1th round, η is the model learning rate of the current round, is the global aggregate gradient, the kth round is the current round, and the k-1th round is the previous round.

[0099] S160: Update the global model based on the global model parameters of the current round.

[0100] Based on the global model parameters of the current round, the global model is updated, that is, the current global model parameters of the global model are updated to the global model parameters of the current round to complete the current round update of the global model. By removing the abnormal local model update gradients sent by abnormal node devices and then updating the global model parameters, a highly reliable model can be obtained through federated learning.

[0101] In an embodiment of the present application, the federated learning method further includes:

[0102] Obtain the cumulative abnormality of each node device in the node device set;

[0103] A first number of node devices are selected from the set of node devices according to the accumulated abnormality of each node device, wherein the selection probability of each node device is negatively correlated with the accumulated abnormality.

[0104] When the global model is updated in each round, the cumulative abnormality of the node device is updated according to the abnormality of the node device. As the number of rounds of global model updates increases, the cumulative abnormality of the abnormal node device will continue to increase. When the global model is updated in the current round, the cumulative abnormality of each node device in the node device set is obtained.

[0105] Usually, the computing device can send global model parameters to all node devices in the node device set, and receive local model update gradients sent by all node devices. However, in actual federated learning, the Byzantine nodes in the node device set will continue to send erroneous or misleading local model update gradients, thereby affecting the global model. In this embodiment, a first number of node devices are selected from the node device set based on the cumulative abnormality of each node device. Since the selection probability of each node device is negatively correlated with the cumulative abnormality, the selection probability of the Byzantine node is reduced, and a high-reliability model can be obtained through federated learning.

[0106] In an embodiment of the present application, the federated learning method further includes:

[0107] When the distance between the first median aggregate gradient and the first mean aggregate gradient is less than or equal to a preset threshold, determining the first mean aggregate gradient as the global aggregate gradient of the global model;

[0108] The global model parameters of the current round are determined according to the global aggregate gradient, the global model parameters of the previous round and the model learning rate of the current round.

[0109] When the distance between the first median aggregate gradient and the first mean aggregate gradient is less than or equal to a preset threshold, it is determined that the current round of update process of the global model is normal. At this time, there is no need to remove abnormal node devices, and the first mean aggregate gradient is directly determined as the global aggregate gradient of the global model.

[0110] It should be understood that as the number of global model update rounds increases, the model learning rate will continue to decrease. When the global model is updated in the current round, the model learning rate of the current round is obtained. The global model parameters of the current round are determined based on the global aggregate gradient, the global model parameters of the previous round, and the model learning rate of the current round.

[0111] In an embodiment of the present application, the federated learning method further includes:

[0112] In the case where the current round is the first round, initializing the global model, obtaining initial global model parameters of the global model, and sending the initial global model parameters to a first number of node devices;

[0113] Sending the global model parameters of the previous round to the first number of node devices includes:

[0114] When the current round is greater than the first round, the global model parameters of the previous round are sent to the first number of node devices.

[0115] When the current round is the first round and there are no global model parameters of the previous round, the parameters of the global model are initialized, and the initial global model parameters of the global model are obtained. The global model parameters are sent to the first number of node devices so that the node devices train the local models according to the initial global model parameters. When the current round is not the first round, that is, the current round is greater than the first round, the global model parameters of the previous round are sent to the first number of node devices so that the node devices train the local models according to the global model parameters of the previous round.

[0116] In an embodiment of the present application, updating the global model based on the global model parameters of the current round includes:

[0117] When the global model update of the current round does not meet the termination condition, the global model is updated based on the global model parameters of the current round, and the step of sending the global model parameters of the previous round to the first number of node devices is performed until the global model update of the current round meets the termination condition.

[0118] Usually the termination condition is that the global model parameters of the current round converge, or the value of the current round is greater than the preset value, where the preset value is set according to actual needs and can be any value such as 50, which is not limited here. When the global model update of the current round meets the termination condition, the global model is updated based on the global model parameters of the current round to obtain a global model that completes the training update.

[0119] In the case where the global model update of the current round does not meet the termination condition, the global model is updated based on the global model parameters of the current round, and the step of sending the global model parameters of the previous round to the first number of node devices is performed until the global model update of the current round meets the termination condition. For ease of understanding, in this embodiment, the current round is taken as an example of the kth round. In the case where the global model update of the kth round does not meet the termination condition, the global model is updated based on the global model parameters of the kth round, and the step of sending the global model parameters of the kth round to the first number of node devices is performed to obtain the k+1th global model parameters.

[0120] If the global model update in the k+1th round does not meet the termination condition, the global model is updated based on the global model parameters in the k+1th round, and the step of sending the global model parameters in the k+1th round to the first number of node devices is performed to obtain the global model parameters in the k+2th round. If the global model update in the k+1th round meets the termination condition, the global model is updated based on the global model parameters in the k+1th round, and the global model is no longer trained and updated in the k+2th round, so as to obtain a global model that has completed the training update.

[0121] The present application provides a federated learning method, which includes: sending the global model parameters of the previous round to a first number of node devices, so that the node devices train local models according to the global model parameters to obtain local model update gradients; determining the first median aggregation gradient and the first mean aggregation gradient of the global model according to the local model update gradients corresponding to the first number of node devices; determining the abnormality of each node device respectively when the distance between the first median aggregation gradient and the first mean aggregation gradient is greater than a preset threshold; removing abnormal node devices based on the abnormality of each node device to obtain a second number of node devices; determining the global model parameters of the current round according to the second mean aggregation gradient and the global model parameters of the previous round; and updating the global model based on the global model parameters of the current round. Since the influence of the abnormal information sent by the abnormal node device on the median aggregation gradient can be ignored, the mean aggregation gradient is detected by the median aggregation gradient, thereby accurately detecting whether it is attacked by Byzantine. At the same time, by removing the abnormal local model update gradient sent by the abnormal node device, and then updating the global model parameters, a high reliability model can be obtained through federated learning.

[0122] Example 2

[0123] See also Figure 3 , Figure 3 A schematic diagram of the structure of a federated learning device provided in an embodiment of the present application is shown. Figure 3 The federated learning device in includes:

[0124] A model parameter sending module 310 is used to send the global model parameters of the previous round to a first number of node devices, so that the node devices train local models according to the global model parameters to obtain local model update gradients;

[0125] An aggregate gradient determination module 320, configured to determine a first median aggregate gradient and a first mean aggregate gradient of a global model according to local model update gradients corresponding to a first number of node devices;

[0126] An abnormality determination module 330, used to determine the abnormality of each node device respectively when the distance between the first median aggregate gradient and the first mean aggregate gradient is greater than a preset threshold;

[0127] A node device determination module 340 is used to remove abnormal node devices based on the abnormality degree of each node device to obtain a second number of node devices, wherein the distance between the second median aggregation gradient and the second mean aggregation gradient corresponding to the second number of node devices is less than or equal to a preset threshold, and the second number is the maximum number of node devices that satisfy the distance between the second median aggregation gradient and the second mean aggregation gradient is less than or equal to the preset threshold;

[0128] A model parameter determination module 350, configured to determine the global model parameters of the current round according to the second mean aggregate gradient and the global model parameters of the previous round;

[0129] The global model updating module 360 ​​is used to update the global model based on the global model parameters of the current round.

[0130] In the embodiment of the present application, the federated learning device 200 further includes:

[0131] The cumulative abnormality acquisition module is used to acquire the cumulative abnormality of each node device in the node device set;

[0132] The node device selection module is used to select a first number of node devices from the node device set according to the cumulative abnormality of each node device, wherein the selection probability of each node device is negatively correlated with the cumulative abnormality.

[0133] In an embodiment of the present application, the node device determination module 340 includes:

[0134] An abnormality ranking submodule, used to rank the first number of node devices by abnormality;

[0135] The abnormal node determination submodule is used to determine the node device with the highest abnormality as the abnormal node device;

[0136] The abnormal node removal submodule is used to remove abnormal node devices and obtain a preset number of node devices;

[0137] The repeated determination submodule is used to repeatedly execute the step of determining the node device with the highest abnormality as the abnormal node device when the preset number is not the second number, until the second number of node devices is obtained.

[0138] In the embodiment of the present application, the federated learning device 200 further includes:

[0139] A global aggregate gradient determination module, configured to determine the first mean aggregate gradient as a global aggregate gradient of a global model when a distance between the first median aggregate gradient and the first mean aggregate gradient is less than or equal to a preset threshold;

[0140] The global model parameter determination module is used to determine the global model parameters of the current round according to the global aggregate gradient, the global model parameters of the previous round and the model learning rate of the current round.

[0141] In the embodiment of the present application, the abnormality determination module 330 includes:

[0142] A gradient determination submodule, configured to update the gradient according to the local model corresponding to the node device other than the target node device, and determine the third median aggregate gradient and the third mean aggregate gradient corresponding to the target node device when the distance between the first median aggregate gradient and the first mean aggregate gradient is greater than a preset threshold;

[0143] The target abnormality determination submodule is used to determine the abnormality of the target node device according to the distance between the first median aggregate gradient and the first mean aggregate gradient, and the distance between the third median aggregate gradient and the third mean aggregate gradient.

[0144] In the embodiment of the present application, the federated learning device 200 further includes:

[0145] an initial parameter sending module, used to initialize the global model, obtain initial global model parameters of the global model, and send the initial global model parameters to a first number of node devices when the current round is the first round;

[0146] The model parameter sending module 310 is further configured to send the global model parameters of the previous round to the first number of node devices when the current round is greater than the first round.

[0147] In an embodiment of the present application, the global model update module 360 ​​is also used to update the global model based on the global model parameters of the current round when the global model update of the current round does not meet the termination conditions, and execute the step of sending the global model parameters of the previous round to the first number of node devices until the global model update of the current round meets the termination conditions.

[0148] The federated learning device 200 is used to execute the corresponding steps in the above-mentioned federated learning method, and the specific implementation of each function is not described one by one here. In addition, the optional examples in embodiment 1 are also applicable to the federated learning device 200 of embodiment 2.

[0149] The present application also provides a computing device, including:

[0150] a memory configured to store instructions; and

[0151] The processor is configured to call instructions from the memory and implement the above-mentioned federated learning method when executing the instructions.

[0152] The model parameter sending module 310, the aggregate gradient determination module 320, the abnormality determination module 330, the node device determination module 340, the model parameter determination module 350 and the global model update module 360 ​​in this embodiment are all stored in the memory as program units, and the processor executes the above program units stored in the memory to implement corresponding functions.

[0153] The processor contains a kernel, which calls the corresponding program unit from the memory. One or more kernels can be set, and the problem of models that cannot be highly reliable through federated learning can be solved by adjusting kernel parameters.

[0154] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0155] An embodiment of the present application also provides a machine-readable storage medium, on which instructions are stored, and the instructions are used to enable a processor to execute the above-mentioned federated learning method.

[0156] 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.

[0157] 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.

[0158] 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.

[0159] 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. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

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

[0161] 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.

[0162] Machine-readable storage 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.

[0163] 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.

[0164] 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 learning method, It is characterized in that The federated learning method includes: Sending the global model parameters of the previous round to a first number of node devices, so that the node devices train local models according to the global model parameters to obtain local model update gradients; Determine a first median aggregate gradient and a first mean aggregate gradient of a global model according to the local model update gradients corresponding to the first number of node devices, wherein the first median aggregate gradient is the median of the local model update gradients corresponding to the first number of node devices, and the first mean aggregate gradient is the mean of the local model update gradients corresponding to the first number of node devices; When the distance between the first median aggregate gradient and the first mean aggregate gradient is greater than a preset threshold, determining the abnormality degree of each node device respectively; Abnormal node devices are removed based on the abnormality degree of each node device to obtain a second number of node devices, wherein the distance between the second median aggregate gradient and the second mean aggregate gradient corresponding to the second number of node devices is less than or equal to the preset threshold, and the second number is the maximum number of node devices that satisfy the distance between the second median aggregate gradient and the second mean aggregate gradient is less than or equal to the preset threshold, the second median aggregate gradient is the median of the local model update gradients corresponding to the second number of node devices, and the second mean aggregate gradient is the mean of the local model update gradients corresponding to the second number of node devices; Determining the global model parameters of the current round according to the second mean aggregate gradient and the global model parameters of the previous round; The global model is updated based on the global model parameters of the current round.

2. The federated learning method according to claim 1, It is characterized in that The federated learning method further includes: Obtain the cumulative abnormality of each node device in the node device set; A first number of node devices are selected from the set of node devices according to the accumulated abnormality of each node device, wherein the selection probability of each node device is negatively correlated with the accumulated abnormality.

3. The federated learning method according to claim 1, It is characterized in that The removing abnormal node devices based on the abnormality degree of each node device to obtain a second number of node devices includes: sorting the first number of node devices by abnormality; Determine the node device with the highest abnormality as an abnormal node device; Removing the abnormal node devices to obtain a preset number of the node devices; When the preset number is not the second number, the step of determining the node device with the highest abnormality as the abnormal node device is repeatedly performed until the second number of the node devices is obtained.

4. The federated learning method according to claim 1, It is characterized in that The federated learning method further includes: When the distance between the first median aggregate gradient and the first mean aggregate gradient is less than or equal to a preset threshold, determining the first mean aggregate gradient as the global aggregate gradient of the global model; The global model parameters of the current round are determined according to the global aggregate gradient, the global model parameters of the previous round and the model learning rate of the current round.

5. The federated learning method according to claim 1, It is characterized in that The determining the abnormality of each node device respectively when the distance between the first median aggregate gradient and the first mean aggregate gradient is greater than a preset threshold includes: In the case where the distance between the first median aggregate gradient and the first mean aggregate gradient is greater than a preset threshold, determining a third median aggregate gradient and a third mean aggregate gradient corresponding to the target node device according to the local model update gradient corresponding to the node devices other than the target node device, wherein the third median aggregate gradient is the median of the local model update gradient corresponding to the node devices other than the target node device, and the third mean aggregate gradient is the mean of the local model update gradient corresponding to the node devices other than the target node device; The abnormality degree of the target node device is determined according to the distance between the first median aggregate gradient and the first mean aggregate gradient, and the distance between the third median aggregate gradient and the third mean aggregate gradient.

6. The federated learning method according to claim 1, It is characterized in that The federated learning method further includes: In the case where the current round is the first round, initializing the global model, obtaining initial global model parameters of the global model, and sending the initial global model parameters to a first number of node devices; The sending of the global model parameters of the previous round to the first number of node devices includes: When the current round is greater than the first round, the global model parameters of the previous round are sent to the first number of node devices.

7. The federated learning method according to claim 1, It is characterized in that The updating of the global model based on the global model parameters of the current round includes: When the global model update of the current round does not meet the termination condition, the global model is updated based on the global model parameters of the current round, and the step of sending the global model parameters of the previous round to the first number of node devices is performed until the global model update of the current round meets the termination condition.

8. A federated learning device, It is characterized in that The federated learning device comprises: A model parameter sending module, used to send the global model parameters of the previous round to a first number of node devices, so that the node devices train local models according to the global model parameters to obtain local model update gradients; an aggregate gradient determination module, configured to determine a first median aggregate gradient and a first mean aggregate gradient of a global model according to the local model update gradients corresponding to the first number of node devices, wherein the first median aggregate gradient is the median of the local model update gradients corresponding to the first number of node devices, and the first mean aggregate gradient is the mean of the local model update gradients corresponding to the first number of node devices; an abnormality determination module, configured to respectively determine the abnormality of each node device when the distance between the first median aggregate gradient and the first mean aggregate gradient is greater than a preset threshold; A node device determination module, configured to remove abnormal node devices based on the abnormality degree of each node device to obtain a second number of node devices, wherein the distance between the second median aggregate gradient and the second mean aggregate gradient corresponding to the second number of node devices is less than or equal to the preset threshold, and the second number is the maximum number of node devices that satisfy the distance between the second median aggregate gradient and the second mean aggregate gradient is less than or equal to the preset threshold, the second median aggregate gradient is the median of the local model update gradients corresponding to the second number of node devices, and the second mean aggregate gradient is the mean of the local model update gradients corresponding to the second number of node devices; A model parameter determination module, used to determine the global model parameters of the current round according to the second mean aggregation gradient and the global model parameters of the previous round; A global model updating module is used to update the global model based on the global model parameters of the current round.

9. A computing device, It is characterized in that include: a memory configured to store instructions; as well as A processor is configured to call the instructions from the memory and implement the federated learning method according to any one of claims 1 to 7 when executing the instructions.

10. A machine-readable storage medium, It is characterized in that The machine-readable storage medium stores instructions, and the instructions are used to enable a processor to execute the federated learning method according to any one of claims 1 to 7.