Federal learning model training method and device, electronic equipment and storage medium
By constructing the initial forgetting learning model and using the attack model to evaluate the difference, the problem of incomplete forgetting after the client exits in the federated learning system is solved, and efficient training and accuracy improvement of the federated learning model are achieved.
Patent Information
- Application Number
- CN202410122297.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-29
- Publication Date
- 2024-10-18
AI Technical Summary
Existing federated learning systems cannot effectively evaluate and forget the extent of training data after the client exits, leading to the problem of incomplete forgetting.
By building an initial forgetting learning model, the intermediate forgetting learning model is trained based on the client's samples and the model parameters that have not exited the client, to determine the difference in the processing results of the samples, and use the attack model to evaluate the degree of forgetting, and adjust the model parameters to achieve complete forgetting.
It saves the training time of the federated learning system, improves the model processing accuracy, ensures that the impact of client samples on the model is reduced, and achieves complete forgetting of data.
Smart Images

Figure CN118798383A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of computers, and in particular, to a training method, device, electronic device, and storage medium for a federated learning model. Background Art
[0002] The Federated Learning system is a distributed machine learning model that can use data from multiple clients to jointly train models without leaking data, making data available but invisible.
[0003] In the case where one or more clients apply to exit the federated learning system, the training data and training effects provided by the above-mentioned clients need to be forgotten. At present, after re-iterative training to obtain the trained federated learning model after the above-mentioned client exits, the difference between the trained federated learning model and the federated learning model before the client exits can be evaluated by constructing a distance function. However, this method cannot evaluate the degree to which the trained federated learning model forgets the training data, resulting in the problem of incomplete forgetting of the training data that needs to be forgotten. In view of this situation, it is necessary to provide a method that can evaluate the degree to which the federated learning model forgets the training data, and adjust the parameters of the federated learning model according to the degree of forgetting the training data to obtain the trained federated learning model. Summary of the invention
[0004] The embodiments of the present disclosure at least provide a training method, device, electronic device and storage medium for a federated learning model.
[0005] In a first aspect, an embodiment of the present disclosure provides a method for training a federated learning model, including:
[0006] In a case where the first client exits the training task of the federated learning model in the federated learning system, constructing an initial forgetting learning model based on the model structure of the federated learning model;
[0007] Based on the first sample of the first client and the model parameters of the second client that has not exited after executing the training task, training the initial forgetting learning model to obtain an intermediate forgetting learning model;
[0008] Determine a first processing result of the first sample by the federated learning model and a second processing result of the first sample by the intermediate forgetting learning model before the first client exits the training task;
[0009] The first processing result and the second processing result are processed by the post-training attack model to obtain the degree of forgetting of the first sample by the intermediate forgetting learning model, and the parameters of the intermediate forgetting learning model are adjusted according to the degree of forgetting to obtain the post-training federated learning model.
[0010] In an optional implementation, the training of the initial forgetting learning model based on the first sample of the first client and the model parameters of the second client that has not exited after executing the training task to obtain the intermediate forgetting learning model includes:
[0011] Obtaining target model parameters of the federated learning model obtained after the second client executes the training task before the first client exits the training task;
[0012] Processing the first sample through the initial forgetting learning model to obtain an output result;
[0013] A target loss model is constructed based on the output result and the target model parameters, and the target loss model is solved. The initial forgetting learning model is trained according to the solution result to obtain an intermediate forgetting learning model.
[0014] In an optional implementation, constructing a target loss model based on the output result and the target model parameter, solving the target loss model, and training the initial forgetting learning model according to the solution result to obtain an intermediate forgetting learning model includes:
[0015] Determining a target loss function based on the parameter variables of the initial forgetting learning model and the output result, and determining a target constraint condition based on the target model parameters and the parameter variables; wherein the target constraint condition is used to indicate a difference between the target model parameters and the parameter variables;
[0016] Based on the target constraint condition, the target loss function is optimally solved to obtain the target variable value of the parameter variable; wherein the target variable value is used to indicate the variable value of the parameter variable when the target loss function is maximum when the difference meets the preset difference requirement;
[0017] The model parameters of the initial forgetting learning model are adjusted based on the target variable value to obtain the intermediate forgetting learning model.
[0018] In an optional implementation, constructing a target loss model based on the output result and the target model parameters includes:
[0019] Performing mean processing on the target model parameters to obtain mean model parameters;
[0020] Based on the output results and the mean model parameters, the target loss model is constructed.
[0021] In an optional implementation manner, before processing the first processing result and the second processing result by using the trained attack model, the method further includes:
[0022] Acquire a second sample of the second client and a third sample of a third client that does not belong to the federated learning system;
[0023] Determine a positive training sample of the attack model to be trained based on the second sample, and determine a negative training sample of the attack model to be trained based on the third sample;
[0024] Based on the positive training samples and the negative training samples, the attack model to be trained is trained to obtain the trained attack model.
[0025] In an optional implementation, determining a positive training sample of the attack model to be trained based on the second sample, and determining a negative training sample of the attack model to be trained based on the third sample, includes:
[0026] Processing the second sample by using the federated learning model before the first client exits to obtain a first result, and processing the second sample by using the intermediate forgetting learning model to obtain a second result;
[0027] Processing the third sample through the federated learning model before the first client exits to obtain a third result, and processing the third sample through the intermediate forgetting learning model to obtain a fourth result;
[0028] The positive training sample is determined based on the first result, the second result and the sample label of the second sample, and the negative training sample is determined based on the third result, the fourth result and the sample label of the third sample; wherein the sample label is used to indicate whether the corresponding sample has exited the training process of the federated learning model.
[0029] In an optional implementation, the processing of the first processing result and the second processing result by the post-training attack model to obtain the degree of forgetting of the first sample by the intermediate forgetting learning model includes:
[0030] Processing the first processing result and the second processing result by the trained attack model to obtain an output of the trained attack model;
[0031] The output of the trained attack model is processed to obtain the degree of forgetting of the first sample by the intermediate forgetting learning model.
[0032] In an optional implementation, adjusting the parameters of the intermediate forgetting learning model according to the forgetting degree to obtain the trained federated learning model includes:
[0033] When the degree of forgetting is less than a preset degree threshold, the parameters of the intermediate forgetting learning model are adjusted according to the degree of forgetting, and the step of determining the second processing result of the intermediate forgetting learning model on the first sample is returned to execute, until the degree of forgetting is greater than or equal to the preset degree threshold, the intermediate forgetting learning model adjusted at the current moment is determined as the trained federated learning model.
[0034] In an optional implementation, the adjusting the parameters of the intermediate forgetting learning model according to the forgetting degree to obtain the trained federated learning model further includes:
[0035] When the forgetting degree is greater than or equal to a preset degree threshold, the intermediate forgetting learning model is determined as the post-training federated learning model.
[0036] In a second aspect, the present disclosure also provides a training device for a federated learning model, including:
[0037] A construction module, used for constructing an initial forgetting learning model based on the model structure of the federated learning model when the first client exits the training task of the federated learning model in the federated learning system;
[0038] A training module, configured to train the initial forgetting learning model based on the first sample of the first client and the model parameters of the second client that has not exited after executing the training task, so as to obtain an intermediate forgetting learning model;
[0039] A determination module, used to determine a first processing result of the federated learning model on the first sample and a second processing result of the intermediate forgetting learning model on the first sample before the first client exits the training task;
[0040] An adjustment module is used to process the first processing result and the second processing result through a trained attack model to obtain the degree of forgetting of the first sample by the intermediate forgetting learning model, and adjust the parameters of the intermediate forgetting learning model according to the degree of forgetting to obtain a trained federated learning model.
[0041] In a third aspect, an embodiment of the present disclosure further provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the above-mentioned first aspect, or any possible implementation of the first aspect are performed.
[0042] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned first aspect or any possible implementation of the first aspect are executed.
[0043] In an embodiment of the present disclosure, first, when the first client exits the training task of the federated learning model in the federated learning system, an initial forgotten learning model is constructed based on the model structure of the federated learning model; secondly, based on the first sample of the first client and the model parameters of the second client that has not exited after executing the training task, the initial forgotten learning model is trained to obtain an intermediate forgotten learning model; thereafter, a first processing result of the federated learning model on the first sample before the first client exits the training task and a second processing result of the intermediate forgotten learning model on the first sample are determined; finally, the first processing result and the second processing result are processed by the post-training attack model to obtain the degree of forgetting of the first sample by the intermediate forgotten learning model, and the parameters of the intermediate forgotten learning model are adjusted according to the degree of forgetting to obtain the trained federated learning model.
[0044] In the above implementation, the initial forgetting learning model is constructed through the model structure of the federated learning model, and the initial forgetting learning model is trained through the first sample of the first client and the model parameters of the second client that has not exited after executing the training task. This can avoid the repeated training of the federated learning model by the re-iterative training method after the first client exits the federated learning system, thereby saving the training time of the federated learning system. After obtaining the intermediate forgetting learning model, the degree of forgetting of the first sample by the intermediate forgetting learning system is determined, and then the model parameters of the intermediate forgetting system are adjusted according to the degree of forgetting to verify the degree of influence of the first sample of the first client on the federated learning model. By training the federated learning model according to the degree of forgetting, the degree of influence of the first sample of the first client on the federated learning model can be reduced to improve the processing accuracy of the federated learning model.
[0045] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0047] Figure 1 A flowchart of a method for training a federated learning model provided by an embodiment of the present disclosure is shown;
[0048] Figure 2 A flowchart showing a specific method for training an initial forgetting learning model in the training method of a federated learning model provided in an embodiment of the present disclosure;
[0049] Figure 3 A flowchart showing a specific method for training an attack model to be trained in the training method of a federated learning model provided in an embodiment of the present disclosure is shown;
[0050] Figure 4 A schematic diagram of a training device for a federated learning model provided by an embodiment of the present disclosure is shown;
[0051] Figure 5 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0053] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0054] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0055] Research has found that the Federated Learning system is a distributed machine learning model that can use data from multiple clients to jointly train models without leaking data, making data available but invisible.
[0056] In the case where one or more clients apply to exit the federated learning system, the training data and training effects provided by the above-mentioned clients need to be forgotten. At present, after re-iterative training to obtain the trained federated learning model after the above-mentioned client exits, the difference between the trained federated learning model and the federated learning model before the client exits can be evaluated by constructing a distance function. However, this method cannot evaluate the degree to which the trained federated learning model forgets the training data, resulting in the problem of incomplete forgetting of the training data that needs to be forgotten. In view of this situation, it is necessary to provide a method that can evaluate the degree to which the federated learning model forgets the training data, and adjust the parameters of the federated learning model according to the degree of forgetting the training data to obtain the trained federated learning model.
[0057] Based on the above research, the present disclosure provides a method for training a federated learning model. In an embodiment of the present application, an initial forgetting learning model is constructed through the model structure of the federated learning model, and the initial forgetting learning model is trained through the first sample of the first client and the model parameters of the second client that has not exited after executing the training task. This can avoid repeatedly training the federated learning model in an iterative training manner after the first client exits the federated learning system, thereby saving the training time of the federated learning system. After obtaining the intermediate forgetting learning model, the degree of forgetting of the first sample by the intermediate forgetting learning system is determined, and then the model parameters of the intermediate forgetting system are adjusted according to the degree of forgetting to verify the degree of influence of the first sample of the first client on the federated learning model. By training the federated learning model according to the degree of forgetting, the degree of influence of the first sample of the first client on the federated learning model can be reduced to improve the processing accuracy of the federated learning model.
[0058] To facilitate understanding of this embodiment, a training method for a federated learning model disclosed in an embodiment of the present disclosure is first introduced in detail. The execution subject of the training method for a federated learning model provided in an embodiment of the present disclosure is generally a computer device with certain computing capabilities, and the computer device includes, for example, a terminal device or a server or other processing device. In some possible implementations, the training method for the federated learning model can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0059] See also Figure 1 FIG. 1 is a flowchart of a method for training a federated learning model provided in an embodiment of the present disclosure, wherein the method includes steps S101 to S104, wherein:
[0060] S101. In a case where the first client exits the training task of the federated learning model in the federated learning system, an initial forgetting learning model is constructed based on the model structure of the federated learning model.
[0061] In an embodiment of the present disclosure, when it is detected that there is a client applying for withdrawal in the current federated learning system, the client applying for withdrawal can be used as the first client, and the first client can be controlled to withdraw from the training task of the federated learning model.
[0062] Here, after controlling the first client to exit the training task of the federated learning model, an initial forgotten learning model can be constructed. The model structure of the initial forgotten learning model is exactly the same as the model structure of the federated learning model in the federated learning system. The model parameters of the initial forgotten learning model can be set randomly or according to historical experience.
[0063] S102: Based on the first sample of the first client and the model parameters of the second client that has not exited after executing the training task, train an initial forgetting learning model to obtain an intermediate forgetting learning model.
[0064] In an embodiment of the present disclosure, after controlling the first client to exit the training task of the federated learning model, the client that has not exited the training task of the federated learning model may be used as the second client.
[0065] Here, the first sample may be a training sample of the first client; the model parameters after the second client executes the training task may be understood as the model parameters obtained after the last execution of the training task of the federated learning model before the first client exits the federated learning system.
[0066] Each training sample includes a data sample and a category of the data sample. For example, the first sample includes m training samples, wherein the jth training sample is (xj, yj), xj is the data sample of the jth training sample, and yj is the category of the data sample of the jth training sample.
[0067] Here, firstly, the model parameters corresponding to each second client can be processed to obtain the processed model parameters. Secondly, the initial forgetting learning model can be trained based on the processed model parameters to obtain the intermediate forgetting learning model.
[0068] S103: Determine a first processing result of the federated learning model on the first sample before the first client exits the training task and a second processing result of the intermediate forgetting learning model on the first sample.
[0069] In an embodiment of the present disclosure, first, the federated learning model obtained after the first client last executes the training task of the federated learning model can be determined as the federated learning model before the first client exits the training task. Then, the processing result of the first sample by the federated learning model before the first client exits the training task can be used as the first processing result. And the processing result of the first sample by the intermediate forgetting learning model can be used as the second processing result.
[0070] S104. Process the first processing result and the second processing result through the post-training attack model to obtain the degree of forgetting of the first sample by the intermediate forgetting learning model, and adjust the parameters of the intermediate forgetting learning model according to the degree of forgetting to obtain the post-training federated learning model.
[0071] In an embodiment of the present disclosure, the first processing result and the second processing result may be output to a trained attack model for processing to obtain the similarity between the first processing result and the second processing result output by the trained attack model.
[0072] Here, after obtaining the similarity between the first processing result and the second processing result, the similarity can be processed to obtain the degree of forgetting of the first sample by the intermediate forgetting learning model. For example, the difference between the target value and the similarity can be calculated, and the difference can be used as the degree of forgetting. When the target value is "1", the difference between 1 and the similarity can be used as the degree of forgetting of the first sample.
[0073] Here, when the forgetting degree is greater than or equal to the preset forgetting degree threshold, the current intermediate forgetting learning model can be used as the post-training federated learning model.
[0074] Here, when the degree of forgetting is less than the preset forgetting degree threshold, first, the parameters of the intermediate forgetting learning model can be adjusted according to the degree of forgetting. Secondly, the processing result of the first sample by the adjusted intermediate forgetting model can be used as the second processing result. After that, the first processing result and the second processing result can be output to the post-training attack model to obtain the degree of forgetting of the first sample by the adjusted intermediate forgetting learning model. Repeat the above steps until the obtained degree of forgetting is greater than or equal to the preset forgetting degree threshold, and use the current intermediate forgetting learning model as the post-training federated learning model.
[0075] In the above implementation, the initial forgetting learning model is constructed through the model structure of the federated learning model, and the initial forgetting learning model is trained through the first sample of the first client and the model parameters of the second client that has not exited after executing the training task. This can avoid the repeated training of the federated learning model by the re-iterative training method after the first client exits the federated learning system, thereby saving the training time of the federated learning system. After obtaining the intermediate forgetting learning model, the degree of forgetting of the first sample by the intermediate forgetting learning system is determined, and then the model parameters of the intermediate forgetting system are adjusted according to the degree of forgetting to verify the degree of influence of the first sample of the first client on the federated learning model. By training the federated learning model according to the degree of forgetting, the degree of influence of the first sample of the first client on the federated learning model can be reduced to improve the processing accuracy of the federated learning model.
[0076] See also Figure 2 As shown, it is a flowchart of the method for training the initial forgetting learning model provided by an embodiment of the present disclosure.
[0077] The above steps train the initial forgetting learning model based on the first sample of the first client and the model parameters of the second client that has not exited after executing the training task, and obtain the intermediate forgetting learning model, which specifically includes the following steps:
[0078] S10, obtaining target model parameters of the federated learning model obtained after the second client executes the training task before the first client exits the training task;
[0079] S20, processing the first sample through the initial forgetting learning model to obtain an output result;
[0080] S30, constructing a target loss model based on the output results and the target model parameters, and solving the target loss model, training the initial forgetting learning model according to the solution results, and obtaining an intermediate forgetting learning model.
[0081] Here, it is assumed that the federated learning model has been trained for T rounds of iterations using the original training set. The original training set is a training set consisting of the first sample of the first client and the second sample of the second client. It is assumed that after T+1 rounds, the first client exits the training task of the federated learning model.
[0082] At this time, the model parameters obtained by each second client after the T-1th round of executing the training task of the federated learning model before the first client exits the training task can be processed to obtain the target model parameters.
[0083] Here, first, the model parameters of the federated learning model after the Tth round of training tasks can be obtained, recorded as model parameters A; then, the model parameters obtained after each second client performs the training task of the federated learning model in the T-1th round are obtained, recorded as model parameters B (that is, target model parameters). Then, according to the model parameters A of the federated learning model output by the last client after the Tth round of training tasks and the model parameters B obtained after each second client performs the training task of the federated learning model in the T-1th round, as well as the output results, the target loss function is constructed.
[0084] In an optional implementation, the above steps construct a target loss model based on the output result and the target model parameters, specifically including the following steps:
[0085] First, the target model parameters are processed by mean to obtain the mean model parameters;
[0086] Then, based on the output results and the mean model parameters, a target loss model is constructed.
[0087] In an embodiment of the present disclosure, first, the model parameters corresponding to the first client after the Tth round of training tasks can be obtained. Then, the model parameters corresponding to the first client after the Tth round of training tasks can be averaged to obtain the average model parameters.
[0088] Here, it is assumed that the mean model parameter may include multiple parameters, and each parameter W in the mean model parameter ref(i) The following conditions are met, where i ranges from 1 to n and n is the number of parameters of the mean model parameter:
[0089] W ref(i) =1 / N1[(N1+N2)W i T -W T-1 target(i) ];
[0090] Where N1 is the number of second clients in the federated learning system, N2 is the number of first clients in the federated learning system, and W i TThe model parameters of the federated learning model output after the Tth round of training tasks and the parameter W ref(i) The corresponding parameter, W T-1 target(i) The target model parameters output by each second client after the T-1th execution of the federated learning model training task and the parameter W ref(i) The corresponding parameters.
[0091] Here, the first sample can also be processed by the initial forgetting learning model to obtain an output result; then, a target loss model can be constructed based on the output result and the target model parameters, and the target loss model can be solved to obtain a solution result. Then, the initial forgetting learning model can be trained according to the solution result until the initial forgetting model converges to obtain an intermediate forgetting learning model.
[0092] The intermediate forgetting learning model obtained by the above processing method can be close to the federated learning model obtained without the first client training, thereby simplifying the model training process.
[0093] In an optional implementation, the above steps construct a target loss model based on the output results and the target model parameters, solve the target loss model, train the initial forgetting learning model according to the solution results, and obtain the intermediate forgetting learning model, which specifically includes the following steps:
[0094] First, based on the parameter variables and output results of the initial forgetting learning model, the target loss function is determined, and based on the target model parameters and parameter variables, the target constraint conditions are determined; wherein the target constraint conditions are used to indicate the difference between the target model parameters and the parameter variables;
[0095] Secondly, based on the target constraint conditions, the target loss function is optimally solved to obtain the target variable value of the parameter variable; wherein the target variable value is used to indicate the variable value of the parameter variable when the target loss function is maximum when the difference meets the preset difference requirement;
[0096] Finally, the model parameters of the initial forgetting learning model are adjusted based on the target variable value to obtain the intermediate forgetting learning model.
[0097] In the embodiment of the present disclosure, the parameter variable of the initial forgetting learning model is a variable used to indicate the model parameter of the initial forgetting learning model. The initial value of the parameter variable is a preset value, which is not specifically limited here.
[0098] Here, the target loss function can be constructed based on the parameter variables and the output results; wherein the target loss function L(W) can meet the following conditions:
[0099] L(W)=1 / N2∑ mj=1 loss(w;(xj,yj));
[0100] Wherein, w is a parameter variable, xj is the jth first sample, yj is the category of the jth first sample, and loss() is a preset loss function. Here, the output result of the first sample is not reflected in the above formula, or in other words, the expression formula of other parameters in the above formula includes the output result of the first sample.
[0101] The data included in the first sample may be structured data or unstructured data, for example, image data, social media data, and sensor data.
[0102] Here, the target constraint condition can be constructed based on the target model parameters, parameter variables and constraint constant s. The smaller the constraint constant, the more similar the target model parameters and parameter variables are; the larger the constraint constant, the less similar the target model parameters and parameter variables are. The target constraint condition can conform to the following formula:
[0103] ||ww ref ||2≤s; where w ref is the target model parameter, and w is the parameter variable.
[0104] In the embodiments of the present disclosure, first, a target loss model can be constructed based on the target constraint conditions and the target loss function. Secondly, the target loss function in the target loss model is optimally solved based on the target constraint conditions in the target loss model until the target variable value of the parameter variable is obtained.
[0105] Among them, the formula of the target loss model is as follows:
[0106]
[0107] Here, the intermediate forgetting learning model can be made to maximize the degree of forgetting the first sample of the first client when it is closest to the model parameters of the second client. That is, when the intermediate forgetting learning model is closest to the client that has not exited the federated learning system, the degree of forgetting the training effect brought by the training sample of the client that has exited the federated learning system is maximized.
[0108] See also Figure 3 As shown, it is a schematic diagram of the process of training the attack model to be trained provided by an embodiment of the present disclosure.
[0109] Before the first processing result and the second processing result are processed by the trained attack model, the following steps are also included:
[0110] S1. Obtain a second sample of a second client and a third sample of a third client that does not belong to the federated learning system;
[0111] S2. Determine a positive training sample of the attack model to be trained based on the second sample, and determine a negative training sample of the attack model to be trained based on the third sample;
[0112] S3. Based on the positive training samples and the negative training samples, the attack model to be trained is trained to obtain a trained attack model.
[0113] In an embodiment of the present disclosure, the third sample that does not belong to the federated learning system may be a client that exits the federated learning system before the first client exits the federated learning system.
[0114] Here, the positive training sample of the attack model to be trained can be determined based on the second sample, the federated learning model and the intermediate forgotten learning model. The negative training sample of the attack model to be trained can be determined based on the third sample, the federated learning model and the intermediate forgotten learning model.
[0115] Here, based on the positive training samples and the negative training samples, the attack model to be trained is trained until the attack model to be trained converges to obtain a trained attack model.
[0116] In an optional implementation, the above step of determining the positive training sample of the attack model to be trained based on the second sample, and determining the negative training sample of the attack model to be trained based on the third sample, specifically includes the following steps:
[0117] First, the second sample is processed by the federated learning model before the first client exits to obtain a first result, and the second sample is processed by the intermediate forgetting learning model to obtain a second result;
[0118] Secondly, the third sample is processed by the federated learning model before the first client exits to obtain a third result, and the third sample is processed by the intermediate forgetting learning model to obtain a fourth result;
[0119] Finally, based on the first result, the second result and the sample label of the second sample, the positive training sample is determined, and based on the third result, the fourth result and the sample label of the third sample, the negative training sample is determined; wherein the sample label is used to indicate whether the corresponding sample has participated in the training process of the federated learning model.
[0120] In an embodiment of the present disclosure, the second sample may be processed by the federated learning model obtained after the first client exits the last round of training tasks to obtain the first result. That is, the second sample is processed by the federated learning model obtained after the Tth training task to obtain the first result.
[0121] Here, the third sample may be processed by the federated learning model obtained after the last training task of executing the federated learning model before the first client exits to obtain the third result. That is, the third sample is processed by the federated learning model obtained after the Tth training task to obtain the third result.
[0122] Here, the first result Z1, the second result Z2 and the sample label of the second sample can be used as positive training samples; the third result F1, the fourth result F2 and the sample label of the third sample can be used as negative training samples.
[0123] Among them, the sample label of the second sample is used to indicate that the second sample has not exited the training process of the federated learning model; the sample label of the third sample is used to indicate that the third sample has exited the training process of the federated learning model.
[0124] For example, the sample label of the second sample can be set to 1, and the sample label of the third sample can be set to 0. At this time, the positive training sample can be expressed as (Z1, Z2, 1), and the negative training sample can be expressed as (F1, F2, 0).
[0125] In an embodiment of the present disclosure, after determining the positive training sample G1 and the negative training sample G2, the positive training sample G1 and the negative training sample G2 can be input into the attack model to be trained to obtain a first similarity between the first result Z1 and the second result Z2, and a second similarity between the third result F1 and the fourth result F2.
[0126] Among them, when the first similarity is greater than or equal to the preset similarity threshold, it indicates that the learning accuracy of the intermediate forgetting learning model for the second sample meets the requirements, that is, the output result of the intermediate forgetting learning model for the second sample is close to the output result of the federated learning model after the Tth iterative training.
[0127] Among them, when the second similarity is less than the preset similarity threshold, it indicates that the intermediate forgetting learning model has a high degree of forgetting the third sample; otherwise, it will indicate that the intermediate forgetting learning model has a low degree of forgetting the third sample.
[0128] In an optional implementation, the above step processes the first processing result and the second processing result by the post-training attack model to obtain the forgetting degree of the first sample by the intermediate forgetting learning model, specifically including the following steps:
[0129] First, the first processing result and the second processing result are processed by the trained attack model to obtain the output of the trained attack model;
[0130] Then, the output of the trained attack model is processed to obtain the forgetting degree of the first sample by the intermediate forgetting learning model.
[0131] In an embodiment of the present disclosure, a positive training sample consisting of the first processing result, the second processing result, and the sample label of the second sample can be input into the post-training attack model, and the output of the post-training attack model is the similarity between the first processing result and the second processing result. The higher the similarity between the first processing result and the second processing result, the greater the output value of the post-training attack model, and the lower the similarity between the first processing result and the second processing result, the smaller the output value of the post-training attack model.
[0132] Here, the output of the trained attack model can be processed by averaging to obtain the averaging result. Then, the difference between the averaging result and the preset value can be used as the forgetting degree of the first sample by the intermediate forgetting learning model. For example, the preset value is set to 1, and the forgetting degree Y meets the following conditions: Y = 1-PJ; where PJ is the averaging result.
[0133] In an optional implementation, the above steps adjust the parameters of the intermediate forgetting learning model according to the degree of forgetting to obtain the trained federated learning model, which specifically includes the following steps:
[0134] When the degree of forgetting is less than a preset degree threshold, the parameters of the intermediate forgetting learning model are adjusted according to the degree of forgetting, and the step of determining the second processing result of the intermediate forgetting learning model on the first sample is returned to execute, until the degree of forgetting is greater than or equal to the preset degree threshold, the intermediate forgetting learning model adjusted at the current moment is determined as the trained federated learning model.
[0135] In an embodiment of the present disclosure, after adjusting the parameters of the intermediate forgetting learning model, first, the first sample can be processed by the adjusted intermediate forgetting learning model, and the output of the adjusted intermediate forgetting learning model is used as the second processing result of the first sample.
[0136] Secondly, the second sample and the third sample can be processed by the adjusted intermediate forgetting learning model, and the output of the adjusted intermediate forgetting learning model can be used as the second result and the fourth result respectively.
[0137] Afterwards, the first result of the second sample, the currently obtained second result, and the sample label of the second sample can be determined as positive training samples. The third result of the third sample, the currently obtained fourth result, and the sample label of the third sample can be determined as negative training samples. And, the trained attack model is retrained based on the positive training sample and the negative training sample.
[0138] Finally, the first processing result and the second processing result of the first sample are input into the post-training attack sample to obtain the forgetting degree of the adjusted intermediate forgetting learning model. If the forgetting degree is greater than or equal to the preset degree threshold, the adjusted intermediate forgetting learning model is determined as the post-training federated learning model; otherwise, the above steps are re-executed until the obtained forgetting degree is greater than or equal to the preset degree threshold.
[0139] In an optional implementation, the above step adjusts the parameters of the intermediate forgetting learning model according to the degree of forgetting to obtain a trained federated learning model, and further includes the following steps:
[0140] When the forgetting degree is greater than or equal to a preset degree threshold, the intermediate forgetting learning model is determined as the post-training federated learning model.
[0141] In an embodiment of the present disclosure, when the degree of forgetting is greater than or equal to a preset degree threshold, the model parameters of the intermediate forgetting learning model are no longer adjusted, and the intermediate forgetting learning model is determined as a trained federated learning model.
[0142] In the above implementation, the degree of forgetting of the first sample of the first client by the intermediate forgetting learning can be obtained by the output of the post-training attack model. And the obtained degree of forgetting can be used to evaluate whether the intermediate forgetting learning model has deleted the effect and contribution brought by the first sample. This makes the degree of forgetting of the federated learning model after training controllable, avoiding the problem that the training sample of the first client has a greater impact on the federated learning model after training.
[0143] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0144] Based on the same inventive concept, the present disclosure also provides a training device for a federated learning model corresponding to the training method for a federated learning model. Since the principle of solving the problem by the device in the present disclosure is similar to the training method for the federated learning model in the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0145] Reference Figure 4 As shown, it is a schematic diagram of a training device for a federated learning model provided in an embodiment of the present disclosure, wherein the device comprises: a construction module 11, a training module 12, a determination module 13, and an adjustment module 14; wherein,
[0146] A construction module, used for constructing an initial forgetting learning model based on the model structure of the federated learning model when the first client exits the training task of the federated learning model in the federated learning system;
[0147] A training module, configured to train the initial forgetting learning model based on the first sample of the first client and the model parameters of the second client that has not exited after executing the training task, so as to obtain an intermediate forgetting learning model;
[0148] A determination module, used to determine a first processing result of the federated learning model on the first sample and a second processing result of the intermediate forgetting learning model on the first sample before the first client exits the training task;
[0149] An adjustment module is used to process the first processing result and the second processing result through a trained attack model to obtain the degree of forgetting of the first sample by the intermediate forgetting learning model, and adjust the parameters of the intermediate forgetting learning model according to the degree of forgetting to obtain a trained federated learning model.
[0150] The disclosed embodiment constructs an initial forgetting learning model through the model structure of the federated learning model, and trains the initial forgetting learning model through the first sample of the first client and the model parameters of the second client that has not exited after executing the training task, which can avoid the repeated training of the federated learning model by re-iterative training after the first client exits the federated learning system, thereby saving the training time of the federated learning system. After obtaining the intermediate forgetting learning model, the influence of the first sample of the first client on the federated learning model is verified by determining the degree of forgetting of the first sample by the intermediate forgetting learning system, and then adjusting the model parameters of the intermediate forgetting system by the degree of forgetting. By training the federated learning model by the degree of forgetting, the influence of the first sample of the first client on the federated learning model can be reduced to improve the processing accuracy of the federated learning model.
[0151] In a possible implementation manner, the training module is further used to: obtain target model parameters of the federated learning model obtained after the second client executes the training task before the first client exits the training task;
[0152] Processing the first sample through the initial forgetting learning model to obtain an output result;
[0153] A target loss model is constructed based on the output result and the target model parameters, and the target loss model is solved. The initial forgetting learning model is trained according to the solution result to obtain an intermediate forgetting learning model.
[0154] In a possible implementation manner, the training module is specifically used to: determine a target loss function based on the parameter variables of the initial forgetting learning model and the output result, and determine a target constraint condition based on the target model parameters and the parameter variables; wherein the target constraint condition is used to indicate a difference between the target model parameters and the parameter variables;
[0155] Based on the target constraint condition, the target loss function is optimally solved to obtain the target variable value of the parameter variable; wherein the target variable value is used to indicate the variable value of the parameter variable when the target loss function is maximum when the difference meets the preset difference requirement;
[0156] The model parameters of the initial forgetting learning model are adjusted based on the target variable value to obtain the intermediate forgetting learning model.
[0157] In a possible implementation manner, the adjustment module is further used to: process the first processing result and the second processing result by using the trained attack model to obtain an output of the trained attack model;
[0158] The output of the trained attack model is processed to obtain the degree of forgetting of the first sample by the intermediate forgetting learning model.
[0159] In one possible implementation, the adjustment module is specifically used to: when the degree of forgetting is less than a preset degree threshold, adjust the parameters of the intermediate forgetting learning model according to the degree of forgetting, and return to execute the step of determining the second processing result of the intermediate forgetting learning model on the first sample, until the degree of forgetting is greater than or equal to the preset degree threshold, and the intermediate forgetting learning model adjusted at the current moment is determined as the trained federated learning model.
[0160] In a possible implementation, the adjustment module is specifically configured to: when the forgetting degree is greater than or equal to a preset degree threshold, determine the intermediate forgetting learning model as the trained federated learning model.
[0161] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0162] Corresponds to Figure 1 The training method of the federated learning model in the present disclosure also provides an electronic device 500, such as Figure 5 FIG. 5 is a schematic diagram of the structure of an electronic device 500 provided in an embodiment of the present disclosure, including:
[0163] Processor 51, memory 52, and bus 53; memory 52 is used to store execution instructions, including memory 521 and external memory 522; memory 521 here is also called internal memory, which is used to temporarily store operation data in processor 51 and data exchanged with external memory 522 such as hard disk. Processor 51 exchanges data with external memory 522 through memory 521. When the electronic device 500 is running, the processor 51 communicates with the memory 52 through bus 53, so that the processor 51 executes the following instructions:
[0164] In a case where the first client exits the training task of the federated learning model in the federated learning system, constructing an initial forgetting learning model based on the model structure of the federated learning model;
[0165] Based on the first sample of the first client and the model parameters of the second client that has not exited after executing the training task, training the initial forgetting learning model to obtain an intermediate forgetting learning model;
[0166] Determine a first processing result of the first sample by the federated learning model and a second processing result of the first sample by the intermediate forgetting learning model before the first client exits the training task;
[0167] The first processing result and the second processing result are processed by the post-training attack model to obtain the degree of forgetting of the first sample by the intermediate forgetting learning model, and the parameters of the intermediate forgetting learning model are adjusted according to the degree of forgetting to obtain the post-training federated learning model.
[0168] The present disclosure also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the training method of the federated learning model described in the above method embodiment are executed. The storage medium may be a volatile or non-volatile computer-readable storage medium.
[0169] The present disclosure also provides a computer program product that carries a program code. The program code includes instructions that can be used to execute the steps of the training method of the federated learning model described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0170] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0171] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0172] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0173] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0174] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0175] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A method for training a federated learning model, characterized in that: include: In a case where the first client exits the training task of the federated learning model in the federated learning system, constructing an initial forgetting learning model based on the model structure of the federated learning model; Based on the first sample of the first client and the model parameters of the second client that has not exited after executing the training task, training the initial forgetting learning model to obtain an intermediate forgetting learning model; Determine a first processing result of the first sample by the federated learning model and a second processing result of the first sample by the intermediate forgetting learning model before the first client exits the training task; The first processing result and the second processing result are processed by the post-training attack model to obtain the degree of forgetting of the first sample by the intermediate forgetting learning model, and the parameters of the intermediate forgetting learning model are adjusted according to the degree of forgetting to obtain the post-training federated learning model.
2. The method according to claim 1, characterized in that The step of training the initial forgetting learning model based on the first sample of the first client and the model parameters of the second client that has not exited after executing the training task to obtain the intermediate forgetting learning model includes: Obtaining target model parameters of the federated learning model obtained after the second client executes the training task before the first client exits the training task; Processing the first sample through the initial forgetting learning model to obtain an output result; A target loss model is constructed based on the output result and the target model parameters, and the target loss model is solved. The initial forgetting learning model is trained according to the solution result to obtain an intermediate forgetting learning model.
3. The method according to claim 2, characterized in that The target loss model is constructed based on the output result and the target model parameter, and the target loss model is solved, and the initial forgetting learning model is trained according to the solution result to obtain the intermediate forgetting learning model, including: Determining a target loss function based on the parameter variables of the initial forgetting learning model and the output result, and determining a target constraint condition based on the target model parameters and the parameter variables; wherein the target constraint condition is used to indicate a difference between the target model parameters and the parameter variables; Based on the target constraint condition, the target loss function is optimally solved to obtain the target variable value of the parameter variable; wherein the target variable value is used to indicate the variable value of the parameter variable when the target loss function is maximum when the difference meets the preset difference requirement; The model parameters of the initial forgetting learning model are adjusted based on the target variable value to obtain the intermediate forgetting learning model.
4. The method according to claim 2, characterized in that: The constructing a target loss model based on the output result and the target model parameters includes: Performing mean processing on the target model parameters to obtain mean model parameters; Based on the output results and the mean model parameters, the target loss model is constructed.
5. The method according to claim 1, characterized in that Before processing the first processing result and the second processing result by using the trained attack model, the method further includes: Acquire a second sample of the second client and a third sample of a third client that does not belong to the federated learning system; Determine a positive training sample of the attack model to be trained based on the second sample, and determine a negative training sample of the attack model to be trained based on the third sample; Based on the positive training samples and the negative training samples, the attack model to be trained is trained to obtain the trained attack model.
6. The method according to claim 5, characterized in that The step of determining a positive training sample of the attack model to be trained based on the second sample, and determining a negative training sample of the attack model to be trained based on the third sample, comprises: Processing the second sample by using the federated learning model before the first client exits to obtain a first result, and processing the second sample by using the intermediate forgetting learning model to obtain a second result; Processing the third sample through the federated learning model before the first client exits to obtain a third result, and processing the third sample through the intermediate forgetting learning model to obtain a fourth result; The positive training sample is determined based on the first result, the second result and the sample label of the second sample, and the negative training sample is determined based on the third result, the fourth result and the sample label of the third sample; wherein the sample label is used to indicate whether the corresponding sample has exited the training process of the federated learning model.
7. The method according to claim 1, characterized in that The step of processing the first processing result and the second processing result by the post-training attack model to obtain the forgetting degree of the first sample by the intermediate forgetting learning model includes: Processing the first processing result and the second processing result by the trained attack model to obtain an output of the trained attack model; The output of the trained attack model is processed to obtain the degree of forgetting of the first sample by the intermediate forgetting learning model.
8. The method according to claim 1, characterized in that: The step of adjusting the parameters of the intermediate forgetting learning model according to the forgetting degree to obtain a trained federated learning model includes: When the degree of forgetting is less than a preset degree threshold, the parameters of the intermediate forgetting learning model are adjusted according to the degree of forgetting, and the step of determining the second processing result of the intermediate forgetting learning model on the first sample is returned to execute, until the degree of forgetting is greater than or equal to the preset degree threshold, the intermediate forgetting learning model adjusted at the current moment is determined as the trained federated learning model.
9. The method according to claim 8, characterized in that The step of adjusting the parameters of the intermediate forgetting learning model according to the forgetting degree to obtain a trained federated learning model further includes: When the forgetting degree is greater than or equal to a preset degree threshold, the intermediate forgetting learning model is determined as the post-training federated learning model.
10. A training device for a federated learning model, characterized in that: include: A construction module, used for constructing an initial forgetting learning model based on the model structure of the federated learning model when the first client exits the training task of the federated learning model in the federated learning system; A training module, configured to train the initial forgetting learning model based on the first sample of the first client and the model parameters of the second client that has not exited after executing the training task, so as to obtain an intermediate forgetting learning model; A determination module, used to determine a first processing result of the federated learning model on the first sample and a second processing result of the intermediate forgetting learning model on the first sample before the first client exits the training task; An adjustment module is used to process the first processing result and the second processing result through a trained attack model to obtain the degree of forgetting of the first sample by the intermediate forgetting learning model, and adjust the parameters of the intermediate forgetting learning model according to the degree of forgetting to obtain a trained federated learning model.
11. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the training method of the federated learning model as described in any one of claims 1 to 9 are performed.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of the training method of the federated learning model as described in any one of claims 1 to 9.
