Federal modeling method, device, equipment and computer-readable storage medium

By labeling the training data set in the federal study and using the gradient to determine the training model to be trained, combined with the second and third gradient update models, the problem of the balance between gradient protection and model convergence or accuracy of the existing technology has been solved. Efficient privacy protection and model training effect.

CN111582505BActive Publication Date: 2025-01-28WEBANK (CHINA)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010411493.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-14
Publication Date
2025-01-28
Estimated Expiration
2040-05-14

AI Technical Summary

Technical Problem

It is difficult to achieve a balance between gradient protection and model convergence or accuracy in existing federated learning, resulting in insufficient noise, resulting in privacy leakage or excessive noise, resulting in low model training accuracy.

Method used

By labeling the training dataset through the first terminal, obtain the public tag vector and local tag vector, and use the first gradient of the first gradient and the second gradient corresponding to the local tag vector corresponding to the public tag vector to determine the first gradient to the first gradient to the first gradient to the first gradient The second end is obtained by obtaining the third gradient. Based on the second gradient and the third gradient, the target gradient is determined and the training model is updated.

Benefits of technology

A balance between privacy protection and model convergence or accuracy of gradients avoids the low accuracy of model training caused by high privacy leakage and excessive noise caused by insufficient noise, which improves the security of data in federal learning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111582505B_ABST
    Figure CN111582505B_ABST
Patent Text Reader

Abstract

The present invention discloses a federated modeling method, comprising the following steps: a first terminal labels a training data set to obtain a public label vector and a local label vector; a first gradient corresponding to the public label vector and a second gradient corresponding to the local label vector are determined through a model to be trained; the first gradient is sent to a second terminal, so that the second terminal can determine and feedback a third gradient based on the first gradient; a target gradient is determined based on the second gradient and the third gradient, and the model to be trained is updated based on the target gradient to obtain a target model. The present invention also discloses a federated modeling apparatus, device and computer-readable storage medium. The present invention realizes modeling through public label vectors and local label vectors without modifying the gradient, achieves a balance between gradient privacy protection and model convergence or model accuracy, can completely prevent information leakage, and improves the security of data in federated learning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Currently, the training method of federated learning is mainly carried out in the form of gradient sharing. Models with the same structure share their local gradients to jointly train a global model. If the gradient of a model is leaked or eavesdropped during the gradient propagation process, the chain rule and the leaked gradient can be used to restore the input data.

[0003] At present, in order to prevent the gradient from being leaked or eavesdropped, the gradient is often protected through differential privacy protection, gradient quantization, and gradient clipping. Among them, differential privacy protection is to protect the gradient by adding a certain amount of random noise to the gradient that needs to be propagated; gradient quantization is to approximate the gradient to an integer value, such as (0, 1) or (-1, 0, 1), etc.; gradient clipping is to clip the gradient value at certain positions to 0.

[0004] However, differential privacy protection, gradient quantization, and gradient clipping all require adding perturbations to the gradient. If the perturbation is too large, it will affect the convergence of the global model, causing the model to fail to converge or the final global model to have low accuracy. If the perturbation is insufficient, the gradient cannot be effectively protected.

[0005] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention

[0006] The main purpose of the present invention is to provide a federated modeling method, apparatus, device and computer-readable storage medium, aiming to solve the technical problem of difficulty in achieving a balance between protecting gradients and model convergence or model accuracy in existing federated learning.

[0007] To achieve the above object, the present invention provides a federated modeling method, which comprises the following steps:

[0008] The first terminal labels the training data set to obtain a public label vector and a local label vector;

[0009] Determine a first gradient corresponding to the public label vector and a second gradient corresponding to the local label vector by using a model to be trained;

[0010] Sending the first gradient to a second terminal, so that the second terminal determines and feeds back a third gradient based on the first gradient;

[0011] A target gradient is determined based on the second gradient and the third gradient, and the model to be trained is updated based on the target gradient to obtain a target model.

[0012] Further, the step of sending the first gradient to the second terminal so that the second terminal determines and feeds back a third gradient based on the first gradient includes:

[0013] The first gradient is sent to a second terminal, wherein the second terminal obtains fourth gradients sent by multiple third terminals, determines a third gradient based on each fourth gradient and the first gradient, updates a global model of the second terminal based on the third gradient, and feeds back the third gradient to the first terminal.

