A federated learning method and system for heterogeneous data
Through distributed architecture and two-way compression technology, it solves the problems of performance degradation and high communication overhead of federated learning in heterogeneous data processing, achieves efficient model training and data privacy protection, and improves the training performance and communication of heterogeneous data. efficiency.
Patent Information
- Application Number
- CN202210143482.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-16
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2042-02-16
AI Technical Summary
The performance of federated learning decreases significantly when processing heterogeneous data, and the communication bandwidth of smart devices is limited, resulting in high communication overhead. Existing methods such as data sharing and feature fusion have problems of data privacy leakage and limited performance improvement.
Adopting a distributed architecture, through local training calculation model, calculate the model parameter difference value and cross-entropy loss value, perform multiple rounds of training and iterative calculations, combine sparsification and random quantization technology for two-way compression, reduce communication overhead, and use the gradient descent method and balance factors to optimize the loss function and suppress local model drift.
It effectively suppresses local model drift, reduces the randomness of the average aggregation of model parameters, improves global model performance, improves training performance and communication efficiency of heterogeneous data, and ensures the security of data privacy.
Smart Images

Figure CN114611718B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of federated learning technology, and in particular to a federated learning method and system for heterogeneous data. Background Art
[0002] Traditional centralized deep learning systems can no longer effectively process private data from massive users. Federated learning is an efficient distributed deep learning / machine learning training method that allows global models to be built by exchanging local training model parameters while ensuring that training data does not leave the local device, thereby achieving privacy protection and reducing communication costs. Therefore, federated learning can provide a new solution for distributed learning systems with privacy and efficiency advantages.
[0003] However, federated learning still faces two major challenges in practical application scenarios: (1) Due to the statistical heterogeneity of collected data, distributed training data may be non-IID data sets across devices, and the processing performance of federated learning for non-IID (heterogeneous) data is significantly lower than that for independent and identically distributed (homogeneous) data. (2) The communication bandwidth of smart devices is limited, and it is challenging to further reduce the communication overhead of federated learning.
[0004] Currently, federated learning faces the problem of significantly degraded performance when processing heterogeneous data. One solution is to improve the performance of federated learning on non-IID training data by creating a data subset that is globally shared among all edge devices, but this method requires sharing data, which will lead to data privacy leakage. Another method is to use feature fusion to solve the non-IID problem, aggregate the features of local and global models, and improve the performance of federated learning on heterogeneous data, but because local model drift inhibits the learning of the global model, the performance improvement ability for training data with a high degree of heterogeneity is still limited. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a federated learning method for heterogeneous data to eliminate or improve one or more defects existing in the prior art.
[0006] One aspect of the present invention provides a federated learning method for heterogeneous data, the method is based on a distributed architecture, the distributed architecture includes a server end and a plurality of node ends connected to the server end, the steps of the method include:
[0007] Performing local training on the computing model in each node end, wherein the local training includes at least one iteration, and calculating the cross entropy loss value based on the training data set preset by each preset node end during each iteration, and calculating the model parameter difference value based on the model parameter value of the computing model of the current node end in the current iterative calculation and the model parameter value of the computing model of other node ends in the previous round of iterative calculation;
[0008] The loss function value of the computing model at the current node end is calculated based on the model parameter difference value and the cross entropy loss value. The loss function value is used to calculate the model parameter value of the next iteration. The model parameter value calculated by the loss function value calculated by the last iteration is used as the first model parameter to complete the local training.
[0009] Substituting the initial model parameters calculated in the first iteration into the calculation model of the current node end based on the first model parameter and the calculation model of the current node end calculates the first parameter difference, compresses the first parameter difference corresponding to each initial model parameter in the calculation model to obtain the second parameter difference, uploads the second parameter difference to the server end, averages and aggregates the second parameter difference uploaded to the server end by each node end to obtain the third parameter difference, compresses the third parameter difference to obtain the fourth parameter difference, and transmits the fourth parameter difference to the node end;
[0010] The initial model parameters are updated based on the fourth parameter difference to obtain second model parameters, thus completing this round of training.
[0011] By adopting the above scheme, the method can adopt multiple rounds of training. The above steps are the steps of a single round of training. Each round of training can update each computing model. The local training in each round of training can be completed through multiple iterative calculations. The loss function value is calculated each time. The model parameters of this node and other nodes can be jointly calculated, so that each local training model can maintain the ability to learn its own data while making the distribution of each model parameter tend to be consistent, thereby reducing the randomness of the average aggregation of model parameters, thereby improving the performance of the global model, and can effectively suppress the drift of the local model, thereby improving the model training performance.
[0012] In some embodiments of the present invention, based on the model parameter values of the computing model of the current node end in this iterative calculation and the model parameter values of the computing models of other node ends in the previous round of iterative calculation, the step of calculating the model parameter difference value also includes using a gradient descent method to calculate the model parameter values in the current iterative calculation based on the model parameter values of the computing model of the current node end in the previous round of iterative calculation.
[0013] In some embodiments of the present invention, the model parameter values in the current iterative calculation are calculated based on the model parameter values of the calculation model at the current node in the previous round of iterative calculation using the gradient descent method according to the following formula:
[0014]
[0015] Indicates the model parameter value of the kth model parameter in the zth iteration calculation of the current calculation model at the i-th node end, represents the model parameter value of the kth model parameter in the z-1th iteration calculation of the current calculation model at the i-th node end in the tth round, α represents the learning rate, Indicates the gradient value corresponding to the kth model parameter in the z-1th iteration calculation of the current calculation model at the i-th node.
[0016] In some embodiments of the present invention, the loss function value of the computing model at the current node end is calculated based on the model parameter difference value and the cross entropy loss value according to the following formula:
[0017]
[0018] represents the loss function value of the current computing model at the i-th node in the z-th iteration of the t-th round, D i Represents the current training data set preset at the i-th node. It represents the cross entropy loss value of the current training data set preset at the i-th node in the z-th iteration calculation of the t-th round. represents the model parameter difference value, λ represents the balance factor, which takes a value between (0,1], j represents the jth node end, N represents the total number of nodes, and k represents the kth model parameter in the calculation model. represents the importance parameter of the kth parameter in the calculation model of the jth node at the t-1th round, Indicates the model parameter value of the kth model parameter in the zth iteration calculation of the current calculation model at the i-th node end, It represents the initial model parameter value obtained by the j-th node in the t-1th round for substitution into the first iterative calculation of the tth round, A represents the total number of model parameters in the calculation model of the ith node, and parameter k is one of the A model parameters.
[0019] In some embodiments of the present invention, the importance parameter is calculated according to the following formula:
[0020]
[0021] Indicates the importance parameter of the kth parameter in the calculation model of the jth node at the t-1th round, and max indicates the maximum value. represents the change in the value of the model parameter of the kth parameter in the calculation model of the jth node during the time period of the local training in the t-1th round, ζ is the damping coefficient to avoid the denominator being zero, Represents the estimated value of the importance parameter of the kth parameter in the calculation model of the jth node in the t-1th round of calculation.
[0022] In some embodiments of the present invention, the estimated value of the importance parameter is calculated according to the following formula:
[0023]
[0024] It represents the estimated value of the importance parameter of the kth parameter in the calculation model of the jth node in the t-1th round calculation. It represents the gradient value corresponding to the kth model parameter in the last iteration calculation of the calculation model at the jth node in the t-1th round. represents the change in the model parameter value of the kth parameter in the calculation model of the jth node during the time period of the t-1th round of local training, ∫ t-1 Represents the integral during the time period of t-1 rounds of calculation.
[0025] In some embodiments of the present invention, the step of performing data compression on the first parameter difference corresponding to each initial model parameter in the calculation model to obtain the second parameter difference includes:
[0026] A sparse operation is used to select a first parameter differences from the first parameter differences corresponding to all initial model parameters;
[0027] Applying random quantization operation to a first parameter differences to obtain a second parameter differences corresponding to the a first parameter differences;
[0028] A first compression error is calculated based on the first parameter difference and the second parameter difference.
[0029] In some embodiments of the present invention, the first compression error is calculated according to the following formula:
[0030]
[0031] represents the first compression error corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, The second parameter difference corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, The first parameter difference corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation.
[0032] In some embodiments of the present invention, the step of performing data compression on the third parameter difference to obtain the fourth parameter difference includes:
[0033] A sparse operation is used to select a third parameter differences from all third parameter differences of the calculation model on the server side;
[0034] Applying random quantization operation to a third parameter differences to obtain a fourth parameter differences corresponding to the a third parameter differences;
[0035] A second compression error is calculated based on the third parameter difference and the fourth parameter difference.
[0036] In some embodiments of the present invention, the step of averaging and aggregating the second parameter difference uploaded by each node to the server to obtain the third parameter difference includes:
[0037] The second parameter differences uploaded from the multiple nodes to the server are grouped into an aggregation group according to the initial model parameter numbers corresponding to the second parameter differences;
[0038] The second parameter difference of each aggregation group is averaged and aggregated to obtain a third parameter difference.
[0039] In some embodiments of the present invention, the second compression error is calculated based on the third parameter difference and the fourth parameter difference according to the following formula:
[0040]
[0041] represents the second compression error corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, The fourth parameter difference corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, Represents the third parameter difference corresponding to the kth initial model parameter of the server-side calculation model in the tth round of calculation.
[0042] In some embodiments of the present invention, the initial model parameters are updated based on the fourth parameter difference to obtain the second model parameters, and the steps of completing this round of training include:
[0043] Restoring the fourth parameter difference to a fifth parameter difference according to the first compression error and the second compression error;
[0044] The initial model parameters are updated to second model parameters according to the fifth parameter difference.
[0045] In some embodiments of the present invention, the fourth parameter difference is restored to a fifth parameter difference according to the first compression error and the second compression error based on the following formula;
[0046]
[0047] represents the fifth parameter difference corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, The fourth parameter difference corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, represents the first compression error corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, Represents the second compression error corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation.
[0048] Additional advantages, purposes, and features of the present invention will be described in part in the following description, and will become apparent to those skilled in the art after studying the following, or may be learned from the practice of the present invention. The purposes and other advantages of the present invention can be specifically pointed out and obtained in the specification and the accompanying drawings.
[0049] Those skilled in the art will appreciate that the objectives and advantages that can be achieved with the present invention are not limited to the above specific description, and the above and other objectives that can be achieved by the present invention will be more clearly understood from the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention.
[0051] Figure 1 A schematic diagram of an implementation of a federated learning method for heterogeneous data according to the present invention;
[0052] Figure 2 Schematic diagram of the decrease in test loss value. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments and the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0054] It should also be noted that, in order to avoid obscuring the present invention due to unnecessary details, only structures and / or processing steps closely related to the solutions according to the present invention are shown in the accompanying drawings, while other details that are not closely related to the present invention are omitted.
[0055] It should be emphasized that the term “include / comprises” when used herein refers to the presence of features, elements, steps or components, but does not exclude the presence or addition of one or more other features, elements, steps or components.
[0056] It should also be noted that, unless otherwise specified, the term “connection” herein may refer not only to a direct connection but also to an indirect connection involving an intermediate.
[0057] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the accompanying drawings, the same reference numerals represent the same or similar components, or the same or similar steps.
[0058] like Figure 1 As shown, one aspect of the present invention provides a federated learning method for heterogeneous data, the method is based on a distributed architecture, the distributed architecture includes a server end and a plurality of node ends connected to the server end, the steps of the method include:
[0059] S100, performing local training on the computing model in each node end, wherein the local training includes at least one iteration, and in each iteration, calculating a cross entropy loss value based on a preset training data set of each preset node end, and calculating a model parameter difference value based on a model parameter value of the computing model of the current node end in this iterative calculation and a model parameter value of the computing model of other node ends in a previous round of iterative calculation;
[0060] In some embodiments of the present invention, the federated learning method for heterogeneous data of the present application may adopt a multi-round training method, where each round of training includes local training with at least one iterative calculation.
[0061] In some embodiments of the present invention, the training data set used in each iteration may be a different training data set.
[0062] S200, calculating the loss function value of the computing model of the current node end based on the model parameter difference value and the cross entropy loss value, wherein the loss function value is used to calculate the model parameter value of the next iteration, and the model parameter value calculated by the loss function value calculated by the last iteration is used as the first model parameter, and the local training is completed;
[0063] In some embodiments of the present invention, local training can be performed in a multi-iteration manner, and each iteration calculates the cross entropy loss value and the model parameter difference value. The number of iterations can be a preset number. The current gradient value is calculated based on the loss function value calculated in the last iteration, and the first model parameter is calculated based on the gradient value and the model parameter value calculated in the last iteration using the gradient descent method.
[0064] S300, based on the first model parameter and the calculation model of the current node end, substitute the initial model parameter calculated in the first iteration to calculate the first parameter difference, perform data compression on the first parameter difference corresponding to each initial model parameter in the calculation model to obtain the second parameter difference, upload the second parameter difference to the server end, perform average aggregation processing on the second parameter difference uploaded to the server end by each node end to obtain the third parameter difference, perform data compression on the third parameter difference to obtain the fourth parameter difference, and transmit the fourth parameter difference to the node end;
[0065] In some embodiments of the present invention, the initial model parameters of the first iterative calculation substituted into the calculation model of the current node end are the second model parameters updated in the previous round of calculation.
[0066] In some embodiments of the present invention, the data compression method for the first parameter difference or the third parameter difference may be a sparse method and / or a random quantization operation method.
[0067] Model compression is a commonly used technique in distributed learning to reduce communication overhead, including methods such as sparsification, quantization, or low-rank decomposition, which reduces the amount of communication by transmitting compressed model parameters. The latest progress in federated learning combined with model compression technology has attracted widespread attention, but these studies mainly focus on model compression of uplink data from the client to the server. In addition, model compression technology may introduce compression errors during local training, which will further affect the convergence performance of training.
[0068] Different from the traditional way of uploading model parameters, this application uploads parameter differences, and the parameter difference is the update amount of the model parameters. Therefore, the size of the parameter difference is much smaller than the model parameters, further reducing the communication cost; and this application adopts bidirectional compression including uplink compression and downlink compression to reduce communication overhead and ensure the convergence performance of distributed learning.
[0069] S400: Update the initial model parameters based on the fourth parameter difference to obtain second model parameters, thereby completing this round of training.
[0070] By adopting the above scheme, the method can adopt multiple rounds of training. The above steps are the steps of a single round of training. Each round of training can update each computing model. The local training in each round of training can be completed through multiple iterative calculations. The loss function value is calculated each time. The model parameters of this node and other nodes can be jointly calculated, so that each local training model can maintain the ability to learn its own data while making the distribution of each model parameter tend to be consistent, thereby reducing the randomness of the average aggregation of model parameters, thereby improving the performance of the global model, and can effectively suppress the drift of the local model, thereby improving the model training performance.
[0071] The reason why the performance of federated learning on non-independent and identically distributed data (heterogeneous data) in existing schemes is that local model drift inhibits the learning of the global model. The distribution of each local training data set is different, resulting in large differences in the distribution of local model parameters, which in turn leads to randomness in the global model parameters obtained by aggregating the local model parameters using the federated average algorithm. The greater the difference in the distribution of local model parameters, the worse the performance of the global model obtained by the federated average aggregation. The federated learning method for heterogeneous data of the present application can improve the performance and communication efficiency of the federated learning system when processing heterogeneous data. First, a new local training loss function is proposed to reduce local model drift, thereby improving its performance on heterogeneous data. In addition, the present invention proposes a bidirectional compression error compensation algorithm to compress uplink and downlink transmission data to reduce communication overhead and to ensure the convergence performance of distributed learning.
[0072] In some embodiments of the present invention, based on the model parameter values of the computing model of the current node end in this iterative calculation and the model parameter values of the computing models of other node ends in the previous round of iterative calculation, the step of calculating the model parameter difference value also includes using a gradient descent method to calculate the model parameter values in the current iterative calculation based on the model parameter values of the computing model of the current node end in the previous round of iterative calculation.
[0073] In some embodiments of the present invention, each node end and server end of the method adopts a model of the same architecture, the number of model parameters of the model of each node end and server end is the same, and the same numbering method is used for sequential numbering. The sequence numbers of model parameters at different node ends or server ends but at the same position are the same. The model can be a convolutional neural network model, etc.
[0074] In some embodiments of the present invention, the model parameter values in the current iterative calculation are calculated based on the model parameter values of the calculation model at the current node in the previous round of iterative calculation using the gradient descent method according to the following formula:
[0075]
[0076] Indicates the model parameter value of the kth model parameter in the zth iteration calculation of the current calculation model at the i-th node end, represents the model parameter value of the kth model parameter in the z-1th iteration calculation of the current calculation model at the i-th node end in the tth round, α represents the learning rate, Indicates the gradient value corresponding to the kth model parameter in the z-1th iteration calculation of the current calculation model at the i-th node.
[0077] In some embodiments of the present invention, the learning rate may be a parameter of .
[0078] The importance of model parameters can be estimated by the contribution of a single parameter to the overall loss change. Considering that the loss change caused by an infinitesimal parameter update in the tth round can be estimated by the gradient, the total loss change in the entire parameter space can be obtained by summing up all infinitesimal changes in all iterations of local training, which is used as an estimate of the importance of the model parameters.
[0079] In some embodiments of the present invention, the loss function value of the computing model at the current node end is calculated based on the model parameter difference value and the cross entropy loss value according to the following formula:
[0080]
[0081] represents the loss function value of the current computing model at the i-th node in the t-th round of computing, D i Represents the current training data set preset at the i-th node. Indicates the cross entropy loss value of the training data set preset at the current i-th node in the t-th round of calculation. represents the model parameter difference value, λ represents the balance factor, which takes a value between (0,1], j represents the jth node end, N represents the total number of nodes, and k represents the kth model parameter in the calculation model. represents the importance parameter of the kth parameter in the calculation model of the jth node at the t-1th round, Indicates the model parameter value of the kth model parameter in the zth iteration calculation of the current calculation model at the i-th node end, It represents the initial model parameter value obtained by the j-th node in the t-1th round for substitution into the first iterative calculation of the tth round, A represents the total number of model parameters in the calculation model of the ith node, and parameter k is one of the A model parameters.
[0082] The initial model parameter value calculated at the jth node in the t-1th round is used to substitute into the first iteration calculation of the tth round and All of them can be uploaded from the jth node to the server, and then transmitted from the server to the i-th node;
[0083] In order to improve the performance of federated learning on non-independent and identically distributed data, this application introduces other local model parameters into the loss function so that each local training model can maintain the ability to learn its own data while making the distribution of model parameters tend to be consistent, thereby reducing the randomness of the average aggregation of model parameters and improving the performance of the global model.
[0084] In some embodiments of the present invention, the total number of model parameters of the model may be A, and k may be any value from 1 to A.
[0085] In some embodiments of the present invention, λ may be 0.5.
[0086] In some embodiments of the present invention, the gradient value in the z-1th iteration calculation of the tth round can be calculated in the formula In Derivative of the variable .
[0087] In some embodiments of the present invention, the importance parameter is calculated according to the following formula:
[0088]
[0089] Indicates the importance parameter of the kth parameter in the calculation model of the jth node at the t-1th round, and max indicates the maximum value. represents the change in the value of the model parameter of the kth parameter in the calculation model of the jth node during the time period of the local training in the t-1th round, ζ is the damping coefficient to avoid the denominator being zero, Represents the estimated value of the importance parameter of the kth parameter in the calculation model of the jth node in the t-1th round of calculation.
[0090] The damping coefficient may be a preset fixed value.
[0091] It represents the change in the model parameter value of the kth parameter in the calculation model of the jth node during the t-1th round of local training, that is, the difference between the initial model parameter value of the kth parameter in the calculation model of the jth node and the model parameter value corresponding to the kth parameter in the last iteration.
[0092] In order to ensure that the units of the second term of the loss value are consistent with the first term, we normalize the importance values. In addition, in order to ensure that the importance factor is positive, the importance values calculated as negative values are forced to be 0.
[0093] In some embodiments of the present invention, the step of uploading the second parameter difference to the server side also includes uploading the importance parameter of the last iteration of local training to the server side, and transmitting the importance parameter to each node side in the step of transmitting the fourth parameter difference to the node side.
[0094] In some implementations of the present invention, the importance parameter is compressed in a random quantization manner during the uploading process.
[0095] In some embodiments of the present invention, the estimated value of the importance parameter is calculated according to the following formula:
[0096]
[0097] It represents the estimated value of the importance parameter of the kth parameter in the calculation model of the jth node in the t-1th round calculation. It represents the gradient value corresponding to the kth model parameter in the last iteration calculation of the calculation model at the jth node in the t-1th round. represents the change in the model parameter value of the kth parameter in the calculation model of the jth node during the time period of the t-1th round of local training, ∫ t-1 Represents the integral during the time period of t-1 rounds of calculation.
[0098] In some embodiments of the present invention, the step of performing data compression on the first parameter difference corresponding to each initial model parameter in the calculation model to obtain the second parameter difference includes:
[0099] A sparse operation is used to select a first parameter differences from the first parameter differences corresponding to all initial model parameters;
[0100] Applying random quantization operation to a first parameter differences to obtain a second parameter differences corresponding to the a first parameter differences;
[0101] A first compression error is calculated based on the first parameter difference and the second parameter difference.
[0102] In order to reduce the communication overhead of federated learning, we will combine the two model compression strategies of sparsification and quantization to alleviate the communication bottleneck in distributed optimization, and propose a bidirectional compression error compensation algorithm. In sparsification, the gradient vector is sparsely processed and the largest a elements in the vector are selected for transmission. In quantization, the accuracy of the gradient vector is reduced by mapping it to a finite number of quantization levels. We use random quantization.
[0103] In some embodiments of the present invention, a sparse operation can be used to screen out a larger first parameter differences from the first parameter differences of each node end. If a is 3 in the specific implementation process, if there are 3 node ends in total, and each node end has 5 model parameters in total, the corresponding first parameter differences are also 5. Then, the first parameter differences screened out at the first node end can be the first parameter differences corresponding to the model parameters numbered first, third, and fifth, and the first parameter differences corresponding to the model parameters numbered first, third, and fifth are randomly quantized to obtain the second parameter differences corresponding to the model parameters numbered first, third, and fifth. The first parameter differences screened out at the second node end can be the first parameter differences corresponding to the model parameters numbered first, second, and fifth, and the first parameter differences corresponding to the model parameters numbered first, second, and fifth are randomly quantized to obtain the second parameter differences corresponding to the model parameters numbered first, second, and fifth. The first parameter differences screened out at the third node end can be the first parameter differences corresponding to the model parameters numbered second, fourth, and fifth, and the first parameter differences corresponding to the model parameters numbered second, fourth, and fifth are randomly quantized to obtain the second parameter differences corresponding to the model parameters numbered second, fourth, and fifth.
[0104] In some embodiments of the present invention, the first compression error is calculated according to the following formula:
[0105]
[0106] represents the first compression error corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, The second parameter difference corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, The first parameter difference corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation.
[0107] Considering that compressing the first parameter difference will bring certain errors, as the iteration proceeds, the errors gradually accumulate and affect the convergence performance of local training. Therefore, we will calculate the compression error of the first parameter difference and store the error locally, and compensate for the compression error during calculation.
[0108] In some embodiments of the present invention, the step of averaging and aggregating the second parameter difference uploaded by each node to the server to obtain the third parameter difference includes:
[0109] The second parameter differences uploaded from the multiple nodes to the server are grouped into an aggregation group according to the initial model parameter numbers corresponding to the second parameter differences;
[0110] The second parameter difference of each aggregation group is averaged and aggregated to obtain a third parameter difference.
[0111] In some embodiments of the present invention, the second parameter differences corresponding to the two model parameters with the same number one in the above example are grouped into an aggregation group, the first parameter differences corresponding to the two model parameters with the same number two are grouped into an aggregation group, and the second parameter differences corresponding to the three model parameters with the same number five are grouped into an aggregation group, and the average aggregation is performed respectively to obtain the third parameter differences corresponding to the model parameters numbered one, two, three, four, and five.
[0112] In some embodiments of the present invention, the step of performing data compression on the third parameter difference to obtain the fourth parameter difference includes:
[0113] A sparse operation is used to select a third parameter differences from all third parameter differences of the calculation model on the server side;
[0114] Applying random quantization operation to a third parameter differences to obtain a fourth parameter differences corresponding to the a third parameter differences;
[0115] A second compression error is calculated based on the third parameter difference and the fourth parameter difference.
[0116] In some embodiments of the present invention, in the above example, data compression is performed on the third parameter differences corresponding to the model parameters numbered one, two, three, four, and five. If a is 3, a sparse operation is used to screen out the three larger third parameter differences corresponding to the model parameters numbered one, two, three, four, and five, and a random quantization operation is performed on the three third parameter differences to obtain three fourth parameter differences.
[0117] Considering that the number of third parameter differences on the server side after completing average aggregation will inevitably be greater than a, in order to further reduce the downlink communication overhead, we use sparsification to compress the global model weight update.
[0118] The sparse operation is completed through the sparse index in the sparse operation.
[0119] In some embodiments of the present invention, the second compression error is calculated based on the third parameter difference and the fourth parameter difference according to the following formula:
[0120]
[0121] represents the second compression error corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, The fourth parameter difference corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, Represents the third parameter difference corresponding to the kth initial model parameter of the server-side calculation model in the tth round of calculation.
[0122] In some embodiments of the present invention, the initial model parameters are updated based on the fourth parameter difference to obtain the second model parameters, and the steps of completing this round of training include:
[0123] Restoring the fourth parameter difference to a fifth parameter difference according to the first compression error and the second compression error;
[0124] The initial model parameters are updated to second model parameters according to the fifth parameter difference.
[0125] In some embodiments of the present invention, the step of updating the initial model parameters to the second model parameters according to the fifth parameter difference may be performed by adding or subtracting the fifth parameter difference from the initial model parameters.
[0126] In some embodiments of the present invention, the fourth parameter difference is restored to a fifth parameter difference according to the first compression error and the second compression error based on the following formula;
[0127]
[0128] represents the fifth parameter difference corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, The fourth parameter difference corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, represents the first compression error corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, Represents the second compression error corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation.
[0129] In the above example, if the three largest third parameter differences corresponding to the model parameters numbered one, two, three, four, and five are the third parameter differences corresponding to the second, third, and fourth model parameters, then the fourth parameter differences corresponding to the second, third, and fourth model parameters are transmitted back to each node end, and the fourth parameter differences corresponding to the second, third, and fourth model parameters are restored to the fifth parameter differences at each node end, and the initial model parameters in the model of the original node end are added to the fifth parameter differences to obtain the second model parameters;
[0130] The second model parameters are used as initial model parameters in the next round of calculations.
[0131] Experimental example:
[0132] We validate the proposed federated learning method for heterogeneous data on a public network intrusion detection dataset, KDDCUP 99 (KDD). Each local model in the federated learning system adopts a network intrusion detection model based on a convolutional neural network. For the KDD dataset, considering that the KDD dataset has 41-dimensional features, the CNN-based intrusion detection model uses a 1-dimensional convolution layer and a 1-dimensional maximum pooling layer, with the number of convolution kernels being 16 and 32 respectively. The size of each convolution kernel is fixed to 3, the stride is set to 1, the pooling size is 4, and the stride is 2.
[0133] In order to evaluate the performance of our proposed federated learning method in processing heterogeneous data, we conducted experiments on independent and identically distributed data (homogeneous) and non-independent and identically distributed (heterogeneous) distributed training data, and compared it with existing commonly used federated learning algorithms, including FedAvg and FedProx methods. The experimental results on the KDD dataset are shown in Table 1. As can be seen from Table 1, on non-independent and identically distributed data, our proposed federated learning has more advantages than other compared federated learning methods, and significantly improves the performance on non-independent and identically distributed data. In addition, the proposed federated learning algorithm combined with the proposed bidirectional compression and error compensation method increases gradient compression and quantization, reduces communication overhead, and the performance is slightly lower than that of using only the proposed federated learning algorithm. However, whether on independent and identically distributed data or non-independent and identically distributed data, the accuracy is above 88%, indicating that the proposed bidirectional compression and error compensation method does not affect the performance too much while reducing communication overhead.
[0134] Table 1
[0135] FedAvg FedProx OUR (uncompressed) This method (compression) IID 88.18 85.00 88.17 88.00 Non-IID2 88.17 88.00 88.14 88.00 Non-IID1 41.72 41.00 88.11 88.10
[0136] Figure 2 The test loss value of each method on the KDD dataset on non-independent and identically distributed data changes with the number of communication rounds. As the number of communication rounds increases, the test loss value of the proposed method decreases compared to other federated learning methods.
[0137] Considering that the performance of the proposed bidirectional compression error compensation algorithm is mainly affected by the compression rate and quantization level, we will evaluate the performance of the proposed federated learning method under different compression rates and quantization levels. The experimental results are shown in Tables 2 and 3. The experimental results show that the method proposed by us can effectively reduce the communication overhead for a given compression rate and quantization technology. The higher the compression rate and the lower the quantization level, the less the communication overhead.
[0138] Table 2 Different compression rates and communication volumes of KDD under noniid1
[0139]
[0140] Table 3 Different quantization levels and communication volume of KDD under noniid1
[0141]
[0142]
[0143] An embodiment of the present invention also provides a federated learning system for heterogeneous data, the system comprising a computer device, the computer device comprising a processor and a memory, the memory storing computer instructions, the processor being used to execute the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the system implements the steps of the method described above.
[0144] The embodiment of the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the aforementioned federated learning method for heterogeneous data. The computer-readable storage medium may be a tangible storage medium, such as a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a floppy disk, a hard disk, a removable storage disk, a CD-ROM, or any other form of storage medium known in the technical field.
[0145] It should be understood by those skilled in the art that the exemplary components, systems and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software or a combination of the two. Whether it is performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier.
[0146] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.
[0147] In the present invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with features of other embodiments or replace features of other embodiments.
[0148] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A federated learning method for heterogeneous data, characterized in that: The method is based on a distributed architecture, which includes a server end and a plurality of node ends connected to the server end. The steps of the method include: Performing local training on the computing model in each node end, wherein the local training includes at least one iteration, and calculating the cross entropy loss value based on the training data set preset by each preset node end during each iteration, and calculating the model parameter difference value based on the model parameter value of the computing model of the current node end in the current iterative calculation and the model parameter value of the computing model of other node ends in the previous round of iterative calculation; According to the following formula, the loss function value of the calculation model at the current node end is calculated based on the model parameter difference value and the cross entropy loss value: represents the loss function value of the current computing model at the i-th node in the z-th iteration of the t-th round, D i Represents the current training data set preset at the i-th node. It represents the cross entropy loss value of the current training data set preset at the i-th node in the z-th iteration calculation of the t-th round. represents the model parameter difference value, λ represents the balance factor, which takes a value between (0,1], j represents the jth node end, N represents the total number of nodes, and k represents the kth model parameter in the calculation model. represents the importance parameter of the kth parameter in the calculation model of the jth node at the t-1th round, Indicates the model parameter value of the kth model parameter in the zth iteration calculation of the current calculation model at the i-th node end, represents the initial model parameter value calculated by the j-th node in the t-1th round and used for substitution into the first iteration calculation of the tth round, A represents the total number of model parameters in the calculation model of the i-th node, and parameter k is one of the A model parameters; The loss function value is used to calculate the model parameter value of the next iteration, and the model parameter value calculated by the loss function value calculated in the last iteration is used as the first model parameter to complete the local training; Substituting the initial model parameters calculated in the first iteration into the calculation model of the current node end based on the first model parameter and the calculation model of the current node end calculates the first parameter difference, compresses the first parameter difference corresponding to each initial model parameter in the calculation model to obtain the second parameter difference, uploads the second parameter difference to the server end, averages and aggregates the second parameter difference uploaded to the server end by each node end to obtain the third parameter difference, compresses the third parameter difference to obtain the fourth parameter difference, and transmits the fourth parameter difference to the node end; The initial model parameters are updated based on the fourth parameter difference to obtain second model parameters, thus completing this round of training.
2. The federated learning method for heterogeneous data according to claim 1, characterized in that: Based on the model parameter values of the computing model at the current node end in this iterative calculation and the model parameter values of the computing models at other node ends in the previous iterative calculation, the step of calculating the model parameter difference values also includes using a gradient descent method to calculate the model parameter values in this iterative calculation based on the model parameter values of the computing model at the current node end in the previous iterative calculation.
3. The federated learning method for heterogeneous data according to claim 2, characterized in that: According to the following formula, the gradient descent method is used to calculate the model parameter value in this iteration based on the model parameter value of the calculation model at the current node end in the previous round of iteration calculation: Indicates the model parameter value of the kth model parameter in the zth iteration calculation of the current calculation model at the i-th node end, represents the model parameter value of the kth model parameter in the z-1th iteration calculation of the current calculation model at the i-th node end in the tth round, α represents the learning rate, Indicates the gradient value corresponding to the kth model parameter in the z-1th iteration calculation of the current calculation model at the i-th node.
4. The federated learning method for heterogeneous data according to claim 1, characterized in that: The importance parameter is calculated according to the following formula: Indicates the importance parameter of the kth parameter in the calculation model of the jth node at the t-1th round, and max indicates the maximum value. represents the change in the value of the model parameter of the kth parameter in the calculation model of the jth node during the time period of the local training in the t-1th round, ζ is the damping coefficient to avoid the denominator being zero, Represents the estimated value of the importance parameter of the kth parameter in the calculation model of the jth node in the t-1th round of calculation.
5. The method for federated learning of heterogeneous data according to claim 4, characterized in that: The estimated value of the importance parameter is calculated according to the following formula: It represents the estimated value of the importance parameter of the kth parameter in the calculation model of the jth node in the t-1th round calculation. It represents the gradient value corresponding to the kth model parameter in the last iteration calculation of the calculation model at the jth node in the t-1th round. represents the change in the model parameter value of the kth parameter in the calculation model of the jth node during the time period of the t-1th round of local training, ∫ t-1 Represents the integral during the time period of t-1 rounds of calculation.
6. The federated learning method for heterogeneous data according to claim 1, characterized in that: The step of performing data compression on the first parameter difference corresponding to each initial model parameter in the calculation model to obtain the second parameter difference comprises: A sparse operation is used to select a first parameter differences from the first parameter differences corresponding to all initial model parameters; Applying random quantization operation to a first parameter differences to obtain a second parameter differences corresponding to the a first parameter differences; A first compression error is calculated based on the first parameter difference and the second parameter difference.
7. The method for federated learning of heterogeneous data according to claim 6, characterized in that: The step of performing data compression on the third parameter difference to obtain a fourth parameter difference comprises: A sparse operation is used to select a third parameter differences from all third parameter differences of the calculation model on the server side; Applying random quantization operation to a third parameter differences to obtain a fourth parameter differences corresponding to the a third parameter differences; A second compression error is calculated based on the third parameter difference and the fourth parameter difference.
8. The federated learning method for heterogeneous data according to claim 7, characterized in that: The steps of updating the initial model parameters based on the fourth parameter difference to obtain the second model parameters and completing this round of training include: Restoring the fourth parameter difference to a fifth parameter difference according to the first compression error and the second compression error; The initial model parameters are updated to second model parameters according to the fifth parameter difference.
9. The federated learning method for heterogeneous data according to claim 8, characterized in that: Restore the fourth parameter difference to a fifth parameter difference according to the first compression error and the second compression error based on the following formula; represents the fifth parameter difference corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, The fourth parameter difference corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, represents the first compression error corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation, Represents the second compression error corresponding to the kth initial model parameter of the calculation model at the i-th node in the t-th round of calculation.
10. A federated learning system for heterogeneous data, characterized in that: The system includes a computer device, which includes a processor and a memory. The memory stores computer instructions. The processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the system implements the steps of the method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Federal learning training method based on training stage perception strategy
CN113723619A
Method and device for training a model based on federated learning
US20210004718A1
Federated learning method and apparatus based on multi-source heterogeneous system
WO2021109647A1
Federated learning data processing method and apparatus, and device and storage medium
WO2021204040A1
