Deep understanding of federated learning - vertical federated learning

Category Catalog: "In-depth Understanding of Federated Learning" General Catalog


Assume that the data provider for federated learning is AAA andBBB , the third party isCCC , then the steps of vertical federated learning are as follows:

  1. Encrypted sample alignment is performed at the system level, and non-crossing users will not be exposed at the enterprise perception level.
  2. Align samples for model encryption training:
    • CC by third partyC toAAA andBBB sends the public key to encrypt the data that needs to be transmitted;
    • A A A andBBB respectively calculates the intermediate results of features related to itself and encrypts the interaction.
    • A AA andBBB calculates their respective encrypted gradients and adds masks and sends them toCC.C , while owning the class standard side, calculate the encrypted loss and send it toCCC
    • C C C decrypts the gradient and loss and passes it back toAAA andBBB
    • A AA andBBB remove the mask and update the model

vertical federated learning

We take ridge regression as an example to illustrate the training process of longitudinal federated learning. Suppose there is a data set { xi A } ( i ∈ DA ) \{x_i^A\}(i\in D_A){ xiA}(iDA) 和数据集 { x i B , y i B } ( i ∈ D B ) \{x_i^B, y_i^B\}(i\in D_B) { xiB,yiB}(iDB) , whereBBB is the data owner with the class label. We take linear regression as an example to illustrate the training process of vertical federated learning:

  1. A A A andBBB initialize the model parametersΘ A \Theta_AThAΘ B \Theta_BThBFor example: min ⁡ Θ A , Θ B ∑ i ( Θ A xi A + Θ B xi B − yi ) 2 + λ 2 ( ∣ ∣ Θ A ∣ ∣ 2 + ∣ ∣ Θ B ∣ ∣ 2 ) \ min_{\Theta_A, \Theta_B}\sum_i(\Theta_Ax_i^A+\Theta_Bx_i^B-y_i)^2+\frac{\lambda}{2}(||\Theta_A||^2+||\Theta_B|| ^2)ThA, ThBmini( ThAxiA+ThBxiByi)2+2l(∣∣ΘA2+∣∣ΘB2)
  2. u i A = Θ A x i A u_i^A=\Theta_Ax_i^A uiA=ThAxiAsumui B = Θ B xi B u_i^B=\Theta_Bx_i^BuiB=ThBxiB, then the original objective function is homomorphically encrypted ( [ [ ⋅ ] ] [[\cdot]][[]]表示同态加密)可表示为: [ [ L ] ] = [ [ ∑ i ( u i A + u i B − y i ) 2 + λ 2 ( ∣ ∣ Θ A ∣ ∣ 2 + ∣ ∣ Θ B ∣ ∣ 2 ) ] ] = [ [ ∑ i ( u i A ) 2 + λ 2 ∣ ∣ Θ A ∣ ∣ 2 ] ] + [ [ ∑ i ( ( u i B − y i ) 2 ) + λ 2 ∣ ∣ Θ B ∣ ∣ 2 ] ] + 2 ∑ i ( [ [ u i A ] ] ( u i B − y i ) ) \begin{aligned}[[L]] &= [[\sum_i(u_i^A+u_i^B-y_i)^2+\frac{\lambda}{2}(||\Theta_A||^2+||\Theta_B||^2)]]\\&=[[\sum_i(u_i^A)^2+\frac{\lambda}{2}||\Theta_A||^2]]+[[\sum_i((u_i^B-y_i)^2)+\frac{\lambda}{2}||\Theta_B||^2]]+2\sum_i([[u_i^A]](u_i^B-y_i))\end{aligned} [[L]]=[[i(uiA+uiByi)2+2l(∣∣ΘA2+∣∣ΘB2)]]=[[i(uiA)2+2l∣∣ΘA2]]+[[i((uiByi)2)+2l∣∣ΘB2]]+2i([[uiA]](uiByi))
  3. 我们令: [ [ L A ] ] = [ [ ∑ i ( u i A ) 2 + λ 2 ∣ ∣ Θ A ∣ ∣ 2 ] ] [ [ L B ] ] = [ [ ∑ i ( ( u i B − y i ) 2 ) + λ 2 ∣ ∣ Θ B ∣ ∣ 2 ] ] [ [ L A B = 2 ∑ i ( [ [ u i A ] ] ( u i B − y i ) ) ] ] [ [ d i ] ] = [ [ u i A ] ] + [ [ u i B − y i ] ] \begin{aligned}[[L_A]]&=[[\sum_i(u_i^A)^2+\frac{\lambda}{2}||\Theta_A||^2]] \\ [[L_B]]&=[[\sum_i((u_i^B-y_i)^2)+\frac{\lambda}{2}||\Theta_B||^2]] \\ [[L_{AB}&=2\sum_i([[u_i^A]](u_i^B-y_i))]] \\ [[d_i]]&=[[u_i^A]]+[[u_i^B-y_i]]\end{aligned} [[LA]][[LB]][[LAB[[di]]=[[i(uiA)2+2l∣∣ΘA2]]=[[i((uiByi)2)+2l∣∣ΘB2]]=2i([[uiA]](uiByi))]]=[[uiA]]+[[uiByi]][ [ L ] ] = [ [ LA ] ] + [ [ LB ] ] + [ [ LAB ] ] [[L]]=[[L_A]]+[[L_B]]+[[L_{AB}]][[L]]=[[LA]]+[[LB]]+[[LAB]]
  4. 计算梯度: [ [ ∂ L ∂ Θ A ] ] = ∑ i [ [ d i ] ] x i A + [ [ λ Θ A ] ] [ [ ∂ L ∂ Θ B ] ] = ∑ i [ [ d i ] ] x i B + [ [ λ Θ B ] ] \begin{aligned}[[\frac{\partial L}{\partial\Theta_A}]]&=\sum_i[[d_i]]x_i^A+[[\lambda\Theta_A]]\\ [[\frac{\partial L}{\partial\Theta_B}]]&=\sum_i[[d_i]]x_i^B+[[\lambda\Theta_B]]\end{aligned} [[ΘAL]][[ΘBL]]=i[[di]]xiA+[[ λ ThA]]=i[[di]]xiB+[[ λ ThB]]