[0014] Furthermore, the first terminal labels the training data set to obtain a public label vector and a local label vector, including:

[0015] Annotating the training data set based on one-hot encoding to obtain a public label vector;

[0016] The training data set is labeled based on random encoding to obtain a local label vector.

[0017] Furthermore, the step of determining the first gradient corresponding to the public label vector and the second gradient corresponding to the local label vector by the model to be trained includes:

[0018] Inputting the public label vector and the local label vector into the to-be-trained model for model training respectively, so as to obtain a first loss function value corresponding to the public label vector and a second loss function value corresponding to the local label vector;

[0019] The first gradient is determined based on the first loss function value, and the second gradient is determined based on the second loss function value.

[0020] Further, the step of determining the target gradient based on the second gradient and the third gradient includes:

[0021] A first weight corresponding to the second gradient and a second weight corresponding to the third gradient are obtained, and the target gradient is determined based on the first weight, the second weight, the second gradient, and the third gradient.

[0022] Furthermore, the step of updating the model to be trained based on the target gradient to obtain a target model includes:

[0023] Updating the model parameters of the model to be trained based on the target gradient to obtain an updated model to be trained;

[0024] If the updated model to be trained converges, the updated model to be trained is used as the target model.

[0025] Furthermore, after the step of updating the model parameters of the model to be trained based on the target gradient to obtain an updated model to be trained, the federated modeling method further includes:

[0026] If the updated model to be trained does not converge, the updated model to be trained is used as the model to be trained, and the step of labeling the training data set to obtain a public label vector and a local label vector is returned.

[0027] In addition, to achieve the above-mentioned purpose, the present invention further provides a federated modeling device, the federated modeling device comprising:

[0028] Annotation module, used to annotate the training data set to obtain a public label vector and a local label vector;

[0029] A determination module, used to determine a first gradient corresponding to the public label vector and a second gradient corresponding to the local label vector through a model to be trained;

[0030] a sending module, configured to send the first gradient to a second terminal, so that the second terminal determines and feeds back a third gradient based on the first gradient;

[0031] A model updating module is used to determine a target gradient based on the first gradient and the third gradient, and to update the model to be trained based on the target gradient to obtain a target model.

[0032] In addition, to achieve the above-mentioned purpose, the present invention also provides a federal modeling device, which includes: a memory, a processor, and a federal modeling program stored in the memory and executable on the processor, and the federal modeling program implements the steps of the aforementioned federal modeling method when executed by the processor.

[0033] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a federated modeling program is stored, and when the federated modeling program is executed by a processor, the steps of the aforementioned federated modeling method are implemented.

[0034] The present invention labels a training data set through a first terminal to obtain a public label vector and a local label vector; then determines a first gradient corresponding to the public label vector and a second gradient corresponding to the local label vector through a model to be trained; then sends the first gradient to a second terminal, so that the second terminal determines and feeds back a third gradient based on the first gradient; finally, determines a target gradient based on the second gradient and the third gradient, and updates the model to be trained based on the target gradient to obtain a target model, thereby realizing modeling through a public label vector and a local label vector without modifying the gradient, avoiding privacy leakage caused by insufficient noise and low model training accuracy caused by excessive noise, achieving a balance between gradient privacy protection and model convergence or model accuracy, the second gradient does not participate in the training of a gradient sharing federated model, the attacker can only obtain the first gradient, and thus cannot restore the input data by chain rule based on the stolen gradient; and there is no situation where part of the information is restored when the gradient clipping ratio or the noise ratio is too low, thereby being able to completely prevent information leakage and improve the security of data in federated learning. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 It is a schematic diagram of the structure of a federated modeling device in a hardware operating environment involved in an embodiment of the present invention;

[0036] Figure 2 It is a flowchart of the first embodiment of the federated modeling method of the present invention;

[0037] Figure 3 A schematic diagram of a scenario in an embodiment of a federated modeling method of the present invention;

[0038] Figure 4 It is a schematic diagram of functional modules of an embodiment of a federated modeling device of the present invention.

[0039] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0040] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0041] like Figure 1 As shown, Figure 1 It is a schematic diagram of the structure of a federated modeling device in a hardware operating environment involved in an embodiment of the present invention.

