A federated learning method, apparatus, device, and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-13
- Publication Date
- 2026-08-11
AI Technical Summary
[0005]然而上述方法也存在以下缺点:(1)强制局部模型与全局模型保持一致的方法最终得到了一个模型,但过于强调了局部目标和全局目标之间的一致性,不能很好的泛化不同参与方的特征
[0041]The above technical solution is applied to a federated system composed of multiple participants. First, the local model parameters of each participant in the federated system are obtained. Then, Round training is iterated through the local base network and the encoder/decoder layer of the autoencoder, and a preset loss function is used to determine the loss value corresponding to the completion of multiple epochs during each Round training process. Here, an epoch is the process of all local training samples of the participant completing one training iteration in the local base network and the encoder/decoder layer of the autoencoder; Round training is the process of the participant completing the epoch iteration and performing an aggregation through a secure aggregation server. The local model parameters and the loss value are sent to the secure aggregation server so that the secure aggregation server aggregates the local model parameters to obtain global parameters, aggregates the loss value, and determines the convergence state of the participant based on the aggregated loss value. Then, the global parameters and the convergence state are returned to the participant. Upon receiving the global parameters and the convergence state returned by the secure aggregation server, the local model parameters are updated according to the global parameters, and the Round training is stopped when the convergence state meets a preset condition. As can be seen, in federated learning scenarios, the lack of convergence guarantee for the global model due to the non-independent and identically distributed data of different participants is addressed by introducing an autoencoder during the model training process of a federated system composed of multiple participants. Through the reconstruction of features by the autoencoder, not only are the most valuable features of the local model preserved, but the features of other models are also provided with maximum flexibility, thereby improving the training effect of the federated learning model. In this way, the learning effect of federated learning can be improved in scenarios where the data of participants are not independent and identically distributed, training speed can be increased, and communication volume can be reduced.
Smart Images

