WO2020248537A1 - Model parameter determination method and apparatus based on federated learning - Google Patents

Model parameter determination method and apparatus based on federated learning Download PDF

Info

Publication number
WO2020248537A1
WO2020248537A1 PCT/CN2019/122824 CN2019122824W WO2020248537A1 WO 2020248537 A1 WO2020248537 A1 WO 2020248537A1 CN 2019122824 W CN2019122824 W CN 2019122824W WO 2020248537 A1 WO2020248537 A1 WO 2020248537A1
Authority
WO
WIPO (PCT)
Prior art keywords
sample
data
preset
terminal
algorithm
Prior art date
Application number
PCT/CN2019/122824
Other languages
French (fr)
Chinese (zh)
Inventor
范涛
陈天健
杨强
Original Assignee
深圳前海微众银行股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳前海微众银行股份有限公司 filed Critical 深圳前海微众银行股份有限公司
Publication of WO2020248537A1 publication Critical patent/WO2020248537A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules

Definitions

  • This application relates to the field of data processing technology, and in particular to a method and device for determining model parameters based on federated learning.
  • Federated learning protects user data privacy through parameter exchange under the encryption mechanism. Data and model It does not transmit itself, nor can it reversely crack the counterparty's data, so there is no possibility of leakage at the data level, and it can maintain data integrity to a high degree while ensuring data privacy.
  • traditional federated learning when both federations A and B conduct model training, in order to ensure the confidentiality of the data during the training process, it is necessary to rely on a third-party collaborator C for encryption training.
  • the embodiment of the present application provides a method and device for determining model parameters based on federated learning, which solves the problem that the use of traditional federated learning in the prior art will be limited, and improves user experience.
  • a method for determining model parameters based on federated learning may include:
  • the second terminal A receives the first encrypted data sent by the first terminal B, where the first encrypted data is obtained after the first terminal B encrypts the label data according to a preset encryption algorithm;
  • the label data is the Sample data of any sample in the first terminal B, where the label data is data describing the extent to which the behavior of the sample reaches;
  • a preset algorithm is used to obtain second encrypted data, where the second encrypted data includes an encryption gradient value and Encryption loss value, the preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm, and the sample characteristic data is characteristic data of sample behavior;
  • a preset characteristic parameter algorithm is adopted to obtain the first characteristic parameter
  • the first characteristic parameter is determined as the model parameter of the sample model to be trained.
  • the method further includes:
  • the acquired first characteristic parameter is determined as a new current characteristic parameter
  • the new second encrypted data includes a new encryption gradient value and a new Encryption loss value
  • the second characteristic parameter is determined as the model parameter of the sample model to be trained .
  • using a preset algorithm to obtain the second encrypted data corresponding to the sample identifier includes:
  • the sample characteristic data the current characteristic parameters of the sample characteristic data, and a preset random number
  • a preset algorithm is used to obtain the second encrypted data
  • the preset random number includes the preset gradient A first random number corresponding to the value algorithm and a second random number corresponding to the preset loss value algorithm
  • the method further includes:
  • the first gradient value, and the first loss value a new first gradient value and a new first loss value are acquired, and then the step of acquiring the first characteristic parameter is performed.
  • the method further includes:
  • the sample prediction score is sent to the first terminal B.
  • the preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm
  • x is the sample feature data of the second terminal
  • y is the sample feature data of the first terminal
  • g(w) is the preset gradient value
  • l(w) is the preset loss value
  • w is the feature parameter .
  • a method for determining model parameters based on federated learning may include:
  • the first terminal B sends first encrypted data to the second terminal A, where the first encrypted data is obtained after the first terminal B encrypts the label data according to a preset encryption algorithm;
  • the label data is the first Label data of any sample in terminal B, where the label data is data describing the extent to which the sample behavior reaches;
  • the preset decryption algorithm is used to decrypt the encryption gradient and the encryption loss value respectively to obtain a first gradient value and a first loss value, and the preset encryption algorithm and the preset decryption algorithm are reciprocal algorithm;
  • the method further includes:
  • the first terminal B receives the new second encrypted data of the sample sent by the second terminal A, so
  • the new second encrypted data includes a new encryption gradient value and a new encryption loss value, and the new second encrypted data is a sample of the second terminal A according to the first encrypted data and the second terminal
  • the feature data and the new current feature parameters are obtained by using a preset algorithm, and the new current feature parameters are the first gradient value and the sample feature corresponding to the second terminal A according to the first loss value
  • the current characteristic parameters of the data are obtained by using a preset characteristic parameter algorithm, and the sample characteristic data is characteristic data of sample behavior;
  • the preset decryption algorithm is used to decrypt the new encryption gradient value and the new encryption loss value respectively to obtain that the second first terminal B sends the first encrypted data to the second terminal A, and the first The encrypted data is obtained after the first terminal B encrypts the label data according to a preset encryption algorithm; the label data is sample data of any sample in the first terminal B;
  • the preset decryption algorithm is used to decrypt the encryption gradient and the encryption loss value respectively to obtain a first gradient value and a first loss value, and the preset encryption algorithm and the preset decryption algorithm are reciprocal algorithm;
  • the method further includes:
  • the second terminal A detects that the first characteristic parameter is not in a convergent state according to the first loss value, it receives new second encrypted data sent by the second terminal A, and the new second encrypted data includes A new encryption gradient value and a new encryption loss value, the new second encrypted data is obtained by the second terminal A using a preset algorithm according to the first encrypted data, sample characteristic data and new current characteristic parameters , The new current characteristic parameter is obtained by the second terminal A using a preset characteristic parameter algorithm based on the first gradient value corresponding to the first loss value and the current characteristic parameter of the sample characteristic data ;
  • the method further includes:
  • model score is less than a preset score threshold, it is determined that the sample model is a normal sample model. Gradient value and second loss value;
  • the method further includes:
  • the first terminal B sends a prediction request to the second terminal A, where the prediction request includes a sample identifier
  • model score is less than a preset score threshold, it is determined that the sample model is a normal sample model.
  • g is the gradient value
  • W n+1 is the characteristic parameter corresponding to the gradient value g
  • w n is the current characteristic parameter
  • is the preset coefficient
  • a device for determining model parameters based on federated learning may include: a receiving unit, an acquiring unit, a sending unit, and a determining unit;
  • the receiving unit is configured to receive first encrypted data sent by the first terminal B, where the first encrypted data is obtained after the first terminal B encrypts label data according to a preset encryption algorithm; the label data Is the label data of any sample in the first terminal B, and the label data is data describing the extent to which the sample behavior reaches;
  • the acquiring unit is configured to use a preset algorithm to acquire second encrypted data based on the first encrypted data, the sample characteristic data of the second terminal, and the current characteristic parameters of the sample characteristic data.
  • the encrypted data includes an encryption gradient value and an encryption loss value
  • the preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm
  • the sample characteristic data is characteristic data of a sample behavior
  • the sending unit is configured to send the second encrypted data to the first terminal B;
  • the receiving unit is further configured to receive the first gradient value and the first loss value sent by the first terminal B according to the second encrypted data;
  • the acquiring unit is further configured to use a preset characteristic parameter algorithm to acquire the first characteristic parameter according to the first gradient value and the current characteristic parameter of the sample characteristic data;
  • the determining unit is configured to determine the first characteristic parameter as a model parameter of the sample model to be trained if it is detected that the first characteristic parameter is in a convergent state according to the first loss value.
  • the determining unit is further configured to, if it is detected that the first characteristic parameter is not in a convergent state according to the first loss value, determine the acquired first characteristic parameter as a new Current characteristic parameters;
  • the acquiring unit is further configured to use a preset algorithm to acquire new second encrypted data according to the first encrypted data, sample characteristic data, and the new current characteristic parameters, where the new second encrypted data includes New encryption gradient value and new encryption loss value;
  • the sending unit is further configured to send the new second encrypted data to the first terminal B;
  • the receiving unit is further configured to receive a second gradient value and a second loss value sent by the first terminal B according to the new second encrypted data;
  • the acquiring unit is further configured to use a preset characteristic parameter algorithm to acquire a second characteristic parameter according to the second gradient value and the new current characteristic parameter;
  • the determining unit is further configured to determine that the second characteristic parameter is the second characteristic parameter if it is detected that the second characteristic parameter is in a convergent state according to the difference between the first loss value and the second loss value
  • the model parameters of the sample model to be trained.
  • the acquiring unit is further configured to use a preset algorithm according to the first encrypted data, sample characteristic data, current characteristic parameters of the sample characteristic data, and preset random numbers to obtain all
  • the preset random number includes a first random number corresponding to the preset gradient value algorithm and a second random number corresponding to the preset loss value algorithm;
  • the first gradient value, and the first loss value a new first gradient value and a new first loss value are acquired, and then the step of acquiring the first characteristic parameter is performed.
  • the receiving unit is further configured to receive a prediction request sent by the first terminal B, where the prediction request includes a sample identifier;
  • the acquiring unit is further configured to acquire the sample prediction score corresponding to the sample identifier according to the sample characteristic data corresponding to the sample identifier and the current characteristic parameter of the sample characteristic data;
  • the sending unit is further configured to send the sample prediction score to the first terminal B.
  • the preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm
  • x is the sample feature data of the second terminal
  • y is the sample feature data of the first terminal
  • g(w) is the preset gradient value
  • l(w) is the preset loss value
  • w is the feature parameter .
  • a device for determining model parameters based on federated learning may include: a sending unit, a receiving unit, and a decrypting unit;
  • the sending unit is configured to send first encrypted data to the second terminal A, where the first encrypted data is obtained after the first terminal B encrypts the label data according to a preset encryption algorithm;
  • the label data is Label data of any sample in the first terminal B, where the label data is data describing the extent to which the sample behavior reaches;
  • the receiving unit is configured to receive second encrypted data sent by the second terminal A according to the first encrypted data, where the second encrypted data includes an encryption gradient and an encryption loss value;
  • the decryption unit is configured to use the preset decryption algorithm to decrypt the encryption gradient and the encryption loss value respectively to obtain a first gradient value and a first loss value, the preset encryption algorithm and the
  • the preset decryption algorithm is a reciprocal algorithm
  • the sending unit is further configured to send the first gradient value and the first loss value to the second terminal A.
  • the receiving unit is further configured to: if the second terminal A detects that the first characteristic parameter is not in a convergent state according to the first loss value, then receive the data sent by the second terminal A New second encrypted data, the new second encrypted data includes a new encryption gradient value and a new encryption loss value, the new second encrypted data is the second terminal A according to the first encrypted data
  • the sample feature data and new current feature parameters of the second terminal are acquired by using a preset algorithm, and the new current feature parameters are the second terminal A corresponding to the first loss value according to the first loss value.
  • a gradient value and the current characteristic parameters of the sample characteristic data are obtained by using a preset characteristic parameter algorithm, and the sample characteristic data is characteristic data of sample behavior;
  • the decryption unit is further configured to use the preset decryption algorithm to decrypt the new encryption gradient value and the new encryption loss value respectively to obtain a second gradient value and a second loss value;
  • the sending unit is further configured to send the second gradient value and the second loss value to the second terminal A.
  • the device further includes an acquiring unit and a determining unit;
  • the sending unit is further configured to send a prediction request to the second terminal A, where the prediction request includes a sample identifier;
  • the receiving unit is further configured to receive the sample prediction score corresponding to the sample identifier sent by the second terminal A, where the sample prediction score is the sample feature data corresponding to the sample identifier and the The current characteristic parameters of the sample characteristic data are obtained;
  • the obtaining unit is configured to obtain the model score of the sample model according to the sample prediction score and a preset test algorithm
  • the determining unit is configured to determine that the sample model is a normal sample model if the model score is less than a preset score threshold.
  • g is the gradient value
  • W n+1 is the characteristic parameter corresponding to the gradient value g
  • w n is the current characteristic parameter
  • is the preset coefficient
  • a terminal in a fifth aspect, includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete mutual communication through the communication bus;
  • Memory used to store computer programs
  • the processor is configured to implement the method steps described in any one of the foregoing first aspect or the method steps described in any one of the foregoing second aspect when executing the program stored in the memory.
  • a computer-readable storage medium is provided, and a computer program is stored in the computer-readable storage medium.
  • the computer program when executed by a processor, implements the method steps in any one of the first aspects or the above The method steps of any one of the second aspect.
  • the second terminal A receives the first encrypted data sent by the first terminal B, where the first encrypted data is obtained after the first terminal B encrypts the label data according to a preset encryption algorithm;
  • the label data is the sample data of any sample in the first terminal B; according to the first encrypted data, the sample characteristic data, and the current characteristic parameters of the sample characteristic data of the second terminal, the second encrypted data is obtained by using a preset algorithm,
  • the second encrypted data includes an encryption gradient value and an encryption loss value.
  • the preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm; sending the second encrypted data to the first terminal B; receiving the first terminal B according to the second encrypted data The first gradient value and the first loss value sent; according to the first gradient value and the current characteristic parameter of the sample characteristic data, the preset characteristic parameter algorithm is used to obtain the first characteristic parameter; if the first characteristic parameter is detected according to the first loss value If the characteristic parameter is in a state of convergence, the first characteristic parameter is determined as the model parameter of the sample model to be trained.
  • this method does not require a third-party collaborator C, and the first terminal and the second terminal do not have overlapping feature data, realizes the determination of model parameters, and effectively protects their privacy Data improves training efficiency.
  • FIG. 1 is a schematic diagram of a scenario framework for application of a method for determining model parameters based on federated learning according to an embodiment of the present invention
  • FIG. 2 is a schematic flowchart of a method for determining model parameters based on federated learning according to an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of a device for determining model parameters based on federated learning according to an embodiment of the present invention
  • FIG. 4 is a schematic structural diagram of another device for determining model parameters based on federated learning according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of a terminal provided by an embodiment of the present invention.
  • the method for determining model parameters based on federated learning can be applied to the scenario framework shown in FIG. 1.
  • the scenario framework may include at least one terminal, and each terminal is a data owner. At least one terminal establishes a model through a federated learning system to train model parameters.
  • Terminals can be mobile phones, smart phones, notebook computers, digital broadcast receivers, personal digital assistants (PDA), tablet computers (PAD) and other user equipment (User Equipment, UE), handheld devices, vehicle-mounted devices, wearable devices, computing Equipment or other processing equipment connected to a wireless modem, mobile station (MS), etc.
  • PDA personal digital assistants
  • PAD tablet computers
  • UE user equipment
  • MS mobile station
  • the data set held by each data owner can be represented by a matrix. Each row of the matrix represents a sample, and each column represents the characteristics of a sample.
  • some data sets may also contain label data. If you want to build a predictive model of user behavior, you must have label data.
  • the characteristic data of the sample is X
  • the label data of the sample is Y.
  • label data Y is the user’s credit
  • label data Y is the user’s purchase desire
  • label data Y is the degree of students' knowledge.
  • the label data is the data describing the extent of the sample behavior
  • the sample characteristic data is the characteristic data of the sample behavior
  • party A and party B Taking a scenario involving two data owners, party A and party B, as an example, suppose party A and party B want to jointly train a machine learning model, and their business systems each have relevant data of their respective users.
  • This application uses encrypted sample alignment technology to obtain shared samples between party A and party B, where party A’s sample data only has sample feature data X, and party B’s sample data only has label data Y that the model needs to predict. .
  • party A and Party B cannot directly exchange data.
  • a federated learning system can be used to build a model and train model parameters.
  • the data set held by Party A can be as shown in Table 1, and the data set held by Party B can be as shown in Table 2.
  • Party A includes samples with sample identifiers U1-U4, and each sample includes three characteristic data.
  • the current feature parameter of X1 corresponding to sample identification U1 is 9
  • the current feature parameter of X2 is 8000
  • the current feature parameter of X3 is A
  • the current feature parameter of X1 corresponding to sample identification U2 is 4, and the current feature parameter of X2 is
  • the current feature parameter of 5000 and X3 is C
  • the current feature parameter of X1 corresponding to sample identification U3 is 2
  • the current feature parameter of X2 is 3500 and the current feature parameter of X3 is C
  • the current feature parameter of X1 corresponding to sample identification U4 is 10.
  • the current characteristic parameter of X2 is 10000 and the current characteristic parameter of X3 is A.
  • Party B includes samples with sample identifiers U1-U4, and each sample only includes label data.
  • the label data Y corresponding to the sample identifier U1 is 0; the label data Y1 corresponding to the sample identifier U2; the label data Y corresponding to the sample identifier U3 is 1; the label data Y corresponding to the sample identifier U4 is 0.
  • the following takes party A as the second terminal A and party B as the first terminal B as an example to determine the model parameters.
  • Fig. 2 is a schematic flowchart of a method for determining model parameters based on federated learning according to an embodiment of the present invention. As shown in Figure 2, the method may include:
  • Step 210 The first terminal B sends the first encrypted data to the second terminal A.
  • the first terminal B Before performing this step, the first terminal B generates an encrypted public key and a private key, and uses a preset encryption algorithm to encrypt the tag data in the tag data, that is, uses the public key to encrypt the tag data in the tag data to obtain The first encrypted data.
  • the label data is sample data of any sample in the first terminal B, for example, the label data is sample data corresponding to the sample identifier U1 or the label data is sample data corresponding to the sample identifier U2.
  • the preset encryption algorithm may be a homomorphic encryption algorithm.
  • Step 220 The second terminal A uses a preset algorithm to obtain the second encrypted data of the sample according to the first encrypted data, the sample characteristic data of the second terminal, and the current characteristic parameters of the sample characteristic data.
  • the sample feature data corresponding to the sample identification U1 are X1, X2, and X3, and the current feature parameters of the sample feature data are 9, 8000, and A, respectively.
  • the preset algorithm may include a preset gradient value algorithm and a preset loss value algorithm.
  • the formula of the preset gradient value algorithm can be expressed as:
  • the formula of the preset loss value algorithm can be expressed as:
  • w is the characteristic parameter.
  • the preset algorithm is used to obtain the sample identifier U1 corresponding to the encrypted gradient value and The second encrypted data of the encrypted loss value.
  • the formula of the encryption gradient value can be expressed as:
  • the formula for the encryption loss value can be expressed as:
  • the second terminal A may obtain a preset random number, and the preset random number includes the first random number r1 corresponding to the preset gradient value algorithm and the preset The second random number r2 corresponding to the loss value algorithm.
  • the second terminal A uses a preset algorithm to obtain the second encrypted data including the encryption gradient value and the encryption loss value according to the first encrypted data, the sample characteristic data, the current characteristic parameters of the sample characteristic data, and the preset random number.
  • the formula for the encryption loss value can be expressed as:
  • Step 230 The second terminal A sends the second encrypted data to the first terminal B.
  • Step 240 The first terminal B uses a preset decryption algorithm to decrypt the second encrypted data to obtain the first gradient value and the first loss value.
  • the first terminal B uses a preset decryption algorithm to decrypt the encryption gradient and the encryption loss value respectively, that is, decrypts using the private key to obtain the first gradient value and the first loss value.
  • the preset encryption algorithm and the preset decryption algorithm are reciprocal algorithms, so the preset decryption algorithm may be a homomorphic decryption algorithm.
  • Step 250 The first terminal B sends the first gradient value and the first loss value to the second terminal A.
  • Step 260 The second terminal A uses a preset feature parameter algorithm to obtain the first feature parameter according to the first gradient value corresponding to the first loss value and the current feature parameter of the sample feature data.
  • the second terminal A uses a preset feature parameter algorithm to obtain the first feature of the sample feature data corresponding to the first gradient value g Parameter w 1 .
  • the second terminal A According to the preset random number, the first gradient value, and the first loss value, a new first gradient value and a new first loss value are acquired.
  • the new first gradient value l is l'/r2; the new first loss value g Is g'/r1.
  • the second terminal A uses the preset feature parameter algorithm to obtain the sample feature corresponding to the new first gradient value according to the new first gradient value corresponding to the new first loss value and the current feature parameter w 0 of the sample feature data The first characteristic parameter w 1 of the data.
  • Step 270 The second terminal A determines model parameters according to whether the first characteristic parameter is in a convergent state.
  • the second terminal A detects whether the first characteristic parameter is in a convergent state according to the first loss value. Wherein, if the first loss value is less than the preset loss threshold, it is determined that the first characteristic parameter is in a convergent state, or if the first characteristic parameter has reached the maximum number of iterations, it is determined that the first characteristic parameter has converged.
  • the user or the operation and maintenance personnel can set the size of the preset loss threshold as needed, which is not limited in this embodiment.
  • the first feature parameter is determined as the model parameter of the sample model to be trained, so that the second terminal A trains the sample model.
  • the first characteristic parameter is determined as the new current characteristic parameter; and step 260 is executed.
  • the second terminal A uses a preset algorithm to obtain the new second encrypted data of the sample according to the first encrypted data, the sample characteristic data and the new current characteristic parameter w 2 , and the new second encrypted data includes the new encrypted data.
  • the second terminal A sends the new second encrypted data to the first terminal B, so that the first terminal B decrypts the new second encrypted data to obtain the second gradient value and the second loss value;
  • the second terminal A receives the second gradient value and the second loss value sent by the first terminal B according to the new second encrypted data
  • the second terminal A adopts a preset characteristic parameter algorithm to obtain the second characteristic parameter w 3 .
  • the difference between the first loss value and the second loss value detecting that the second characteristic parameter is in a convergent state. If the difference between the first loss value and the second loss value is less than the preset loss threshold, it is determined that the second characteristic parameter w 2 is in a convergent state, or the second characteristic parameter w 2 has reached the maximum number of iterations, then the first 2. Convergence of characteristic parameters.
  • the second feature parameter w 2 is determined as the model parameter of the sample model to be trained, so that the second terminal A trains the sample model.
  • the first terminal B may send a prediction request to the second terminal A, and the prediction request includes a sample identifier, such as UI;
  • the second terminal A obtains corresponding sample characteristic data and current characteristic parameters of the sample characteristic data according to the sample identifier U1, and obtains the sample prediction score corresponding to the sample identifier;
  • the sample prediction score of sample U1 in the second terminal A can be expressed as:
  • the second terminal A sends the sample prediction score corresponding to the sample identifier to the first terminal B.
  • the first terminal B receives the sample prediction score sent by the second terminal A, and obtains the model score of the sample model according to the sample prediction score and the preset test algorithm;
  • the formula of the preset test algorithm can be expressed as:
  • the first terminal B can obtain the model score P of the sample model. If the model score P is less than the preset score threshold, it is determined that the sample model is a normal sample model.
  • the method provided by the foregoing embodiment of the present invention realizes the determination of model parameters without the need for a third-party collaborator C and the first terminal and the second terminal do not have overlapping feature data. , It effectively protects its own private data and improves training efficiency.
  • an embodiment of the present invention also provides a device for determining model parameters based on federated learning.
  • the device includes: a receiving unit 310, an acquiring unit 320, a sending unit 330, and a determining unit 340;
  • the receiving unit 310 is configured to receive first encrypted data sent by the first terminal B, where the first encrypted data is obtained after the first terminal B encrypts label data according to a preset encryption algorithm; the label data is Label data of any sample in the first terminal B, where the label data is data describing the extent to which the sample behavior reaches;
  • the acquiring unit 320 is configured to use a preset algorithm to acquire second encrypted data according to the first encrypted data, the sample characteristic data of the second terminal, and the current characteristic parameters of the sample characteristic data.
  • the data includes an encryption gradient value and an encryption loss value
  • the preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm
  • the sample characteristic data is characteristic data of a sample behavior
  • the sending unit 330 is configured to send the second encrypted data to the first terminal B;
  • the receiving unit 310 is further configured to receive the first gradient value and the first loss value sent by the first terminal B according to the second encrypted data;
  • the acquiring unit 320 is further configured to acquire the first characteristic parameter by using a preset characteristic parameter algorithm according to the first gradient value and the current characteristic parameter of the sample characteristic data;
  • the determining unit 340 is configured to determine the first characteristic parameter as a model parameter of the sample model to be trained if it is detected that the first characteristic parameter is in a convergent state according to the first loss value.
  • each functional unit of the device for determining model parameters based on federated learning provided in the foregoing embodiment of the present invention can be implemented through the above method steps. Therefore, in the device for determining model parameters based on federated learning provided by the embodiment of the present invention The specific working process and beneficial effects of the various units of the unit will not be repeated here.
  • an embodiment of the present invention also provides an apparatus for determining model parameters based on federated learning.
  • the apparatus includes: a sending unit 410, a receiving unit 420, and a decrypting unit 430;
  • the sending unit 410 is configured to send first encrypted data to the second terminal A, where the first encrypted data is obtained after the first terminal B encrypts label data according to a preset encryption algorithm; the label data is all The label data of any sample in the first terminal B, where the label data is data describing the extent to which the sample behavior reaches;
  • the receiving unit 420 is configured to receive second encrypted data sent by the second terminal A according to the first encrypted data, where the second encrypted data includes an encryption gradient and an encryption loss value;
  • the decryption unit 430 is configured to use the preset decryption algorithm to decrypt the encryption gradient and the encryption loss value respectively to obtain a first gradient value and a first loss value, the preset encryption algorithm and the prediction Let the decryption algorithm be a reciprocal algorithm;
  • the sending unit 410 is further configured to send the first gradient value and the first loss value to the second terminal A.
  • each functional unit of the device for determining model parameters based on federated learning provided in the foregoing embodiment of the present invention can be implemented by the above method steps. Therefore, in the device for determining model parameters based on federated learning provided by the embodiment of the present invention The specific working process and beneficial effects of the various units of the unit will not be repeated here.
  • the embodiment of the present invention also provides a terminal. As shown in FIG. 5, it includes a processor 510, a communication interface 520, a memory 530, and a communication bus 540.
  • the processor 510, the communication interface 520, and the memory 530 are implemented through the communication bus 540. Communication between each other.
  • the memory 530 is used to store computer programs
  • the processor 510 is configured to implement the following steps when executing the program stored in the memory 530:
  • first encrypted data sent by a first terminal where the first encrypted data is obtained after the first terminal encrypts tag data according to a preset encryption algorithm; the tag data is any of the first terminals
  • the label data of this book, the label data is data describing the extent to which the behavior of the sample has reached;
  • a preset algorithm is used to obtain second encrypted data, where the second encrypted data includes an encryption gradient value and Encryption loss value, the preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm, and the sample characteristic data is characteristic data of sample behavior;
  • a preset characteristic parameter algorithm is adopted to obtain the first characteristic parameter
  • the first characteristic parameter is determined as the model parameter of the sample model to be trained.
  • the preset decryption algorithm is used to decrypt the encryption gradient and the encryption loss value respectively to obtain a first gradient value and a first loss value, and the preset encryption algorithm and the preset decryption algorithm are reciprocal algorithm;
  • the aforementioned communication bus may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus.
  • PCI Peripheral Component Interconnect
  • EISA Extended Industry Standard Architecture
  • the communication bus can be divided into address bus, data bus, control bus and so on. For ease of representation, the figure is only represented by a thick line, but it does not mean that there is only one bus or one type of bus.
  • the communication interface is used for communication between the aforementioned terminal and other devices.
  • the memory may include random access memory (Random Access Memory, RAM), and may also include non-volatile memory (Non-Volatile Memory, NVM), such as at least one disk storage.
  • NVM non-Volatile Memory
  • the memory may also be at least one storage device located far away from the foregoing processor.
  • the above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processing, DSP), a dedicated integrated Circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
  • CPU central processing unit
  • NP Network Processor
  • DSP Digital Signal Processing
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • a computer-readable storage medium stores instructions that, when run on a computer, cause the computer to execute any of the above embodiments.
  • the described method for determining model parameters based on federated learning is also provided.
  • a computer program product containing instructions, which, when run on a computer, causes the computer to execute the model parameters based on federated learning described in any of the above embodiments. Determine the method.
  • the embodiments in the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the embodiments of the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. .
  • computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing equipment to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing equipment are generated It is a device that realizes the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Bioethics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Storage Device Security (AREA)