[0042] The federal modeling device of the embodiment of the present invention can be a PC, or it can be a smart phone, a tablet computer, an e-book reader, an MP3 (Moving Picture Experts Group Audio Layer III) player, an MP4 (Moving Picture Experts Group Audio Layer IV) player, a portable computer, or other mobile terminal devices with display function.

[0043] like Figure 1 As shown, the federal modeling device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0044] Optionally, the federated modeling device may also include a camera, an RF (Radio Frequency) circuit, a sensor, an audio circuit, a WiFi module, etc. Among them, sensors include light sensors, motion sensors, and other sensors. Of course, the federated modeling device may also be configured with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be described in detail here.

[0045] Those skilled in the art will understand that Figure 1 The federated modeling device structure shown in the figure does not constitute a limitation of the federated modeling device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0046] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a federated modeling program.

[0047] exist Figure 1In the federal modeling device shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the client (user end) and communicate data with the client; and the processor 1001 can be used to call the federal modeling program stored in the memory 1005.

[0048] In this embodiment, the federal modeling device includes: a memory 1005, a processor 1001, and a federal modeling program stored in the memory 1005 and executable on the processor 1001, wherein the processor 1001 calls the federal modeling program stored in the memory 1005 and executes the steps of the federal modeling method in each of the following embodiments.

[0049] The present invention also provides a federated modeling method, referring to Figure 2 , Figure 2 It is a flowchart of the first embodiment of the federated modeling method of the present invention.

[0050] In this embodiment, the federated modeling method includes the following steps:

[0051] Step S100, the first terminal labels the training data set to obtain a public label vector and a local label vector;

[0052] In this embodiment, the first terminal is a participant in the federated learning, that is, the first terminal is any one of all the participants in the federated learning, and the training data set is a training sample pre-set for model training.

[0053] In this embodiment, the first terminal first obtains a training data set and labels the obtained training data set to obtain a public label vector and a local label vector, wherein the public label vector is used for federal model (global model) training, and the local label vector is used for local model training of the first terminal.

[0054] Step S200, determining a first gradient corresponding to the public label vector and a second gradient corresponding to the local label vector through a model to be trained;

[0055] In this embodiment, when a public label vector and a local label vector are obtained, a first gradient is determined based on the public label vector, and a second gradient is determined based on the local label vector. Specifically, the public label vector is input into the model to be trained, so that the model is trained through the encoding classifier in the model to be trained to obtain a first training result, and a first loss function value is calculated according to the first training result and the public label vector, and a first gradient is obtained according to the first loss function value, and the local label vector is input into the model to be trained, so that the model is trained through the hash coding classifier in the model to be trained to obtain a second training result, and a second loss function value is calculated according to the second training result and the local label vector, and a second gradient is obtained according to the second loss function value.

[0056] Step S300, sending the first gradient to a second terminal, so that the second terminal determines and feeds back a third gradient based on the first gradient;

[0057] It should be noted that the second terminal is a coordinator in federated learning. The second terminal receives the gradients of each participant including the first terminal, and determines the third gradient according to the gradients of each participant.

[0058] In this embodiment, when the first gradient and the second gradient are obtained, the first terminal sends the first gradient to the second terminal, so that the second terminal determines and feeds back the third gradient based on the first gradient, wherein when the second terminal obtains the first gradient, the second terminal receives or obtains the fourth gradient of each other participant in the federated learning except the first terminal, and determines the third gradient based on the fourth gradient of each other participant and the first gradient, and feeds back the third gradient value to the first terminal. Of course, the second terminal also feeds back the third gradient to each other participant. It should be noted that each participant in the federated learning except the first terminal performs model training by inputting their respective public label vectors into the model to be trained to obtain the fourth gradient.

[0059] Reference Figure 3 , Figure 3 In the example, the public gradient is the first gradient, the local private gradient is the second gradient, the collector is the second terminal (coordinator), the first terminal uploads the first gradient to the collector, the collector determines the third gradient based on the first gradient and the gradients of other participants, and feeds the third gradient back to the first terminal.

[0060] Step S400: determine a target gradient based on the second gradient and the third gradient, and update the model to be trained based on the target gradient to obtain a target model.