The data provider is AAA andBBB and the third party areCCC. The training steps of vertical federated learning are as follows:

\qquad\quad The data provider is AAA The data provider is BBB The third party is CCC
Step 1 11 Initialization parameter Θ A \Theta_AThA Initialization parameter Θ B \Theta_BThB Create an encryption key pair and send the public key to the data provider as AAA andBBB
Step 2 22 Calculation [ [ u IA ] ] [[u_I^A]][[uIA]] Sum[ [ LA ] ] [[L_A]][[LA]] and sent to data providerBBB Calculation [ [ u IB ] ] [[u_I^B]][[uIB]] [ [ d i ] ] [[d_i]] [[di]] and[ [ L ] ] [[L]][[ L ]] and[ [ di ] ] [[d_i]][[di]] Sent to data providerAAA , will[[L]][[L]][[ L ]] Send to third partyCCC
Step 3 33 Initialization mask RA R_ARA,计算 [ [ ∂ L ∂ Θ A ] ] + [ [ R A ] ] [[\frac{\partial L}{\partial\Theta_A}]]+[[R_A]] [[ΘAL]]+[[RA]] and send it to the third partyCCC Initialization mask RB R_BRB,计算 [ [ ∂ L ∂ Θ B ] ] + [ [ R B ] ] [[\frac{\partial L}{\partial\Theta_B}]]+[[R_B]] [[ΘBL]]+[[RB]] and send it to the third partyCCC Decrypt LLL并发送 ∂ L ∂ Θ A + R A \frac{\partial L}{\partial\Theta_A} + R_A ΘAL+RATo data provider AAA,发送 ∂ L ∂ Θ B + R A \frac{\partial L}{\partial\Theta_B} + R_A ΘBL+RATo data provider BBB
Step 4 44 Update parameters Θ A \Theta_AThA Update parameters Θ B \Theta_BThB

During the whole process, the participants do not know the data and characteristics of the other party, and after the training, the participants only get the model parameters of their own side, that is, the half model. Since each participant can only obtain the model parameters related to itself, prediction requires collaboration between both parties:

  1. Third party CCC sends the user ID to be predicted to the data providerAAA andBBB
  2. Data provider AAA andBBB minute calculationu A u^AuAu B u^BuB and perform homomorphic encryption to obtain[ [ u A ] ] [[u^A]][[uA ]]Sum[ [ u B ] ] [[u^B]][[uB]]
  3. Data provider AAA andBBB homomorphically encrypted[ [ u A ] ] [[u^A]][[uA ]]Sum[ [ u B ] ] [[u^B]][[uB ]]sent to third partyCCC
  4. Third party CCC calculates the predicted value after homomorphic encryption[ [ y ] ] = [ [ u A ] ] + [ [ u B ] ] [[y]]=[[u^A]]+[[u^B]][[y]]=[[uA]]+[[uB ]]and then decrypt to get the predicted valueyyy

References:
[1] Yang Qiang, Liu Yang, Cheng Yong, Kang Yan, Chen Tianjian, Yu Han. Federated Learning [M]. Electronic Industry Press, 2020 [2] WeBank, FedAI. Federated Learning White Paper V2.0
. Tencent Research Institute, etc., 2021

Guess you like

Origin blog.csdn.net/hy592070616/article/details/132699917