Method for processing federal learning data isomerism based on swarm intelligence optimization algorithm
By using the FedCPSO algorithm on the server side, and updating the model parameters with weighted averaging and search strategies, the global model performance problem caused by data heterogeneity in federated learning is solved, and higher adaptability and accuracy are achieved, especially in non-independent and homogeneous Significant improvements in distribution scenarios.
Patent Information
- Application Number
- CN202411250288.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2024-12-06
AI Technical Summary
Data heterogeneity in federated learning leads to poor global model performance, and existing methods often lead to increased client computing or storage costs.
FedCPSO is used on the server side to upgrade the model and approximate the test accuracy, obtain local and global optimal models, and update model parameters in combination with global and local search strategies, dynamically adjust the client model to get it close to global optimal Model.
The performance and adaptability of the global model are improved, the client model parameters are dynamically adjusted, and the overall effect of federated learning is improved, especially in non-independent and same-distribution scenarios, which significantly improve the testing accuracy.
Smart Images

Figure CN119090029A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method for processing heterogeneous federated learning data based on a swarm intelligence optimization algorithm. Background Art
[0002] In today's data-driven world, data privacy and security are becoming increasingly important. Federated Learning (FL), as an emerging machine learning paradigm, aims to address data privacy issues. Unlike traditional centralized machine learning, traditional methods centralize all data to a server for training, leading to data leakage and privacy risks. Federated learning provides an effective way to protect data privacy and distributed data processing by training models locally on multiple client devices and sharing only model updates instead of original data.
[0003] In each iteration of federated learning, the server coordinates the client to download the model, the client uses local data to train the model, and then uploads the updated model to the server for aggregation. This process is repeated until the model converges. Since the server needs to coordinate and save the models of multiple clients, generally speaking, the server has larger memory and stronger computing power than the client.
[0004] During the model training process, all data will not leave the respective clients, thus meeting the requirements for data privacy protection. Although federated learning has shown great potential in protecting data privacy, it still faces many challenges, one of which is data heterogeneity. Data heterogeneity refers to the fact that the data between each client participating in federated learning is non-independent and identically distributed (Non-IID). For example, each client may have a different amount of data, the data labels may be different, or even both. This makes it very difficult to train a global model that applies to all clients.
[0005] To address this challenge, previous studies have focused on adjusting the model from the client's perspective, but these methods often increase the client's computing or storage costs. To solve this problem, we propose a new method for model aggregation on the server - FedCPSO. When the server receives the client's model, it aggregates and sends different models according to the needs of different clients, thereby solving the problem of poor global model performance in non-IID data scenarios to a certain extent. Summary of the invention
[0006] The present invention provides a method for processing federated learning data heterogeneity based on a swarm intelligence optimization algorithm, aiming to solve the data heterogeneity problem in federated learning. The method effectively improves the performance and adaptability of the global model by performing intelligent model aggregation on the server side.
[0007] In order to achieve the above object, the present invention adopts the following technical solutions:
[0008] A method for processing heterogeneous federated learning data based on a swarm intelligence optimization algorithm includes the following specific steps:
[0009] Step S1, the server receives model updates from each client;
[0010] Step S2, the server calculates the global model and performs intelligent aggregation based on the model uploaded by the client and the locally stored information;
[0011] In step S3, the server sends the aggregated model to each client and starts a new round of local training.
[0012] As a further improvement of the technical solution: in step S1, in the tth round of each round of training, the server receives the model set from the client
[0013] As a further improvement of the technical solution: in step S2, the server calculates the global model and performs intelligent aggregation based on the model uploaded by the client and the locally stored information, which specifically includes the following four steps:
[0014] Step 1: Take a weighted average of all clients’ models to get the average model for this round
[0015] Step 2: The server uses the dataset D s Evaluate each model and get their test accuracy separately For the i-th client, its own optimal accuracy will be given by The corresponding model is considered as the local optimal model of the client.
[0016] Step 3: Obtaining the global optimal accuracy The corresponding global optimal model θ * ;
[0017] Step 4: Use the FedCPSO algorithm to update the average model obtained above, the local optimal model of each client, and the global optimal model to obtain the model required by each client in the t+1 round.
[0018] As a further improvement of this technical solution: the first step is to obtain the average model of this round It is used to integrate the information of each client model to form an initial model with strong integrity.
[0019] As a further improvement of this technical solution: Step 3: Obtain the global optimal model θ * This ensures that the entire system can find the current optimal model and provides the best reference model for subsequent updates.
[0020] As a further improvement of this technical solution: Step 4: Use the FedCPSO algorithm to update the average model obtained above, the local optimal model of each client, and the global optimal model to obtain the model required by each client in the t+1 round. The specific process is as follows:
[0021] In round t, after each client uploads their model, the server first calculates the weighted average model of all clients. The server also stores the update direction of client i in the previous round Next, the model parameters are updated according to the global search and local search strategies. For global search, the server updates the model parameters according to the weighted average model. and the global optimal model θ * Update the parameters. The specific formula is as follows:
[0022]
[0023] in, represents the state of the i-th client model in round t, r t is a random number uniformly distributed in the range [0,1]. Represents crow x i The length of the iterative flight in the tth round. This update strategy utilizes the information of the global optimal model, so that each client model can be close to the global optimal model, thereby improving the performance of the overall model.
[0024] As a further improvement of this technical solution: for local search, the server uses a weighted average model The client's historical optimal model And the global optimal model θ * Update the parameters. The specific formula is as follows:
[0025]
[0026] Among them, α represents the inertia weight, c1 and c2 are acceleration constants, and r1 and r2 are random numbers uniformly distributed in the range [0,1].
[0027] Compared with the prior art, the present invention has the following beneficial effects:
[0028] The present invention effectively improves the performance and adaptability of the global model by performing intelligent model aggregation on the server side, and through the combination of global and local search strategies, it can dynamically adjust the parameters of each client model in each round of training to gradually approach the global optimal model, thereby improving the overall effect of federated learning.
[0029] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention and implement it according to the contents of the specification, the following is a detailed description of the preferred embodiments of the present invention in conjunction with the accompanying drawings. The specific implementation of the present invention is given in detail by the following embodiments and their accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0031] Figure 1 For Schematic diagram of the crow search principle
[0032] Figure 2 For Schematic diagram of the crow search principle
[0033] Figure 3 It is a pseudo code schematic diagram of the present invention;
[0034] Figure 4 A flow chart of the present invention in a server;
[0035] Figure 5 This is the experimental effect diagram. DETAILED DESCRIPTION
[0036] The present invention sets up a small-scale IID dataset on the server to evaluate the performance of each client model, so as to select the historical best model of each client and the overall global best model. Then, we use the FedCPSO method to aggregate their own models for each client. Through extensive experiments on MNIST, CIFAR-10, and FashionMNIST standard datasets, we show the significant improvement of FedCPSO over traditional federated learning baseline methods.
[0037] This method involves two swarm intelligence optimization algorithms:
[0038] Crow Search Algorithm (CSA) is an optimization algorithm based on swarm intelligence. It imitates the memory and search behavior of crows to solve optimization problems. It has been widely used to solve various optimization problems in multiple fields and research fields.
[0039] Crows are intelligent birds that have the ability to remember the location of food caches and will spy on and steal food from other crows.
[0040] Each crow hides the food and retrieves it when needed. They will stalk each other, watching and tracking down other crows' food caches, and steal the food once its owner leaves.
[0041] When a crow finds itself being followed, it will move its hiding place to prevent theft. Based on the crow's behavior habits, the algorithm has four basic principles:
[0042] 1. Crows live in groups.
[0043] 2. Crows can remember where they hide their food.
[0044] 3. Crows chase each other to steal food.
[0045] 4. Crows have the ability to sense when they are being followed and they change their behavior.
[0046] The goal of this method is that a given crow i can follow another crow j to find the location of the food it hides. In the process, the crow should gradually update its position. The complete formula for crow search is as follows:
[0047]
[0048] in represents the position of the i-th crow in the t-th round, r is a random number uniformly distributed in [0,1], represents the perception probability of crow j, It's Crow x i The length of the flight in the tth iteration, Value affects the crow's searching ability Large values of result in a global search, while small values result in a local search. Figure 1 Shown Impact on CSA search capabilities
[0049] Particle Swarm Optimization (PSO) is an optimization algorithm based on swarm intelligence, proposed by James Kennedy and Russell Eberhart in 1995. Inspired by the predatory behavior of bird flocks, PSO simulates individuals moving in the search space and searching for the global optimal solution.
[0050] Its core idea is to make the particle swarm gradually approach the global optimal solution by constantly adjusting the speed and position of the particles. Each particle has a position x and a speed v in the search space. The position represents the solution of the current particle in the search space, while the speed determines the next moving direction and moving distance of the particle.
[0051] Particles share their historical optimal value P best , and thus obtain the global optimal value G best ,,Then calculate the direction and distance of the next move.
[0052]
[0053] in, is the velocity of particle i in generation t, α is the inertia weight, c1 and c2 are learning factors, r1 and r2 are random numbers between [0,1], is the position of particle i at the tth iteration. The particle position update formula is:
[0054]
[0055] Through each round of iteration, the global optimal point is found.
[0056] The overall framework of this method follows the standard federated learning process, with the server and multiple clients working together. The slight difference is that all clients will participate in the update and aggregation in each round, and each round of training includes the following steps:
[0057] Step S1, the server receives model updates from each client;
[0058] Step S2, the server calculates the global model and performs intelligent aggregation based on the model uploaded by the client and the locally stored information;
[0059] In step S3, the server sends the aggregated model to each client and starts a new round of local training.
[0060] Steps S1 and S3 are the same as the general method FeeAvg. The method proposed in this invention mainly focuses on the second step. It should also be noted that this method will place a very small independent and identically distributed data set D on the server side. s(10 data of each type) are used to measure the performance of the model, with the aim of selecting the client's own optimal model and the global optimal model.
[0061] The core operation of this method is mainly performed on the server side. The specific steps are as follows Figure 5 As shown in the figure. In traditional federated learning methods, after the server receives the models of all clients, it usually adopts a simple weighted average method and then sends the resulting model to all clients. However, unlike traditional methods, our method uses the FedCPSO algorithm to update each model separately. FedCPSO not only considers the differences between the models of each client, but also improves the adaptability of the global model through optimization strategies. Specifically, in the tth round of each training, the server receives the model set from the client. After that, the following four steps will be performed:
[0062] Step 1: Take a weighted average of all clients’ models to get the average model for this round This operation can integrate the information of each client model to form an initial model with stronger integrity.
[0063] Step 2: The server uses the dataset D s Evaluate each model and get their test accuracy separately For the i-th client, its own optimal accuracy will be given by The corresponding model is considered as the local optimal model of the client. The purpose of this step is to find and update the historical optimal model for each client.
[0064] Step 3: Obtaining the global optimal accuracy The corresponding global optimal model θ * This operation ensures that the entire system can find the current optimal model and provides the best reference model for subsequent updates.
[0065] Step 4: Use the FedCPSO algorithm to update the average model obtained above, the local optimal model of each client, and the global optimal model to obtain the model required by each client in the t+1th round. Then, the server sends these updated models to each client respectively.
[0066] Through the above process, our method can not only flexibly process the model of each client, but also improve the generalization ability and accuracy of the model, thereby achieving better performance in federated learning.
[0067] The detailed update process in the fourth step is as follows: In the tth round, after each client uploads their model, the server first calculates the weighted average model of all clients (as the initial position of this round). The server also stores the update direction of client i in the previous round (as the initial momentum of this round). Then, according to the global search and local search strategies, the model parameters are updated. For global search, the server updates the model parameters according to the weighted average model. and the global optimal model θ * Update the parameters. The specific formula is as follows:
[0068]
[0069] in, represents the state of the i-th client model in round t, r t is a random number uniformly distributed in the range [0,1]. Represents crow x i The length of the iterative flight in the tth round. This update strategy uses the information of the global optimal model, so that each client model can be close to the global optimal model, thereby improving the performance of the overall model. Regarding hyperparameters, we recommend using To get better results, fl max =2,fl min =0.1
[0070] For local searches, the server uses a weighted average model The client's historical optimal model And the global optimal model θ * Update the parameters. The specific formula is as follows:
[0071]
[0072] Among them, α represents the inertia weight, c1 and c2 are acceleration constants, and r1 and r2 are random numbers uniformly distributed in the range [0,1]. In this way, the local search strategy combines the information of the global average model, the local optimal model, and the global optimal model, thereby effectively guiding the update direction of the model so that it can not only retain historical valid information but also quickly converge to the optimal solution. Through the combination of the above global and local search strategies, our method can dynamically adjust the parameters of each client model in each round of training, so that it gradually approaches the global optimal model, thereby improving the overall effect of federated learning. In this step, we recommend using α=0.3, c1=0.4, c2=0.5 for better performance.
[0073] Experimental verification
[0074] In order to verify the feasibility of the effect of the present invention, we adopted a typical federated learning setting, that is, each client receives a model from a central server, trains it using its own private data, and then sends the trained model back to the central server.
[0075] The experiment used three widely used datasets: MNIST, Fashion-MNIST, and CIFAR-10. Specifically, the MNIST and Fashion-MNIST datasets contain 60,000 training samples and 10,000 test samples, respectively, each of which is a 28x28 grayscale image; the CIFAR-10 dataset contains 50,000 training samples and 10,000 test samples, each of which is a 32x32 color three-channel image. For different datasets, we used different neural network architectures: the MNIST dataset uses the LeNet network, the Fashion-MNIST dataset uses the LightVGG network, and the CIFAR-10 dataset uses the CNN network.
[0076] We will compare with the following baselines: FedAvg, FedProx, SCAFFOLD, FedNova, FedSAM, which are classic FL methods or methods proposed to solve data heterogeneity.
[0077] In the experiment, we set up 10 clients, and all clients participated in each round of training, with a total of 50 rounds of communication.
[0078]
[0079]
[0080] Table 1 Experimental results display
[0081] On the number of each client, we use normal distribution sampling, sampling 1000 samples for each client, and the error of the number of samples is within the range of ±100. In addition, we use the parameter m to control the maximum number of categories for each client. For example, when m = 3, each client contains at most 3 categories of data. For all experimental methods, the learning rate is set to 0.01, the local training Epoch is 5, and the batch size is 32.
[0082] Table 1 reports the differences between our method and the baseline method under different degrees of heterogeneity. In general, our method can effectively alleviate the problems caused by data heterogeneity. As m increases, that is, the degree of data heterogeneity decreases, all methods can improve the test accuracy, and the FedCPSO method achieves the highest accuracy in most cases, especially in all non-independent and identically distributed scenarios, it outperforms the comparison methods.
[0083] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Any ordinary technician in the industry can smoothly implement the present invention as shown in the drawings and described above. However, any equivalent changes, modifications and evolutions made by technicians familiar with the profession without departing from the scope of the technical solution of the present invention using the technical content disclosed above are all equivalent embodiments of the present invention. At the same time, any equivalent changes, modifications and evolutions made to the above embodiments based on the essential technology of the present invention are still within the protection scope of the technical solution of the present invention.
Claims
1. A method for processing heterogeneous federated learning data based on swarm intelligence optimization algorithm, It is characterized in that The specific steps include: Step S1, the server receives model updates from each client; Step S2, the server calculates the global model and performs intelligent aggregation based on the model uploaded by the client and the locally stored information; In step S3, the server sends the aggregated model to each client and starts a new round of local training.
2. According to claim 1, a method for processing heterogeneous federated learning data based on a swarm intelligence optimization algorithm, It is characterized in that In step S1, at the tth round of each training, the server receives the model set from the client 3. According to claim 2, a method for processing heterogeneous federated learning data based on a swarm intelligence optimization algorithm, It is characterized in that In step S2, the server calculates the global model and performs intelligent aggregation based on the model uploaded by the client and the locally stored information, which specifically includes the following four steps: Step 1: Take a weighted average of all clients’ models to get the average model for this round Step 2: The server uses the dataset D s Evaluate each model and get their test accuracy separately For the i-th client, its own optimal accuracy will be given by The corresponding model is considered as the local optimal model of the client. Step 3: Obtaining the global optimal accuracy The corresponding global optimal model θ * ; Step 4: Use the FedCPSO algorithm to update the average model obtained above, the local optimal model of each client, and the global optimal model to obtain the model required by each client in the t+1 round.
4. According to claim 3, a method for processing heterogeneous federated learning data based on a swarm intelligence optimization algorithm, It is characterized in that The first step is to obtain the average model of this round It is used to integrate the information of each client model to form an initial model with strong integrity.
5. According to claim 4, a method for processing heterogeneous federated learning data based on a swarm intelligence optimization algorithm, It is characterized in that Step 3: Obtain the global optimal model θ * This ensures that the entire system can find the current optimal model and provides the best reference model for subsequent updates.
6. According to claim 5, a method for processing heterogeneous federated learning data based on a swarm intelligence optimization algorithm, It is characterized in that Step 4: Use the FedCPSO algorithm to update the average model obtained above, the local optimal model of each client, and the global optimal model to obtain the model required by each client in the t+1 round. The specific process is as follows: In round t, after each client uploads their model, the server first calculates the weighted average model of all clients. The server also stores the update direction of client i in the previous round Next, the model parameters are updated according to the global search and local search strategies. For global search, the server updates the model parameters according to the weighted average model. and the global optimal model θ * Update the parameters. The specific formula is as follows: in, represents the state of the i-th client model in round t, r t is a random number uniformly distributed in the range [0,1]. Represents crow x i The length of the iterative flight in the tth round. This update strategy utilizes the information of the global optimal model, so that each client model can be close to the global optimal model, thereby improving the performance of the overall model.
7. The method for processing heterogeneous federated learning data based on a swarm intelligence optimization algorithm according to claim 6, It is characterized in that For local searches, the server uses a weighted average model The client's historical optimal model And the global optimal model θ * Update the parameters. The specific formula is as follows: Among them, α represents the inertia weight, c 1 and c 2 are the acceleration constant, r 1 and r 1 is a random number uniformly distributed in the range [0,1].