[0061] In this embodiment, when the third gradient is obtained, the first terminal determines the target gradient based on the second gradient and the third gradient. Specifically, the first terminal fuses the second gradient with the third gradient to obtain the target gradient, for example, the second gradient is added to the third gradient (vector addition) to obtain the target gradient, or the first terminal assigns different weights to the second gradient and the third gradient, respectively, multiplies the second gradient and the third gradient by their respective weights and then adds them (vector addition) to obtain the target gradient. Then, the model to be trained is updated based on the target gradient to obtain the target model.

[0062] Reference Figure 3 The first terminal receives the third gradient fed back by the collector, and merges (fuses) the local private gradient (second gradient) with the third gradient to obtain a target gradient, and updates the model to be trained according to the target gradient.

[0063] Furthermore, in one embodiment, step S300 includes:

[0064] The first gradient is sent to a second terminal, wherein the second terminal obtains fourth gradients sent by multiple third terminals, determines a third gradient based on each fourth gradient and the first gradient, updates a global model of the second terminal based on the third gradient, and feeds back the third gradient to the first terminal.

[0065] In this embodiment, the second terminal receives the first gradient sent by the first terminal. At the same time, the second terminal obtains or receives the fourth gradient sent by multiple third terminals. The third terminal is each participant in the federated learning except the first terminal. The second terminal determines the third gradient based on each fourth gradient and the first gradient. Specifically, each fourth gradient and the first gradient are added (vector addition) to obtain the third gradient, and the third gradient is fed back to the first terminal. At the same time, the second terminal feeds back the third gradient to each third terminal, and updates the global model of the second terminal based on the third gradient. Among them, the fourth gradient is the gradient obtained by the third terminal inputting their respective public label vectors into the model to be trained for training. The public label vector of the third terminal is similar to the acquisition method of the public label vector of the first terminal in this embodiment, which will not be repeated here.

[0066] Furthermore, in yet another embodiment, step S400 includes:

[0067] A first weight corresponding to the second gradient and a second weight corresponding to the third gradient are obtained, and the target gradient is determined based on the first weight, the second weight, the second gradient, and the third gradient.

[0068] In this embodiment, when the third gradient is obtained, the first weight corresponding to the second gradient and the second weight corresponding to the third gradient are first obtained, and then the target gradient is calculated according to the first weight, the second weight, the second gradient and the third gradient, that is, the second gradient is multiplied by the weight of the second gradient to obtain the first result, and the third gradient is multiplied by the weight of the third gradient to obtain the second result, and the first result is added to the second result (vector addition) to obtain the target gradient. Specifically, the target gradient = first weight * second gradient + second weight * third gradient.

[0069] It should be noted that, in other embodiments, the first terminal may also use other methods to fuse the second gradient and the third gradient to obtain the target gradient, for example, adding the second gradient and the third gradient (vector addition) to obtain the target gradient.

[0070] It should be noted that the strength of data privacy (security) in this embodiment can be freely adjusted by the dimension of the local label vector. The higher the dimension of the local label vector, the higher the degree of data privacy protection. In addition, the federated modeling method in this embodiment can be connected to various mainstream models (Alex, VGG and ResNet, etc.), which is easy to use and can support federated distributed model training.

[0071] The federated modeling method proposed in this embodiment labels the training data set through the first terminal to obtain a public label vector and a local label vector; then determines the first gradient corresponding to the public label vector and the second gradient corresponding to the local label vector through the model to be trained; then sends the first gradient to the second terminal, so that the second terminal can determine and feedback the third gradient based on the first gradient; finally, determines the target gradient based on the second gradient and the third gradient, and updates the model to be trained based on the target gradient to obtain the target model, thereby realizing modeling through the public label vector and the local label vector without modifying the gradient, avoiding privacy leakage caused by insufficient noise and low model training accuracy caused by excessive noise, and achieving a balance between gradient privacy protection and model convergence or model accuracy. The second gradient does not participate in the training of the gradient sharing federated model, and the attacker can only obtain the first gradient, and thus cannot restore the input data by chain rule based on the stolen gradient; and there is no situation where part of the information is restored when the gradient clipping ratio or the noise ratio is too low, thereby completely preventing information leakage and improving the security of data in federated learning.

[0072] Based on the first embodiment, a second embodiment of the federated modeling method of the present invention is proposed. In this embodiment, step S100 includes:

[0073] Step S110, annotating the training data set based on one-hot encoding to obtain a public label vector;

[0074] Step S120: labeling the training data set based on random coding to obtain a local label vector.