Abstract

Disclosed are a model parameter determination method and apparatus based on federated learning. The method comprises: a second terminal receiving first encrypted data sent by a first terminal, wherein the first encrypted data is obtained by means of the first terminal encrypting label data according to a pre-set encryption algorithm; acquiring, according to the first encrypted data, sample feature data and the current feature parameter of the sample feature data, second encrypted data comprising an encryption gradient value and an encryption loss value by means of a pre-set algorithm, and receiving a first gradient value and a first loss value sent, according to the second encrypted data, by the first terminal; acquiring, according to the first gradient value and the current feature parameter of the sample feature data, a first feature parameter by means of a pre-set feature parameter algorithm; and if it is detected, according to the first loss value, that the first feature parameter is in a convergence state, determining the first feature parameter to be a model parameter of a sample model to be trained. The method does not require a collaborator of a third party, thereby improving the training efficiency.

Description

基于联邦学习的模型参数的确定方法及装置Method and device for determining model parameters based on federated learning
相关申请的交叉引用Cross references to related applications
本申请要求在2019年06月12日提交中国专利局、申请号为201910507242.2、申请名称为“基于联邦学习的模型参数的确定方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on June 12, 2019, the application number is 201910507242.2, and the application name is "Method and Device for Determining Model Parameters Based on Federal Learning", the entire content of which is incorporated by reference In this application.
技术领域Technical field
本申请涉及数据处理技术领域,尤其涉及一种基于联邦学习的模型参数的确定方法及装置。This application relates to the field of data processing technology, and in particular to a method and device for determining model parameters based on federated learning.
背景技术Background technique
在人工智能领域,传统的数据处理模式往往是一方收集数据,再转移到另一方进行处理、清洗并建模,最后把模型卖给第三方。但随着法规完善和监控愈加严格,如果数据离开收集方或者用户不清楚模型的具体用途,运营者可能会触犯法律。数据是以孤岛的形式存在的,解决孤岛的直接方案就是把数据整合到一方进行处理。但由于法律不允许运营者粗暴地进行数据聚合,故为解决此困境,人们研究提出了“联邦学习”。联邦学习利用技术算法加密建造的模型,联邦双方在不用给出己方数据的情况下,也可进行模型训练得到模型参数,联邦学习通过加密机制下的参数交换方式保护用户数据隐私,而数据和模型本身不会进行传输,也不能反向破解对方数据,因此在数据层面不存在泄露的可能,能够在较高程度保持数据完整性的同时,保障数据隐私。传统的联邦学习在联邦A,B双方进行模型训练时,为了保证训练过程中数据的保密性,需要借助第三方的协作者C进行加密训练。In the field of artificial intelligence, the traditional data processing model is often that one party collects data, then transfers it to the other party for processing, cleaning and modeling, and finally selling the model to a third party. However, with the improvement of regulations and stricter monitoring, if the data leaves the collector or the user is not clear about the specific purpose of the model, the operator may violate the law. Data exists in the form of islands. The direct solution to the islands is to integrate the data into one party for processing. However, because the law does not allow operators to crudely aggregate data, in order to solve this dilemma, people researched and proposed "federal learning." Federated learning uses technical algorithms to encrypt the model built. Both parties of the federation can also perform model training to obtain model parameters without giving out their own data. Federated learning protects user data privacy through parameter exchange under the encryption mechanism. Data and model It does not transmit itself, nor can it reversely crack the counterparty's data, so there is no possibility of leakage at the data level, and it can maintain data integrity to a high degree while ensuring data privacy. In traditional federated learning, when both federations A and B conduct model training, in order to ensure the confidentiality of the data during the training process, it is necessary to rely on a third-party collaborator C for encryption training.
然而,发明人发现传统的联邦学习都需要先找寻可信的协作者C,若没有协作者C,则传统的联邦学习的使用将被限制,降低了用户体验。However, the inventor found that traditional federated learning needs to find a credible collaborator C first. If there is no collaborator C, the use of traditional federated learning will be restricted and the user experience will be reduced.
发明内容Summary of the invention
本申请实施例提供一种基于联邦学习的模型参数的确定方法及装置,解决了现有技术中传统的联邦学习的使用将被限制的问题,提高了用户体验。The embodiment of the present application provides a method and device for determining model parameters based on federated learning, which solves the problem that the use of traditional federated learning in the prior art will be limited, and improves user experience.
第一方面,提供了一种基于联邦学习的模型参数的确定方法,该方法可以包括:In the first aspect, a method for determining model parameters based on federated learning is provided. The method may include:
第二终端A接收第一终端B发送的第一加密数据,所述第一加密数据为所述第一终端B根据预设加密算法对标签数据进行加密后得到的;所述标签数据为所述第一终端B中任一样本的样本数据,所述标签数据是描述样本行为达到的程度的数据;The second terminal A receives the first encrypted data sent by the first terminal B, where the first encrypted data is obtained after the first terminal B encrypts the label data according to a preset encryption algorithm; the label data is the Sample data of any sample in the first terminal B, where the label data is data describing the extent to which the behavior of the sample reaches;
根据所述第一加密数据、所述第二终端的样本特征数据和所述样本特征数据的当前特征参数,采用预设算法,获取第二加密数据,所述第二加密数据包括加密梯度值和加密损失值,所述预设算法包括预设梯度值算法和预设 损失值算法,所述样本特征数据是样本行为的特征数据;According to the first encrypted data, the sample characteristic data of the second terminal, and the current characteristic parameters of the sample characteristic data, a preset algorithm is used to obtain second encrypted data, where the second encrypted data includes an encryption gradient value and Encryption loss value, the preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm, and the sample characteristic data is characteristic data of sample behavior;
向所述第一终端B发送所述第二加密数据;Sending the second encrypted data to the first terminal B;
接收所述第一终端B根据所述第二加密数据发送的第一梯度值和第一损失值;Receiving the first gradient value and the first loss value sent by the first terminal B according to the second encrypted data;
根据所述第一梯度值和所述样本特征数据的当前特征参数,采用预设特征参数算法,获取第一特征参数;According to the first gradient value and the current characteristic parameter of the sample characteristic data, a preset characteristic parameter algorithm is adopted to obtain the first characteristic parameter;
若根据所述第一损失值,检测出所述第一特征参数处于收敛状态,则将所述第一特征参数确定为待训练的样本模型的模型参数。If it is detected that the first characteristic parameter is in a convergent state according to the first loss value, the first characteristic parameter is determined as the model parameter of the sample model to be trained.
在一个可选的实现中,所述方法还包括:In an optional implementation, the method further includes:
若根据所述第一损失值,检测出第一特征参数未处于收敛状态,则将获取的所述第一特征参数确定为新的当前特征参数;If it is detected that the first characteristic parameter is not in a convergent state according to the first loss value, the acquired first characteristic parameter is determined as a new current characteristic parameter;
根据所述第一加密数据、样本特征数据和所述新的当前特征参数,采用预设算法,获取新的第二加密数据,所述新的第二加密数据包括新的加密梯度值和新的加密损失值;According to the first encrypted data, the sample characteristic data, and the new current characteristic parameters, a preset algorithm is used to obtain new second encrypted data. The new second encrypted data includes a new encryption gradient value and a new Encryption loss value;
向所述第一终端B发送所述新的第二加密数据;Sending the new second encrypted data to the first terminal B;
接收所述第一终端B根据所述新的第二加密数据发送的第二梯度值和第二损失值;Receiving the second gradient value and the second loss value sent by the first terminal B according to the new second encrypted data;
根据所述第二梯度值和所述新的当前特征参数,采用预设特征参数算法,获取第二特征参数;According to the second gradient value and the new current characteristic parameter, using a preset characteristic parameter algorithm to obtain the second characteristic parameter;
若根据所述第一损失值与所述第二损失值的差值,检测所述第二特征参数处于收敛状态,则将所述第二特征参数确定为所述待训练的样本模型的模型参数。If it is detected that the second characteristic parameter is in a convergent state according to the difference between the first loss value and the second loss value, the second characteristic parameter is determined as the model parameter of the sample model to be trained .
在一个可选的实现中,根据所述第一加密数据、样本特征数据和所述样本特征数据的当前特征参数,采用预设算法,获取所述样本标识对应的第二加密数据,包括:In an optional implementation, according to the first encrypted data, sample characteristic data, and current characteristic parameters of the sample characteristic data, using a preset algorithm to obtain the second encrypted data corresponding to the sample identifier includes:
根据所述第一加密数据、样本特征数据、所述样本特征数据的当前特征参数和预设随机数,采用预设算法,获取第二加密数据,所述预设随机数包括所述预设梯度值算法对应的第一随机数和所述预设损失值算法对应的第二随机数;According to the first encrypted data, the sample characteristic data, the current characteristic parameters of the sample characteristic data, and a preset random number, a preset algorithm is used to obtain the second encrypted data, and the preset random number includes the preset gradient A first random number corresponding to the value algorithm and a second random number corresponding to the preset loss value algorithm;
接收所述第一终端B根据所述第二加密数据发送的第一梯度值和第一损失值之后,所述方法还包括:After receiving the first gradient value and the first loss value sent by the first terminal B according to the second encrypted data, the method further includes:
根据所述预设随机数、第一梯度值和第一损失值,获取新的第一梯度值和新的第一损失值,之后执行获取第一特征参数的步骤。According to the preset random number, the first gradient value, and the first loss value, a new first gradient value and a new first loss value are acquired, and then the step of acquiring the first characteristic parameter is performed.
在一个可选的实现中,将所述第一特征参数确定为所述待训练的样本模型的模型参数之后,所述方法还包括:In an optional implementation, after the first characteristic parameter is determined as the model parameter of the sample model to be trained, the method further includes:
接收第一终端B发送的预测请求,所述预测请求包括样本标识U1;Receiving a prediction request sent by the first terminal B, where the prediction request includes a sample identifier U1;
根据所述样本标识对应的样本特征数据和所述样本特征数据的当前特征参数,获取所述样本标识对应的样本预测分数;Acquiring the sample prediction score corresponding to the sample identifier according to the sample characteristic data corresponding to the sample identifier and the current characteristic parameter of the sample characteristic data;
向第一终端B发送所述样本预测分数。The sample prediction score is sent to the first terminal B.
在一个可选的实现中,所述预设算法包括预设梯度值算法和预设损失值 算法;In an optional implementation, the preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm;
所述预设梯度值算法的公式表示为:The formula of the preset gradient value algorithm is expressed as:
Figure PCTCN2019122824-appb-000001
Figure PCTCN2019122824-appb-000001
所述预设损失值算法的公式表示为:The formula of the preset loss value algorithm is expressed as:
Figure PCTCN2019122824-appb-000002
Figure PCTCN2019122824-appb-000002
其中,x为所述第二终端的样本特征数据,y为所述第一终端的样本特征数据,g(w)为预设梯度值、l(w)为预设损失值、w为特征参数。Where x is the sample feature data of the second terminal, y is the sample feature data of the first terminal, g(w) is the preset gradient value, l(w) is the preset loss value, and w is the feature parameter .
第二方面,提供了一种基于联邦学习的模型参数的确定方法,该方法可以包括:In the second aspect, a method for determining model parameters based on federated learning is provided. The method may include:
第一终端B向第二终端A发送第一加密数据,所述第一加密数据为所述第一终端B根据预设加密算法对标签数据进行加密后得到的;所述标签数据为所述第一终端B中任一样本的标签数据,所述标签数据是描述样本行为达到的程度的数据;The first terminal B sends first encrypted data to the second terminal A, where the first encrypted data is obtained after the first terminal B encrypts the label data according to a preset encryption algorithm; the label data is the first Label data of any sample in terminal B, where the label data is data describing the extent to which the sample behavior reaches;
接收所述第二终端A根据所述第一加密数据发送的所述样本的第二加密数据,所述第二加密数据包括加密梯度和加密损失值;Receiving second encrypted data of the sample sent by the second terminal A according to the first encrypted data, where the second encrypted data includes an encryption gradient and an encryption loss value;
采用所述预设解密算法,分别对所述加密梯度和所述加密损失值进行解密,得到第一梯度值和第一损失值,所述预设加密算法和所述预设解密算法为互逆算法;The preset decryption algorithm is used to decrypt the encryption gradient and the encryption loss value respectively to obtain a first gradient value and a first loss value, and the preset encryption algorithm and the preset decryption algorithm are reciprocal algorithm;
向所述第二终端A发送所述第一梯度值和第一损失值。Sending the first gradient value and the first loss value to the second terminal A.
在一个可选的实现中,所述方法还包括:In an optional implementation, the method further includes:
若所述第二终端A根据所述第一损失值,检测出第一特征参数未处于收敛状态,则第一终端B接收第二终端A发送的所述样本的新的第二加密数据,所述新的第二加密数据包括新的加密梯度值和新的加密损失值,所述新的第二加密数据为所述第二终端A根据所述第一加密数据、所述第二终端的样本特征数据和新的当前特征参数,采用预设算法获取的,所述新的当前特征参数为所述第二终端A根据所述第一损失值对应的所述第一梯度值和所述样本特征数据的当前特征参数,采用预设特征参数算法获取的,所述样本特征数据是样本行为的特征数据;If the second terminal A detects that the first characteristic parameter is not in a convergent state according to the first loss value, the first terminal B receives the new second encrypted data of the sample sent by the second terminal A, so The new second encrypted data includes a new encryption gradient value and a new encryption loss value, and the new second encrypted data is a sample of the second terminal A according to the first encrypted data and the second terminal The feature data and the new current feature parameters are obtained by using a preset algorithm, and the new current feature parameters are the first gradient value and the sample feature corresponding to the second terminal A according to the first loss value The current characteristic parameters of the data are obtained by using a preset characteristic parameter algorithm, and the sample characteristic data is characteristic data of sample behavior;
采用所述预设解密算法,分别对所述新的加密梯度值和所述新的加密损失值进行解密,得到第二第一终端B向第二终端A发送第一加密数据,所述第一加密数据为所述第一终端B根据预设加密算法对标签数据进行加密后得到的;所述标签数据为所述第一终端B中任一样本的样本数据;The preset decryption algorithm is used to decrypt the new encryption gradient value and the new encryption loss value respectively to obtain that the second first terminal B sends the first encrypted data to the second terminal A, and the first The encrypted data is obtained after the first terminal B encrypts the label data according to a preset encryption algorithm; the label data is sample data of any sample in the first terminal B;
接收所述第二终端A根据所述第一加密数据发送的第二加密数据,所述第二加密数据包括加密梯度和加密损失值;Receiving second encrypted data sent by the second terminal A according to the first encrypted data, where the second encrypted data includes an encryption gradient and an encryption loss value;
采用所述预设解密算法,分别对所述加密梯度和所述加密损失值进行解密,得到第一梯度值和第一损失值,所述预设加密算法和所述预设解密算法为互逆算法;The preset decryption algorithm is used to decrypt the encryption gradient and the encryption loss value respectively to obtain a first gradient value and a first loss value, and the preset encryption algorithm and the preset decryption algorithm are reciprocal algorithm;
向所述第二终端A发送所述第一梯度值和第一损失值。Sending the first gradient value and the first loss value to the second terminal A.
在一个可选的实现中,所述方法还包括:In an optional implementation, the method further includes:
若所述第二终端A根据所述第一损失值,检测出第一特征参数未处于收敛状态,则接收第二终端A发送的新的第二加密数据,所述新的第二加密数据包括新的加密梯度值和新的加密损失值,所述新的第二加密数据为所述第二终端A根据所述第一加密数据、样本特征数据和新的当前特征参数,采用预设算法获取的,所述新的当前特征参数为所述第二终端A根据所述第一损失值对应的所述第一梯度值和所述样本特征数据的当前特征参数,采用预设特征参数算法获取的;If the second terminal A detects that the first characteristic parameter is not in a convergent state according to the first loss value, it receives new second encrypted data sent by the second terminal A, and the new second encrypted data includes A new encryption gradient value and a new encryption loss value, the new second encrypted data is obtained by the second terminal A using a preset algorithm according to the first encrypted data, sample characteristic data and new current characteristic parameters , The new current characteristic parameter is obtained by the second terminal A using a preset characteristic parameter algorithm based on the first gradient value corresponding to the first loss value and the current characteristic parameter of the sample characteristic data ;
采用所述预设解密算法,分别对所述新的加密梯度值和所述新的加密损失值进行解密,得到第二梯度值和第二损失值;Using the preset decryption algorithm to decrypt the new encryption gradient value and the new encryption loss value to obtain a second gradient value and a second loss value;
向所述第二终端A发送所述第二梯度值和第二损失值。Sending the second gradient value and the second loss value to the second terminal A.
在一个可选的实现中,向第二终端A发送所述第一梯度值和第一损失值之后,所述方法还包括:In an optional implementation, after sending the first gradient value and the first loss value to the second terminal A, the method further includes:
向第二终端A发送预测请求,所述预测请求包括样本标识;Sending a prediction request to the second terminal A, where the prediction request includes a sample identifier;
接收所述第二终端A发送的所述样本标识对应的样本预测分数,所述样本预测分数是第二终端A根据所述样本标识对应的样本特征数据和所述样本特征数据的当前特征参数获得的;Receive the sample prediction score corresponding to the sample identifier sent by the second terminal A, where the sample prediction score is obtained by the second terminal A according to the sample feature data corresponding to the sample identifier and the current feature parameters of the sample feature data of;
根据所述样本预测分数和预设测试算法,获取所述样本模型的模型分数;Obtaining the model score of the sample model according to the sample prediction score and a preset test algorithm;
若所述模型分数小于预设分数阈值,则确定所述样本模型为正常样本模型。梯度值和第二损失值;If the model score is less than a preset score threshold, it is determined that the sample model is a normal sample model. Gradient value and second loss value;
向所述第二终端A发送所述第二梯度值和第二损失值。Sending the second gradient value and the second loss value to the second terminal A.
在一个可选的实现中,向第二终端A发送所述第一梯度值和第一损失值之后,所述方法还包括:In an optional implementation, after sending the first gradient value and the first loss value to the second terminal A, the method further includes:
第一终端B向第二终端A发送预测请求,所述预测请求包括样本标识;The first terminal B sends a prediction request to the second terminal A, where the prediction request includes a sample identifier;
接收所述第二终端A发送的所述样本标识对应的样本预测分数,所述样本预测分数是第二终端A根据所述样本标识U1对应的样本特征数据和所述样本特征数据的当前特征参数获得的;Receive the sample prediction score corresponding to the sample identifier sent by the second terminal A, where the sample prediction score is the second terminal A according to the sample feature data corresponding to the sample identifier U1 and the current feature parameters of the sample feature data acquired;
根据所述样本预测分数和预设测试算法,获取所述样本模型的模型分数;Obtaining the model score of the sample model according to the sample prediction score and a preset test algorithm;
若所述模型分数小于预设分数阈值,则确定所述样本模型为正常样本模型。If the model score is less than a preset score threshold, it is determined that the sample model is a normal sample model.
在一个可选的实现中,所述预设特征参数算法表示为:W n+1=w n-η*g; In an optional implementation, the preset characteristic parameter algorithm is expressed as: W n+1 =w n -η*g;
其中,g为梯度值,W n+1为梯度值g对应的特征参数,w n为当前特征参数,η为预设系数。 Among them, g is the gradient value, W n+1 is the characteristic parameter corresponding to the gradient value g, w n is the current characteristic parameter, and η is the preset coefficient.
第三方面,提供了一种基于联邦学习的模型参数的确定装置,该装置可以包括:接收单元、获取单元、发送单元和确定单元;In a third aspect, a device for determining model parameters based on federated learning is provided. The device may include: a receiving unit, an acquiring unit, a sending unit, and a determining unit;
所述接收单元,用于接收第一终端B发送的第一加密数据,所述第一加密数据为所述第一终端B根据预设加密算法对标签数据进行加密后得到的;所述标签数据为所述第一终端B中任一样本的标签数据,所述标签数据是描述样本行为达到的程度的数据;The receiving unit is configured to receive first encrypted data sent by the first terminal B, where the first encrypted data is obtained after the first terminal B encrypts label data according to a preset encryption algorithm; the label data Is the label data of any sample in the first terminal B, and the label data is data describing the extent to which the sample behavior reaches;
所述获取单元,用于根据所述第一加密数据、所述第二终端的样本特征数据和所述样本特征数据的当前特征参数,采用预设算法,获取第二加密数据,所述第二加密数据包括加密梯度值和加密损失值,所述预设算法包括预设梯度值算法和预设损失值算法,所述样本特征数据是样本行为的特征数据;The acquiring unit is configured to use a preset algorithm to acquire second encrypted data based on the first encrypted data, the sample characteristic data of the second terminal, and the current characteristic parameters of the sample characteristic data. The encrypted data includes an encryption gradient value and an encryption loss value, the preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm, and the sample characteristic data is characteristic data of a sample behavior;
所述发送单元,用于向所述第一终端B发送所述第二加密数据;The sending unit is configured to send the second encrypted data to the first terminal B;
所述接收单元,还用于接收所述第一终端B根据所述第二加密数据发送的第一梯度值和第一损失值;The receiving unit is further configured to receive the first gradient value and the first loss value sent by the first terminal B according to the second encrypted data;
所述获取单元,还用于根据所述第一梯度值和所述样本特征数据的当前特征参数,采用预设特征参数算法,获取第一特征参数;The acquiring unit is further configured to use a preset characteristic parameter algorithm to acquire the first characteristic parameter according to the first gradient value and the current characteristic parameter of the sample characteristic data;
所述确定单元,用于若根据所述第一损失值,检测出所述第一特征参数处于收敛状态,则将所述第一特征参数确定为待训练的样本模型的模型参数。The determining unit is configured to determine the first characteristic parameter as a model parameter of the sample model to be trained if it is detected that the first characteristic parameter is in a convergent state according to the first loss value.
在一个可选的实现中,所述确定单元,还用于若根据所述第一损失值,检测出第一特征参数未处于收敛状态,则将获取的所述第一特征参数确定为新的当前特征参数;In an optional implementation, the determining unit is further configured to, if it is detected that the first characteristic parameter is not in a convergent state according to the first loss value, determine the acquired first characteristic parameter as a new Current characteristic parameters;
所述获取单元,还用于根据所述第一加密数据、样本特征数据和所述新的当前特征参数,采用预设算法,获取新的第二加密数据,所述新的第二加密数据包括新的加密梯度值和新的加密损失值;The acquiring unit is further configured to use a preset algorithm to acquire new second encrypted data according to the first encrypted data, sample characteristic data, and the new current characteristic parameters, where the new second encrypted data includes New encryption gradient value and new encryption loss value;
所述发送单元,还用于向所述第一终端B发送所述新的第二加密数据;The sending unit is further configured to send the new second encrypted data to the first terminal B;
所述接收单元,还用于接收所述第一终端B根据所述新的第二加密数据发送的第二梯度值和第二损失值;The receiving unit is further configured to receive a second gradient value and a second loss value sent by the first terminal B according to the new second encrypted data;
所述获取单元,还用于根据所述第二梯度值和所述新的当前特征参数,采用预设特征参数算法,获取第二特征参数;The acquiring unit is further configured to use a preset characteristic parameter algorithm to acquire a second characteristic parameter according to the second gradient value and the new current characteristic parameter;
所述确定单元,还用于若根据所述第一损失值与所述第二损失值的差值,检测所述第二特征参数处于收敛状态,则将所述第二特征参数确定为所述待训练的样本模型的模型参数。The determining unit is further configured to determine that the second characteristic parameter is the second characteristic parameter if it is detected that the second characteristic parameter is in a convergent state according to the difference between the first loss value and the second loss value The model parameters of the sample model to be trained.
在一个可选的实现中,所述获取单元,还用于根据所述第一加密数据、样本特征数据、所述样本特征数据的当前特征参数和预设随机数,采用预设算法,获取所述样本的第二加密数据,所述预设随机数包括所述预设梯度值算法对应的第一随机数和所述预设损失值算法对应的第二随机数;In an optional implementation, the acquiring unit is further configured to use a preset algorithm according to the first encrypted data, sample characteristic data, current characteristic parameters of the sample characteristic data, and preset random numbers to obtain all For the second encrypted data of the sample, the preset random number includes a first random number corresponding to the preset gradient value algorithm and a second random number corresponding to the preset loss value algorithm;
根据所述预设随机数、第一梯度值和第一损失值,获取新的第一梯度值和新的第一损失值,之后执行获取第一特征参数的步骤。According to the preset random number, the first gradient value, and the first loss value, a new first gradient value and a new first loss value are acquired, and then the step of acquiring the first characteristic parameter is performed.
在一个可选的实现中,所述接收单元,还用于接收第一终端B发送的预测请求,所述预测请求包括样本标识;In an optional implementation, the receiving unit is further configured to receive a prediction request sent by the first terminal B, where the prediction request includes a sample identifier;
所述获取单元,还用于根据所述样本标识对应的样本特征数据和所述样本特征数据的当前特征参数,获取所述样本标识对应的样本预测分数;The acquiring unit is further configured to acquire the sample prediction score corresponding to the sample identifier according to the sample characteristic data corresponding to the sample identifier and the current characteristic parameter of the sample characteristic data;
所述发送单元,还用于向第一终端B发送所述样本预测分数。The sending unit is further configured to send the sample prediction score to the first terminal B.
在一个可选的实现中,所述预设算法包括预设梯度值算法和预设损失值算法;In an optional implementation, the preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm;
所述预设梯度值算法的公式表示为:The formula of the preset gradient value algorithm is expressed as:
Figure PCTCN2019122824-appb-000003
Figure PCTCN2019122824-appb-000003
所述预设损失值算法的公式表示为:The formula of the preset loss value algorithm is expressed as:
Figure PCTCN2019122824-appb-000004
Figure PCTCN2019122824-appb-000004
其中,x为所述第二终端的样本特征数据,y为所述第一终端的样本特征数据,g(w)为预设梯度值、l(w)为预设损失值、w为特征参数。Where x is the sample feature data of the second terminal, y is the sample feature data of the first terminal, g(w) is the preset gradient value, l(w) is the preset loss value, and w is the feature parameter .
第四方面,提供了一种基于联邦学习的模型参数的确定装置,该装置可以包括:发送单元、接收单元和解密单元;In a fourth aspect, a device for determining model parameters based on federated learning is provided. The device may include: a sending unit, a receiving unit, and a decrypting unit;
所述发送单元,用于向第二终端A发送第一加密数据,所述第一加密数据为所述第一终端B根据预设加密算法对标签数据进行加密后得到的;所述标签数据为所述第一终端B中任一样本的标签数据,所述标签数据是描述样本行为达到的程度的数据;The sending unit is configured to send first encrypted data to the second terminal A, where the first encrypted data is obtained after the first terminal B encrypts the label data according to a preset encryption algorithm; the label data is Label data of any sample in the first terminal B, where the label data is data describing the extent to which the sample behavior reaches;
所述接收单元,用于接收所述第二终端A根据所述第一加密数据发送的第二加密数据,所述第二加密数据包括加密梯度和加密损失值;The receiving unit is configured to receive second encrypted data sent by the second terminal A according to the first encrypted data, where the second encrypted data includes an encryption gradient and an encryption loss value;
所述解密单元,用于采用所述预设解密算法,分别对所述加密梯度和所述加密损失值进行解密,得到第一梯度值和第一损失值,所述预设加密算法和所述预设解密算法为互逆算法;The decryption unit is configured to use the preset decryption algorithm to decrypt the encryption gradient and the encryption loss value respectively to obtain a first gradient value and a first loss value, the preset encryption algorithm and the The preset decryption algorithm is a reciprocal algorithm;
所述发送单元,还用于向所述第二终端A发送所述第一梯度值和第一损失值。The sending unit is further configured to send the first gradient value and the first loss value to the second terminal A.
在一个可选的实现中,所述接收单元,还用于若所述第二终端A根据所述第一损失值,检测出第一特征参数未处于收敛状态,则接收第二终端A发送的新的第二加密数据,所述新的第二加密数据包括新的加密梯度值和新的加密损失值,所述新的第二加密数据为所述第二终端A根据所述第一加密数据、所述第二终端的样本特征数据和新的当前特征参数,采用预设算法获取的,所述新的当前特征参数为所述第二终端A根据所述第一损失值对应的所述第一梯度值和所述样本特征数据的当前特征参数,采用预设特征参数算法获取的,所述样本特征数据是样本行为的特征数据;In an optional implementation, the receiving unit is further configured to: if the second terminal A detects that the first characteristic parameter is not in a convergent state according to the first loss value, then receive the data sent by the second terminal A New second encrypted data, the new second encrypted data includes a new encryption gradient value and a new encryption loss value, the new second encrypted data is the second terminal A according to the first encrypted data The sample feature data and new current feature parameters of the second terminal are acquired by using a preset algorithm, and the new current feature parameters are the second terminal A corresponding to the first loss value according to the first loss value. A gradient value and the current characteristic parameters of the sample characteristic data are obtained by using a preset characteristic parameter algorithm, and the sample characteristic data is characteristic data of sample behavior;
所述解密单元,还用于采用所述预设解密算法,分别对所述新的加密梯度值和所述新的加密损失值进行解密,得到第二梯度值和第二损失值;The decryption unit is further configured to use the preset decryption algorithm to decrypt the new encryption gradient value and the new encryption loss value respectively to obtain a second gradient value and a second loss value;
所述发送单元,还用于向所述第二终端A发送所述第二梯度值和第二损失值。The sending unit is further configured to send the second gradient value and the second loss value to the second terminal A.
在一个可选的实现中,所述装置还包括获取单元和确定单元;In an optional implementation, the device further includes an acquiring unit and a determining unit;
所述发送单元,还用于向第二终端A发送预测请求,所述预测请求包括样本标识;The sending unit is further configured to send a prediction request to the second terminal A, where the prediction request includes a sample identifier;
所述接收单元,还用于接收所述第二终端A发送的所述样本标识对应的样本预测分数,所述样本预测分数是第二终端A根据所述样本标识对应的样本特征数据和所述样本特征数据的当前特征参数获得的;The receiving unit is further configured to receive the sample prediction score corresponding to the sample identifier sent by the second terminal A, where the sample prediction score is the sample feature data corresponding to the sample identifier and the The current characteristic parameters of the sample characteristic data are obtained;
所述获取单元,用于根据所述样本预测分数和预设测试算法,获取所述 样本模型的模型分数;The obtaining unit is configured to obtain the model score of the sample model according to the sample prediction score and a preset test algorithm;
所述确定单元,用于若所述模型分数小于预设分数阈值,则确定所述样本模型为正常样本模型。The determining unit is configured to determine that the sample model is a normal sample model if the model score is less than a preset score threshold.
在一个可选的实现中,所述预设特征参数算法表示为:W n+1=w n-η*g; In an optional implementation, the preset characteristic parameter algorithm is expressed as: W n+1 =w n -η*g;
其中,g为梯度值,W n+1为梯度值g对应的特征参数,w n为当前特征参数,η为预设系数。 Among them, g is the gradient value, W n+1 is the characteristic parameter corresponding to the gradient value g, w n is the current characteristic parameter, and η is the preset coefficient.
第五方面,提供了一种终端,该终端包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;In a fifth aspect, a terminal is provided. The terminal includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete mutual communication through the communication bus;
存储器,用于存放计算机程序;Memory, used to store computer programs;
处理器,用于执行存储器上所存放的程序时,实现上述第一方面中任一所述的方法步骤或上述第二方面中任一项上所述的方法步骤。The processor is configured to implement the method steps described in any one of the foregoing first aspect or the method steps described in any one of the foregoing second aspect when executing the program stored in the memory.
第六方面,提供了一种计算机可读存储介质,该计算机可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现上述第一方面中任一所述的方法步骤或上述第二方面中任一所述的方法步骤。In a sixth aspect, a computer-readable storage medium is provided, and a computer program is stored in the computer-readable storage medium. The computer program, when executed by a processor, implements the method steps in any one of the first aspects or the above The method steps of any one of the second aspect.
本发明上述实施例提供的方法中第二终端A接收第一终端B发送的第一加密数据,第一加密数据为所述第一终端B根据预设加密算法对标签数据进行加密后得到的;标签数据为第一终端B中任一样本的样本数据;根据第一加密数据、样本特征数据和所述第二终端的样本特征数据的当前特征参数,采用预设算法,获取第二加密数据,第二加密数据包括加密梯度值和加密损失值,预设算法包括预设梯度值算法和预设损失值算法;向第一终端B发送第二加密数据;接收第一终端B根据第二加密数据发送的第一梯度值和第一损失值;根据第一梯度值和样本特征数据的当前特征参数,采用预设特征参数算法,获取第一特征参数;若根据第一损失值,检测出第一特征参数处于收敛状态,则将第一特征参数确定为待训练的样本模型的模型参数。与现有技术相比,该方法在不需要第三方的协作者C,以及第一终端与第二终端不存在重叠特征数据的情况下,实现了模型参数的确定,有效的保护了自身的隐私数据,提高了训练效率。In the method provided by the foregoing embodiment of the present invention, the second terminal A receives the first encrypted data sent by the first terminal B, where the first encrypted data is obtained after the first terminal B encrypts the label data according to a preset encryption algorithm; The label data is the sample data of any sample in the first terminal B; according to the first encrypted data, the sample characteristic data, and the current characteristic parameters of the sample characteristic data of the second terminal, the second encrypted data is obtained by using a preset algorithm, The second encrypted data includes an encryption gradient value and an encryption loss value. The preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm; sending the second encrypted data to the first terminal B; receiving the first terminal B according to the second encrypted data The first gradient value and the first loss value sent; according to the first gradient value and the current characteristic parameter of the sample characteristic data, the preset characteristic parameter algorithm is used to obtain the first characteristic parameter; if the first characteristic parameter is detected according to the first loss value If the characteristic parameter is in a state of convergence, the first characteristic parameter is determined as the model parameter of the sample model to be trained. Compared with the prior art, this method does not require a third-party collaborator C, and the first terminal and the second terminal do not have overlapping feature data, realizes the determination of model parameters, and effectively protects their privacy Data improves training efficiency.
附图说明Description of the drawings
图1为本发明实施例提供的一种基于联邦学习的模型参数的确定方法应用的场景构架示意图;FIG. 1 is a schematic diagram of a scenario framework for application of a method for determining model parameters based on federated learning according to an embodiment of the present invention;
图2为本发明实施例提供的一种基于联邦学习的模型参数确定方法的流程示意图;2 is a schematic flowchart of a method for determining model parameters based on federated learning according to an embodiment of the present invention;
图3为本发明实施例提供的一种基于联邦学习的模型参数的确定装置的结构示意图;3 is a schematic structural diagram of a device for determining model parameters based on federated learning according to an embodiment of the present invention;
图4为本发明实施例提供的另一种基于联邦学习的模型参数的确定装置的结构示意图;4 is a schematic structural diagram of another device for determining model parameters based on federated learning according to an embodiment of the present invention;
图5为本发明实施例提供的一种终端的结构示意图。FIG. 5 is a schematic structural diagram of a terminal provided by an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅是本申请一部分实施例,并不是全部的实施例。基于本申请实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all of the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present application.
本发明实施例提供的基于联邦学习的模型参数的确定方法可以应用在图1所示的场景构架中,该场景构架可以包括至少一个终端,每个终端为一个数据拥有方。至少一个终端间通过联邦学习***建立模型,训练模型参数。The method for determining model parameters based on federated learning provided by the embodiment of the present invention can be applied to the scenario framework shown in FIG. 1. The scenario framework may include at least one terminal, and each terminal is a data owner. At least one terminal establishes a model through a federated learning system to train model parameters.
终端可以是移动电话、智能电话、笔记本电脑、数字广播接收器、个人数字助理(PDA)、平板电脑(PAD)等用户设备(User Equipment,UE)、手持设备、车载设备、可穿戴设备、计算设备或连接到无线调制解调器的其它处理设备、移动台(Mobile station,MS)等。Terminals can be mobile phones, smart phones, notebook computers, digital broadcast receivers, personal digital assistants (PDA), tablet computers (PAD) and other user equipment (User Equipment, UE), handheld devices, vehicle-mounted devices, wearable devices, computing Equipment or other processing equipment connected to a wireless modem, mobile station (MS), etc.
其中,每个数据拥有方各自所持有的数据集,其可以用一个矩阵来表示。矩阵的每一行代表一个样本,每一列代表一种样本的特征。同时,某些数据集可能还包含标签数据。如果要对用户行为建立预测模型,就必须要有标签数据。设样本的特征数据为X,样本的标签数据为Y。例如,在金融领域,标签数据Y是用户的信用;在营销领域,标签数据Y是用户的购买愿望;在教育领域,标签数据Y是学生掌握知识的程度。标签数据是描述样本行为达到的程度的数据,样本特征数据是样本行为的特征数据;Among them, the data set held by each data owner can be represented by a matrix. Each row of the matrix represents a sample, and each column represents the characteristics of a sample. At the same time, some data sets may also contain label data. If you want to build a predictive model of user behavior, you must have label data. Suppose the characteristic data of the sample is X, and the label data of the sample is Y. For example, in the financial field, label data Y is the user’s credit; in the marketing field, label data Y is the user’s purchase desire; in the education field, label data Y is the degree of students' knowledge. The label data is the data describing the extent of the sample behavior, and the sample characteristic data is the characteristic data of the sample behavior;
以包含两个数据拥有方,A方和B方的场景为例,假设A方和B方想联合训练一个机器学习模型,它们的业务***分别拥有各自用户的相关数据。Taking a scenario involving two data owners, party A and party B, as an example, suppose party A and party B want to jointly train a machine learning model, and their business systems each have relevant data of their respective users.
本申请通过加密的样本对齐技术,获取A方和B方存在的共有样本,其中,A方的样本数据中仅拥有样本特征数据X,B方的样本数据中仅拥有模型需要预测的标签数据Y。为了数据隐私和安全考虑,A方和B方无法直接进行数据交换。此时,可使用联邦学习***建立模型,并训练模型参数。This application uses encrypted sample alignment technology to obtain shared samples between party A and party B, where party A’s sample data only has sample feature data X, and party B’s sample data only has label data Y that the model needs to predict. . For data privacy and security considerations, Party A and Party B cannot directly exchange data. At this time, a federated learning system can be used to build a model and train model parameters.
A方持有的数据集可以如表1所示,B方持有的数据集可以如表2所示。The data set held by Party A can be as shown in Table 1, and the data set held by Party B can be as shown in Table 2.
表1Table 1
样本标识Sample identification 特征数据X1Characteristic data X1 特征数据X2Characteristic data X2 特征数据X3Characteristic data X3
U1U1 99 80008000 AA
U2U2 44 50005000 CC
U3U3 22 35003500 CC
U4U4 1010 1000010000 AA
表1中,A方包括样本标识为U1-U4的样本,每种样本包括三个特征数据。其中,样本标识U1对应的X1的当前特征参数为9、X2的当前特征参数为8000和X3的当前特征参数为A;样本标识U2对应的X1的当前特征参数为4、X2的当前特征参数为5000和X3的当前特征参数为C;样本标识U3对应的X1的当前特征参数为2、X2的当前特征参数为3500和X3的当前特征参数为C;样本标识U4对应的X1的当前特征参数为10、X2的当前特征参数为10000和X3的当前特征参数为A。In Table 1, Party A includes samples with sample identifiers U1-U4, and each sample includes three characteristic data. Among them, the current feature parameter of X1 corresponding to sample identification U1 is 9, the current feature parameter of X2 is 8000, and the current feature parameter of X3 is A; the current feature parameter of X1 corresponding to sample identification U2 is 4, and the current feature parameter of X2 is The current feature parameter of 5000 and X3 is C; the current feature parameter of X1 corresponding to sample identification U3 is 2, the current feature parameter of X2 is 3500 and the current feature parameter of X3 is C; the current feature parameter of X1 corresponding to sample identification U4 is 10. The current characteristic parameter of X2 is 10000 and the current characteristic parameter of X3 is A.
表2Table 2
样本标识Sample identification 标签数据YLabel data Y
U1U1 00
U2U2 11
U3U3 11
U4U4 00
表2中,B方包括样本标识为U1-U4的样本,每种样本仅包括标签数据。其中,样本标识U1对应的标签数据Y为0;样本标识U2对应的标签数据Y1;样本标识U3对应的标签数据Y为1;样本标识U4对应的标签数据Y为0。In Table 2, Party B includes samples with sample identifiers U1-U4, and each sample only includes label data. Among them, the label data Y corresponding to the sample identifier U1 is 0; the label data Y1 corresponding to the sample identifier U2; the label data Y corresponding to the sample identifier U3 is 1; the label data Y corresponding to the sample identifier U4 is 0.
下面以A方为第二终端A,B方为第一终端B为例进行模型参数确定。The following takes party A as the second terminal A and party B as the first terminal B as an example to determine the model parameters.
图2为本发明实施例提供的一种基于联邦学习的模型参数确定方法的流程示意图。如图2所示,该方法可以包括:Fig. 2 is a schematic flowchart of a method for determining model parameters based on federated learning according to an embodiment of the present invention. As shown in Figure 2, the method may include:
步骤210、第一终端B向第二终端A发送第一加密数据。Step 210: The first terminal B sends the first encrypted data to the second terminal A.
在执行该步骤之前,第一终端B生成加密的公钥和私钥,并采用预设加密算法对标签数据中的标签数据进行加密,即使用公钥对标签数据中的标签数据进行加密,得到第一加密数据。其中,标签数据为第一终端B中任一样本的样本数据,如标签数据为样本标识U1对应的样本数据或标签数据为样本标识U2对应的样本数据。其中,预设加密算法可以是同态加密算法。Before performing this step, the first terminal B generates an encrypted public key and a private key, and uses a preset encryption algorithm to encrypt the tag data in the tag data, that is, uses the public key to encrypt the tag data in the tag data to obtain The first encrypted data. Wherein, the label data is sample data of any sample in the first terminal B, for example, the label data is sample data corresponding to the sample identifier U1 or the label data is sample data corresponding to the sample identifier U2. Among them, the preset encryption algorithm may be a homomorphic encryption algorithm.
若标签数据为y,第一加密数据可以是[[Ny]],N为非零数,如N=1时,第一加密数据为[[y]];N=-1/2时,第一加密数据为[[-1/2y]]。If the label data is y, the first encrypted data can be [[Ny]], and N is a non-zero number. For example, when N=1, the first encrypted data is [[y]]; when N=-1/2, the first encrypted data is [[y]]; One encrypted data is [[-1/2y]].
步骤220、第二终端A根据第一加密数据、第二终端的样本特征数据和样本特征数据的当前特征参数,采用预设算法,获取样本的第二加密数据。Step 220: The second terminal A uses a preset algorithm to obtain the second encrypted data of the sample according to the first encrypted data, the sample characteristic data of the second terminal, and the current characteristic parameters of the sample characteristic data.
结合表1,以样本标识U1为例,样本标识U1对应的样本特征数据分别为X1、X2和X3,样本特征数据的当前特征参数分别为9、8000、A。预设算法可以包括预设梯度值算法和预设损失值算法。Combining Table 1, taking the sample identification U1 as an example, the sample feature data corresponding to the sample identification U1 are X1, X2, and X3, and the current feature parameters of the sample feature data are 9, 8000, and A, respectively. The preset algorithm may include a preset gradient value algorithm and a preset loss value algorithm.
预设梯度值算法的公式可以表示为:
Figure PCTCN2019122824-appb-000005
The formula of the preset gradient value algorithm can be expressed as:
Figure PCTCN2019122824-appb-000005
又可以表示为:
Figure PCTCN2019122824-appb-000006
It can be expressed as:
Figure PCTCN2019122824-appb-000006
预设损失值算法的公式可以表示为:The formula of the preset loss value algorithm can be expressed as:
Figure PCTCN2019122824-appb-000007
其中,w为特征参数。
Figure PCTCN2019122824-appb-000007
Among them, w is the characteristic parameter.
在第一加密数据为[[-1/2y]]时,根据第一加密数据、样本特征数据和样本特征数据的当前特征参数,采用预设算法,获取样本标识U1对应的包括加密梯度值和加密损失值的第二加密数据。When the first encrypted data is [[-1/2y]], according to the first encrypted data, the sample characteristic data, and the current characteristic parameters of the sample characteristic data, the preset algorithm is used to obtain the sample identifier U1 corresponding to the encrypted gradient value and The second encrypted data of the encrypted loss value.
加密梯度值的公式可以表示为:
Figure PCTCN2019122824-appb-000008
The formula of the encryption gradient value can be expressed as:
Figure PCTCN2019122824-appb-000008
加密损失值的公式可以表示为:The formula for the encryption loss value can be expressed as:
Figure PCTCN2019122824-appb-000009
Figure PCTCN2019122824-appb-000009
可选地,为了进一步提高A方和B方间数据传输的安全性,第二终端A可以获取预设随机数,预设随机数包括预设梯度值算法对应的第一随机数r1和预设损失值算法对应的第二随机数r2。Optionally, in order to further improve the security of data transmission between party A and party B, the second terminal A may obtain a preset random number, and the preset random number includes the first random number r1 corresponding to the preset gradient value algorithm and the preset The second random number r2 corresponding to the loss value algorithm.
第二终端A根据第一加密数据、样本特征数据、样本特征数据的当前特征参数和预设随机数,采用预设算法,获取包括加密梯度值和加密损失值的第二加密数据。The second terminal A uses a preset algorithm to obtain the second encrypted data including the encryption gradient value and the encryption loss value according to the first encrypted data, the sample characteristic data, the current characteristic parameters of the sample characteristic data, and the preset random number.
此时,加密梯度值的公式可以表示为:At this time, the formula for the encrypted gradient value can be expressed as:
Figure PCTCN2019122824-appb-000010
Figure PCTCN2019122824-appb-000010
加密损失值的公式可以表示为:The formula for the encryption loss value can be expressed as:
Figure PCTCN2019122824-appb-000011
Figure PCTCN2019122824-appb-000011
步骤230、第二终端A向第一终端B发送第二加密数据。Step 230: The second terminal A sends the second encrypted data to the first terminal B.
步骤240、第一终端B采用预设解密算法,对第二加密数据进行解密,得到第一梯度值和第一损失值。Step 240: The first terminal B uses a preset decryption algorithm to decrypt the second encrypted data to obtain the first gradient value and the first loss value.
第一终端B采用预设解密算法,分别对加密梯度和加密损失值进行解密,即采用私钥进行解密,得到第一梯度值和第一损失值。预设加密算法和预设解密算法为互逆算法,故预设解密算法可以是同态解密算法。The first terminal B uses a preset decryption algorithm to decrypt the encryption gradient and the encryption loss value respectively, that is, decrypts using the private key to obtain the first gradient value and the first loss value. The preset encryption algorithm and the preset decryption algorithm are reciprocal algorithms, so the preset decryption algorithm may be a homomorphic decryption algorithm.
步骤250、第一终端B向第二终端A发送第一梯度值和第一损失值。Step 250: The first terminal B sends the first gradient value and the first loss value to the second terminal A.
步骤260、第二终端A根据第一损失值对应的第一梯度值和样本特征数据的当前特征参数,采用预设特征参数算法,获取第一特征参数。Step 260: The second terminal A uses a preset feature parameter algorithm to obtain the first feature parameter according to the first gradient value corresponding to the first loss value and the current feature parameter of the sample feature data.
第二终端A根据第一损失值l对应的第一梯度值g和样本特征数据的当前特征参数w 0,采用预设特征参数算法,获取第一梯度值g对应的样本特征数据的第一特征参数w 1According to the first gradient value g corresponding to the first loss value l and the current feature parameter w 0 of the sample feature data, the second terminal A uses a preset feature parameter algorithm to obtain the first feature of the sample feature data corresponding to the first gradient value g Parameter w 1 .
预设特征参数算法可以表示为:W n+1=w n-η*g;其中,g为梯度值,W n+1为梯度值g对应的特征参数,w n为当前特征参数,η为预设系数。 The preset feature parameter algorithm can be expressed as: W n+1 =w n -η*g; where g is the gradient value, W n+1 is the feature parameter corresponding to the gradient value g, w n is the current feature parameter, and η is Preset coefficients.
可选地,若第二加密数据是第二终端A根据第一加密数据、样本特征数据、样本特征数据的当前特征参数w 0和预设随机数采用预设算法得到的,则第二终端A根据预设随机数、第一梯度值和第一损失值,获取新的第一梯度值和新的第一损失值。 Optionally, if the second encrypted data is obtained by the second terminal A using a preset algorithm according to the first encrypted data, the sample characteristic data, the current characteristic parameter w 0 of the sample characteristic data and a preset random number, the second terminal A According to the preset random number, the first gradient value, and the first loss value, a new first gradient value and a new first loss value are acquired.
例如,设第一随机数r1、第二随机数r2、第一梯度值g’和第一损失值l’,则新的第一梯度值l为l’/r2;新的第一损失值g为g’/r1。For example, suppose the first random number r1, the second random number r2, the first gradient value g', and the first loss value l', the new first gradient value l is l'/r2; the new first loss value g Is g'/r1.
之后,第二终端A根据新的第一损失值对应的新的第一梯度值和样本特征数据的当前特征参数w 0,采用预设特征参数算法,获取新的第一梯度值对应的样本特征数据的第一特征参数w 1After that, the second terminal A uses the preset feature parameter algorithm to obtain the sample feature corresponding to the new first gradient value according to the new first gradient value corresponding to the new first loss value and the current feature parameter w 0 of the sample feature data The first characteristic parameter w 1 of the data.
步骤270、第二终端A根据第一特征参数是否处于收敛状态,确定模型 参数。Step 270: The second terminal A determines model parameters according to whether the first characteristic parameter is in a convergent state.
第二终端A根据第一损失值,检测第一特征参数是否处于收敛状态。其中,若第一损失值小于预设损失阈值,则确定第一特征参数处于收敛状态,或者,若第一特征参数己达到最大迭代次数,则确定第一特征参数收敛。其中,用户或者运维人员可根据需要设置预设损失阈值的大小,本实施例不做限制。The second terminal A detects whether the first characteristic parameter is in a convergent state according to the first loss value. Wherein, if the first loss value is less than the preset loss threshold, it is determined that the first characteristic parameter is in a convergent state, or if the first characteristic parameter has reached the maximum number of iterations, it is determined that the first characteristic parameter has converged. Among them, the user or the operation and maintenance personnel can set the size of the preset loss threshold as needed, which is not limited in this embodiment.
若根据第一损失值,检测出第一特征参数处于收敛状态,则将第一特征参数确定为待训练的样本模型的模型参数,以使第二终端A训练样本模型。If it is detected that the first feature parameter is in a convergent state according to the first loss value, the first feature parameter is determined as the model parameter of the sample model to be trained, so that the second terminal A trains the sample model.
若根据第一损失值,检测出第一特征参数未处于收敛状态,则将第一特征参数确定为新的当前特征参数;返回执行步骤260。If it is detected that the first characteristic parameter is not in a convergent state according to the first loss value, the first characteristic parameter is determined as the new current characteristic parameter; and step 260 is executed.
具体为,第二终端A根据第一加密数据、样本特征数据和新的当前特征参数w 2,采用预设算法,获取样本的新的第二加密数据,新的第二加密数据包括新的加密梯度值和新的加密损失值; Specifically, the second terminal A uses a preset algorithm to obtain the new second encrypted data of the sample according to the first encrypted data, the sample characteristic data and the new current characteristic parameter w 2 , and the new second encrypted data includes the new encrypted data. Gradient value and new encryption loss value;
第二终端A向第一终端B发送新的第二加密数据,以使第一终端B对新的第二加密数据进行解密,得到第二梯度值和第二损失值;The second terminal A sends the new second encrypted data to the first terminal B, so that the first terminal B decrypts the new second encrypted data to obtain the second gradient value and the second loss value;
之后,第二终端A接收第一终端B根据新的第二加密数据发送的第二梯度值和第二损失值;After that, the second terminal A receives the second gradient value and the second loss value sent by the first terminal B according to the new second encrypted data;
第二终端A根据第二梯度值和新的当前特征参数w 2,采用预设特征参数算法,获取第二特征参数w 3According to the second gradient value and the new current characteristic parameter w 2 , the second terminal A adopts a preset characteristic parameter algorithm to obtain the second characteristic parameter w 3 .
根据所述第一损失值与所述第二损失值的差值,检测所述第二特征参数处于收敛状态。若第一损失值与所述第二损失值的差值小于预设损失阈值,则确定第二特征参数w 2处于收敛状态,或者,第二特征参数w 2己达到最大迭代次数,则确定第二特征参数收敛。 According to the difference between the first loss value and the second loss value, detecting that the second characteristic parameter is in a convergent state. If the difference between the first loss value and the second loss value is less than the preset loss threshold, it is determined that the second characteristic parameter w 2 is in a convergent state, or the second characteristic parameter w 2 has reached the maximum number of iterations, then the first 2. Convergence of characteristic parameters.
之后,将第二特征参数w 2确定为待训练的样本模型的模型参数,以使第二终端A训练样本模型。 After that, the second feature parameter w 2 is determined as the model parameter of the sample model to be trained, so that the second terminal A trains the sample model.
可选地,为了检测训练的样本U1的样本模型的准确性,在执行该步骤之后,第一终端B可以向第二终端A发送预测请求,预测请求包括样本标识,如UI;Optionally, in order to detect the accuracy of the sample model of the trained sample U1, after performing this step, the first terminal B may send a prediction request to the second terminal A, and the prediction request includes a sample identifier, such as UI;
第二终端A根据样本标识U1,获取相应的样本特征数据和样本特征数据的当前特征参数,获取样本标识对应的样本预测分数;The second terminal A obtains corresponding sample characteristic data and current characteristic parameters of the sample characteristic data according to the sample identifier U1, and obtains the sample prediction score corresponding to the sample identifier;
第二终端A中样本U1的样本预测分数可以表示为:The sample prediction score of sample U1 in the second terminal A can be expressed as:
w A Tx A=w 1x u1.1+w 2x u1.2+w 3x u1.3w A T x A =w 1 x u1.1 +w 2 x u1.2 +w 3 x u1.3 ;
之后,第二终端A向第一终端B发送样本标识对应的样本预测分数。After that, the second terminal A sends the sample prediction score corresponding to the sample identifier to the first terminal B.
第一终端B接收第二终端A发送的样本预测分数,并根据样本预测分数和预设测试算法,获取样本模型的模型分数;The first terminal B receives the sample prediction score sent by the second terminal A, and obtains the model score of the sample model according to the sample prediction score and the preset test algorithm;
预设测试算法的公式可以表示为:The formula of the preset test algorithm can be expressed as:
Figure PCTCN2019122824-appb-000012
Figure PCTCN2019122824-appb-000012
由于w Tx=w A Tx A,故第一终端B可以获取到样本模型的模型分数P,若模型分数P小于预设分数阈值,则确定样本模型为正常样本模型。 Since w T x = w A T x A , the first terminal B can obtain the model score P of the sample model. If the model score P is less than the preset score threshold, it is determined that the sample model is a normal sample model.
本发明上述实施例提供的方法与现有技术相比,该方法在不需要第三方的协作者C,以及第一终端与第二终端不存在重叠特征数据的情况下,实现了模型参数的确定,有效的保护了自身的隐私数据,提高了训练效率。Compared with the prior art, the method provided by the foregoing embodiment of the present invention realizes the determination of model parameters without the need for a third-party collaborator C and the first terminal and the second terminal do not have overlapping feature data. , It effectively protects its own private data and improves training efficiency.
与上述方法对应的,本发明实施例还提供一种基于联邦学习的模型参数的确定装置,如图3所示,该装置包括:接收单元310、获取单元320、发送单元330和确定单元340;Corresponding to the above method, an embodiment of the present invention also provides a device for determining model parameters based on federated learning. As shown in FIG. 3, the device includes: a receiving unit 310, an acquiring unit 320, a sending unit 330, and a determining unit 340;
接收单元310,用于接收第一终端B发送的第一加密数据,所述第一加密数据为所述第一终端B根据预设加密算法对标签数据进行加密后得到的;所述标签数据为所述第一终端B中任一样本的标签数据,所述标签数据是描述样本行为达到的程度的数据;The receiving unit 310 is configured to receive first encrypted data sent by the first terminal B, where the first encrypted data is obtained after the first terminal B encrypts label data according to a preset encryption algorithm; the label data is Label data of any sample in the first terminal B, where the label data is data describing the extent to which the sample behavior reaches;
获取单元320,用于根据所述第一加密数据、所述第二终端的样本特征数据和所述样本特征数据的当前特征参数,采用预设算法,获取第二加密数据,所述第二加密数据包括加密梯度值和加密损失值,所述预设算法包括预设梯度值算法和预设损失值算法,所述样本特征数据是样本行为的特征数据;The acquiring unit 320 is configured to use a preset algorithm to acquire second encrypted data according to the first encrypted data, the sample characteristic data of the second terminal, and the current characteristic parameters of the sample characteristic data. The data includes an encryption gradient value and an encryption loss value, the preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm, and the sample characteristic data is characteristic data of a sample behavior;
发送单元330,用于向所述第一终端B发送所述第二加密数据;The sending unit 330 is configured to send the second encrypted data to the first terminal B;
接收单元310,还用于接收所述第一终端B根据所述第二加密数据发送的第一梯度值和第一损失值;The receiving unit 310 is further configured to receive the first gradient value and the first loss value sent by the first terminal B according to the second encrypted data;
获取单元320,还用于根据所述第一梯度值和所述样本特征数据的当前特征参数,采用预设特征参数算法,获取第一特征参数;The acquiring unit 320 is further configured to acquire the first characteristic parameter by using a preset characteristic parameter algorithm according to the first gradient value and the current characteristic parameter of the sample characteristic data;
确定单元340,用于若根据所述第一损失值,检测出所述第一特征参数处于收敛状态,则将所述第一特征参数确定为待训练的样本模型的模型参数。The determining unit 340 is configured to determine the first characteristic parameter as a model parameter of the sample model to be trained if it is detected that the first characteristic parameter is in a convergent state according to the first loss value.
本发明上述实施例提供的基于联邦学习的模型参数的确定装置的各功能单元的功能,可以通过上述各方法步骤来实现,因此,本发明实施例提供的基于联邦学习的模型参数的确定装置中的各个单元的具体工作过程和有益效果,在此不复赘述。The functions of each functional unit of the device for determining model parameters based on federated learning provided in the foregoing embodiment of the present invention can be implemented through the above method steps. Therefore, in the device for determining model parameters based on federated learning provided by the embodiment of the present invention The specific working process and beneficial effects of the various units of the unit will not be repeated here.
与上述方法对应的,本发明实施例还提供一种基于联邦学习的模型参数的确定装置,如图4所示,该装置包括:发送单元410、接收单元420和解密单元430;Corresponding to the foregoing method, an embodiment of the present invention also provides an apparatus for determining model parameters based on federated learning. As shown in FIG. 4, the apparatus includes: a sending unit 410, a receiving unit 420, and a decrypting unit 430;
发送单元410,用于向第二终端A发送第一加密数据,所述第一加密数据为所述第一终端B根据预设加密算法对标签数据进行加密后得到的;所述标签数据为所述第一终端B中任一样本的标签数据,所述标签数据是描述样本行为达到的程度的数据;The sending unit 410 is configured to send first encrypted data to the second terminal A, where the first encrypted data is obtained after the first terminal B encrypts label data according to a preset encryption algorithm; the label data is all The label data of any sample in the first terminal B, where the label data is data describing the extent to which the sample behavior reaches;
接收单元420,用于接收所述第二终端A根据所述第一加密数据发送的第二加密数据,所述第二加密数据包括加密梯度和加密损失值;The receiving unit 420 is configured to receive second encrypted data sent by the second terminal A according to the first encrypted data, where the second encrypted data includes an encryption gradient and an encryption loss value;
解密单元430,用于采用所述预设解密算法,分别对所述加密梯度和所述加密损失值进行解密,得到第一梯度值和第一损失值,所述预设加密算法和所述预设解密算法为互逆算法;The decryption unit 430 is configured to use the preset decryption algorithm to decrypt the encryption gradient and the encryption loss value respectively to obtain a first gradient value and a first loss value, the preset encryption algorithm and the prediction Let the decryption algorithm be a reciprocal algorithm;
发送单元410,还用于向所述第二终端A发送所述第一梯度值和第一损失值。The sending unit 410 is further configured to send the first gradient value and the first loss value to the second terminal A.
本发明上述实施例提供的基于联邦学习的模型参数的确定装置的各功能单元的功能,可以通过上述各方法步骤来实现,因此,本发明实施例提供的基于联邦学习的模型参数的确定装置中的各个单元的具体工作过程和有益效果,在此不复赘述。The functions of each functional unit of the device for determining model parameters based on federated learning provided in the foregoing embodiment of the present invention can be implemented by the above method steps. Therefore, in the device for determining model parameters based on federated learning provided by the embodiment of the present invention The specific working process and beneficial effects of the various units of the unit will not be repeated here.
本发明实施例还提供了一种终端,如图5所示,包括处理器510、通信接口520、存储器530和通信总线540,其中,处理器510,通信接口520,存储器530通过通信总线540完成相互间的通信。The embodiment of the present invention also provides a terminal. As shown in FIG. 5, it includes a processor 510, a communication interface 520, a memory 530, and a communication bus 540. The processor 510, the communication interface 520, and the memory 530 are implemented through the communication bus 540. Communication between each other.
存储器530,用于存放计算机程序;The memory 530 is used to store computer programs;
处理器510,用于执行存储器530上所存放的程序时,实现如下步骤:The processor 510 is configured to implement the following steps when executing the program stored in the memory 530:
接收第一终端发送的第一加密数据,所述第一加密数据为所述第一终端根据预设加密算法对标签数据进行加密后得到的;所述标签数据为所述第一终端中任一样本的标签数据,所述标签数据是描述样本行为达到的程度的数据;Receiving first encrypted data sent by a first terminal, where the first encrypted data is obtained after the first terminal encrypts tag data according to a preset encryption algorithm; the tag data is any of the first terminals The label data of this book, the label data is data describing the extent to which the behavior of the sample has reached;
根据所述第一加密数据、所述第二终端的样本特征数据和所述样本特征数据的当前特征参数,采用预设算法,获取第二加密数据,所述第二加密数据包括加密梯度值和加密损失值,所述预设算法包括预设梯度值算法和预设损失值算法,所述样本特征数据是样本行为的特征数据;According to the first encrypted data, the sample characteristic data of the second terminal, and the current characteristic parameters of the sample characteristic data, a preset algorithm is used to obtain second encrypted data, where the second encrypted data includes an encryption gradient value and Encryption loss value, the preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm, and the sample characteristic data is characteristic data of sample behavior;
向所述第一终端发送所述第二加密数据;Sending the second encrypted data to the first terminal;
接收所述第一终端根据所述第二加密数据发送的第一梯度值和第一损失值;Receiving the first gradient value and the first loss value sent by the first terminal according to the second encrypted data;
根据所述第一梯度值和所述样本特征数据的当前特征参数,采用预设特征参数算法,获取第一特征参数;According to the first gradient value and the current characteristic parameter of the sample characteristic data, a preset characteristic parameter algorithm is adopted to obtain the first characteristic parameter;
若根据所述第一损失值,检测出所述第一特征参数处于收敛状态,则将所述第一特征参数确定为待训练的样本模型的模型参数。If it is detected that the first characteristic parameter is in a convergent state according to the first loss value, the first characteristic parameter is determined as the model parameter of the sample model to be trained.
或者,执行以下步骤:Or, perform the following steps:
向第二终端发送第一加密数据,所述第一加密数据为所述第一终端根据预设加密算法对标签数据进行加密后得到的;所述标签数据为所述第一终端中任一样本的样本数据;Send first encrypted data to the second terminal, where the first encrypted data is obtained after the first terminal encrypts label data according to a preset encryption algorithm; the label data is any sample in the first terminal Sample data;
接收所述第二终端根据所述第一加密数据发送的所述样本的第二加密数据,所述第二加密数据包括加密梯度和加密损失值;Receiving second encrypted data of the sample sent by the second terminal according to the first encrypted data, where the second encrypted data includes an encryption gradient and an encryption loss value;
采用所述预设解密算法,分别对所述加密梯度和所述加密损失值进行解密,得到第一梯度值和第一损失值,所述预设加密算法和所述预设解密算法为互逆算法;The preset decryption algorithm is used to decrypt the encryption gradient and the encryption loss value respectively to obtain a first gradient value and a first loss value, and the preset encryption algorithm and the preset decryption algorithm are reciprocal algorithm;
向所述第二终端发送所述第一梯度值和第一损失值。Sending the first gradient value and the first loss value to the second terminal.
上述提到的通信总线可以是外设部件互连标准(Peripheral Component Interconnect,PCI)总线或扩展工业标准结构(Extended Industry Standard Architecture,EISA)总线等。该通信总线可以分为地址总线、数据总线、控制总线等。为便于表示,图中仅用一条粗线表示,但并不表示仅有一根总线 或一种类型的总线。The aforementioned communication bus may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus can be divided into address bus, data bus, control bus and so on. For ease of representation, the figure is only represented by a thick line, but it does not mean that there is only one bus or one type of bus.
通信接口用于上述终端与其他设备之间的通信。The communication interface is used for communication between the aforementioned terminal and other devices.
存储器可以包括随机存取存储器(Random Access Memory,RAM),也可以包括非易失性存储器(Non-Volatile Memory,NVM),例如至少一个磁盘存储器。可选的,存储器还可以是至少一个位于远离前述处理器的存储装置。The memory may include random access memory (Random Access Memory, RAM), and may also include non-volatile memory (Non-Volatile Memory, NVM), such as at least one disk storage. Optionally, the memory may also be at least one storage device located far away from the foregoing processor.
上述的处理器可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(Network Processor,NP)等;还可以是数字信号处理器(Digital Signal Processing,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processing, DSP), a dedicated integrated Circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
由于上述实施例中终端的各器件解决问题的实施方式以及有益效果可以参见图2所示的实施例中的各步骤来实现,因此,本发明实施例提供的终端的具体工作过程和有益效果,在此不复赘述。Since the implementation manners and beneficial effects of the various devices of the terminal in the foregoing embodiment to solve the problem can be achieved by referring to the steps in the embodiment shown in FIG. 2, therefore, the specific working process and beneficial effects of the terminal provided by the embodiment of the present invention are: I won't repeat it here.
在本发明提供的又一实施例中,还提供了一种计算机可读存储介质,该计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述实施例中任一所述的基于联邦学习的模型参数的确定方法。In yet another embodiment provided by the present invention, a computer-readable storage medium is also provided. The computer-readable storage medium stores instructions that, when run on a computer, cause the computer to execute any of the above embodiments. The described method for determining model parameters based on federated learning.
在本发明提供的又一实施例中,还提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述实施例中任一所述的基于联邦学习的模型参数的确定方法。In yet another embodiment provided by the present invention, there is also provided a computer program product containing instructions, which, when run on a computer, causes the computer to execute the model parameters based on federated learning described in any of the above embodiments. Determine the method.
本领域内的技术人员应明白,本申请实施例中的实施例可提供为方法、***、或计算机程序产品。因此,本申请实施例中可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请实施例中可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments in the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the embodiments of the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. .
本申请实施例中是参照根据本申请实施例中实施例的方法、设备(***)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The embodiments of the present application are described with reference to the flowcharts and/or block diagrams of the methods, equipment (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and/or block in the flowchart and/or block diagram, and the combination of processes and/or blocks in the flowchart and/or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing equipment to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing equipment are generated It is a device that realizes the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device. The device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的 处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment. The instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.
尽管已描述了本申请实施例中的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请实施例中范围的所有变更和修改。Although the preferred embodiments of the embodiments of the present application have been described, those skilled in the art can make additional changes and modifications to these embodiments once they learn the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the embodiments of the present application.
显然,本领域的技术人员可以对本申请实施例中实施例进行各种改动和变型而不脱离本申请实施例中实施例的精神和范围。这样,倘若本申请实施例中实施例的这些修改和变型属于本申请实施例中权利要求及其等同技术的范围之内,则本申请实施例中也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various changes and modifications to the embodiments of the present application without departing from the spirit and scope of the embodiments of the present application. In this way, if these modifications and variations of the embodiments in the embodiments of the application fall within the scope of the claims in the embodiments of the application and their equivalent technologies, the embodiments of the application are also intended to include these modifications and variations.

Claims (20)

  1. 一种基于联邦学习的模型参数的确定方法,其特征在于,所述方法包括:A method for determining model parameters based on federated learning, characterized in that the method includes:
    第二终端接收第一终端发送的第一加密数据,所述第一加密数据为所述第一终端根据预设加密算法对标签数据进行加密后得到的;所述标签数据为所述第一终端中任一样本的标签数据,所述标签数据是描述样本行为达到的程度的数据;The second terminal receives the first encrypted data sent by the first terminal, where the first encrypted data is obtained after the first terminal encrypts the label data according to a preset encryption algorithm; the label data is the first terminal The label data of any sample in, where the label data is data describing the extent to which the behavior of the sample reaches;
    根据所述第一加密数据、所述第二终端的样本特征数据和所述样本特征数据的当前特征参数,采用预设算法,获取第二加密数据,所述第二加密数据包括加密梯度值和加密损失值,所述预设算法包括预设梯度值算法和预设损失值算法,所述样本特征数据是样本行为的特征数据;According to the first encrypted data, the sample characteristic data of the second terminal, and the current characteristic parameters of the sample characteristic data, a preset algorithm is used to obtain second encrypted data, where the second encrypted data includes an encryption gradient value and Encryption loss value, the preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm, and the sample characteristic data is characteristic data of sample behavior;
    向所述第一终端发送所述第二加密数据;Sending the second encrypted data to the first terminal;
    接收所述第一终端根据所述第二加密数据发送的第一梯度值和第一损失值;Receiving the first gradient value and the first loss value sent by the first terminal according to the second encrypted data;
    根据所述第一梯度值和所述样本特征数据的当前特征参数,采用预设特征参数算法,获取第一特征参数;According to the first gradient value and the current characteristic parameter of the sample characteristic data, a preset characteristic parameter algorithm is adopted to obtain the first characteristic parameter;
    若根据所述第一损失值,检测出所述第一特征参数处于收敛状态,则将所述第一特征参数确定为待训练的样本模型的模型参数。If it is detected that the first characteristic parameter is in a convergent state according to the first loss value, the first characteristic parameter is determined as the model parameter of the sample model to be trained.
  2. 如权利要求1所述的方法,其特征在于,所述方法还包括:The method of claim 1, wherein the method further comprises:
    若根据所述第一损失值,检测出第一特征参数未处于收敛状态,则将获取的所述第一特征参数确定为新的当前特征参数;If it is detected that the first characteristic parameter is not in a convergent state according to the first loss value, the acquired first characteristic parameter is determined as a new current characteristic parameter;
    根据所述第一加密数据、样本特征数据和所述新的当前特征参数,采用预设算法,获取新的第二加密数据,所述新的第二加密数据包括新的加密梯度值和新的加密损失值;According to the first encrypted data, the sample characteristic data, and the new current characteristic parameters, a preset algorithm is used to obtain new second encrypted data. The new second encrypted data includes a new encryption gradient value and a new Encryption loss value;
    向所述第一终端发送所述新的第二加密数据;Sending the new second encrypted data to the first terminal;
    接收所述第一终端根据所述新的第二加密数据发送的第二梯度值和第二损失值;Receiving the second gradient value and the second loss value sent by the first terminal according to the new second encrypted data;
    根据所述第二梯度值和所述新的当前特征参数,采用预设特征参数算法,获取第二特征参数;According to the second gradient value and the new current characteristic parameter, using a preset characteristic parameter algorithm to obtain the second characteristic parameter;
    若根据所述第一损失值与所述第二损失值的差值,检测所述第二特征参数处于收敛状态,则将所述第二特征参数确定为所述待训练的样本模型的模型参数。If it is detected that the second characteristic parameter is in a convergent state according to the difference between the first loss value and the second loss value, the second characteristic parameter is determined as the model parameter of the sample model to be trained .
  3. 如权利要求1所述的方法,其特征在于,根据所述第一加密数据、样本特征数据和所述样本特征数据的当前特征参数,采用预设算法,获取所述样本标识对应的第二加密数据,包括:The method of claim 1, wherein a preset algorithm is used to obtain the second encrypted data corresponding to the sample identification according to the first encrypted data, the sample characteristic data, and the current characteristic parameters of the sample characteristic data. Data, including:
    根据所述第一加密数据、样本特征数据、所述样本特征数据的当前特征参数和预设随机数,采用预设算法,获取第二加密数据,所述预设随机数包括所述预设梯度值算法对应的第一随机数和所述预设损失值算法对应的第二随机数;According to the first encrypted data, the sample characteristic data, the current characteristic parameters of the sample characteristic data, and a preset random number, a preset algorithm is used to obtain the second encrypted data, and the preset random number includes the preset gradient A first random number corresponding to the value algorithm and a second random number corresponding to the preset loss value algorithm;
    接收所述第一终端根据所述第二加密数据发送的第一梯度值和第一损失值之后,所述方法还包括:After receiving the first gradient value and the first loss value sent by the first terminal according to the second encrypted data, the method further includes:
    根据所述预设随机数、第一梯度值和第一损失值,获取新的第一梯度值和新的第一损失值,之后执行获取第一特征参数的步骤。According to the preset random number, the first gradient value, and the first loss value, a new first gradient value and a new first loss value are acquired, and then the step of acquiring the first characteristic parameter is performed.
  4. 如权利要求1所述的方法,其特征在于,将所述第一特征参数确定为所述待训练的样本模型的模型参数之后,所述方法还包括:The method according to claim 1, wherein after the first characteristic parameter is determined as the model parameter of the sample model to be trained, the method further comprises:
    接收第一终端发送的预测请求,所述预测请求包括样本标识;Receiving a prediction request sent by the first terminal, where the prediction request includes a sample identifier;
    根据所述样本标识对应的样本特征数据和所述样本特征数据的当前特征参数,获取所述样本标识对应的样本预测分数;Acquiring the sample prediction score corresponding to the sample identifier according to the sample characteristic data corresponding to the sample identifier and the current characteristic parameter of the sample characteristic data;
    向第一终端发送所述样本预测分数。Send the sample prediction score to the first terminal.
  5. 如权利要求1所述的方法,其特征在于,所述预设算法包括预设梯度值算法和预设损失值算法;The method according to claim 1, wherein the preset algorithm comprises a preset gradient value algorithm and a preset loss value algorithm;
    所述预设梯度值算法的公式表示为:The formula of the preset gradient value algorithm is expressed as:
    Figure PCTCN2019122824-appb-100001
    Figure PCTCN2019122824-appb-100001
    所述预设损失值算法的公式表示为:The formula of the preset loss value algorithm is expressed as:
    Figure PCTCN2019122824-appb-100002
    Figure PCTCN2019122824-appb-100002
    其中,x为所述第二终端的样本特征数据,y为所述第一终端的样本特征数据,g(w)为预设梯度值、l(w)为预设损失值、w为特征参数。Where x is the sample feature data of the second terminal, y is the sample feature data of the first terminal, g(w) is the preset gradient value, l(w) is the preset loss value, and w is the feature parameter .
  6. 一种基于联邦学习的模型参数的确定方法,其特征在于,所述方法包括:A method for determining model parameters based on federated learning, characterized in that the method includes:
    第一终端向第二终端发送第一加密数据,所述第一加密数据为所述第一终端根据预设加密算法对标签数据进行加密后得到的;所述标签数据为所述第一终端中任一样本的标签数据,所述标签数据是描述样本行为达到的程度的数据;The first terminal sends first encrypted data to the second terminal, where the first encrypted data is obtained after the first terminal encrypts the label data according to a preset encryption algorithm; the label data is in the first terminal Label data of any sample, where the label data is data describing the extent to which the behavior of the sample reaches;
    接收所述第二终端根据所述第一加密数据发送的第二加密数据,所述第二加密数据包括加密梯度和加密损失值;Receiving second encrypted data sent by the second terminal according to the first encrypted data, where the second encrypted data includes an encryption gradient and an encryption loss value;
    采用所述预设解密算法,分别对所述加密梯度和所述加密损失值进行解密,得到第一梯度值和第一损失值,所述预设加密算法和所述预设解密算法为互逆算法;The preset decryption algorithm is used to decrypt the encryption gradient and the encryption loss value respectively to obtain a first gradient value and a first loss value, and the preset encryption algorithm and the preset decryption algorithm are reciprocal algorithm;
    向所述第二终端发送所述第一梯度值和第一损失值。Sending the first gradient value and the first loss value to the second terminal.
  7. 如权利要求6所述的方法,其特征在于,所述方法还包括:The method of claim 6, wherein the method further comprises:
    若所述第二终端根据所述第一损失值,检测出第一特征参数未处于收敛状态,则接收第二终端发送的新的第二加密数据,所述新的第二加密数据包括新的加密梯度值和新的加密损失值,所述新的第二加密数据为所述第二终端根据所述第一加密数据、所述第二终端的样本特征数据和新的当前特征参数,采用预设算法获取的,所述新的当前特征参数为所述第二终端根据所述第一损失值对应的所述第一梯度值和所述样本特征数据的当前特征参数,采 用预设特征参数算法获取的,所述样本特征数据是样本行为的特征数据;If the second terminal detects that the first characteristic parameter is not in a convergent state according to the first loss value, then it receives new second encrypted data sent by the second terminal, and the new second encrypted data includes new The encryption gradient value and the new encryption loss value, the new second encrypted data is that the second terminal adopts the preset according to the first encrypted data, the sample characteristic data of the second terminal, and new current characteristic parameters. Assuming that the new current characteristic parameter is acquired by an algorithm, the second terminal uses a preset characteristic parameter algorithm according to the first gradient value corresponding to the first loss value and the current characteristic parameter of the sample characteristic data Obtained, the sample characteristic data is characteristic data of sample behavior;
    采用所述预设解密算法,分别对所述新的加密梯度值和所述新的加密损失值进行解密,得到第二梯度值和第二损失值;Using the preset decryption algorithm to decrypt the new encryption gradient value and the new encryption loss value to obtain a second gradient value and a second loss value;
    向所述第二终端发送所述第二梯度值和第二损失值。Sending the second gradient value and the second loss value to the second terminal.
  8. 如权利要求6所述的方法,其特征在于,向第二终端发送所述第一梯度值和第一损失值之后,所述方法还包括:The method according to claim 6, wherein after sending the first gradient value and the first loss value to the second terminal, the method further comprises:
    向第二终端发送预测请求,所述预测请求包括样本标识;Sending a prediction request to the second terminal, where the prediction request includes a sample identifier;
    接收所述第二终端发送的所述样本标识对应的样本预测分数,所述样本预测分数是第二终端根据所述样本标识对应的样本特征数据和所述样本特征数据的当前特征参数获得的;Receiving a sample prediction score corresponding to the sample identifier sent by the second terminal, where the sample prediction score is obtained by the second terminal according to the sample feature data corresponding to the sample identifier and the current feature parameter of the sample feature data;
    根据所述样本预测分数和预设测试算法,获取所述样本模型的模型分数;Obtaining the model score of the sample model according to the sample prediction score and a preset test algorithm;
    若所述模型分数小于预设分数阈值,则确定所述样本模型为正常样本模型。If the model score is less than a preset score threshold, it is determined that the sample model is a normal sample model.
  9. 如权利要求7所述的方法,其特征在于,所述预设特征参数算法表示为:W n+1=w n-η*g; 8. The method of claim 7, wherein the preset characteristic parameter algorithm is expressed as: W n+1 =w n -η*g;
    其中,g为梯度值,W n+1为梯度值g对应的特征参数,w n为当前特征参数,η为预设系数。 Among them, g is the gradient value, W n+1 is the characteristic parameter corresponding to the gradient value g, w n is the current characteristic parameter, and η is the preset coefficient.
  10. 一种基于联邦学习的模型参数的确定装置,其特征在于,所述装置包括:接收单元、获取单元、发送单元和确定单元;A device for determining model parameters based on federated learning, characterized in that the device includes: a receiving unit, an acquiring unit, a sending unit, and a determining unit;
    所述接收单元,用于接收第一终端发送的第一加密数据,所述第一加密数据为所述第一终端根据预设加密算法对标签数据进行加密后得到的;所述标签数据为所述第一终端中任一样本的标签数据,所述标签数据是描述样本行为达到的程度的数据;The receiving unit is configured to receive first encrypted data sent by a first terminal, where the first encrypted data is obtained after the first terminal encrypts label data according to a preset encryption algorithm; and the label data is obtained by Label data of any sample in the first terminal, where the label data is data describing the extent to which the sample behavior reaches;
    所述获取单元,用于根据所述第一加密数据、样本特征数据和所述样本特征数据的当前特征参数,采用预设算法,获取第二加密数据,所述第二加密数据包括加密梯度值和加密损失值,所述预设算法包括预设梯度值算法和预设损失值算法,所述样本特征数据是样本行为的特征数据;The acquiring unit is configured to use a preset algorithm to acquire second encrypted data according to the first encrypted data, sample characteristic data, and current characteristic parameters of the sample characteristic data, where the second encrypted data includes an encrypted gradient value And encryption loss value, the preset algorithm includes a preset gradient value algorithm and a preset loss value algorithm, and the sample characteristic data is characteristic data of sample behavior;
    所述发送单元,用于向所述第一终端发送所述第二加密数据;The sending unit is configured to send the second encrypted data to the first terminal;
    所述接收单元,还用于接收所述第一终端根据所述第二加密数据发送的第一梯度值和第一损失值;The receiving unit is further configured to receive the first gradient value and the first loss value sent by the first terminal according to the second encrypted data;
    所述获取单元,还用于根据所述第一梯度值和所述样本特征数据的当前特征参数,采用预设特征参数算法,获取第一特征参数;The acquiring unit is further configured to use a preset characteristic parameter algorithm to acquire the first characteristic parameter according to the first gradient value and the current characteristic parameter of the sample characteristic data;
    所述确定单元,用于若根据所述第一损失值,检测出所述第一特征参数处于收敛状态,则将所述第一特征参数确定为待训练的样本模型的模型参数。The determining unit is configured to determine the first characteristic parameter as a model parameter of the sample model to be trained if it is detected that the first characteristic parameter is in a convergent state according to the first loss value.
  11. 如权利要求10所述的装置,其特征在于,The device of claim 10, wherein:
    所述确定单元,还用于若根据所述第一损失值,检测出第一特征参数未处于收敛状态,则将获取的所述第一特征参数确定为新的当前特征参数;The determining unit is further configured to, if it is detected that the first characteristic parameter is not in a convergent state according to the first loss value, determine the acquired first characteristic parameter as a new current characteristic parameter;
    所述获取单元,还用于根据所述第一加密数据、样本特征数据和所述新的当前特征参数,采用预设算法,获取新的第二加密数据,所述新的第二加密数据包括新的加密梯度值和新的加密损失值;The acquiring unit is further configured to use a preset algorithm to acquire new second encrypted data according to the first encrypted data, sample characteristic data, and the new current characteristic parameters, where the new second encrypted data includes New encryption gradient value and new encryption loss value;
    所述发送单元,还用于向所述第一终端发送所述新的第二加密数据;The sending unit is further configured to send the new second encrypted data to the first terminal;
    所述接收单元,还用于接收所述第一终端根据所述新的第二加密数据发送的第二梯度值和第二损失值;The receiving unit is further configured to receive a second gradient value and a second loss value sent by the first terminal according to the new second encrypted data;
    所述获取单元,还用于根据所述第二梯度值和所述新的当前特征参数,采用预设特征参数算法,获取第二特征参数;The acquiring unit is further configured to use a preset characteristic parameter algorithm to acquire a second characteristic parameter according to the second gradient value and the new current characteristic parameter;
    所述确定单元,还用于若根据所述第一损失值与所述第二损失值的差值,检测所述第二特征参数处于收敛状态,则将所述第二特征参数确定为所述待训练的样本模型的模型参数。The determining unit is further configured to determine that the second characteristic parameter is the second characteristic parameter if it is detected that the second characteristic parameter is in a convergent state according to the difference between the first loss value and the second loss value The model parameters of the sample model to be trained.
  12. 如权利要求10所述的装置,其特征在于,所述获取单元,还用于根据所述第一加密数据、样本特征数据、所述样本特征数据的当前特征参数和预设随机数,采用预设算法,获取所述样本的第二加密数据,所述预设随机数包括所述预设梯度值算法对应的第一随机数和所述预设损失值算法对应的第二随机数;The device according to claim 10, wherein the acquiring unit is further configured to use a preset random number according to the first encrypted data, sample characteristic data, current characteristic parameters of the sample characteristic data, and preset random numbers. Set an algorithm to obtain the second encrypted data of the sample, and the preset random number includes a first random number corresponding to the preset gradient value algorithm and a second random number corresponding to the preset loss value algorithm;
    根据所述预设随机数、第一梯度值和第一损失值,获取新的第一梯度值和新的第一损失值,之后执行获取第一特征参数的步骤。According to the preset random number, the first gradient value, and the first loss value, a new first gradient value and a new first loss value are acquired, and then the step of acquiring the first characteristic parameter is performed.
  13. 如权利要求10所述的装置,其特征在于,The device of claim 10, wherein:
    所述接收单元,还用于接收第一终端发送的预测请求,所述预测请求包括样本标识;The receiving unit is further configured to receive a prediction request sent by the first terminal, where the prediction request includes a sample identifier;
    所述获取单元,还用于根据所述样本标识对应的样本特征数据和所述样本特征数据的当前特征参数,获取所述样本标识对应的样本预测分数;The acquiring unit is further configured to acquire the sample prediction score corresponding to the sample identifier according to the sample characteristic data corresponding to the sample identifier and the current characteristic parameter of the sample characteristic data;
    所述发送单元,还用于向第一终端发送所述样本预测分数。The sending unit is further configured to send the sample prediction score to the first terminal.
  14. 如权利要求10所述的装置,其特征在于,所述预设算法包括预设梯度值算法和预设损失值算法;10. The device of claim 10, wherein the preset algorithm comprises a preset gradient value algorithm and a preset loss value algorithm;
    所述预设梯度值算法的公式表示为:The formula of the preset gradient value algorithm is expressed as:
    Figure PCTCN2019122824-appb-100003
    Figure PCTCN2019122824-appb-100003
    所述预设损失值算法的公式表示为:The formula of the preset loss value algorithm is expressed as:
    Figure PCTCN2019122824-appb-100004
    Figure PCTCN2019122824-appb-100004
    其中,x为所述第二终端的样本特征数据,y为所述第一终端的样本特征数据,g(w)为预设梯度值、l(w)为预设损失值、w为特征参数。Where x is the sample feature data of the second terminal, y is the sample feature data of the first terminal, g(w) is the preset gradient value, l(w) is the preset loss value, and w is the feature parameter .
  15. 一种基于联邦学习的模型参数的确定装置,其特征在于,所述装置包括:发送单元、接收单元和解密单元;A device for determining model parameters based on federated learning, characterized in that the device includes: a sending unit, a receiving unit, and a decrypting unit;
    所述发送单元,用于向第二终端发送第一加密数据,所述第一加密数据为所述第一终端根据预设加密算法对标签数据进行加密后得到的;所述标签数据为所述第一终端中任一样本的标签数据,所述标签数据是描述样本行为达到的程度的数据;The sending unit is configured to send first encrypted data to a second terminal, where the first encrypted data is obtained after the first terminal encrypts label data according to a preset encryption algorithm; the label data is the Label data of any sample in the first terminal, where the label data is data describing the extent to which the sample behavior reaches;
    所述接收单元,用于接收所述第二终端根据所述第一加密数据发送的第 二加密数据,所述第二加密数据包括加密梯度和加密损失值;The receiving unit is configured to receive second encrypted data sent by the second terminal according to the first encrypted data, where the second encrypted data includes an encryption gradient and an encryption loss value;
    所述解密单元,用于采用所述预设解密算法,分别对所述加密梯度和所述加密损失值进行解密,得到第一梯度值和第一损失值,所述预设加密算法和所述预设解密算法为互逆算法;The decryption unit is configured to use the preset decryption algorithm to decrypt the encryption gradient and the encryption loss value respectively to obtain a first gradient value and a first loss value, the preset encryption algorithm and the The preset decryption algorithm is a reciprocal algorithm;
    所述发送单元,还用于向所述第二终端发送所述第一梯度值和第一损失值。The sending unit is further configured to send the first gradient value and the first loss value to the second terminal.
  16. 如权利要求15所述的装置,其特征在于,所述接收单元,还用于若所述第二终端根据所述第一损失值,检测出第一特征参数未处于收敛状态,则接收第二终端发送的新的第二加密数据,所述新的第二加密数据包括新的加密梯度值和新的加密损失值,所述新的第二加密数据为所述第二终端根据所述第一加密数据、所述第二终端的样本特征数据和新的当前特征参数,采用预设算法获取的,所述新的当前特征参数为所述第二终端根据所述第一损失值对应的所述第一梯度值和所述样本特征数据的当前特征参数,采用预设特征参数算法获取的,所述样本特征数据是样本行为的特征数据;The apparatus according to claim 15, wherein the receiving unit is further configured to: if the second terminal detects that the first characteristic parameter is not in a convergent state according to the first loss value, then receive a second The new second encrypted data sent by the terminal, the new second encrypted data includes a new encryption gradient value and a new encryption loss value, the new second encrypted data is the second terminal according to the first The encrypted data, the sample characteristic data of the second terminal, and the new current characteristic parameter are acquired by using a preset algorithm, and the new current characteristic parameter is the second terminal corresponding to the first loss value according to the The first gradient value and the current characteristic parameters of the sample characteristic data are obtained by using a preset characteristic parameter algorithm, and the sample characteristic data is characteristic data of sample behavior;
    所述解密单元,还用于采用所述预设解密算法,分别对所述新的加密梯度值和所述新的加密损失值进行解密,得到第二梯度值和第二损失值;The decryption unit is further configured to use the preset decryption algorithm to decrypt the new encryption gradient value and the new encryption loss value respectively to obtain a second gradient value and a second loss value;
    所述发送单元,还用于向所述第二终端发送所述第二梯度值和第二损失值。The sending unit is further configured to send the second gradient value and the second loss value to the second terminal.
  17. 如权利要求15所述的装置,其特征在于,所述装置还包括获取单元和确定单元;15. The device according to claim 15, wherein the device further comprises an acquiring unit and a determining unit;
    所述发送单元,还用于向第二终端发送预测请求,所述预测请求包括样本标识;The sending unit is further configured to send a prediction request to the second terminal, where the prediction request includes a sample identifier;
    所述接收单元,还用于接收所述第二终端发送的所述样本标识对应的样本预测分数,所述样本预测分数是第二终端根据所述样本标识对应的样本特征数据和所述样本特征数据的当前特征参数获得的;The receiving unit is further configured to receive a sample prediction score corresponding to the sample identifier sent by the second terminal, where the sample prediction score is the sample feature data corresponding to the sample identifier and the sample feature by the second terminal The current characteristic parameters of the data are obtained;
    所述获取单元,用于根据所述样本预测分数和预设测试算法,获取所述样本模型的模型分数;The obtaining unit is configured to obtain the model score of the sample model according to the sample prediction score and a preset test algorithm;
    所述确定单元,用于若所述模型分数小于预设分数阈值,则确定所述样本模型为正常样本模型。The determining unit is configured to determine that the sample model is a normal sample model if the model score is less than a preset score threshold.
  18. 如权利要求16所述的装置,其特征在于,所述预设特征参数算法表示为:Wn+1=wn-η*g;The device of claim 16, wherein the preset characteristic parameter algorithm is expressed as: Wn+1=wn-η*g;
    其中,g为梯度值,W n+1为梯度值g对应的特征参数,w n为当前特征参数,η为预设系数。 Among them, g is the gradient value, W n+1 is the characteristic parameter corresponding to the gradient value g, w n is the current characteristic parameter, and η is the preset coefficient.
  19. 一种终端,其特征在于,所述终端包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;A terminal, characterized in that the terminal includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete mutual communication through the communication bus;
    存储器,用于存放计算机程序;Memory, used to store computer programs;
    处理器,用于执行存储器上所存储的程序时,实现权利要求1-5任一所述的方法步骤或实现权利要求6-9任一所述的方法步骤。The processor is configured to implement the method steps described in any one of claims 1-5 or implement the method steps described in any one of claims 6-9 when executing the program stored on the memory.
  20. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质 内存储有计算机程序,所述计算机程序被处理器执行时实现权利要求1-5任一所述的方法步骤或实现权利要求6-9任一所述的方法步骤。A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method steps or realization rights of any one of claims 1-5 are Requires any of the method steps described in 6-9.
PCT/CN2019/122824 2019-06-12 2019-12-03 Model parameter determination method and apparatus based on federated learning WO2020248537A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910507242.2 2019-06-12
CN201910507242.2A CN110276210B (en) 2019-06-12 2019-06-12 Method and device for determining model parameters based on federal learning

Publications (1)

Publication Number Publication Date
WO2020248537A1 true WO2020248537A1 (en) 2020-12-17

Family

ID=67960754

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/122824 WO2020248537A1 (en) 2019-06-12 2019-12-03 Model parameter determination method and apparatus based on federated learning

Country Status (2)

Country Link
CN (1) CN110276210B (en)
WO (1) WO2020248537A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115021985A (en) * 2022-05-23 2022-09-06 北京融数联智科技有限公司 Logistic regression model training method and system without third party participation

Families Citing this family (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110276210B (en) * 2019-06-12 2021-04-23 深圳前海微众银行股份有限公司 Method and device for determining model parameters based on federal learning
CN110688419A (en) * 2019-10-09 2020-01-14 京东城市(南京)科技有限公司 Federated modeling system and federated modeling method
CN110728375B (en) * 2019-10-16 2021-03-19 支付宝(杭州)信息技术有限公司 Method and device for training logistic regression model by combining multiple computing units
CN110837653B (en) * 2019-11-07 2023-09-19 深圳前海微众银行股份有限公司 Label prediction method, apparatus and computer readable storage medium
CN110990857B (en) * 2019-12-11 2021-04-06 支付宝(杭州)信息技术有限公司 Multi-party combined feature evaluation method and device for protecting privacy and safety
CN110955907B (en) * 2019-12-13 2022-03-25 支付宝(杭州)信息技术有限公司 Model training method based on federal learning
CN110995737B (en) * 2019-12-13 2022-08-02 支付宝(杭州)信息技术有限公司 Gradient fusion method and device for federal learning and electronic equipment
CN111144576A (en) * 2019-12-13 2020-05-12 支付宝(杭州)信息技术有限公司 Model training method and device and electronic equipment
CN111178538B (en) * 2019-12-17 2023-08-15 杭州睿信数据科技有限公司 Federal learning method and device for vertical data
CN111160961B (en) * 2019-12-20 2023-10-17 深圳前海微众银行股份有限公司 Information recommendation method and device
CN111143878B (en) * 2019-12-20 2021-08-03 支付宝(杭州)信息技术有限公司 Method and system for model training based on private data
CN111125735B (en) * 2019-12-20 2021-11-02 支付宝(杭州)信息技术有限公司 Method and system for model training based on private data
CN111401621B (en) * 2020-03-10 2023-06-23 深圳前海微众银行股份有限公司 Prediction method, device, equipment and storage medium based on federal learning
CN111460528B (en) * 2020-04-01 2022-06-14 支付宝(杭州)信息技术有限公司 Multi-party combined training method and system based on Adam optimization algorithm
CN111460511B (en) * 2020-04-17 2023-05-02 支付宝(杭州)信息技术有限公司 Federal learning and virtual object distribution method and device based on privacy protection
CN111368336B (en) * 2020-05-27 2020-09-04 支付宝(杭州)信息技术有限公司 Secret sharing-based training method and device, electronic equipment and storage medium
CN111800265B (en) * 2020-07-07 2021-06-25 上海大学 Privacy protection-based material reverse design method and system
CN112257105B (en) * 2020-10-19 2022-01-11 中山大学 Federal learning method and system based on parameter replacement algorithm
CN112257063B (en) * 2020-10-19 2022-09-02 上海交通大学 Cooperative game theory-based detection method for backdoor attacks in federal learning
CN112989929B (en) * 2021-02-04 2022-08-09 支付宝(杭州)信息技术有限公司 Target user identification method and device and electronic equipment
CN112733967B (en) * 2021-03-30 2021-06-29 腾讯科技(深圳)有限公司 Model training method, device, equipment and storage medium for federal learning
CN113378198B (en) * 2021-06-24 2022-04-15 深圳市洞见智慧科技有限公司 Federal training system, method and device for model for protecting user identification
CN113722738B (en) * 2021-09-02 2023-08-08 脸萌有限公司 Data protection method, device, medium and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109165515A (en) * 2018-08-10 2019-01-08 深圳前海微众银行股份有限公司 Model parameter acquisition methods, system and readable storage medium storing program for executing based on federation's study
US20190108417A1 (en) * 2017-10-05 2019-04-11 Parallel Machines, Inc. Machine learning abstraction
CN109635462A (en) * 2018-12-17 2019-04-16 深圳前海微众银行股份有限公司 Model parameter training method, device, equipment and medium based on federation's study
CN110276210A (en) * 2019-06-12 2019-09-24 深圳前海微众银行股份有限公司 Based on the determination method and device of the model parameter of federation's study

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109492420B (en) * 2018-12-28 2021-07-20 深圳前海微众银行股份有限公司 Model parameter training method, terminal, system and medium based on federal learning

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190108417A1 (en) * 2017-10-05 2019-04-11 Parallel Machines, Inc. Machine learning abstraction
CN109165515A (en) * 2018-08-10 2019-01-08 深圳前海微众银行股份有限公司 Model parameter acquisition methods, system and readable storage medium storing program for executing based on federation's study
CN109635462A (en) * 2018-12-17 2019-04-16 深圳前海微众银行股份有限公司 Model parameter training method, device, equipment and medium based on federation's study
CN110276210A (en) * 2019-06-12 2019-09-24 深圳前海微众银行股份有限公司 Based on the determination method and device of the model parameter of federation's study

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115021985A (en) * 2022-05-23 2022-09-06 北京融数联智科技有限公司 Logistic regression model training method and system without third party participation
CN115021985B (en) * 2022-05-23 2023-06-16 北京融数联智科技有限公司 Logistic regression model training method and system without third party participation

Also Published As

Publication number Publication date
CN110276210A (en) 2019-09-24
CN110276210B (en) 2021-04-23

Similar Documents

Publication Publication Date Title
WO2020248537A1 (en) Model parameter determination method and apparatus based on federated learning
WO2020248538A1 (en) Federated learning-based model parameter training method and device
US20210248244A1 (en) Model parameter training method, terminal, and system based on federation learning, and medium
CN110399742B (en) Method and device for training and predicting federated migration learning model
WO2020177392A1 (en) Federated learning-based model parameter training method, apparatus and device, and medium
US11989634B2 (en) Private federated learning with protection against reconstruction
CN113505894A (en) Longitudinal federated learning linear regression and logistic regression model training method and device
WO2022116491A1 (en) Dbscan clustering method based on horizontal federation, and related device therefor
CN112149174B (en) Model training method, device, equipment and medium
WO2021114932A1 (en) Private data protection-based service risk control method, apparatus, platform, and system
CN107204997A (en) The method and apparatus for managing cloud storage data
CN113434898B (en) Non-interactive privacy protection logistic regression federal training method and system
US20230068770A1 (en) Federated model training method and apparatus, electronic device, computer program product, and computer-readable storage medium
WO2023216494A1 (en) Federated learning-based user service strategy determination method and apparatus
CN112149706A (en) Model training method, device, equipment and medium
CN110750520A (en) Feature data processing method, device and equipment and readable storage medium
CN115130121A (en) Method for training longitudinal logistic regression model under privacy calculation of third party
CN112906052B (en) Aggregation method of multi-user gradient permutation in federated learning
CN112001452B (en) Feature selection method, device, equipment and readable storage medium
CN117171779A (en) Data processing device based on intersection protection
CN112149141B (en) Model training method, device, equipment and medium
CN112149834A (en) Model training method, device, equipment and medium
CN115599959A (en) Data sharing method, device, equipment and storage medium
CN112257081B (en) Longitudinal federal standard deviation comprehensive scoring method, system, medium and equipment
CN112149140B (en) Prediction method, prediction device, prediction equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19933172

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19933172

Country of ref document: EP

Kind code of ref document: A1