Bayesian federal learning method based on Stein variation gradient descent
By using the Stein variational gradient descent method in the Bayesian federal learning system, the server side uses average likelihood particles to replace the client's local likelihood particles, solving the server's storage pressure and computational instability problems, and achieving a more accurate and efficient global posterior distribution estimation.
Patent Information
- Application Number
- CN202510076505.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-05-13
AI Technical Summary
Particle-based Bayesian federated learning systems face the problem that server storage pressure, computational instability, and outdated likelihoods of unscheduled clients have adverse effects on the estimation of global posterior distributions.
The Bayesian federated learning method based on Stein variational gradient descent is adopted to replace the local likelihood particles on the client by using average likelihood particles on the server side, and the global posterior particles and average likelihood particles are optimized and updated to reduce the storage pressure of the server and improve the computing stability.
It alleviates the storage pressure on the server, allows more clients to participate in federated learning, improves the estimation accuracy of the global posterior distribution, and balances the inconsistency of local likelihoods of the client.
Smart Images

Figure CN119990259A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Bayesian federated learning, and in particular to a Bayesian federated learning method based on Stein variational gradient descent. Background Art
[0002] In recent years, machine learning has achieved a series of breakthroughs in computer vision, natural language processing, autonomous driving, and medical diagnosis, and has gradually become the core driving force of technological reform. However, due to data privacy concerns, distributed data cannot be transmitted to servers or stored in servers for centralized training, which poses a severe challenge to data-driven artificial intelligence applications. As a widely used distributed machine learning framework, Federated Learning (FL) trains global models collaboratively among a large number of FL clients without transmitting the client's private data, thereby ensuring the privacy of distributed clients.
[0003] However, most current research on federated learning still focuses on federated learning under the frequentist school, using point estimation models for training to achieve single-valued inference. On the one hand, this approach cannot quantify the uncertainty of the inference results, which is very important in certain mission-critical applications such as autonomous driving, medical diagnosis, and industrial IoT. On the other hand, the inference results of frequentist federated learning are prone to overfitting, resulting in overconfident predictions for data points outside the training data distribution. In contrast, Bayesian Federated Learning (BFL) infers the posterior distribution of model parameters rather than a set of fixed parameters. The uncertainty of the inference results can be further obtained by utilizing uncertainty quantification methods such as Bayesian model averaging or Bayesian hierarchical stacking.
[0004] Despite the great progress in the field of Bayesian federated learning, mainstream methods still rely on variational inference (VI) or Monte Carlo (MC) sampling techniques, such as the expectation propagation method (FedEP) in federated learning relying on variational inference, and the distributed stochastic gradient Langevin dynamics method (DSGLD) relying on Monte Carlo sampling techniques. Variational inference transforms the Bayesian posterior estimation problem into an optimization problem in a predefined probability distribution space. However, the deviation between the actual posterior distribution and the predefined probability distribution space may weaken the accuracy of the variational inference algorithm. In contrast, the Monte Carlo sampling algorithm estimates the posterior distribution by sampling from the unnormalized distribution according to the acceptance-rejection sampling rule.
[0005] Although this approach generally provides high accuracy, Monte Carlo sampling algorithms are usually inefficient and difficult to analyze. Recently, the Stein Variational Gradient Descent (SVGD) method has been proposed to overcome the above shortcomings of variational inference and Monte Carlo sampling algorithms. As a non-parametric particle-based Bayesian method, SVGD approximates the target distribution by iteratively updating a set of non-random and interacting particles, which can be viewed as samples drawn from the approximated distribution. The SVGD method combines the computational efficiency of variational inference algorithms with the statistical accuracy of Monte Carlo sampling algorithms by simply updating the positions of the particles according to the classical gradient descent method.
[0006] Although the distributed SVGD algorithm has been proposed to solve the problems of global posterior distribution estimation, client selection and model forgetting in federated learning, the particle-based Bayesian federated learning system still faces problems such as the huge storage pressure on the server, the computational instability in the high-dimensional particle distribution estimation destroying the estimation of the global posterior distribution, and the outdated likelihood of unscheduled clients having an adverse effect on the estimation of the global posterior distribution. Summary of the invention
[0007] The technical problem to be solved by the present invention is to address the deficiencies of the above-mentioned prior art and to provide a Bayesian federated learning method based on Stein variational gradient descent, which is used to solve the problems faced by the particle-based Bayesian federated learning system, namely, the server needs to bear huge storage pressure, the computational instability in high-dimensional particle distribution estimation destroys the estimation of the global posterior distribution, and the outdated likelihood of unscheduled clients has an adverse effect on the estimation of the global posterior distribution.
[0008] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0009] The present invention provides a Bayesian federated learning method based on Stein variational gradient descent for regression tasks and classification tasks, comprising the following steps:
[0010] Step 1: Initialize server and client parameters according to specific task requirements;
[0011] Initialize server parameters according to specific task requirements, including: setting the total number of clients M; model parameters θ; global iteration number I; initializing temperature coefficient α according to different task requirements; determining the prior distribution p0(θ) of model parameters according to specific tasks; initializing the global posterior distribution based on the prior distribution, i.e. p (0) (θ) = p0(θ); Initialize the average likelihood to t (0) (θ) = 1; sample N initial global posterior particles from the initial global posterior distribution is the nth initial global posterior particle, each global posterior particle corresponds to a model parameter θ vector; N initial average likelihood particles are sampled from the initial average likelihood distribution is the nth initial average likelihood particle, each average likelihood particle corresponds to a model parameter θ vector; set the number of iterations of global posterior particle update L2 and the number of iterations of average likelihood particle update L3;
[0012] Initialize client parameters according to specific task requirements, including: Setting the local loss function of client m∈M according to the specific task Where L m (θ) is the local loss function of client m; set the number of iterations of the client local posterior particle update L1;
[0013] Step 2: The server selects and schedules the client, sends the global posterior particles and average likelihood particles to the scheduled client, and waits for the scheduled client to complete the local posterior particle optimization update task;
[0014] Set the current iteration round to i∈I, and the server randomly selects S clients from all clients to participate in this iteration. The selected clients form a scheduled client subset. Scheduled client subset The client in is called the scheduled client, and the server sends the global posterior particle obtained in the i-1th iteration round and average likelihood particle Broadcast to the scheduled client k, and wait for the scheduled client to complete the local a posteriori particle optimization update task;
[0015] Step 3: The scheduled client receives the global posterior particles and average likelihood particles sent by the server, uses the global posterior particles to initialize the local posterior particles of the scheduled client, and uses the SVGD algorithm to optimize and update the local posterior particles based on the local data set of the scheduled client to obtain the optimized and updated local posterior particles, and uploads them to the server;
[0016] The scheduled client k performs iterative optimization and update of the local posterior particles of the current iteration round based on the SVGD algorithm, including the following steps:
[0017] Step 3.1: In the current iteration round i∈I, the scheduled client Download the global posterior particles of the i-1th iteration round from the server and average likelihood particle Initialize the local posterior particles of the scheduled client k in the i-th iteration round for in is the nth local posterior particle of the scheduled client k in the i-th iteration round, and the average likelihood particle in the i-1-th iteration round As the local likelihood particle of client k, is the nth average likelihood particle in the i-1th iteration round;
[0018] Step 3.2: The scheduled client k uses the global posterior distribution p in the i-1th iteration round (i-1) (θ) and the average likelihood distribution t in the i-1th iteration round (i-1) (θ) Calculate the cavity distribution of client k in the i-th iteration round As shown in the following formula:
[0019]
[0020] Among them, the global posterior distribution p in the i-1th iteration round (i-1) (θ) is obtained by the global posterior particle in the i-1th iteration round Using kernel density estimation, we can get the average likelihood t in the i-1th iteration. (i-1) (θ) is calculated by averaging the likelihood particles in the i-1th iteration round. The kernel density estimation is used to obtain;
[0021] Step 3.3: Initialize the local posterior particle as In the scheduled client k’s local l1∈L1 round iteration, based on the cavity distribution in the scheduled client k’s i-th iteration round and the true likelihood calculated locally by client k is skewed As shown below:
[0022]
[0023] in, is the local true likelihood of the scheduled client k;
[0024] Use the skewed distribution at the l1th iteration As the target distribution in the SVGD algorithm, it guides the k local posterior particles of the scheduled client in the l1th iteration round. The optimization update rule is:
[0025]
[0026] in, is the kernel function used when executing the SVGD algorithm, is the kernel function used for kernel density estimation, ε1 is the optimization update step size of the local posterior particles, is the jth particle scheduled by client k in the l1-1th iteration round, is the nth particle scheduled by client k in the l1-1th iteration round, for The derivative of
[0027] Step 3.4: After completing the L1 iteration round, obtain the local posterior particle after the client's i-th iteration round optimization update for Client k optimizes the updated local posterior particles in the i-th iteration round Upload to the server;
[0028] Step 4: The server receives the optimized and updated local posterior particles uploaded by all scheduled clients in the current iteration round, and optimizes and updates the global posterior particles and average likelihood particles of the current iteration round in turn based on the SVGD algorithm;
[0029] Step 4.1: The server optimizes and updates the global a posteriori particles of the current iteration round based on the SVGD algorithm to obtain the global a posteriori particles of the current iteration round after optimization and update;
[0030] In the i-th iteration, initialize the global posterior particles to be optimized and updated for The server calculates the local posterior particles of the i-th iteration round uploaded by the scheduled client k. Estimate the local posterior distribution of the scheduled clients in the i-th iteration round Then calculate the global posterior distribution p in the i-th iteration round (i) (θ), as shown in the following formula:
[0031]
[0032] In the l2∈L2 iteration round when the server updates the global posterior particle, the global posterior distribution p of the i-th iteration round is used. (i) (θ) is used as the target distribution of the SVGD algorithm to guide the global posterior particle The optimization update rule is:
[0033]
[0034] Among them, ε2 is the update step size of the global posterior particle, is the jth global posterior particle of the server in the l2-1th iteration round, is the nth global posterior particle of the server in the l2-1th iteration round;
[0035] After completing the L2 iteration round, the global posterior particle of the i-th iteration round after optimization update is obtained. for
[0036] Step 4.2: The server optimizes and updates the average likelihood particles of the current iteration round based on the SVGD algorithm to obtain the average likelihood particles of the current iteration round after optimization and update;
[0037] In the i-th iteration round, the average likelihood particle to be optimized and updated is initialized as The server calculates the average likelihood particle in the i-1th iteration round. Estimate the average likelihood t in the i-1th iteration (i-1) (θ), and then calculate the average likelihood t in the i-th iteration round (i) (θ), as shown in the following formula:
[0038]
[0039] In the l3∈L3th iteration when the server updates the average likelihood particle, the average likelihood t of the i-th iteration is used. (i) (θ) is used as the target distribution of the SVGD algorithm to guide the average likelihood particle in the l3-1th iteration. The optimization update rule is:
[0040]
[0041] Among them, ε3 is the update step size of the average likelihood particle, is the jth average likelihood particle of the server in the l3-1th iteration round; is the nth average likelihood particle of the server in the l3-1th iteration round, is the n′th global posterior particle obtained in the i-th iteration round, n′∈[1,N];
[0042] After completing the L3 iteration round, the average likelihood particle of the i-th iteration round after optimization update is obtained.
[0043] Step 4.3: After completing the optimization and update of the global posterior particles and average likelihood particles in the i-th iteration round, the server updates the number of iterations to i+1. If the preset number of iterations has not been reached at this time, it returns to step 2 to start the next round of iterations. Otherwise, the server completes the model training and obtains the global posterior particles after I rounds of iterations. Go to step 5;
[0044] Step 5: According to the global posterior particle after I iterations Estimate the global posterior distribution p(θ), and use the global posterior particles that obey the global posterior distribution p(θ) after I rounds of iterations Complete specific tasks, according to specific task requirements, based on the global posterior particles after I rounds of iterations Quantify the uncertainty of task outcomes.
[0045] The beneficial effects of adopting the above technical solution are: the present invention provides a Bayesian federated learning method based on Stein variational gradient descent. First, the average likelihood particles are used on the server side to replace the local likelihood particles on the client side. The advantage is that when a large number of clients are involved in the Bayesian federated learning system, the existing technology needs to store the local likelihood particles of all clients on the server side to ensure that the global posterior distribution can be calculated, which puts great storage pressure on the server and limits the scale of clients participating in federated learning. In the present invention, the server side only needs to use the average likelihood particles to complete the calculation task of the global posterior distribution. This means that the server can replace a large number of local likelihood particles with a very small number of average likelihood particles, thereby alleviating the storage pressure of the server to a great extent and allowing more clients to participate in the federated learning system. Secondly, the average likelihood is the average of the contributions of all client local likelihoods to the posterior distribution. When estimating the average likelihood on the server side, the average likelihood of the previous iteration can be used as a regularization term for the implicitly obtained client local likelihood. On the one hand, it can implicitly eliminate the influence of outdated local likelihoods of unscheduled clients. On the other hand, it can also balance the inconsistency of the local likelihoods of scheduled clients caused by the non-independent and identically distributed characteristics of the federated learning system. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 A flow chart of a Bayesian federated learning method based on Stein variational gradient descent provided in an embodiment of the present invention;
[0047] Figure 2 A schematic diagram of the interaction between a server and a client of a Bayesian federated learning method based on Stein variational gradient descent provided in an embodiment of the present invention;
[0048] Figure 3 A flowchart of a server and a client of a Bayesian federated learning method based on Stein variational gradient descent is provided in an embodiment of the present invention, wherein (a) is a client flowchart and (b) is a server flowchart. DETAILED DESCRIPTION
[0049] The specific implementation of the present invention is further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0050] A Bayesian federated learning method based on Stein variational gradient descent in this embodiment, such as Figure 1 As shown, the following steps are included:
[0051] Step 1: Initialize server and client parameters according to specific task requirements;
[0052] Initialize server parameters according to specific task requirements, including: setting the total number of clients M; model parameters θ; global iteration number I; initializing temperature coefficient α according to different task requirements; determining the prior distribution p0(θ) of model parameters according to specific tasks; initializing the global posterior distribution based on the prior distribution, i.e. p (0) (θ) = p0(θ); Initialize the average likelihood to t (0) (θ) = 1; sample N initial global posterior particles from the initial global posterior distribution is the nth initial global posterior particle, each global posterior particle corresponds to a model parameter θ vector; N initial average likelihood particles are sampled from the initial average likelihood distribution is the nth initial average likelihood particle, each average likelihood particle corresponds to a model parameter θ vector; set the number of iterations of global posterior particle update L2 and the number of iterations of average likelihood particle update L3;
[0053] Each particle corresponds to a model parameter θ vector;
[0054] Initialize client parameters according to specific task requirements, including: Setting the local loss function of client m∈M according to the specific task Where L m (θ) is the local loss function of client m; set the number of iterations of the client local posterior particle update L1;
[0055] The interaction between the server and the client of the Bayesian federated learning method based on Stein variational gradient descent is shown in the figure below: Figure 2As shown in the figure, the server, as the coordinator of the Bayesian federated learning method based on Stein variational gradient descent, does not hold any data set, but only saves the global posterior particles and the average likelihood particles, completes the client selection and aggregates the local posterior information about the model parameters provided by the client to obtain a global posterior distribution, with the goal of being able to approximate the true posterior distribution of the model parameters; the client has its own unique data set, and can estimate the local posterior distribution of the model parameters based on its own data set, and save the relevant information in the local posterior particles by optimizing and updating the global posterior particles. The server and the client complete the information transmission by exchanging particles, specifically: the server completes the transmission of the global posterior distribution and the average likelihood information by sending the global posterior particles and the average likelihood particles to the client, and the client completes the transmission of the client's local posterior information by sending the local posterior particles to the server.
[0056] In this embodiment, the Bayesian federated learning method based on Stein variational gradient descent is used to perform the classification task of images in the image multi-classification dataset FashionMnist. The total number of clients is set to M = 20, and the FashionMnist dataset is distributed to each client m based on the Dirichlet distribution in a non-independent and identically distributed manner as the client local dataset; the local loss function of client m is The cross entropy loss function is used; the temperature coefficient α is set to 1; the global posterior distribution is initialized using the prior distribution, i.e., p (0) (θ) = p0(θ); the average likelihood is initialized to t (0) (θ) = 1; the initial global posterior particle is sampled from the global posterior distribution In this embodiment, p0(θ) is a complex distribution, specifically: each weight part of θ is initialized using a standard normal distribution, and each bias part of θ is set to 0; the initial average likelihood particle is sampled from the average likelihood distribution Set the number of global iterations I = 50, the number of iterations of the client local posterior particle update L1 = 200, the number of iterations of the global posterior particle update L2 = 200, and the number of iterations of the average likelihood particle update L3 = 200;
[0057] Step 2: The server selects and schedules the client, sends the global posterior particles and average likelihood particles to the scheduled client, and waits for the scheduled client to complete the local posterior particle optimization update task;
[0058] Set the current iteration round number to i∈I, and the server randomly selects S clients from all clients to participate in this iteration round. The selected clients form a scheduled client subset. Scheduled client subset The client in is called the scheduled client, and the server sends the global posterior particle obtained in the i-1th iteration round and average likelihood particle Broadcast to the scheduled client k, and wait for the scheduled client to complete the local a posteriori particle optimization update task;
[0059] In this embodiment, S=2 is set, and the server selects 2 clients from all clients by random selection to form a client subset.
[0060] Step 3: The scheduled client receives the global posterior particles and average likelihood particles sent by the server, uses the global posterior particles to initialize the local posterior particles of the scheduled client, and uses the SVGD algorithm to optimize and update the local posterior particles based on the local data set of the scheduled client to obtain the optimized and updated local posterior particles, and uploads them to the server;
[0061] The scheduled client k performs iterative optimization and update of the local posterior particles of the current iteration round based on the SVGD algorithm, such as Figure 3 (a), comprising the following steps:
[0062] Step 3.1: In the current iteration round i∈I, the scheduled client Download the global posterior particles of the i-1th iteration round from the server and average likelihood particles Initialize the local posterior particles of the scheduled client k in the i-th iteration round for in is the nth local posterior particle of the scheduled client k in the i-th iteration round, and the average likelihood particle in the i-1-th iteration round As the local likelihood particle of client k, is the nth average likelihood particle in the i-1th iteration round;
[0063] Step 3.2: The scheduled client k uses the global posterior distribution p in the i-1th iteration round (i-1) (θ) and the average likelihood distribution t in the i-1th iteration round (i-1) (θ) Calculate the cavity distribution of client k in the i-th iteration round As shown in the following formula:
[0064]
[0065] Among them, the global posterior distribution p in the i-1th iteration round (i-1) (θ) is obtained by the global posterior particle in the i-1th iteration round Using kernel density estimation, we can get the average likelihood t in the i-1th iteration. (i-1) (θ) is calculated by averaging the likelihood particles in the i-1th iteration round. The kernel density estimation is used to obtain;
[0066] Step 3.3: Initialize the local posterior particle as In the scheduled client k’s local l1∈L1 round iteration, based on the cavity distribution in the scheduled client k’s i-th iteration round and the true likelihood calculated locally by client k is skewed As shown below:
[0067]
[0068] in, is the local true likelihood of the scheduled client k;
[0069] Use the skewed distribution at the l1th iteration As the target distribution in the SVGD algorithm, it guides the k local posterior particles of the scheduled client in the l1th iteration round. The optimization update rule is:
[0070]
[0071] in, is the kernel function used when executing the SVGD algorithm, is the kernel function used for kernel density estimation, ε1 is the optimization update step size of the local posterior particles, is the jth particle scheduled by client k in the l1-1th iteration round, is the nth particle scheduled by client k in the l1-1th iteration round, for The derivative of
[0072] In this embodiment, the kernel function and All are RBF kernel functions;
[0073] Step 3.4: After completing the L1 iteration round, obtain the local posterior particle after the client's i-th iteration round optimization update for Client k optimizes the updated local posterior particles in the i-th iteration round Upload to the server;
[0074] The local posterior particle is a mapping of the posterior distribution of the model parameters based on the client's local data set. Therefore, the local posterior particle is the target of the client update. The client completes the transmission of distribution information by updating the local posterior particle and uploading it to the server.
[0075] Step 4: The server receives the optimized and updated local posterior particles uploaded by all scheduled clients in the current iteration round, and optimizes and updates the global posterior particles and average likelihood particles of the current iteration round in turn based on the SVGD algorithm;
[0076] In the i-th iteration round, the server receives the optimized and updated local posterior particles uploaded by the scheduled client. After the collection is completed, the global posterior particles of the current iteration round are first updated and optimized, and then the average likelihood particles of the current iteration round are updated and optimized, such as Figure 3 (b), comprising the following steps:
[0077] Step 4.1: The server optimizes and updates the global a posteriori particles of the current iteration round based on the SVGD algorithm to obtain the global a posteriori particles of the current iteration round after optimization and update;
[0078] In the i-th iteration, initialize the global posterior particles to be optimized and updated for The server calculates the local posterior particles of the i-th iteration round uploaded by the scheduled client k. Estimate the local posterior distribution of the scheduled clients in the i-th iteration round Then calculate the global posterior distribution p in the i-th iteration round (i) (θ), as shown in the following formula:
[0079]
[0080] In the l2∈L2 iteration round when the server updates the global posterior particle, the global posterior distribution p of the i-th iteration round is used. (i) (θ) is used as the target distribution of the SVGD algorithm to guide the global posterior particle The optimization update rule is:
[0081]
[0082] Among them, ε2 is the update step size of the global posterior particle, is the jth global posterior particle of the server in the l2-1th iteration round, is the nth global posterior particle of the server in the l2-1th iteration round;
[0083] After completing the L2 iteration round, the global posterior particle of the i-th iteration round after optimization update is obtained. for
[0084] Step 4.2: The server optimizes and updates the average likelihood particles of the current iteration round based on the SVGD algorithm to obtain the average likelihood particles of the current iteration round after optimization and update;
[0085] In the i-th iteration round, the average likelihood particle to be optimized and updated is initialized as The server calculates the average likelihood particle in the i-1th iteration round. Estimate the average likelihood t in the i-1th iteration (i-1) (θ), and then calculate the average likelihood t in the i-th iteration round (i) (θ), as shown in the following formula:
[0086]
[0087] In the l3∈L3th iteration when the server updates the average likelihood particle, the average likelihood t of the i-th iteration is used. (i) (θ) is used as the target distribution of the SVGD algorithm to guide the average likelihood particle in the l3th iteration. The optimization update rule is:
[0088]
[0089] Among them, ε3 is the update step size of the average likelihood particle, is the jth average likelihood particle of the server in the l3-1th iteration round; is the nth average likelihood particle of the server in the l3-1th iteration round, is the n′th global posterior particle obtained in the i-th iteration round, n′∈[1,N];
[0090] After completing the L3 iteration round, the average likelihood particle of the i-th iteration round after optimization update is obtained.
[0091] Step 4.3: After completing the optimization and update of the global posterior particles and average likelihood particles in the i-th iteration round, the server updates the number of iterations to i+1. If the preset number of iterations has not been reached at this time, it returns to step 2 to start the next round of iterations. Otherwise, the server completes the model training and obtains the global posterior particles after I rounds of iterations. Go to step 5;
[0092] Step 5: Based on the global posterior particle after I iterations Estimate the global posterior distribution p(θ), and use the global posterior particles that obey the global posterior distribution p(θ) after I rounds of iterations Complete specific tasks, according to specific task requirements, based on the global posterior particles after I rounds of iterations Quantify the uncertainty of task outcomes.
[0093] The global posterior particles obtained using the Bayesian federated learning method based on Stein variational gradient descent can be approximately considered as non-independent and identically distributed sampling from the true posterior distribution obeyed by the model parameters, and predictions are made based on these particles while providing uncertainty analysis for the prediction results. In this embodiment, after completing the training based on the FashionMnist dataset, the global posterior particles obtained are used for image classification tasks and provide uncertainty estimates for the image classification results.
[0094] In order to verify the performance of the Bayesian federated learning method based on Stein variational gradient descent provided in this embodiment, this method is used to compare with PDSVGD, FedAvg, FedAvg-M, and DSGLD methods on four classification data sets, MNIST, Fashion MNIST, Covertype, and Twonorm, using test accuracy Accuracy as the performance indicator. Comparative experiments are conducted on two regression data sets, Kin8nm and YearPrediction, using mean square error loss RMSE as the performance indicator. The experimental results are shown in Table 1, where SDSVGD is the Bayesian federated learning method based on Stein variational gradient descent provided in this embodiment. The higher the test accuracy Accuracy, the better the performance of the corresponding method, and the smaller the mean square error loss RMSE, the better the performance of the corresponding method. As can be seen from Table 1, the Bayesian federated learning method based on Stein variational gradient descent provided in this embodiment, namely SDSVGD, has achieved the best performance indicators on most classification and regression data sets.
[0095] Table 1 Performance comparison experimental results
[0096]
[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some or all of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope defined by the claims of the present invention.
Claims
1. A Bayesian federated learning method based on Stein variational gradient descent, characterized by: The following steps are involved: Step 1: Initialize server and client parameters according to specific task requirements; Step 2: The server selects and schedules the client, sends the global posterior particles and average likelihood particles to the scheduled client, and waits for the scheduled client to complete the local posterior particle optimization update task; Step 3: The scheduled client receives the global posterior particles and average likelihood particles sent by the server, uses the global posterior particles to initialize the local posterior particles of the scheduled client, and uses the SVGD algorithm to optimize and update the local posterior particles based on the local data set of the scheduled client to obtain the optimized and updated local posterior particles, and uploads them to the server; Step 4: The server receives the optimized and updated local posterior particles uploaded by all scheduled clients in the current iteration round, and optimizes and updates the global posterior particles and average likelihood particles of the current iteration round in turn based on the SVGD algorithm; Step 5: Estimate the global posterior distribution based on the global posterior particles that have undergone I iterations, use the global posterior particles that have undergone I iterations and obey the global posterior distribution to complete specific tasks, and quantify the uncertainty of the task results based on the global posterior particles that have undergone I iterations according to the specific task requirements.
2. The Bayesian federated learning method based on Stein variational gradient descent according to claim 1, characterized in that: The step 1 specifically includes: Initialize server parameters according to specific task requirements, including: setting the total number of clients M; model parameters θ; global iteration number I; initializing temperature coefficient α according to different task requirements; determining the prior distribution p0(θ) of model parameters according to specific tasks; initializing the global posterior distribution based on the prior distribution, i.e. p (0) (θ) = p0(θ); Initialize the average likelihood to t (0) (θ) = 1; sample N initial global posterior particles from the initial global posterior distribution is the nth initial global posterior particle, each global posterior particle corresponds to a model parameter θ vector; N initial average likelihood particles are sampled from the initial average likelihood distribution is the nth initial average likelihood particle, each average likelihood particle corresponds to a model parameter θ vector; set the number of iterations of global posterior particle update L2 and the number of iterations of average likelihood particle update L3; Initialize client parameters according to specific task requirements, including: Setting the local loss function of client m∈M according to the specific task Where L m (θ) is the local loss function of client m; set the number of iterations of the client local posterior particle update L1.
3. The Bayesian federated learning method based on Stein variational gradient descent according to claim 2, characterized in that: The specific method of step 2 is: Set the current iteration round to i∈I, and the server randomly selects S clients from all clients to participate in this iteration. The selected clients form a scheduled client subset. Scheduled client subset The client in is called the scheduled client, and the server sends the global posterior particle obtained in the i-1th iteration round and average likelihood particle Broadcast to the scheduled client k, and wait for the scheduled client to complete the local posterior particle optimization update task.
4. The Bayesian federated learning method based on Stein variational gradient descent according to claim 3, characterized in that: The step 3 specifically includes: Step 3.1: In the current iteration round i∈I, the scheduled client Download the global posterior particles of the i-1th iteration round from the server and average likelihood particle Initialize the local posterior particles of the scheduled client k in the i-th iteration round for in is the nth local posterior particle of the scheduled client k in the i-th iteration round, and the average likelihood particle in the i-1-th iteration round As the local likelihood particle of client k, is the nth average likelihood particle in the i-1th iteration round; Step 3.2: The scheduled client k uses the global posterior distribution p in the i-1th iteration round (i-1) (θ) and the average likelihood distribution t in the i-1th iteration round (i-1) (θ) Calculate the cavity distribution of client k in the i-th iteration round As shown in the following formula: Among them, the global posterior distribution p in the i-1th iteration round (i-1) (θ) is obtained by the global posterior particle in the i-1th iteration round Using kernel density estimation, we can get the average likelihood t in the i-1th iteration round. (i-1) (θ) is calculated by averaging the likelihood particles in the i-1th iteration round. The kernel density estimation is used to obtain; Step 3.3: Initialize the local posterior particle as In the scheduled client k’s local l1∈L1 round iteration, based on the cavity distribution in the scheduled client k’s i-th iteration round and the true likelihood calculated locally by client k is skewed As shown below: in, is the local true likelihood of the scheduled client k; Use the skewed distribution at the l1th iteration As the target distribution in the SVGD algorithm, it guides the k local posterior particles of the scheduled client in the l1th iteration round. The optimization update rule is: in, is the kernel function used when executing the SVGD algorithm, is the kernel function used for kernel density estimation, ε1 is the optimization update step size of the local posterior particles, is the jth particle scheduled by client k in the l1-1th iteration round, is the nth particle scheduled by client k in the l1-1th iteration round, for The derivative of Step 3.4: After completing the L1 iteration round, obtain the local posterior particle after the client's i-th iteration round optimization update for Client k optimizes the updated local posterior particles in the i-th iteration round Upload to the server.
5. The Bayesian federated learning method based on Stein variational gradient descent according to claim 4, characterized in that: The step 4 specifically includes: Step 4.1: The server optimizes and updates the global a posteriori particles of the current iteration round based on the SVGD algorithm to obtain the global a posteriori particles of the current iteration round after optimization and update; Step 4.2: The server optimizes and updates the average likelihood particles of the current iteration round based on the SVGD algorithm to obtain the average likelihood particles of the current iteration round after optimization and update; Step 4.3: After completing the optimization and update of the global posterior particles and average likelihood particles in the i-th iteration round, the server updates the number of iterations to i+1. If the preset number of iterations has not been reached at this time, it returns to step 2 to start the next round of iterations. Otherwise, the server completes the model training and obtains the global posterior particles after I rounds of iterations. Go to step 5.
6. The Bayesian federated learning method based on Stein variational gradient descent according to claim 5, characterized in that: The specific method of step 4.1 is: In the i-th iteration, initialize the global posterior particles to be optimized and updated for The server calculates the local posterior particles of the i-th iteration round uploaded by the scheduled client k. Estimate the local posterior distribution of the scheduled clients in the i-th iteration round Then calculate the global posterior distribution p in the i-th iteration round (i) (θ), as shown in the following formula: In the l2∈L2 iteration round when the server updates the global posterior particle, the global posterior distribution p of the i-th iteration round is used. (i) (θ) is used as the target distribution of the SVGD algorithm to guide the global posterior particle The optimization update rule is: Among them, ε2 is the update step size of the global posterior particle, is the jth global posterior particle of the server in the l2-1th iteration round, is the nth global posterior particle of the server in the l2-1th iteration round; After completing the L2 iteration round, the global posterior particle of the i-th iteration round after optimization update is obtained. for 7. The Bayesian federated learning method based on Stein variational gradient descent according to claim 6, characterized in that: The specific method of step 4.2 is: In the i-th iteration round, the average likelihood particle to be optimized and updated is initialized as The server calculates the average likelihood particle in the i-1th iteration round. Estimate the average likelihood t in the i-1th iteration (i-1) (θ), and then calculate the average likelihood t in the i-th iteration round (i) (θ), as shown in the following formula: In the l3∈L3th iteration when the server updates the average likelihood particle, the average likelihood t of the i-th iteration is used. (i) (θ) is used as the target distribution of the SVGD algorithm to guide the average likelihood particle in the l3-1th iteration. The optimization update rule is: Among them, ε3 is the update step size of the average likelihood particle, is the jth average likelihood particle of the server in the l3-1th iteration round; is the nth average likelihood particle of the server in the l3-1th iteration round, is the n′th global posterior particle obtained in the i-th iteration round, n′∈[1,N]; After completing the L3 iteration round, the average likelihood particle of the i-th iteration round after optimization update is obtained.