[0075] In this embodiment, when annotating the acquired training data set, the training data set is annotated based on one-hot encoding to obtain a public label vector. For details, refer to Figure 3 , the first terminal and other participants in federated learning use unified one-hot encoding to label their own training data sets, that is, the first terminal uses one-hot labels to label its own training data sets to obtain a public label vector. For example, a 5-classification data set, and the label of one category is a 5-dimensional vector (1, 0, 0, 0, 0), and the labels of the other four categories cannot be repeated, where the dimension of the public label vector depends on the classification problem category.

[0076] At the same time, the training data set is labeled based on random coding to obtain a local label vector, referring to Figure 3 ,The first terminal and other participants in federated learning use random codes to annotate the training data set, Figure 3 The private label in is generated by the first terminal using random coding to annotate the training data set to obtain a local label vector. For example, a 5-category data set, the label of one category is a 6-dimensional vector (1, 0, 1, 1, 0, 0), and the labels of the other four categories cannot be repeated. It should be noted that the dimension of the random label is not limited by the total number of categories, and the label dimension can be greater than or equal to the total number of categories. Among them, the random code is a local random code, so the hash code used by each participant is random, so that the random codes of each participant are basically different, and then the second gradients generated by each participant are different. It should be noted that the local random code can no longer be changed after it is determined, and the random code can be a random hash code.

[0077] By labeling the training data set based on random coding, each type of data can be uniformly mapped into a hash code. For example, images of apples can be mapped into a hash value of (0, 1, 0, 1, 1, 0).

[0078] The federated modeling method proposed in this embodiment labels the training data set based on one-hot encoding to obtain a public label vector; and labels the training data set based on random encoding to obtain a local label vector. The public label vector and the local label vector can be accurately obtained, thereby improving the training efficiency of the model.

[0079] Based on the first embodiment, a third embodiment of the federated modeling method of the present invention is proposed. In this embodiment, step S200 includes:

[0080] Step S210, respectively inputting the public label vector and the local label vector into a to-be-trained model for model training to obtain a first loss function value corresponding to the public label vector and a second loss function value corresponding to the local label vector;

[0081] Step S220: determining the first gradient based on the first loss function value, and determining the second gradient based on the second loss function value.

[0082] In this embodiment, when the public label vector and the local label vector are obtained, the public label vector and the local label vector are respectively input into the model to be trained for model training to obtain the first loss function value corresponding to the public label vector and the second loss function value corresponding to the local label vector. Specifically, the public label vector is input into the model to be trained to perform model training through the one-hot encoding classifier in the model to be trained to obtain the first training result corresponding to the public label vector, and the first loss function value is calculated according to the first training result and the public label vector, and the local label vector is input into the model to be trained to perform model training through the hash encoding classifier in the model to be trained to obtain the second training result corresponding to the local label vector, and the second loss function value is calculated according to the second training result and the local label vector. Among them, the first loss function value can be a mean square estimation loss function or a cross entropy loss function, and the second loss function value can be a mean square estimation loss function, a cross entropy loss function or a polarization loss function.

[0083] Then, the first gradient is determined based on the first loss function value, and the second gradient is determined based on the second loss function value. Specifically, the existing gradient calculation algorithm can be used to calculate the first gradient according to the first loss function value.

[0084] The federated modeling method proposed in this embodiment performs model training by respectively inputting the public label vector and the local label vector into the model to be trained to obtain a first loss function value corresponding to the public label vector and a second loss function value corresponding to the local label vector; then, the first gradient is determined based on the first loss function value, and the second gradient is determined based on the second loss function value. The first gradient and the second gradient can be accurately obtained through model training, thereby further improving the efficiency of model training.

[0085] Based on the first embodiment, a forty-second embodiment of the federated modeling method of the present invention is proposed. In this embodiment, step S400 includes:

[0086] Step S410, updating the model parameters of the model to be trained based on the target gradient to obtain an updated model to be trained;

[0087] Step S420: If the updated model to be trained converges, the updated model to be trained is used as the target model.

[0088] In this embodiment, when the target gradient is obtained, the first terminal updates the model parameters of the model to be trained according to the target gradient to obtain an updated model to be trained, and then determines whether the updated model to be trained converges. If the updated model to be trained converges, the updated model to be trained is used as the target model.