Figure CN115841133B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of privacy computing technology, and more specifically, to a federated learning method, apparatus, device, and storage medium. Background Technology
[0002] In recent years, machine learning has made tremendous progress, but its effectiveness heavily relies on large amounts of high-quality training data. However, due to increasing privacy concerns and data security regulations, "data silos" are forming. How to perform machine learning from distributed datasets without exchanging local data has become an emerging topic. Recently, federated learning has emerged as a solution of growing interest, enabling multiple participants to collaboratively train machine learning models without exchanging local data. Federated learning surpasses traditional parallel optimization and avoids systemic privacy risks.
[0003] Data independence and identical distribution (IoD) means that the data are independent of each other but follow the same distribution. In the context of federated learning, data is IoD when each sample has an equal probability of appearing in each participant. However, in many federated learning scenarios, the data distributions of different participants may differ significantly, making IoD unlikely. This is because the data is generated by the participants, who independently collect local data based on their preferences and sampling spaces. The scenarios, business needs, and data collection levels of different participants all affect the sample distribution, resulting in non-IoD data. In non-IoD data scenarios, the local objective functions and optimization directions of different participants in federated learning are inconsistent, leading to a lack of convergence guarantees in the global model and resulting in poor convergence speed and model performance.
[0004] The most commonly used methods in federated learning scenarios are average federation and its extensions. In environments with non-independent and identically distributed data, there is a fundamental contradiction between minimizing local loss and reducing global loss due to differences in data distribution. Past methods lacked convergence guarantees and could only achieve poor convergence speed and model performance. Because the differences between models are accumulated and amplified during training, this is the main factor that slows down the convergence speed and leads to performance degradation. Recently, some scholars have also studied how to solve the problem of non-independent and identically distributed data in federated learning and have given several solutions to handle highly skewed non-independent and identically distributed data, such as (1) adding a proximal term to force a reduction in the difference between the local model and the global model. This type of method forces the local model to be consistent with the global model. (2) Other scholars have proposed heuristic-based methods by sharing local device data or creating some server-side proxy data.
[0005] However, the above methods also have the following drawbacks: (1) The method of forcing the local model to be consistent with the global model eventually yields a model, but it overemphasizes the consistency between the local and global objectives and cannot generalize the features of different participants well. (2) Heuristic methods may be impractical. In addition to burdening network bandwidth, sending local data to the server violates the privacy protection assumption of federated learning.
[0006] In summary, how to improve the learning effect of federated learning in scenarios where the data of the participants are not independent and identically distributed is a problem that needs to be solved. Summary of the Invention
[0007] In view of this, the purpose of this disclosure is to provide a federated learning method, apparatus, device, and storage medium that can improve the learning effect of federated learning in scenarios where the data of participating parties are not independent and identically distributed. The specific solution is as follows:
[0008] Firstly, this application discloses a federated learning method applied to a federated system composed of multiple participants, including:
[0009] Obtain the local model parameters of each participant in the federated system;
[0010] Round training iterates through a local base network and the encoder / decoder layer of the autoencoder, and uses a preset loss function to determine the loss value corresponding to completing multiple epochs in each round training process; wherein, an epoch is the process in which all local training samples of the participant complete one training in the local base network and the encoder / decoder layer of the autoencoder; and round training is the process in which the participant completes the epoch iteration and performs an aggregation through a secure aggregation server.
[0011] The local model parameters and the loss value are sent to the security aggregation server, so that the security aggregation server can aggregate the local model parameters to obtain global parameters, aggregate the loss value, determine the convergence state of the participant based on the aggregated loss value, and then return the global parameters and the convergence state to the participant.
[0012] Upon receiving the global parameters and convergence status returned by the security aggregation server, the local model parameters are updated according to the global parameters, and the Round training is stopped when the convergence status meets the preset conditions.
[0013] Optionally, obtaining the local model parameters of each participant in the federated system includes:
[0014] Obtain the basic model parameters and encoding layer parameters of each participant in the federated system; wherein, the basic model parameters include feature extraction layer parameters and regular training network layer parameters; the encoding layer parameters include local encoding / decoding layer parameters and global encoding / decoding layer parameters.
[0015] Optionally, the step of iterating the Round training through the local base network and the encoder-decoder layer of the autoencoder, and determining the loss value corresponding to completing multiple epochs in each Round training process using a preset loss function, includes:
[0016] During the first round of training, the first loss value for completing multiple epochs is determined using the local base network and the local encoder / decoder layer with the first preset loss function;
[0017] During other rounds of training, the second loss value for completing multiple epochs is determined by the local base network, the local encoding / decoding layer, and the global encoding / decoding layer using a second preset loss function; wherein, the other rounds of training are rounds of training other than the first round of training.
[0018] Optionally, the step of iterating the Round training through the local base network and the encoder-decoder layer of the autoencoder, and determining the loss value corresponding to completing multiple epochs in each Round training process using a preset loss function, includes:
[0019] During the first round of training, the local base network and the local encoder / decoder layer utilize Loss = Loss1 + ||F t (X)-J t (F t (X))||2 determines the first loss value after completing multiple epochs; where Loss1 is the cross-entropy loss; F t (*) indicates the feature extraction module; J t (*) represents the local autoencoder network provided by the participant t; ||*||2 represents the l2 distance;
[0020] During the other rounds of training, the second loss value for completing multiple epochs is determined using the local base network, the local encoder-decoder layer, and the global encoder-decoder layer, using Loss = Loss1 + z * Loss2; where Loss2 = min(||F t (X)-J t (F t (X))||2+k*||F t (X)-J g (F t(X))||2); X represents the input sample; J g (*) indicates the global autoencoder network after the parameters are aggregated on the security aggregation server; k and z are adjustable parameters used to adjust the weights.
[0021] Optionally, the process of iterating the Round training through the local base network and the encoder-decoder layer of the autoencoder, and determining the loss value corresponding to completing multiple epochs in each Round training using a preset loss function, further includes:
[0022] The gradient is updated using the preset loss function, and the local model parameters are also updated so that the target model parameters can be determined after completing multiple epochs.
[0023] Accordingly, sending the local model parameters and the loss value to the security aggregation server, so that the security aggregation server can aggregate the local model parameters to obtain global parameters, includes:
[0024] The target model parameters and the loss value are sent to the security aggregation server so that the security aggregation server can aggregate the target model parameters to obtain global parameters.
[0025] Optionally, sending the target model parameters and the loss value to the security aggregation server, so that the security aggregation server aggregates the target model parameters to obtain global parameters, includes:
[0026] The target model parameters are encrypted using a preset homomorphic encryption technique, and the encrypted target model parameters and the loss value are sent to the security aggregation server so that the security aggregation server can aggregate the target model parameters to obtain global parameters.
[0027] Accordingly, upon receiving the global parameters and the convergence status returned by the security aggregation server, updating the local model parameters based on the global parameters includes:
[0028] Upon receiving the global parameters and convergence status returned by the security aggregation server, the global parameters are decrypted, and then the target model parameters are updated using the decrypted global parameters.
[0029] Optionally, stopping the Round training when the convergence state meets a preset condition includes:
[0030] When the convergence state is that the current round training of the participating party has converged, the round training is stopped;
[0031] Alternatively, when the convergence state is that the number of iterations of the current Round training of the participating party reaches a preset threshold, the Round training is stopped.
[0032] Secondly, this application discloses a federal learning device for use in a federal system composed of multiple participants, comprising:
[0033] The parameter acquisition module is used to acquire the local model parameters of each participant in the federated system.
[0034] An iteration module is used to iterate the Round training through the local base network and the encoder / decoder layer of the autoencoder, and to determine the loss value corresponding to the completion of multiple Epochs in each Round training process using a preset loss function; wherein, the Epoch is the process of all local training samples of the participant completing one training in the local base network and the encoder / decoder layer of the autoencoder; the Round training is the process of the participant completing the Epoch iteration and performing one aggregation through a secure aggregation server;
[0035] An aggregation module is used to send the local model parameters and the loss value to the secure aggregation server, so that the secure aggregation server can aggregate the local model parameters to obtain global parameters, aggregate the loss value, determine the convergence state of the participant based on the aggregated loss value, and then return the global parameters and the convergence state to the participant.
[0036] The update module is used to update the local model parameters according to the global parameters and the convergence status returned by the security aggregation server, and to stop the Round training when the convergence status meets the preset conditions.
[0037] Thirdly, this application discloses an electronic device, including:
[0038] Memory: Used to store computer programs;
[0039] Processor: Used to execute the computer program in the memory to implement the steps of the federated learning method as described above.
[0040] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the steps of the federated learning method as described above.
[0041] The above technical solution is applied to a federated system composed of multiple participants. First, the local model parameters of each participant in the federated system are obtained. Then, Round training is iterated through the local base network and the encoder / decoder layer of the autoencoder, and a preset loss function is used to determine the loss value corresponding to the completion of multiple epochs during each Round training process. Here, an epoch is the process of all local training samples of the participant completing one training iteration in the local base network and the encoder / decoder layer of the autoencoder; Round training is the process of the participant completing the epoch iteration and performing an aggregation through a secure aggregation server. The local model parameters and the loss value are sent to the secure aggregation server so that the secure aggregation server aggregates the local model parameters to obtain global parameters, aggregates the loss value, and determines the convergence state of the participant based on the aggregated loss value. Then, the global parameters and the convergence state are returned to the participant. Upon receiving the global parameters and the convergence state returned by the secure aggregation server, the local model parameters are updated according to the global parameters, and the Round training is stopped when the convergence state meets a preset condition. As can be seen, in federated learning scenarios, the lack of convergence guarantee for the global model due to the non-independent and identically distributed data of different participants is addressed by introducing an autoencoder during the model training process of a federated system composed of multiple participants. Through the reconstruction of features by the autoencoder, not only are the most valuable features of the local model preserved, but the features of other models are also provided with maximum flexibility, thereby improving the training effect of the federated learning model. In this way, the learning effect of federated learning can be improved in scenarios where the data of participants are not independent and identically distributed, training speed can be increased, and communication volume can be reduced.
[0042] Other features and advantages disclosed in this application will be described in detail in the following detailed description section. Attached Figure Description
[0043] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the following detailed description to explain the present disclosure, but do not constitute a limitation thereof. In the drawings:
[0044] Figure 1 This is a flowchart of a federal learning method disclosed in this application;
[0045] Figure 2 This is a schematic diagram of client-server communication in a federated learning scenario disclosed in this application;
[0046] Figure 3 This is a schematic diagram of a federated learning model framework disclosed in this application;
[0047] Figure 4This application discloses a flowchart of a specific federal learning method.
[0048] Figure 5 This is a schematic diagram of a federal learning device disclosed in this application;
[0049] Figure 6 This is a diagram of a client-side electronic device disclosed in this application;
[0050] Figure 7 This is a diagram of a server-side electronic device disclosed in this application. Detailed Implementation
[0051] The technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this disclosure.
[0052] Currently, methods that force local and global models to maintain consistency when addressing the issue of non-independent and identically distributed data in federated learning fail to generalize well to the features of different participants. Heuristic methods, besides burdening network bandwidth, violate the privacy assumptions of federated learning by sending local data to the server. These approaches suffer from poor implementation results.
[0053] To this end, this application discloses a federated learning scheme that can improve the learning effect of federated learning in scenarios where the data of the participants are not independent and identically distributed.
[0054] This application discloses a federated learning method; see [link to relevant documentation]. Figure 1 As shown, the method, applied to a federated system composed of multiple participants, includes:
[0055] Step S11: Obtain the local model parameters of each participant in the federation system.
[0056] In this embodiment, the application is applied to a federated system composed of multiple participants. Assuming a federated learning scenario involves multiple participants, the security aggregation server can send and receive messages from T participants, such as... Figure 2 As shown. Each participant t∈T is represented by M. t The training data consists of several feature forms, and the data distribution of different participants varies greatly, which constitutes the learning environment of federated learning in the scenario where the data of the participants are not independent and are identically distributed.
[0057] First, participant 1, participant t, ..., participant T initialize their local model parameters W respectively. tIt should be noted that the local model parameter W in the embodiments of this application... t Based on the basic model parameters and coding layer parameters Composition, including basic model parameters Including feature extraction layer parameters And the parameters of conventionally trained network layers The coding layer parameters include local coding / decoding layer parameters and global coding / decoding layer parameters.
[0058] Step S12: Iterate the Round training through the local base network and the encoder / decoder layer of the autoencoder, and use the preset loss function to determine the loss value corresponding to the completion of multiple Epochs in each Round training process.
[0059] For most commonly used machine learning models f t In related technologies, f is usually referred to as t Decompose into F t (*)+S t (*), where F t (*) indicates the feature extraction module, S t (*) indicates that F is excluded. t (*) The model training layer and classification layer outside; during the training process, the data is usually sent to the regular training network layer S after feature extraction. t (*). However, in this embodiment, an autoencoder is introduced during the training of the federated model to capture the most important features for the task. It is understood that an autoencoder is a neural network trained to reconstruct its input, consisting of symmetrical encoding and decoding parts. The optimal model is generally obtained by minimizing the L2 distance between the input and its reconstruction.
[0060] It should be noted that, for better description of the steps in this patent, it is assumed that in a federated learning scenario, the process of all local training samples of each participant completing one training iteration in the local base network and the encoder / decoder layer of the autoencoder is called an Epoch; each interaction of parameters between the participant and the secure aggregation server, and the subsequent aggregation process, is called a Round. During local training, the participants iterate through the Epoch; after sending the iterated data to the secure aggregation server, the secure aggregation server aggregates the parameters, completing one Round. After returning the aggregated parameters to each participant, the next local Round begins.
[0061] In this embodiment, during the first round of training, since there is no global encoder-decoder layer and only a local encoder-decoder layer, the local base network and the local encoder-decoder layer utilize the first preset loss function Loss = Loss1 + ||F|| at each epoch. t (X)-J t (F t (X))||2 determines the first loss value after completing N epochs; where Loss1 is the cross-entropy loss; F t (*) indicates the feature extraction module; J t (*) represents the local autoencoder network provided by the participant t; ||*||2 represents the l2 distance.
[0062] During other rounds of training, the second loss value for completing multiple epochs is determined using the local base network, the local encoder-decoder layer, and the global encoder-decoder layer through a second preset loss function; these other rounds of training refer to rounds of training other than the first round. It should be noted that in subsequent rounds of training, the loss value is determined using Loss = Loss1 + z * Loss2; where Loss2 = min(||F t (X)-J t (F t (X))||2+k*||F t (X)-J g (F t (X))||2); X represents the input sample; J g (*) indicates the global autoencoder network after the parameters are aggregated on the server; k and z are adjustable parameters used to adjust the weights.
[0063] Step S13: Send the local model parameters and the loss value to the secure aggregation server so that the secure aggregation server can aggregate the local model parameters to obtain global parameters, aggregate the loss value, determine the convergence state of the participant based on the aggregated loss value, and then return the global parameters and the convergence state to the participant.
[0064] In this embodiment of the application, during the first round of training, the gradient is updated using the first preset loss function in each epoch, and the local model parameters are updated. After N epochs, the target model parameters and loss values are obtained and sent to the server for aggregation. During other rounds of training, the gradient is updated using the second preset loss function, and the local model parameters are updated. After N epochs of training, the target model parameters and loss values are obtained and sent to the server for aggregation.
[0065] It is understandable that during the first round of training, Epoch completes one training cycle for all local training samples of the participating party in the local network and local codec layer; during other rounds of training, Epoch completes one training cycle for all local training samples of the participating party in the local network, local codec layer, and global codec layer.
[0066] In a first specific implementation, the target model parameters are encrypted using a preset homomorphic encryption technique, and the encrypted target model parameters are sent to a secure aggregation server. For example, suppose the symbol X... t This indicates that participant t in federated learning provides the corresponding label Y. t Given the input samples, then each participant f t (X t Y t Basic model parameters and coding layer J t (X t ) parameters By using pre-set homomorphic encryption technology, the basic model parameters are... and coding layer parameters The information is concealed, and the concealed information is... and Send to the secure aggregation server. It should be noted that at this time... These are the network parameters for the local codec layer; additionally, the default homomorphic encryption technology can also be differential privacy or password sharing encryption technology, etc., without specific limitations here.
[0067] Furthermore, when training using data from all participants, a common approach used by secure aggregation servers in federated learning is average federation, which averages the locally encrypted model parameters. Aggregate the parameters of the basic model; utilize Aggregate the coding layer parameters; where T is the number of participants; sn t Let be the number of local samples of the participant t; sn a The total number of samples is denoted as Enc(*); the encryption algorithm is denoted as Enc(*). These are the parameters of the basic model; These are the parameters of the coding layer.
[0068] In another specific implementation, the loss value is sent to a secure aggregation server; that is, each participant sends its local loss value. t Send to the secure aggregation server for loss tPerform secure aggregation. Specifically, based on the number of samples among the participants, use a preset weighting rule to apply the loss value. t Perform a weighted average to obtain the aggregated loss value. g Furthermore, based on the weighted average loss... g The value determines whether the current iteration has converged and returns the convergence status to each participant.
[0069] Step S14: After receiving the global parameters and convergence status returned by the security aggregation server, update the local model parameters according to the global parameters, and stop the Round training when the convergence status meets the preset conditions.
[0070] Accordingly, in the first specific implementation, each participating party receives the aggregated global parameters returned by the security aggregation server, including global basic model parameters. and global coding layer parameters right and Decrypt and update local model parameters. and It should be noted that during this process, the following methods are simultaneously utilized: The global encoder-decoder layer in the autoencoder is updated, and then preparation for the next local iteration begins. In this way, the autoencoder not only utilizes the local encoder-decoder layer to obtain the reconstruction of local features, but also utilizes the global encoder-decoder layer to complete the reconstruction of local features.
[0071] In another specific implementation, each participant receives the convergence status returned by the secure aggregation server and determines whether the convergence status meets a preset condition. If the convergence status does not meet the preset condition, a second loss value is determined using the loss function Loss = Loss1 + z*Loss2, so that the gradient and the local model parameters are updated using the second loss value in subsequent iterations. For example, it can be determined whether the convergence status has reached convergence and whether the current training has reached the maximum number of iterations. It should be noted that the maximum number of iterations can be arbitrarily set to flexibly set the number of iteration rounds between each participant and the secure aggregation server. For example, if the current model has not converged and has not reached the maximum number of iterations, it is determined that the convergence status does not meet the preset condition, and iteration should continue; if the current model has not converged but has reached the maximum number of iterations, the convergence status meets the preset condition, and iteration stops.
[0072] Understandably, in subsequent iterations, the gradient update formula differs from that of the first iteration, and the model framework is as follows: Figure 3 As shown. Additionally, during the local Epoch iteration process, J...g (*) During local training, network parameters are not updated. Updates are performed only after the security aggregation server returns the corresponding aggregation parameters.
[0073] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this disclosure.
[0074] The above technical solution is applied to a federated system composed of multiple participants. First, the local model parameters of each participant in the federated system are obtained. Then, Round training is iterated through the local base network and the encoder / decoder layer of the autoencoder, and a preset loss function is used to determine the loss value corresponding to the completion of multiple epochs during each Round training process. Here, an epoch is the process of all local training samples of the participant completing one training iteration in the local base network and the encoder / decoder layer of the autoencoder; Round training is the process of the participant completing the epoch iteration and performing an aggregation through a secure aggregation server. The local model parameters and the loss value are sent to the secure aggregation server so that the secure aggregation server aggregates the local model parameters to obtain global parameters, aggregates the loss value, and determines the convergence state of the participant based on the aggregated loss value. Then, the global parameters and the convergence state are returned to the participant. Upon receiving the global parameters and the convergence state returned by the secure aggregation server, the local model parameters are updated according to the global parameters, and the Round training is stopped when the convergence state meets a preset condition. As can be seen, in federated learning scenarios, the lack of convergence guarantee for the global model due to the non-independent and identically distributed data of different participants is addressed by introducing an autoencoder during the model training process of a federated system composed of multiple participants. Through the reconstruction of features by the autoencoder, not only are the most valuable features of the local model preserved, but the features of other models are also provided with maximum flexibility, thereby improving the training effect of the federated learning model. In this way, the learning effect of federated learning can be improved in scenarios where the data of participants are not independent and identically distributed, training speed can be increased, and communication volume can be reduced.
[0075] This application discloses a specific federated learning method; see [link to relevant documentation]. Figure 4As shown, in federated learning scenarios, different participants train local models, and a secure aggregation server performs secure aggregation of parameter models. The data distribution differences between participants are significant, and each round of training and local model parameter updates are associated with minimizing the local loss function, resulting in insufficient performance of the globally secure aggregation parameters across different participants. Therefore, the technical solution provided by the embodiments of this disclosure can include the following beneficial effects: bridging different participants by learning global and local feature memory encoding modules, thereby improving the robustness and speed of model convergence. Unlike previous processes that retained all features during training, this method only retains the features most useful to the local model, while providing greater flexibility for feature learning by other participants, thus improving the performance of the global model. This method is applied to federated systems composed of multiple participants, including:
[0076] Step S21: Obtain the basic model parameters and encoding layer parameters of each participant in the federated system; wherein, the basic model parameters include feature extraction layer parameters and regular training network layer parameters; the encoding layer parameters include local encoding / decoding layer parameters and global encoding / decoding layer parameters.
[0077] In this embodiment of the application, participant 1, participant t, ..., participant T respectively initialize the local model parameter W. t Basic model parameters and encoding layer parameters Among them, the basic model parameters Including feature extraction layer parameters And the parameters of conventionally trained network layers
[0078] Step S22: During the first round of training, the first loss value for completing multiple epochs is determined using the local base network and the local codec layer with the first preset loss function; during other rounds of training, the second loss value for completing multiple epochs is determined using the local base network, the local codec layer, and the global codec layer with the second preset loss function.
[0079] In one specific implementation, during the first round of training, the local base network and the local coding layer utilize Loss = Loss1 + ||F t (X)-J t (F t (X))||2 performs N epochs; it can be understood that the local base network consists of a feature extraction layer and a regular network training layer; during the first round of training, the epoch is the process in which all local training samples of the participating party complete one training cycle in the local network and the local encoder-decoder layer, at which time there is no global encoder-decoder layer. Here, Loss1 is the cross-entropy loss; F t(*) indicates the feature extraction module; J t (*) represents the local autoencoder network provided by the participant t; ||*||2 represents the l2 distance.
[0080] In another specific implementation, before other rounds of training begin, the security aggregation server will perform a weighted aggregation based on the loss. g The convergence state of the participant is determined by the value, and further, it is determined whether the convergence state meets preset conditions, such as whether the current iteration of the current round of training has converged, or whether the current iteration number of the participant has reached a preset threshold. If the convergence state does not meet the preset conditions, then in subsequent rounds of training, the basic model parameters are updated using the global parameters returned after aggregation by the secure aggregation server, and the local encoding / decoding layer and the global encoding / decoding layer are updated. Then, in subsequent rounds of training, N epochs of training are performed based on the preset second loss function.
[0081] Step S23: Update the gradient using the preset loss function and update the local model parameters so as to determine the target model parameters after completing multiple Epochs.
[0082] In this embodiment of the application, during the first round of training, the gradient is updated using the first preset loss function in each epoch, and the local model parameters are updated. After N epochs, the target model parameters and loss values are obtained and sent to the secure aggregation server for aggregation.
[0083] During subsequent rounds of training, the gradients are updated using the second loss function, and the local model parameters are also updated. After N epochs, the target model parameters and gradients are obtained. It is worth noting that in each round of N epochs, the parameters of the global encoder layer are not updated. Only the network parameters of the local base network and the local encoder layer are updated.
[0084] Step S24: Encrypt the target model parameters using a preset homomorphic encryption technique, and send the encrypted target model parameters and the loss value to the secure aggregation server, so that the secure aggregation server can aggregate the target model parameters to obtain global parameters, aggregate the loss value, determine the convergence state of the participant based on the aggregated loss value, and then return the global parameters and the convergence state to the participant.
[0085] In this embodiment of the application, each participant will f t (X t Y t ) parameters and coding layer J t (Xt The parameter W) J t uses encryption techniques such as homomorphic encryption, differential privacy, or password sharing to protect parameters. and parameters The information is concealed, and the concealed information is... and Send to the secure aggregation server on the server side.
[0086] In this embodiment, the security aggregation server performs security aggregation. Unlike traditional security aggregation, this disclosure introduces coding layer parameters in addition to ordinary network layer parameters during aggregation. The formula is as follows:
[0087] Aggregated global parameters and Returned to all participants. Each participant receives the global parameters of the aggregation. and Decrypt and update local model parameters and Simultaneously use Update the local global codec layer, and then prepare to start the next local iteration.
[0088] In this embodiment of the application, each participating party will also report its local loss value. t Send to the security aggregation server, the security aggregation server performs loss analysis. t Safe aggregation, based on the weighted average loss g The value determines whether the current iteration has converged and returns the convergence status to each participant.
[0089] The participants receive the current convergence state of the model and determine whether the convergence state meets the preset conditions. If the preset conditions are not met, it is necessary to continue iterating. The gradient update formula is different from the first round of training. The update formula is as follows: Loss = Loss1 + z * Loss2; where Loss2 = min(||F t (X)-J t (F t (X))||2+k*||F t (X)-J g (F t (X))||2); F t (*) indicates the feature extraction module; J t (*) represents the local autoencoder network provided by participant t; X represents the input sample; J g (*) indicates the global autoencoder network after the parameters are aggregated on the server; k and z are adjustable parameters used to adjust the weights; ||*||2 represents the L2 distance.
[0090] Understandably, because there is no global encoder / decoder layer in the first iteration (first round of training), the first iteration uses the first preset loss function Loss = Loss1 + ||F t (X)-J t (F t (X))||2;In subsequent iterations, since the local global encoder-decoder layer is updated, the second loss value is determined using the second preset loss function Loss=Loss1+z*Loss2, and the gradient and the local model parameters are updated. In this way, to address the problem of the lack of convergence guarantee in the global model due to the non-independent and identically distributed data of different participants in federated learning, an autoencoder is introduced during the federated model training process. Through the reconstruction of features by two encoders, the local encoder-decoder layer and the global encoder-decoder layer, not only are the most valuable features of the local model preserved, but greater flexibility is also provided for learning features of other models, thereby improving the training effect of federated learning.
[0091] Step S25: After receiving the global parameters and convergence status returned by the secure aggregation server, the global parameters are decrypted, and the target model parameters are updated using the decrypted global parameters. The Round training is stopped when the convergence status meets the preset conditions.
[0092] In this embodiment, to ensure data security, each participant sends the updated target model parameters to the secure aggregation server using a preset homomorphic encryption technique. Therefore, after receiving the aggregated global parameters and the convergence status of each participant returned by the secure aggregation server, the model parameters are decrypted and updated. and Simultaneously utilize Update the global encoder / decoder layer in the autoencoder, and then start preparing for the next round of local iterations. Stop the Round training iterations when the convergence state meets the preset conditions.
[0093] As can be seen, in federated learning scenarios, the lack of convergence guarantee for the global model due to the non-independent and identically distributed data of different participants is addressed by introducing an autoencoder during the model training process of a federated system composed of multiple participants. Through the reconstruction of features by the autoencoder, not only are the most valuable features of the local model preserved, but the features of other models are also provided with maximum flexibility, thereby improving the training effect of the federated learning model. In this way, the learning effect of federated learning can be improved in scenarios where the data of participants are not independent and identically distributed, training speed can be increased, and communication volume can be reduced.
[0094] Accordingly, this application also discloses a federated learning device, see [link to relevant documentation]. Figure 5As shown, the device, applied to a federated system composed of multiple participants, includes:
[0095] The parameter acquisition module 11 is used to acquire the local model parameters of each participant in the federated system.
[0096] The iteration module 12 is used to iterate the Round training through the local base network and the encoder-decoder layer of the autoencoder, and to determine the loss value corresponding to the completion of multiple Epochs in each Round training process using a preset loss function; wherein, the Epoch is the process in which all local training samples of the participant complete one training in the local base network and the encoder-decoder layer; the Round training is the process in which the participant completes the Epoch iteration and performs one aggregation through a secure aggregation server;
[0097] The aggregation module 13 is used to send the local model parameters and the loss value to the secure aggregation server, so that the secure aggregation server can aggregate the local model parameters to obtain global parameters, aggregate the loss value, determine the convergence state of the participant based on the aggregated loss value, and then return the global parameters and the convergence state to the participant.
[0098] The update module 14 is used to update the local model parameters according to the global parameters and the convergence status returned by the security aggregation server, and to stop the Round training when the convergence status meets the preset conditions.
[0099] For more detailed information on the working process of each of the above modules, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0100] Therefore, the above-described scheme of this embodiment, applied to a federated system composed of multiple participants, firstly obtains the local model parameters of each participant in the federated system; then iterates the Round training through the local base network and the encoder-decoder layer of the autoencoder, and uses a preset loss function to determine the loss value corresponding to the completion of multiple Epochs in each Round training process; wherein, the Epoch is the process of all local training samples of the participant completing one training in the local base network and the encoder-decoder layer of the autoencoder; the Round training is the process of the participant completing the Epoch iteration and performing an aggregation through a secure aggregation server; the local model parameters and the loss value are sent to the secure aggregation server so that the secure aggregation server aggregates the local model parameters to obtain global parameters, aggregates the loss value, and determines the convergence state of the participant based on the aggregated loss value, and then returns the global parameters and the convergence state to the participant; when the global parameters and the convergence state returned by the secure aggregation server are received, the local model parameters are updated according to the global parameters, and the Round training is stopped when the convergence state meets the preset conditions. As can be seen, in federated learning scenarios, the lack of convergence guarantee for the global model due to the non-independent and identically distributed data of different participants is addressed by introducing an autoencoder during the model training process of a federated system composed of multiple participants. Through the reconstruction of features by the autoencoder, not only are the most valuable features of the local model preserved, but the features of other models are also provided with maximum flexibility, thereby improving the training effect of the federated learning model. In this way, the learning effect of federated learning can be improved in scenarios where the data of participants are not independent and identically distributed, training speed can be increased, and communication volume can be reduced.
[0101] Figure 6 A block diagram of an electronic device 200 is shown according to an exemplary embodiment. (See diagram for reference.) Figure 6 As shown, the electronic device 200 may include a processor 201 and a memory 202. The electronic device 200 may also include one or more of a multimedia component 203, an input / output (I / O) interface 204, and a communication component 205.
[0102] The processor 201 controls the overall operation of the electronic device 200 to complete all or part of the steps in the federated learning method described above. The memory 202 stores various types of data to support the operation of the electronic device 200. This data may include, for example, instructions for any application or method operating on the electronic device 200, and application-related data such as contact data, sent and received messages, images, audio, video, etc. The memory 202 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. Multimedia component 203 may include a screen and an audio component. The screen may be, for example, a touchscreen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signals may be further stored in memory 202 or transmitted via communication component 205. The audio component also includes at least one speaker for outputting audio signals. I / O interface 204 provides an interface between processor 201 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual or physical buttons. Communication component 205 is used for wired or wireless communication between the electronic device 200 and other devices. Wireless communication may include Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, or 4G, or a combination of these. Therefore, the corresponding communication component 205 may include a Wi-Fi module, a Bluetooth module, or an NFC module.
[0103] In an exemplary embodiment, the electronic device 200 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the federated learning method described above.
[0104] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, which, when executed by a processor, implement the steps of the federated learning method described above. For example, the computer-readable storage medium may be the memory 202 including program instructions described above, which may be executed by the processor 201 of the electronic device 200 to complete the federated learning method described above.
[0105] Figure 7 This is a block diagram illustrating an electronic device 300 according to an exemplary embodiment. For example, the electronic device 300 may be provided as a server. (Refer to...) Figure 7 The electronic device 300 includes a processor 301, which may be one or more, and a memory 302 for storing computer programs executable by the processor 301. The computer program stored in the memory 302 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processor 301 may be configured to execute the computer program to perform the federated learning method described above.
[0106] Additionally, the electronic device 300 may also include a power supply component 303 and a communication component 304. The power supply component 303 can be configured to perform power management of the electronic device 300, and the communication component 304 can be configured to enable communication of the electronic device 300, such as wired or wireless communication. Furthermore, the electronic device 300 may also include an input / output (I / O) interface 305. The electronic device 300 can operate on an operating system stored in the memory 302, such as Windows Server™, Mac OSX™, Unix™, Linux™, etc.
[0107] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, which, when executed by a processor, implement the steps of the federated learning method described above. For example, the computer-readable storage medium may be the memory 302 including program instructions described above, which may be executed by the processor 301 of the electronic device 300 to complete the federated learning method described above.
[0108] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0109] The foregoing has provided a detailed description of a federated learning method, apparatus, device, and storage medium provided by this disclosure. Specific examples have been used to illustrate the principles and implementation methods of this disclosure. The descriptions of the above embodiments are only for the purpose of helping to understand the method and its core ideas. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this disclosure. Therefore, the content of this specification should not be construed as a limitation of this disclosure.
Claims
1. A federated learning method, characterized in that, Applied to federated systems with multiple participants, including: Obtain the local model parameters of each participant in the federated system; Round training iterates through a local base network and the encoder / decoder layer of the autoencoder, and uses a preset loss function to determine the loss value corresponding to completing multiple epochs in each round training process; wherein, an epoch is the process in which all local training samples of the participant complete one training in the local base network and the encoder / decoder layer of the autoencoder; and round training is the process in which the participant completes the epoch iteration and performs an aggregation through a secure aggregation server. The local model parameters and the loss value are sent to the security aggregation server, so that the security aggregation server can aggregate the local model parameters to obtain global parameters, aggregate the loss value, determine the convergence state of the participant based on the aggregated loss value, and then return the global parameters and the convergence state to the participant. Upon receiving the global parameters and convergence status returned by the security aggregation server, the local model parameters are updated according to the global parameters, and the Round training is stopped when the convergence status meets the preset conditions. The process of obtaining the local model parameters of each participant in the federated system includes: Obtain the basic model parameters and encoding layer parameters of each participant in the federated system; wherein, the basic model parameters include feature extraction layer parameters and regular training network layer parameters; the encoding layer parameters include local encoding / decoding layer parameters and global encoding / decoding layer parameters; Accordingly, the step of iterating the Round training through the local base network and the autoencoder's encoding and decoding layers, and determining the loss value corresponding to completing multiple epochs in each Round training process using a preset loss function, includes: During the first round of training, the first loss value for completing multiple epochs is determined using the local base network and the local encoder / decoder layer with the first preset loss function; During other rounds of training, the second loss value for completing multiple epochs is determined by the local base network, the local encoding / decoding layer, and the global encoding / decoding layer using a second preset loss function; wherein, the other rounds of training are rounds of training other than the first round of training; the parameters corresponding to the global encoding / decoding layer are global autoencoder network parameters returned by the secure aggregation server after aggregating the local encoding / decoding layer parameters uploaded by each participant; Furthermore, the process of iterating Round training through the local base network and the autoencoder's encoding / decoding layer, and determining the loss value corresponding to completing multiple epochs in each Round training using a preset loss function, also includes: The gradient is updated using the preset loss function, and the local model parameters are also updated so that the target model parameters can be determined after completing multiple epochs. Accordingly, sending the local model parameters and the loss value to the security aggregation server, so that the security aggregation server can aggregate the local model parameters to obtain global parameters, includes: The target model parameters and the loss value are sent to the security aggregation server so that the security aggregation server can aggregate the target model parameters to obtain global parameters; Furthermore, the step of sending the target model parameters and the loss value to the security aggregation server, so that the security aggregation server can aggregate the target model parameters to obtain global parameters, includes: The target model parameters are encrypted using a preset homomorphic encryption technique, and the encrypted target model parameters and the loss value are sent to the security aggregation server so that the security aggregation server can aggregate the target model parameters to obtain global parameters. Accordingly, upon receiving the global parameters and the convergence status returned by the security aggregation server, updating the local model parameters based on the global parameters includes: Upon receiving the global parameters and convergence status returned by the security aggregation server, the global parameters are decrypted, and then the target model parameters are updated using the decrypted global parameters.
2. The federated learning method of claim 1, wherein, The iterative training of Round using a local base network and an autoencoder encoding / decoding layer, and the determination of the loss value corresponding to completing multiple epochs in each Round training process using a preset loss function, includes: In the first Round training, the first loss value is determined when a plurality of Epochs are completed, wherein the first loss value is determined by the local base network and the local coding-decoding layer using In the first Round training, the first loss value is determined when a plurality of Epochs are completed, wherein the first loss value is determined by the local base network and the local coding-decoding layer using is a cross-entropy loss; represents a feature extraction module; represents a local auto-encoding network provided by the participant t; represents a distance between the local auto-encoding network provided by the participant t and the global auto-encoding network; is a distance. During the other Round training, the local base network, the local coding-decoding layer and the global coding-decoding layer are utilized by determining a second loss value when a plurality of Epochs are completed; wherein, ; X represents an input sample; represents a global auto-encoding network after the parameters are aggregated at the secure aggregation server; k, z are adjustable parameters for adjusting weights.
3. The federated learning method of claim 1 or 2, wherein, The step of stopping the Round training when the convergence state meets the preset conditions includes: When the convergence state is that the current round training of the participating party has converged, the round training is stopped; Alternatively, when the convergence state is that the number of iterations of the current Round training of the participating party reaches a preset threshold, the Round training is stopped.
4. A federated learning apparatus, comprising: Applied to federated systems with multiple participants, including: The parameter acquisition module is used to acquire the local model parameters of each participant in the federated system. An iteration module is used to iterate the Round training through the local base network and the encoder / decoder layer of the autoencoder, and to determine the loss value corresponding to the completion of multiple Epochs in each Round training process using a preset loss function; wherein, the Epoch is the process of all local training samples of the participant completing one training in the local base network and the encoder / decoder layer of the autoencoder; the Round training is the process of the participant completing the Epoch iteration and performing one aggregation through a secure aggregation server; An aggregation module is used to send the local model parameters and the loss value to the secure aggregation server, so that the secure aggregation server can aggregate the local model parameters to obtain global parameters, aggregate the loss value, determine the convergence state of the participant based on the aggregated loss value, and then return the global parameters and the convergence state to the participant. The update module is used to update the local model parameters according to the global parameters and the convergence status returned by the security aggregation server, and to stop the Round training when the convergence status meets the preset conditions. The parameter acquisition module is specifically used to acquire the basic model parameters and encoding layer parameters of each participant in the federated system; wherein, the basic model parameters include feature extraction layer parameters and regular training network layer parameters; the encoding layer parameters include local encoding / decoding layer parameters and global encoding / decoding layer parameters; Accordingly, the iterative module is specifically used to determine a first loss value for completing multiple epochs using a first preset loss function through the local base network and the local codec layer during the first round of training; and to determine a second loss value for completing multiple epochs using a second preset loss function through the local base network, the local codec layer, and the global codec layer during other rounds of training; wherein, the other rounds of training are rounds of training other than the first round of training; the parameters corresponding to the global codec layer are global autoencoder network parameters returned by the secure aggregation server after aggregating the local codec layer parameters uploaded by each participant; The iteration module is also used to update the gradient using the preset loss function and update the local model parameters so as to determine the target model parameters after completing multiple Epochs. Accordingly, the aggregation module is used to send the target model parameters and the loss value to the secure aggregation server, so that the secure aggregation server can aggregate the target model parameters to obtain global parameters; Furthermore, the aggregation module is specifically used to encrypt the target model parameters using a preset homomorphic encryption technology, and send the encrypted target model parameters and the loss value to the secure aggregation server, so that the secure aggregation server can aggregate the target model parameters to obtain global parameters; Accordingly, the update module is used to decrypt the global parameters and the convergence status returned by the security aggregation server, and then use the decrypted global parameters to update the target model parameters.
5. An electronic device, comprising: include: Memory: Used to store computer programs; Processor: for executing the computer program in the memory to implement the steps of the federated learning method as described in any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein the computer programs, when executed by a processor, implement the steps of the federated learning method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Vertical federated learning defense method based on auto-encoder
CN112464290A
Code completion method and device and related equipment
CN112527273A