Client selection method and system based on hierarchical aggregation
By adopting a hierarchical aggregation-based client selection method in the federated learning environment, the problem of model training consumes more local computing resources and low accuracy is solved, and the training efficiency and effect are improved, and the Generalization ability of the model.
Patent Information
- Application Number
- CN202411385485.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-02-18
AI Technical Summary
In a federated learning environment, model training consumes more local computing resources and low accuracy in training models.
Using a client selection method based on hierarchical aggregation, the training model is built on the central server, the client performs pre-training and clustering, and the edge server performs edge federated learning and global model aggregation, dynamically updates the cluster until the global model is trained to convergence. .
It improves the training efficiency and effectiveness of federated learning, reduces the rounds required for training, improves the generalization ability of the model, and slightly improves the accuracy of the training model.
Smart Images

Figure CN119474854A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of federated learning, and in particular relates to a client selection method and system based on hierarchical aggregation. Background Art
[0002] As an important branch of artificial intelligence, machine learning has been successfully and widely used in various fields such as pattern recognition, data mining, and computer vision. Due to the limited computing resources of terminal devices, the training of machine learning models is usually based on cloud center servers. In this way, the data collected by terminal devices, such as pictures, videos, or personal location information, must be uploaded to the central server to complete the model training. However, uploading real user data will leak their privacy. For the sake of privacy protection, terminal users are reluctant to share their private data, forming "data islands". In the long run, this seriously hinders the development and application of machine learning technology. In order to solve the problem of data islands, federated learning was proposed and attracted great attention. Federated learning provides a privacy-aware learning paradigm without the need to share original data, allowing participants to collaborate to build better global models by sharing only local model updates. The main idea is to train a local model on each client, the central server collects all local models, executes the federated averaging algorithm to complete model aggregation, and distributes the aggregated model to each client for the next round of local training. In this process, sensitive original data will not be exchanged on each client, thereby protecting user privacy. In recent years, the deployment of federated learning in practice has been widely used, such as mobile edge computing, IoT artificial intelligence, and autonomous driving.
[0003] In a federated learning environment, multiple rounds of interaction are required between the end user and the central server to obtain a global model of target accuracy. For complex model training, such as deep learning model training, each model update may contain millions of parameters. The high dimensionality of the model update will consume a lot of communication costs and even become a model training bottleneck. In addition, due to the heterogeneity of end users / devices, the unreliability of the network status of each device, and the asymmetry of the Internet connection speed, if the download speed is greater than the upload speed, resulting in a delay in the end user uploading the updated parameters, the model training bottleneck will be further aggravated.
[0004] In order to solve the problem of high communication cost in federated learning, domestic and foreign researchers have conducted extensive research and proposed many effective communication optimization methods. The mainstream methods to reduce communication volume usually compress, lightweight, distill and sparsify local model updates to make the uploaded model more compact, thereby achieving the purpose of reducing communication volume. However, they are usually accompanied by other shortcomings, such as consuming more local computing resources or seriously reducing the accuracy of the training model. Summary of the invention
[0005] The technical problem to be solved by the present invention is to provide a client selection method and system based on hierarchical aggregation, which solves the problem in the prior art that model training consumes more local computing resources and has low accuracy of the training model.
[0006] The present invention adopts the following technical solutions to solve the above technical problems:
[0007] The client selection method based on hierarchical aggregation includes the following steps:
[0008] Step 1: Build a training model on the central server and initialize the global model and global variables;
[0009] Step 2: Each client performs a small amount of pre-training based on its local data to obtain a local model and perform client clustering to obtain several classification clusters;
[0010] Step 3: Set up an edge server for each classification cluster and initialize the edge server model;
[0011] Step 4: Edge federated learning: The edge server selects some clients from the corresponding cluster as participants to perform edge federated learning. After a certain round of edge training, the aggregated edge model update and edge model are calculated.
[0012] Step 5: Full federated learning: the central server aggregates the edge model updates of all edge servers, calculates the global model of the global model update, and completes a certain number of global model aggregations;
[0013] Step 6: Apply steps 1 and 2 to cluster the global model aggregation again and dynamically update the clusters;
[0014] Step 7: Repeat steps 3 to 6 until the global model training converges and the model training is completed.
[0015] The specific steps of step 1 are as follows:
[0016] Step 1.1, build a training model, design the number of hidden layers and output layers and the number of neurons;
[0017] Step 1.2, initialize global variables, including client set C = {C1, C2, ..., C k}, global training round number R, edge training round number J;
[0018] Step 1.3: Initialize the global model, including global model parameters W0 and global model update G0.
[0019] The specific process of step 2 client clustering is as follows:
[0020] Step 2.1, obtain the initial global model parameter W0 from the central server;
[0021] Step 2.2: The client performs pre-training in parallel based on its local data to obtain a pre-trained local model L k And upload to the central server;
[0022] Step 2.3: The central server calculates the similarity d between models based on the pre-trained model set {L} m,n , construct the similarity graph P;
[0023] Step 2.4: Cluster the clients according to the similarity graph P to obtain several classification clusters.
[0024] The specific process of initializing the edge server model in step 3 is as follows:
[0025] Step 3.1: Build an edge model and assign a different subset of the global model to each edge server as the edge model.
[0026] Step 3.2: Initialize the edge model, including edge model parameters W J , edge model update G J .
[0027] The specific process of step 4 is as follows:
[0028] Step 4.1: Local model training: The client obtains the edge model parameters of the j-th round of edge training from the edge server, and performs local model training in parallel based on its local data to obtain the local model L of the j-th round of edge training. k , and upload the local model update to the edge server;
[0029] Step 4.2: Edge model update: The edge server aggregates the uploaded local updates, calculates the aggregated edge model updates and edge models, and the model training enters the next round of edge training.
[0030] The similarity between the models d m,n Calculated according to the following formula:
[0031]
[0032] The client selection system based on hierarchical aggregation includes a central server module, an edge server module, and a client; wherein the central server module is used to construct a central server model and initialize and set progressive sub-models and global variables;
[0033] The edge server module is used to build an edge server model for the classification cluster, initialize the edge model parameters and edge model updates, perform edge federated learning on some clients selected in the corresponding cluster after clustering, and calculate the aggregated edge model updates and edge models;
[0034] The client is used to obtain edge model parameters from the edge server model, perform local model training in combination with local data, obtain a pre-trained local model, and upload the local model update to the edge server.
[0035] A central server exchanges information with multiple edge servers, and an edge server exchanges information with multiple clients.
[0036] A computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, call all or part of the steps of the method.
[0037] Compared with the prior art, the present invention has the following beneficial effects:
[0038] 1. This method is suitable for improving communication efficiency and reducing computing pressure. By constructing similarity graphs and dynamic clustering, effective client grouping is achieved, the training efficiency and effect of federated learning are improved, and the number of rounds required for training is reduced.
[0039] 2. The allocation of edge servers and global model subsets is set up to retain the unique clustering characteristics of different clusters, further improving the generalization ability of the model.
[0040] 3. The method and system proposed in the present invention can not only reduce the number of federated learning iterations for global model training to convergence, but also slightly improve the accuracy of the training model. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 The present invention provides an overall method flow chart for an embodiment of the present invention.
[0042] Figure 2 A flowchart of specific steps provided for an embodiment of the present invention.
[0043] Figure 3 A schematic diagram of the overall principle provided for an embodiment of the present invention. DETAILED DESCRIPTION
[0044] The structure and working process of the present invention will be further described below in conjunction with the accompanying drawings.
[0045] In order to reduce the number of training rounds to reduce the overall communication data volume, while ensuring the accuracy of the training model, and more effectively solve the problem of high communication cost of federated learning, the present invention proposes a client selection method based on hierarchical aggregation. This method is suitable for improving communication efficiency and reducing computing pressure. By constructing a similarity graph and dynamic clustering, effective grouping of clients is achieved, the training efficiency and effect of federated learning are improved, and the number of rounds required for training is reduced. At the same time, the allocation of edge servers and global model subsets is set, which can retain the unique clustering features of different clusters and further improve the generalization ability of the model. The method and system proposed in the present invention can not only reduce the number of federated learning iterations for global model training to convergence, but also slightly improve the accuracy of the training model.
[0046] The client selection method based on hierarchical aggregation includes the following steps:
[0047] Step 1: Build a training model on the central server and initialize the global model and global variables;
[0048] Step 2: Each client performs a small amount of pre-training based on its local data to obtain a local model and perform client clustering to obtain several classification clusters;
[0049] Step 3: Set up an edge server for each classification cluster and initialize the edge server model;
[0050] Step 4: Edge federated learning: The edge server selects some clients from the corresponding cluster as participants to perform edge federated learning. After a certain round of edge training, the aggregated edge model update and edge model are calculated.
[0051] Step 5: Full federated learning: the central server aggregates the edge model updates of all edge servers, calculates the global model of the global model update, and completes a certain number of global model aggregations;
[0052] Step 6: Apply steps 1 and 2 to cluster the global model aggregation again and dynamically update the clusters;
[0053] Step 7: Repeat steps 3 to 6 until the global model training converges and the model training is completed.
[0054] The specific process is as follows:
[0055] Step S1, central server initialization. The central server builds a training model, initializes the global model and global variables, including the following sub-steps:
[0056] Step S1.1, construct a training model and design the number of layers and neurons in the hidden layer and output layer.
[0057] Step S1.2, initialize global variables, including client set C = {C1, C2, ..., C k}, the number of global training rounds R, and the number of edge training rounds J.
[0058] Step S1.3, initialize the global model, including global model parameters W0, and global model update G0.
[0059] Step S2, client clustering. Each client performs a small amount of pre-training based on its local data to obtain a local model and perform client clustering, including the following sub-steps:
[0060] Step S2.1, obtain the initial global model parameter W0 from the central server.
[0061] Step S2.2: The client performs pre-training in parallel based on its local data to obtain a pre-trained model L k And upload to the central server.
[0062] Step S2.3: The central server calculates the similarity d between models based on the pre-trained model set {L} m,n , construct the similarity graph P.
[0063] Step S2.4, clustering clients according to the similarity graph P, ensuring that clients in the same cluster have high similarity.
[0064] Step S3: Initialize the edge server. Set up an edge server for each classification cluster and initialize the edge server model, including the following sub-steps:
[0065] Step S3.1, construct edge model, each edge server is assigned a different subset of the global model as the edge model.
[0066] Step S3.2, initializing the edge model, including edge model parameters Edge Model Update
[0067] Step S4: edge federated learning. The edge server selects some clients from the corresponding cluster as participants to participate in edge federated learning, and calculates the aggregated edge model update and edge model.
[0068] Step S4.1: local model training. The client obtains the edge model parameters of the jth round of edge training from the edge server, and performs local model training in parallel based on its local data to obtain the local model L of the jth round of edge training. k , and upload the local model update to the edge server.
[0069] Step S4.2: Edge model update: The edge server aggregates the uploaded local updates, calculates the aggregated edge model updates and edge models, and the model training enters the next round of edge training.
[0070] Step S5, global federated learning. After a certain round of edge training, the central server aggregates the edge model updates of all edge servers and calculates the global model for global model updates.
[0071] Step S6, dynamic update: After a certain number of global model aggregations are completed, steps S1 to S2 are repeated to perform clustering again to dynamically update the clusters to ensure that the clustering results are always consistent with the actual situation of the client.
[0072] Repeat steps S4 to S6 until the global model training reaches convergence and the model training is completed.
[0073] Specific embodiments, such as Figures 1 to 3 As shown,
[0074] The concept, specific structure and technical effects of the present invention will be further described below in conjunction with the accompanying drawings and embodiments, so as to fully understand the purpose, characteristics and effects of the present invention.
[0075] The following takes the example of 100 users jointly training a convolutional neural network to illustrate the specific implementation steps of the present invention.
[0076] The method provided by the technical solution of the present invention can use computer software technology to realize automatic operation process. Figure 1 is a flow chart of the overall method of an embodiment of the present invention, combined with Figure 2 The specific steps of the embodiment of the present invention are as follows:
[0077] Step S1, central server initialization. The central server builds a training model, initializes the progressive sub-model and global variables, including the following sub-steps:
[0078] Step S1.1, construct a training model and design the number of layers and neurons in the hidden layer and output layer.
[0079] In the embodiment, a convolutional neural network with 6 Conv layers is simulated.
[0080] Step S1.2, initialize global variables, including client set C = {C1, C2, ..., C k}, the number of global training rounds R, and the number of edge training rounds J.
[0081] In the embodiment, the initialization client set C = {C1, C2, ..., C k}, the number of global training rounds R = 0, and the number of edge training rounds J = 0.
[0082] Step S1.3, initialize the global model M, including the global model parameters W R , the global model update G R .
[0083] In the embodiment, the global model parameter W0 is initialized and the global model is updated G0.
[0084] Step S2, client clustering. Each client performs a small amount of pre-training based on its local data to obtain a local model and perform client clustering, including the following sub-steps:
[0085] Step S2.1, obtain the initial global model parameters W from the central server R .
[0086] In the embodiment, the initialized global model parameter W0 is obtained from the central server.
[0087] Step S2.2: Taking the kth client as an example, local pre-training is performed in parallel based on its local data to obtain the pre-trained model L k .
[0088] In the embodiment, taking the 10th client as an example, local pre-training is performed in parallel based on its local data to obtain a pre-training model L 10 .
[0089] Step S2.3: The central server calculates the similarity d between models based on the pre-trained model set {L} m,n Construct a similarity graph P.
[0090] In the embodiment, the central server aggregates all pre-trained models and calculates the similarity between the models. Construct a similarity graph P.
[0091] Step S2.4, clustering clients according to the similarity graph P, ensuring that clients in the same cluster have high similarity.
[0092] In the embodiment, the central server clusters the clients according to the similarity graph P, and divides the clients into five clusters {Z1, Z2, ..., Z5} according to the similarity of the clients.
[0093] Step S3, edge server initialization. Set up an edge server for each classification cluster and initialize the edge server model, including the following sub-steps:
[0094] Step S3.1, construct edge model, each edge server is assigned a different subset of the global model as the edge model.
[0095] In the embodiment, taking the first cluster as an example, an edge server is assigned to it, and a neural network with the first three Conv layers of the global model is simulated as the edge model.
[0096] Step S3.2, initializing the edge model, including edge model parameters Edge Model Update
[0097] In the embodiment, the edge model parameters are initialized Edge Model Update
[0098] Step S4: edge federated learning. The edge server selects some clients from the corresponding cluster as participants to participate in edge federated learning, and calculates the aggregated edge model update and edge model.
[0099] Step S4.1: local model training. The client obtains the edge model parameters of the jth round of edge training from the edge server, and performs local model training in parallel based on its local data to obtain the local model L of the jth round of edge training. k , and upload the local model update to the edge server.
[0100] In the embodiment, taking the first client in the first cluster as an example, the edge model is first obtained from the edge server, and then the local model is trained in parallel according to the local data set to obtain a round of iterative local model L1, and the local update is uploaded to the edge server.
[0101] Step S4.2: Edge model update: The edge server aggregates the uploaded local updates, calculates the aggregated edge model updates and edge models, and the model training enters the next round of edge training.
[0102] In the embodiment, taking the edge server of the first cluster as an example, the local updates uploaded by the participating clients in the first cluster are aggregated, and the aggregated edge model updates and edge models are calculated.
[0103] Step S5, global federated learning. After a certain number of rounds of edge training, the central server aggregates the edge model updates of all edge servers and calculates the global model for global model updates.
[0104] In the embodiment, the edge training round number J=10 is used as the update threshold, the central server aggregates the edge models of all edge servers, and calculates the global model update G1 and the global model M.
[0105] Step S6, dynamic update: After a certain number of global model aggregations are completed, step S2 is repeated to re-cluster the clusters to dynamically update the clusters, ensuring that the clustering results are always consistent with the actual situation of the client.
[0106] In the embodiment, the edge training round number J=40 is used as the update threshold, and the central server gathers all client models and re-clustering them to make the clustering result consistent with the actual situation of the client.
[0107] Repeat steps S4 to S6 until the global model converges and the model training is completed.
[0108] The client selection system based on hierarchical aggregation includes a central server module, an edge server module, and a client; wherein the central server module is used to construct a central server model and initialize and set progressive sub-models and global variables;
[0109] The edge server module is used to build an edge server model for the classification cluster, initialize the edge model parameters and edge model updates, perform edge federated learning on some clients selected in the corresponding cluster after clustering, and calculate the aggregated edge model updates and edge models;
[0110] The client is used to obtain edge model parameters from the edge server model, perform local model training in combination with local data, obtain a pre-trained local model, and upload the local model update to the edge server.
[0111] A central server exchanges information with multiple edge servers, and an edge server exchanges information with multiple clients.
[0112] A computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, call all or part of the steps of the method.
[0113] If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program code.
[0114] Those skilled in the art should understand that they can implement variations by combining the prior art and the above embodiments. Such variations do not affect the essence of the present solution and are not described in detail here.
[0115] It should be understood that the present solution is not limited to the above-mentioned specific implementation methods, and the devices and structures not described in detail should be understood to be implemented in a common manner in the art; any technician familiar with the art can use the above-disclosed methods and technical contents to make many possible changes and modifications to the technical solution of the present solution without departing from the scope of the technical solution of the present solution, or modify it into an equivalent embodiment with equivalent changes, which does not affect the essential content of the present solution. Therefore, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present solution without departing from the content of the technical solution of the present solution still falls within the scope of protection of the technical solution of the present solution.
Claims
1. A client selection method based on hierarchical aggregation, characterized in that: The steps include: Step 1: Build a training model on the central server and initialize the global model and global variables; Step 2: Each client performs a small amount of pre-training based on its local data to obtain a local model and perform client clustering to obtain several classification clusters; Step 3: Set up an edge server for each classification cluster and initialize the edge server model; Step 4: Edge federated learning: The edge server selects some clients from the corresponding cluster as participants to perform edge federated learning. After a certain round of edge training, the aggregated edge model update and edge model are calculated. Step 5: Full federated learning: the central server aggregates the edge model updates of all edge servers, calculates the global model of the global model update, and completes a certain number of global model aggregations; Step 6: Apply steps 1 and 2 to cluster the global model aggregation again and dynamically update the clusters; Step 7: Repeat steps 3 to 6 until the global model training converges and the model training is completed.
2. The client selection method based on hierarchical aggregation according to claim 1, characterized in that: The specific steps of step 1 are as follows: Step 1.1, build a training model, design the number of hidden layers and output layers and the number of neurons; Step 1.2, initialize global variables, including client set C = {C1, C2, ..., C k }, global training round number R, edge training round number J; Step 1.3: Initialize the global model, including global model parameters W0 and global model update G0.
3. The client selection method based on hierarchical aggregation according to claim 2, characterized in that: The specific process of step 2 client clustering is as follows: Step 2.1, obtain the initial global model parameter W0 from the central server; Step 2.2: The client performs pre-training in parallel based on its local data to obtain a pre-trained local model L k And upload to the central server; Step 2.3: The central server calculates the similarity d between models based on the pre-trained model set {L} m,n , construct a similarity graph P; Step 2.4: Cluster the clients according to the similarity graph P to obtain several classification clusters.
4. The client selection method based on hierarchical aggregation according to claim 3, characterized in that: The specific process of initializing the edge server model in step 3 is as follows: Step 3.1: Build an edge model and assign a different subset of the global model to each edge server as the edge model. Step 3.2: Initialize the edge model, including edge model parameters W J , edge model update G J .
5. The client selection method based on hierarchical aggregation according to claim 4, characterized in that: The specific process of step 4 is as follows: Step 4.1: Local model training: The client obtains the edge model parameters of the j-th round of edge training from the edge server, and performs local model training in parallel based on its local data to obtain the local model L of the j-th round of edge training. k , and upload the local model update to the edge server; Step 4.2: Edge model update: The edge server aggregates the uploaded local updates, calculates the aggregated edge model updates and edge models, and the model training enters the next round of edge training.
6. The client selection method based on hierarchical aggregation according to claim 5, characterized in that: The similarity between the models d m,n Calculated according to the following formula:
7. A client selection system based on hierarchical aggregation, characterized in that: It includes a central server module, an edge server module, and a client; wherein the central server module is used to construct a central server model and initialize the progressive sub-model and global variables; The edge server module is used to build an edge server model for the classification cluster, initialize the edge model parameters and edge model updates, perform edge federated learning on some clients selected in the corresponding cluster after clustering, and calculate the aggregated edge model updates and edge models; The client is used to obtain edge model parameters from the edge server model, perform local model training in combination with local data, obtain a pre-trained local model, and upload the local model update to the edge server.
8. The client selection system based on hierarchical aggregation according to claim 7, characterized in that: A central server exchanges information with multiple edge servers, and an edge server exchanges information with multiple clients.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, all or part of the steps of the method described in any one of claims 1 to 6 are called.