[0089] Specifically, the test sample can be input into the updated model to be trained to obtain the test loss function value. If the test loss function value is less than a preset value, it is determined that the updated model to be trained has converged, and the updated model to be trained is used as the target model.

[0090] Furthermore, in one embodiment, after step S410, the following steps are further included:

[0091] If the updated model to be trained does not converge, the updated model to be trained is used as the model to be trained, and the step of labeling the training data set to obtain a public label vector and a local label vector is returned.

[0092] In this embodiment, if the updated model to be trained has not converged, the updated model to be trained is used as the model to be trained, and the step of labeling the training data set to obtain the public label vector and the local label vector is returned. Specifically, if the test loss function value is greater than or equal to the preset value, it is determined that the updated model to be trained has not converged, and the updated model to be trained can be used as the model to be trained, and step S100 is continued until the new test loss function value is less than the preset value, that is, the updated model to be trained converges, so as to complete the training of the target model and ensure that the trained template model converges. Among them, the test loss function value can be obtained by inputting the test sample into the updated model to be trained. If the test loss function value is less than the preset value, it is determined that the updated model to be trained has converged; if the test loss function value is greater than or equal to the preset value, it is determined that the updated model to be trained has not converged.

[0093] It should be noted that, in other embodiments, when the updated model to be trained continues to fail to converge, in order to avoid the first terminal from continuously performing model training, a preset number of training times may be set, and when the number of training times of the model to be trained reaches the preset number of training times, the model training is terminated. Specifically, step S420 includes:

[0094] Update the training times of the model to be trained, and determine whether the updated training times reach the preset times; if the updated training times reach the preset times, use the updated model to be trained as the target model; if the updated training times do not reach the preset times, use the updated model to be trained as the model to be trained, and return to execute the step of annotating the training data set to obtain a public label vector and a local label vector.

[0095] The federated modeling method proposed in this embodiment updates the model parameters of the model to be trained based on the target gradient to obtain an updated model to be trained; then if the updated model to be trained converges, the updated model to be trained is used as the target model, and the efficiency of anti-sample detection model training is further improved by ensuring the convergence of the target model.

[0096] The embodiment of the present invention also provides a federated modeling device, referring to Figure 4 , the federated modeling device comprises:

[0097] A labeling module 100 is used to label the training data set to obtain a public label vector and a local label vector;

[0098] A determination module 200, configured to determine a first gradient corresponding to the public label vector and a second gradient corresponding to the local label vector through a model to be trained;

[0099] A sending module 300, configured to send the first gradient to a second terminal, so that the second terminal determines and feeds back a third gradient based on the first gradient;

[0100] The model updating module 400 is used to determine a target gradient based on the second gradient and the third gradient, and to update the model to be trained based on the target gradient to obtain a target model.

[0101] Furthermore, the sending module 300 is also used for:

[0102] The first gradient is sent to a second terminal, wherein the second terminal obtains fourth gradients sent by multiple third terminals, determines a third gradient based on each fourth gradient and the first gradient, updates a global model of the second terminal based on the third gradient, and feeds back the third gradient to the first terminal.

[0103] Furthermore, the marking module 100 is also used for:

[0104] Annotating the training data set based on one-hot encoding to obtain a public label vector;

[0105] The training data set is labeled based on random encoding to obtain a local label vector.

[0106] Furthermore, the determination module 200 is further configured to:

[0107] Inputting the public label vector and the local label vector into the to-be-trained model for model training respectively, so as to obtain a first loss function value corresponding to the public label vector and a second loss function value corresponding to the local label vector;

[0108] The first gradient is determined based on the first loss function value, and the second gradient is determined based on the second loss function value.

[0109] Furthermore, the model updating module 400 is also used for:

[0110] A first weight corresponding to the second gradient and a second weight corresponding to the third gradient are obtained, and the target gradient is determined based on the first weight, the second weight, the second gradient, and the third gradient.

[0111] Furthermore, the model updating module 400 is also used for:

[0112] Updating the model parameters of the model to be trained based on the target gradient to obtain an updated model to be trained;

[0113] If the updated model to be trained converges, the updated model to be trained is used as the target model.

[0114] Furthermore, the model updating module 400 is also used for:

[0115] If the updated model to be trained does not converge, the updated model to be trained is used as the model to be trained, and the step of labeling the training data set to obtain a public label vector and a local label vector is returned.

[0116] In addition, an embodiment of the present invention further proposes a computer-readable storage medium, on which a federated modeling program is stored. When the federated modeling program is executed by a processor, the steps of the federated modeling method described above are implemented.

[0117] Among them, the method implemented when the federal modeling program running on the processor is executed can refer to the various embodiments of the federal modeling method of the present invention, and will not be repeated here.

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

[0119] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0120] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0121] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A federated modeling method, characterized in that: The federated modeling method includes the following steps: The first terminal labels the training data set to obtain a public label vector and a local label vector, wherein the training data set includes at least image data; Determine a first gradient corresponding to the public label vector and a second gradient corresponding to the local label vector by using a model to be trained; Sending the first gradient to a second terminal, so that the second terminal determines and feeds back a third gradient based on the first gradient; The first terminal determines a target gradient based on the second gradient and the third gradient, and updates the model to be trained based on the target gradient to obtain a target model; The step of sending the first gradient to the second terminal so that the second terminal determines and feeds back a third gradient based on the first gradient includes: Sending the first gradient to a second terminal, wherein the second terminal obtains fourth gradients sent by multiple third terminals, determines a third gradient based on each fourth gradient and the first gradient, updates a global model of the second terminal based on the third gradient, and feeds back the third gradient to the first terminal; The step of the first terminal labeling the training data set to obtain a public label vector and a local label vector includes: Annotating the training data set based on one-hot encoding to obtain a public label vector; The training data set is labeled based on random encoding to obtain a local label vector.

2. The federated modeling method according to claim 1, characterized in that: The step of determining the first gradient corresponding to the public label vector and the second gradient corresponding to the local label vector by the model to be trained comprises: Inputting the public label vector and the local label vector into the to-be-trained model for model training respectively, so as to obtain a first loss function value corresponding to the public label vector and a second loss function value corresponding to the local label vector; The first gradient is determined based on the first loss function value, and the second gradient is determined based on the second loss function value.

3. The federated modeling method according to claim 1, characterized in that: The step of determining the target gradient based on the second gradient and the third gradient comprises: A first weight corresponding to the second gradient and a second weight corresponding to the third gradient are obtained, and the target gradient is determined based on the first weight, the second weight, the second gradient, and the third gradient.

4. The federated modeling method according to any one of claims 1 to 3, characterized in that: The step of updating the model to be trained based on the target gradient to obtain a target model comprises: Updating the model parameters of the model to be trained based on the target gradient to obtain an updated model to be trained; If the updated model to be trained converges, the updated model to be trained is used as the target model.

5. The federated modeling method according to claim 4, characterized in that: After the step of updating the model parameters of the to-be-trained model based on the target gradient to obtain an updated to-be-trained model, the federated modeling method further includes: If the updated model to be trained does not converge, the updated model to be trained is used as the model to be trained, and the process returns to the step of annotating the training data set by the first terminal to obtain a public label vector and a local label vector.

6. A federated modeling device, characterized in that: The federated modeling device comprises: A labeling module, used for labeling a training data set to obtain a public label vector and a local label vector, wherein the training data set includes at least image data; A determination module, used to determine a first gradient corresponding to the public label vector and a second gradient corresponding to the local label vector through a model to be trained; a sending module, configured to send the first gradient to a second terminal, so that the second terminal determines and feeds back a third gradient based on the first gradient; A model updating module, used to determine a target gradient based on the second gradient and the third gradient, and update the to-be-trained model based on the target gradient to obtain a target model; The sending module is further used for: Sending the first gradient to a second terminal, wherein the second terminal obtains fourth gradients sent by multiple third terminals, determines a third gradient based on each fourth gradient and the first gradient, updates a global model of the second terminal based on the third gradient, and feeds back the third gradient to the first terminal; The annotation module is also used for: Annotating the training data set based on one-hot encoding to obtain a public label vector; The training data set is labeled based on random encoding to obtain a local label vector.

7. A federated modeling device, characterized in that: The federated modeling device comprises: a memory, a processor, and a federated modeling program stored in the memory and executable on the processor, wherein the federated modeling program implements the steps of the federated modeling method as claimed in any one of claims 1 to 5 when executed by the processor.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a federated modeling program, which, when executed by a processor, implements the steps of the federated modeling method according to any one of claims 1 to 5.