A federated learning approach to alleviate heterogeneity problems

By adaptively adjusting the task volume and client clustering, the problems of client laggard and data heterogeneity in federated learning are solved, the fairness of client selection and the convergence speed of the model are improved, and better data distribution balance and data are achieved. Generalization performance.

CN115936110BActive Publication Date: 2024-09-03CHONGQING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211458846.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-18
Publication Date
2024-09-03
Estimated Expiration
2042-11-18

AI Technical Summary

Technical Problem

In federated learning, client drift problems caused by client lag behind, high computational complexity of complex models, and data heterogeneity result in resource-limited clients being unable to participate in training, reduced model generalization performance, and data distribution shifts and convergence. The speed slows down.

Method used

By adaptively adjusting the task volume, the LinUCB algorithm is used to calculate the final task volume of the client. The client selects multiple clusters and balanced clusters, and all tilted clusters are selected to extract data class distribution characteristics. PCA is used for dimensionality reduction, and the MD sampling algorithm is used to select and participate in the overall situation. Model training client.

Benefits of technology

It improves the fairness of participation of resource-constrained clients, reduces client lag, retains important information, reduces information loss after dimensionality reduction of model parameters, reduces weight update offset phenomena, and improves the convergence speed and generalization of the global model. performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115936110B
    Figure CN115936110B
Patent Text Reader

Abstract

The present invention relates to a federated learning method for alleviating heterogeneity problems, comprising initializing the task load and historical training data of all clients; selecting M clients as first clients; generating a feature vector of the client according to a resource report of the client; sending a global model and the task load of the first client to the first client to train the global model to obtain a local model; aggregating the local models uploaded by the client to obtain a global model for the next round of iterative training; updating the first client by using the training data of the global model; a server re-dividing the first client and the second client for the next round of iterative training of the global model according to the local model uploaded by the first client to the server and using an auxiliary data set; and repeatedly executing steps S2-S6 until a preset number of training rounds is reached, and outputting a final global model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of application of federated learning technology, and specifically relates to a federated learning method for alleviating heterogeneity problems. Background Art

[0002] Federated Learning is an emerging basic technology of artificial intelligence. Its design goal is to carry out efficient machine learning among multiple participants or multiple computing nodes under the premise of ensuring information security during big data exchange, protecting terminal data and personal data privacy, and ensuring legality and compliance.

[0003] As an emerging artificial intelligence technology, federated learning mainly includes: a server and multiple clients participating in federated learning. The server sends the machine learning model that needs to be trained to the client. The way the server sends the machine learning model to the client is mainly in the form of model parameters. Multiple clients use local samples to train the model parameters respectively, and upload the trained model parameters to the server. The server generates a local model based on the model parameters uploaded by each client and uses the local model to calculate the gradient changes of the model parameters on each client. The gradient changes of all clients are aggregated to obtain the final global model. The server sends the model parameters of the global model to the client to complete the federated learning task. Federated learning mainly involves moving the model among multiple participants, and the data of the participants will not be moved. The privacy and data security of each participant are guaranteed when federated learning is performed on multiple clients.

[0004] However, there are still some key issues that need to be resolved. The first is the client lagging problem, that is, the client cannot complete the federated training task and upload it to the server local model within the specified time, which makes the global model aggregated by the server invalid. Most of the existing solutions tend to select clients that can quickly complete the federated training task to participate in federated learning; the second is the high computational complexity of complex models. The scale of clients participating in federated learning is huge, and the computational cost of the algorithm increases with the increase of client scale. The existing solutions often reduce the dimensionality of the local model uploaded by the client to reduce the calculation parameters; the last is the client data heterogeneity problem. Since the data of each client is not independent and identically distributed, it is difficult for federated learning to achieve the effect of traditional centralized training. The existing solutions are committed to unbiased sampling of client clusters or maximizing the number of clients participating in model training.

[0005] To sum up, combined with the existing research on client selection, it is found that although many scholars have achieved some results in client selection, there are still some technical problems.

[0006] 1. Resource-constrained clients cannot participate in federated learning training. Giving priority to clients with higher computing resources can reduce the number of laggards, but the data of resource-constrained clients will find it difficult to participate in training, causing the data distribution of the client cluster participating in training to deviate from the data distribution of the overall client cluster for a long time, greatly reducing the generalization performance of the model.

[0007] 2. Information loss caused by dimensionality reduction. Although reducing the dimensionality of the local model parameters effectively reduces the algorithm calculation time, some crucial information is likely to be lost in the process of dimensionality reduction, making it difficult for the algorithm to achieve the desired goal.

[0008] 3. Client drift caused by data heterogeneity, that is, the convergence direction of a small number of clients deviates from the convergence direction of most other clients, see the paper "Towards Personalized Federated Learning" for details. Although unbiased sampling and expanding the number of clients participating in model training make the data distribution of the client cluster participating in training basically consistent with the data distribution of the overall client cluster, ensuring the correctness of the overall convergence direction, it is not the optimal solution. The local model of the client with a deviation in the convergence direction will have a large number of weight update offsets when aggregated on the server, reducing the model convergence speed. Summary of the invention

[0009] In order to solve the problems existing in the background technology, the present invention provides a federated learning method for alleviating the heterogeneity problem, including:

[0010] S1: The server extracts some local samples from the database of all clients to form an auxiliary data set; and randomly initializes the task volume and historical training data of all clients; the server randomly selects M clients from all clients as the first clients according to the preset number of clients M participating in each round of global model training; and the remaining clients are used as the second clients;

[0011] S2: The server obtains resource reports of all clients and generates a feature vector of the client according to the resource reports of the client; wherein the resource reports of the client include: CPU clock frequency, bandwidth, memory and energy of the client;

[0012] S3: The server sends the global model and the workload of the first client to the first client; the first client trains the global model using local samples according to the received workload to obtain a local model, and uploads the training data of the global model and the local model to the server; the server aggregates all local models uploaded by the first client to obtain a global model for the next round of iterative training;

[0013] The training data of the global model includes: the time when the first client receives the global model, the time when the first client uploads the local model, the transmission power when the first client uploads the local model, the channel gain between the first client and the server, the signal interference when the first client uploads the local model, the number of local samples of the first client, the number of CPU cycles required for the first client to train the global model once using a local sample, and the number of model parameters of the global model.

[0014] S4: The server updates the historical training data of the first client using the training data of the global model uploaded by the first client;

[0015] S5: The server calculates the final task amount of the first client using the LinUCB algorithm according to the feature vector of the first client and the historical training data of the first client; and updates the task amount of the first client using the final task amount of the first client;

[0016] The step of calculating the final task amount of the first client by using the LinUCB algorithm according to the feature vector of the first client and the historical training data of the first client includes:

[0017] S51: Based on the feature vector x of the first client i,t Calculate the iterative training time of the first client and the model parameter upload time of the first client using the historical training data of the first client;

[0018] The calculation step of the iterative training time of the first client and the model parameter upload time of the first client includes:

[0019] S511: Calculating the iterative training time of the first client according to the number of CPU cycles required for the first client to train the global model once using a local sample and the CPU cycle frequency of the first client;

[0020] S512: Calculate the model parameter upload time of the first client according to the number of model parameters of the global model and the bandwidth of the first client.

[0021] S52: Calculate the final task amount of the first client by using the LinUCB algorithm according to the iterative training time of the first client and the model parameter upload time of the first client.

[0022] The step of calculating the final task amount of the first client includes:

[0023] S521: judging whether the first client completes the task of the first client within a preset maximum waiting time of the server according to the time when the first client receives the global model and the time when the first client uploads the local model;

[0024] S522: Calculate the initial task amount of the first client by using the LinUCB algorithm according to the completion status of the task amount by the first client and the feature vector of the first client;

[0025] S523: Calculate the final task volume of the first client according to the initial task volume of the first client, the iterative training time of the first client, the model parameter upload time of the first client, the preset maximum waiting time of the server and the number of local samples of the first client.

[0026] S6: The server uses the auxiliary data set to re-divide the first client and the second client for the next round of iterative training of the global model according to the local model uploaded by the first client to the server and the preset number of clients participating in each round of global model training; and repeats steps S2-S6 until the preset number of training rounds is reached, and outputs the final global model.

[0027] The method of selecting a first client to participate in the next round of iterative training of the global model from all clients using an auxiliary data set according to the local model uploaded by the first client to the server and the preset number of clients to participate in each round of global model training includes:

[0028] S61: Calculating data features of the first client using the auxiliary data set according to the local model uploaded by the first client to the server;

[0029] The step of calculating the data feature of the first client includes:

[0030] S611: Input the auxiliary data set into the local model uploaded by the first client to the server to calculate the loss of the local model for the samples in the auxiliary data set, and obtain the gradient vector of the weight parameters from the hidden layer to the output layer of the local model according to the loss of the local model for the samples in the auxiliary data set;

[0031] S612: Calculate the ratio of local samples of each category of the first client to the total local samples of the client according to the gradient vector of the weight parameters from the hidden layer to the output layer of the local model;

[0032] S613: Generate a class distribution feature of the local sample data of the first client according to the ratio of the local samples of each category of the first client to the total local samples of the first client;

[0033] S614: Use PCA to perform dimensionality reduction processing on the weight parameters of the fully connected layer of the local model, and perform feature fusion on the weight parameters of the fully connected layer after the dimensionality reduction processing and the class distribution characteristics of the local sample data of the first client to obtain the data characteristics of the first client.

[0034] S62: randomly selecting k first clients as cluster core clients, and clustering the first clients to the cluster core clients closest to their data features according to the distance between the data features of the first clients and the data features of each cluster core client to obtain multiple client clusters and cluster core clients;

[0035] S63: sequentially use the remaining first clients in the client cluster except the cluster center client as target center points to construct a criterion function, and use the target center point with the smallest criterion function as the cluster center client of the next iteration, repeat steps S62-S63 until the cluster center client does not change, and obtain multiple client clusters and cluster center clients;

[0036] S64: Calculate a balance point according to the clustered multiple client clusters and cluster center clients;

[0037] S65: Calculate the distance between the cluster center client and the balance point;

[0038] S66: The client cluster whose distance from the cluster center client to the balance point is less than a set threshold is used as a balanced cluster, and the remaining client clusters are used as tilted clusters;

[0039] S67: Allocate quotas to each balanced cluster, tilted cluster, and second client using an integer allocation algorithm according to the preset quota of clients participating in each round of global model training and the number of clients owned by each cluster;

[0040] S68: According to the number of client quotas for the next round of global model training owned by each balanced cluster, tilted cluster and second client and the amount of tasks of each client, use the MD sampling algorithm to select a corresponding number of clients from each balanced cluster, tilted cluster and second client as the first clients for the next round of iterative training, and select the remaining clients as the second clients for the next round of iterative training.

[0041] The present invention has at least the following beneficial effects

[0042] 1. The present invention uses an adaptive adjustment method for the task volume so that resource-constrained clients can also complete their federated training tasks within the specified time, thereby improving the fairness of client selection in the federated learning process, solving the problem of clients falling behind, and laying the foundation for subsequent client selection to obtain a more uniform data distribution.

[0043] 2. The present invention adopts a method of extracting the client data class distribution so that the main data characteristics of the client can be retained and more prominent, thereby improving the effectiveness of the client selection algorithm and solving the problem of important information loss after model parameter dimensionality reduction.

[0044] 3. The present invention adopts client clustering, balanced cluster multi-selection and tilted cluster equal selection to make the clients selected by the client selection algorithm more representative, greatly reduce the weight update offset phenomenon of the server-aggregated local model, and the convergence direction of the global model obtained by server aggregation does not deviate from the optimal direction, thereby improving the convergence speed and generalization performance of the global model and solving the client drift problem caused by data heterogeneity. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 is a flow chart of the method of the present invention;

[0046] Figure 2 A schematic diagram of constructing a feature vector of a client of the present invention;

[0047] Figure 3 This is a flow chart of the method for predicting the task load of a client of the present invention;

[0048] Figure 4 Schematic diagram of data feature extraction of the client of the present invention. DETAILED DESCRIPTION

[0049] In order to better illustrate the technical solution of the present invention and make the advantages more concise and clear, the problem to be solved by the present invention is first specifically explained below, and then the specific implementation methods of the present invention are further described in detail with reference to the accompanying drawings of the specification.

[0050] See also Figure 1 The present invention provides a federated learning method for alleviating the heterogeneity problem, comprising:

[0051] S1: The server extracts some local samples from the database of all clients to form an auxiliary data set; and randomly initializes the task volume and historical training data of all clients; the server randomly selects M clients from all clients as the first clients according to the preset number of clients M participating in each round of global model training; and the remaining clients are used as the second clients; the auxiliary data set contains local samples of each category of all clients and the number of local samples of each category is the same, each local sample has a category label of the sample, the local sample can be a medical image, medical statistical data, etc., and the historical training data of each client is initialized to empty, and the client is the corresponding computer or smart device in each medical institution.

[0052] When the global model is trained for the first iteration of federated learning, since all clients have no historical training data, the client's task volume cannot be calculated. Therefore, the present invention randomly initializes the task volume of all clients.

[0053] The task volume of the client is the number of local samples required by the client to train the global model. In order to make it easier to aggregate the local model into a global model in each round of federated learning, the number of clients participating in each round of global model iterative training in the federated learning process is the same in the present invention.

[0054] See also Figure 2 , S2: The server obtains resource reports of all clients and generates a feature vector of the client according to the resource reports of the client; wherein the resource reports of the client include: CPU clock frequency, bandwidth, memory and energy of the client;

[0055] Generating a feature vector of the client according to the resource report of the client includes:

[0056] Before sending the global model each time, the server will obtain resource reports from all clients and divide each resource in the resource report into 10 discrete intervals, represented by 1 to 10. If the client is powered on, the energy is set to 10. If it is not powered on, it is discretized into 10 discrete intervals according to the battery power of the client and represented by 1 to 10. Thus, a resource vector is generated for each client report, and after normalization, a constant 1 is added to obtain the client's feature vector x i,t :

[0057] x i,t =(CPU it ,Bandwidth it ,Memory it ,Energy it ,1)

[0058] Among them, CPU it , Bandwidth it , Memory it and Energy it They represent the discrete normalized clock frequency, discrete normalized bandwidth, discrete normalized memory, and discrete normalized energy of the i-th client during the t-th round of iterative training. This can effectively overcome the hidden defects in the data, such as reducing the number of categories, unifying the dimensions, and balancing the contributions of each feature.

[0059] S3: The server sends the global model and the workload of the first client to the first client; the first client trains the global model using local samples according to the received workload to obtain a local model, and uploads the training data of the global model and the local model to the server; the server aggregates all local models uploaded by the first client to obtain a global model for the next round of iterative training;

[0060] In federated learning, the server will first send the initial global model to the server; after receiving the initial global model, the client will use local samples to train the initial global model and upload the trained initial global model to the server as a local model. The server receives the local models uploaded by all clients, and aggregates the model parameters of all local models to generate a global model for the next round of iterative training. The iterative training process is repeated until the preset number of iterations is reached to obtain the final global model. The server can use the final global model to predict the target sample. At the same time, the server can also send the final global model to the client, and the client predicts the target sample through the final global model. However, among the clients participating in federated learning in the present invention, not all clients will participate in the training of the global model in each round of iterative training. Only some M clients will participate in the training of the global model, where M represents the number of clients participating in the global model training in each round preset by the server. This can avoid the situation where some clients fall behind, resulting in the uploaded local model lacking some data, making the global model aggregated by the server invalid. By setting only some clients to train the global model, the clients participating in the next round of federated learning are adjusted among all clients according to the completion status and the resource status of the clients, thereby avoiding the situation where the global model aggregated by the server becomes invalid.

[0061] The training data of the global model includes: the time when the first client receives the global model, the time when the first client uploads the local model, the transmission power when the first client uploads the local model, the channel gain between the first client and the server, the signal interference when the first client uploads the local model, the number of local samples of the first client, the number of CPU cycles required for the first client to train the global model once using a local sample, and the number of model parameters of the global model.

[0062] In the present invention, the global model is a CNN neural network; the model parameters of the global model include: weight parameters between the hidden layer and the output layer of the CNN neural network, weight parameters between the hidden layers of the CNN neural network, and weight parameters between the input layer and the hidden layer; in other preferred embodiments, the local model can also be a DNN or RNN model.

[0063] S4: The server updates the historical training data of the first client using the training data of the global model uploaded by the first client;

[0064] Before the global model starts training, the server will initialize the historical training data of each client to empty; after the first round of global model training, the server will receive the global model training data uploaded by the first client as the historical training data of the first client; in the subsequent global model iterative training process, if the client uploads new global model training data again, the server will replace the original historical training data of the client with the new global model training data as the new historical training data of the client. For example, there are clients A, B, and C. After the first round of training, the server receives the global model training data a1, b1, and empty uploaded by the client; empty means that the client did not participate in this round of global model training; after the second round of training, the server receives the global model training data a2, empty, and empty uploaded by the client; then in the third round of training, the historical training data of clients A, B, and C are a2, b1, and empty respectively.

[0065] S5: The server calculates the final task amount of the first client using the LinUCB algorithm according to the feature vector of the first client and the historical training data of the first client; and updates the task amount of the first client using the final task amount of the first client;

[0066] The step of calculating the final task amount of the first client by using the LinUCB algorithm according to the feature vector of the first client and the historical training data of the first client includes:

[0067] S51: Based on the feature vector x of the first client i,t Calculate the iterative training time of the first client and the model parameter upload time of the first client using the historical training data of the first client;

[0068] S511: Calculating the iterative training time of the first client according to the number of CPU cycles required for the first client to train the global model once using a local sample and the CPU cycle frequency of the first client;

[0069]

[0070] Among them, g i Indicates the first client A i The number of CPU cycles required to train the global model using a local sample, f i Indicates the first client A i The CPU cycle frequency, Indicates the first client A i Iterative training time, 0<i≤M (M represents the number of first clients).

[0071] S512: Calculate the model parameter upload time of the first client according to the number of model parameters of the global model and the bandwidth of the first client:

[0072]

[0073] Among them, T i com Indicates the first client A i The model parameter upload time, α represents the number of model parameters of the global model, B i Indicates the first client A i The bandwidth, ρ i Indicates the first client A i The transmission power, h i Indicates the first client A i The channel gain between the client and the server, N0 represents the signal interference when the first client uploads the local model. In the present invention, N0 is taken as 50dB, and those skilled in the art can determine the value according to the actual situation.

[0074] See also Figure 3 , S52: Calculate the final task amount of the first client using the LinUCB algorithm according to the iterative training time of the first client and the model parameter upload time of the first client;

[0075] S521: judging whether the first client completes the task of the first client within a preset maximum waiting time of the server according to the time when the first client receives the global model and the time when the first client uploads the local model;

[0076]

[0077]

[0078] Among them, T max is the preset maximum server waiting time, Indicates the time when the first client uploaded the local model; Indicates the time when the first client receives the global model.

[0079] S522: Calculate the initial task amount of the first client by using the LinUCB algorithm according to the completion status of the task amount by the first client and the feature vector of the first client;

[0080]

[0081]

[0082] b i,t =b i,t-1 +r i,t x i,t

[0083]

[0084]

[0085] in, represents the initial task volume of the first client, T max is the preset maximum server waiting time, p i,t For the first client A i The amount of tasks; Indicates the time when the first client uploaded the local model; represents the time when the first client receives the global model, r i,t represents the real return, x i,t The feature vector A of the first client i,t-1 represents a 5×5 dimensional matrix, b i,t-1 Represents a 5-dimensional vector, A i,0 Each element in b is 1, i,0 Every element in is 0; is a positive real number greater than 0. In the present invention, its value is 0.5. Those skilled in the art can randomly select a value according to actual conditions. t represents the number of rounds of iterative training.

[0086] S523: Calculate the final task volume of the first client according to the initial task volume of the first client, the iterative training time of the first client, the model parameter upload time of the first client, the preset maximum waiting time of the server, and the number of local samples of the first client:

[0087]

[0088]

[0089] in, represents the ideal workload of the first client, represents the initial task volume of the first client, T max is the preset maximum server waiting time, Indicates the first client A i Iteration training time, T i com Indicates the first client A i Model parameter upload time, S iIndicates the number of local samples of the first client. The present invention uses the method of adaptively adjusting the task amount so that resource-constrained clients can also complete their federated training tasks within the specified time, thereby improving the fairness of client selection in the federated learning process, solving the problem of clients falling behind, and laying the foundation for subsequent client selection to obtain a more uniform data distribution.

[0090] S6: The server uses the auxiliary data set to re-divide the first client and the second client for the next round of iterative training of the global model according to the local model uploaded by the first client to the server and the preset number of clients participating in each round of global model training; and repeats steps S2-S6 until the preset number of training rounds is reached, and outputs the final global model.

[0091] See also Figure 4 , S61: Calculating data features of the first client using the auxiliary data set according to the local model uploaded by the first client to the server;

[0092] S611: Input the auxiliary data set into the local model uploaded by the first client to the server to calculate the loss of the local model for the samples in the auxiliary data set, and obtain the gradient vector of the weight parameters from the hidden layer to the output layer of the local model according to the loss of the local model for the samples in the auxiliary data set;

[0093]

[0094] in, represents the cth neural weight parameter from the hidden layer to the output layer, 0<c≤z, z is the number of neurons in the output layer, and the number of neurons in the output layer is equal to the number of categories of samples in the auxiliary dataset.

[0095] Input the auxiliary dataset into the local model to calculate the loss of the local model for the samples in the auxiliary dataset;

[0096]

[0097] Among them, y a represents the labels of samples in the auxiliary dataset, Represents the local model's prediction category for samples in the auxiliary dataset, s au Indicates the number of samples in the auxiliary dataset, loss CCE Represents the loss of the local model for samples in the auxiliary dataset.

[0098] Preferably, the loss of the local model to the samples in the auxiliary data set includes:

[0099]

[0100] Among them, y a represents the labels of samples in the auxiliary dataset, Represents the local model's prediction category for samples in the auxiliary dataset, s au Indicates the number of samples in the auxiliary dataset, loss BCE Represents the loss of the local model for samples in the auxiliary dataset.

[0101] Preferably, the loss of the local model to the samples in the auxiliary data set includes:

[0102]

[0103] Among them, y a represents the labels of samples in the auxiliary dataset, Represents the local model's prediction category for samples in the auxiliary dataset, s au Indicates the number of samples in the auxiliary dataset, loss KL Represents the loss of the local model for samples in the auxiliary dataset.

[0104] According to the loss of the local model for the samples in the auxiliary data set, back-propagation is performed using gradient descent to obtain the gradient vector of the weight parameters from the hidden layer to the output layer of the local model;

[0105]

[0106] in, A gradient vector representing a weight parameter from a hidden layer to an output layer of a local model of the first client; Represents the gradient vector of the weight parameters from the hidden layer of the first client local model to the cth element of the output layer.

[0107] S612: Calculate the ratio of local samples of each category of the first client to the total local samples of the client according to the gradient vector of the weight parameters from the hidden layer to the output layer of the local model;

[0108]

[0109] in, Indicates the first client A i The gradient vector of the weight parameters from the hidden layer of the local model to the cth element of the output layer, For the first client A i The number of local samples of type c in the local samples, S i For the first client A i The number of local samples, z is the number of categories of samples in the auxiliary data set, e is the natural logarithm, and τ is the regularization parameter, which is 1 in the present invention, and those skilled in the art can set its value according to actual conditions.

[0110] S613: Generate a class distribution feature of the local sample data of the first client according to the ratio of the local samples of each category of the first client to the total local samples of the first client;

[0111]

[0112] in, For the first client A i The number of local samples of type c in the local samples, S i For the first client A i The number of local samples, Indicates the first client A i Class distribution characteristics of local sample data.

[0113] S614: Performing dimensionality reduction processing on the weight parameters of the fully connected layer of the local model by using PCA, and performing feature fusion on the weight parameters of the fully connected layer after the dimensionality reduction processing and the class distribution characteristics of the local sample data of the first client to obtain the data characteristics of the first client;

[0114]

[0115] in, Indicates the first client A i Class distribution characteristics of local sample data, represents the weight parameter after dimensionality reduction. Here, the number of parameters after dimensionality reduction is equal to the number of layers of the CNN model. i Represents the data characteristics of the first client, such as Figure 4 As shown, the present invention adopts a method of extracting the client data class distribution so that the main data characteristics of the client can be retained and more prominent, thereby improving the effectiveness of the client selection algorithm and solving the problem of important information loss after model parameter dimensionality reduction.

[0116] S62: randomly selecting k first clients as cluster core clients, and clustering the first clients to the cluster core clients closest to their data features according to the distance between the data features of the first clients and the data features of each cluster core client to obtain multiple client clusters and cluster core clients;

[0117]

[0118] Where l = 0, 1, 2, ... is the number of iterations, f i Indicates the first client A i The data characteristics, is the j-th client cluster in the l-th iteration (1<j≤k), Represents the data features of the j-th cluster center client in the l-th iteration.

[0119] S63: sequentially use the remaining first clients in the client cluster except the cluster center client as target center points to construct a criterion function, and use the target center point with the smallest criterion function as the cluster center client of the next iteration, repeat steps S62-S63 until the cluster center client does not change, and obtain multiple client clusters and cluster center clients;

[0120] Preferably, the criterion function comprises:

[0121]

[0122] in, is the jth client cluster in the lth iteration, f i express First Client A i The data characteristics of μ represent the data characteristics of the target center point. represents the data features of the jth cluster center client in the l+1th iteration, argmin μ Retrieve function for minimum value.

[0123] S64: Calculate a balance point according to the clustered multiple client clusters and cluster center clients;

[0124] Preferably, the balance point includes:

[0125]

[0126] in, represents the data characteristics of the equilibrium point, k represents the number of the jth client cluster, M represents the number of the first client, and m j represents the jth client cluster C j The number of first clients in j represents the jth client cluster C j Cluster center client A j data characteristics.

[0127] Preferably, dividing the client cluster into a balanced cluster and a tilted cluster according to the balance point comprises:

[0128] S65: Calculate the distance between the cluster center client and the balance point;

[0129]

[0130] Among them, μ j is the jth client cluster C j The data characteristics of the cluster core client, is the data feature of the equilibrium point, d j Represents the distance of the jth cluster center client relative to the equilibrium point;

[0131] S66: The client cluster whose distance from the cluster center client to the balance point is less than the set threshold is regarded as the balanced cluster, and the remaining client clusters are regarded as the tilted cluster; the global update direction of federated learning is the superposition result of the update directions of each client, so there must be a part of the client update directions that are closer to the global direction. The set of this part of clients is called the balanced cluster, and the remaining client sets are tilted clusters.

[0132] S67: Allocate quotas to each balanced cluster, tilted cluster, and second client using an integer allocation algorithm according to the preset quota of clients participating in each round of global model training and the number of clients owned by each cluster;

[0133]

[0134]

[0135]

[0136]

[0137] Where n represents the number of all clients, β is the ratio of the number of clients participating in global model training in each round to the number of all clients, and m j represents the jth client cluster C j , h is the number of first clients, h is the number of balanced clusters, σ represents a preset tilt parameter, 0≤σ≤1, which is set to 0.5 in the present invention, and can be set by technicians in this field according to actual needs, M is the number of first clients, M bal represents the total number of first clients in all balanced clusters, M tilt represents the total number of first clients in all tilted clusters, Y bal represents the number of balanced cluster samples, Y tilt represents the number of tilted cluster samples, Y other Indicates the number of samples from the second client. Represents cluster C j The client quota for the next round of global model training is allocated. Function means to calculate function for each cluster in the balanced cluster a The values ​​are sorted from large to small and the corresponding cluster C is output j The ranking of the values ​​of , bal, tilt, and other represent the balanced cluster, tilted cluster, and the second client respectively.

[0138] S68: According to the number of client quotas for the next round of global model training owned by each balanced cluster, tilted cluster and second client and the task amount of each client, a corresponding number of clients are selected from each balanced cluster, tilted cluster and second client as first clients for the next round of iterative training using the MD sampling algorithm, and the remaining clients are selected as second clients for the next round of iterative training;

[0139]

[0140]

[0141]

[0142] in, represents the jth client cluster C j The amount of tasks for all clients in represents the sum of the tasks of all clients in the second client, p i,t Indicates client A i The amount of tasks, Represents cluster C j The client quota for the next round of global model training is allocated. represents the jth client cluster C j The first client of the next round of iterative training is sampled from It represents the first client sampled from the second client for the next round of iterative training. The MD sampling algorithm can select the required number of clients according to the selection probability of each client.

[0143] The present invention allocates clients according to the proportion of the number of clients in each client cluster. The present invention adopts client clustering, balanced cluster multi-selection and tilted cluster equal selection to make the clients selected by the client selection algorithm more representative, greatly reduce the weight update offset phenomenon of the server-aggregated local model, and the convergence direction of the global model obtained by server aggregation does not deviate from the optimal direction, thereby improving the convergence speed and generalization performance of the global model, solving the client drift problem caused by data heterogeneity, and applying the present invention to the medical field can help medical institutions train better auxiliary models and improve the work efficiency of medical institutions.

[0144] It should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution, which should be included in the scope of the claims of the present invention.

Claims

1. A federated learning method for alleviating heterogeneity problems, characterized in that: include: S1: The server extracts some local samples from the databases of all clients to form an auxiliary data set; And randomly initialize the task volume and historical training data of all clients; The server randomly selects M clients as the first clients from all clients according to the preset number M of clients participating in each round of global model training; Treat the remaining clients as second clients; S2: The server obtains resource reports of all clients and generates a feature vector of the client according to the resource reports of the client; wherein the resource reports of the client include: CPU clock frequency, bandwidth, memory and energy of the client; S3: The server sends the global model and the workload of the first client to the first client; the first client trains the global model using local samples according to the received workload to obtain a local model, and uploads the training data of the global model and the local model to the server; the server aggregates all local models uploaded by the first client to obtain a global model for the next round of iterative training; S4: The server updates the historical training data of the first client using the training data of the global model uploaded by the first client; S5: The server calculates the final task amount of the first client using the LinUCB algorithm according to the feature vector of the first client and the historical training data of the first client; and updates the task amount of the first client using the final task amount of the first client; S6: The server selects the first client participating in the next round of iterative training of the global model from all the clients using the auxiliary data set according to the local model uploaded by the first client to the server and the preset number of clients participating in each round of global model training; and repeats steps S2-S6 until the preset number of training rounds is reached, and outputs the final global model; The method of selecting a first client to participate in the next round of iterative training of the global model from all clients using an auxiliary data set according to the local model uploaded by the first client to the server and the preset number of clients to participate in each round of global model training includes: S61: Calculating data features of the first client using the auxiliary data set according to the local model uploaded by the first client to the server; S62: randomly selecting k first clients as cluster core clients, and clustering the first clients to the cluster core clients closest to their data features according to the distance between the data features of the first clients and the data features of each cluster core client to obtain multiple client clusters and cluster core clients; S63: sequentially use the remaining first clients in the client cluster except the cluster center client as target center points to construct a criterion function, and use the target center point with the smallest criterion function as the cluster center client of the next iteration, repeat steps S62-S63 until the cluster center client does not change, and obtain multiple client clusters and cluster center clients; S64: Calculate a balance point according to the clustered multiple client clusters and cluster center clients; The balance points include: in, represents the data characteristics of the equilibrium point, k represents the number of the jth client cluster, M represents the number of the first client, and m j represents the jth client cluster C j The number of first clients in j represents the jth client cluster C j Cluster center client A j Data characteristics; S65: Calculate the distance between the cluster center client and the balance point; S66: The client cluster whose distance from the cluster center client to the balance point is less than a set threshold is used as a balanced cluster, and the remaining client clusters are used as tilted clusters; S67: Allocate quotas to each balanced cluster, tilted cluster, and second client using an integer allocation algorithm according to the preset quota of clients participating in each round of global model training and the number of clients owned by each cluster; S68: According to the number of client quotas for the next round of global model training owned by each balanced cluster, tilted cluster and second client and the amount of tasks of each client, use the MD sampling algorithm to select a corresponding number of clients from each balanced cluster, tilted cluster and second client as the first clients for the next round of iterative training, and select the remaining clients as the second clients for the next round of iterative training.

2. A federated learning method for alleviating heterogeneity problems according to claim 1, characterized in that: The training data of the global model includes: the time when the first client receives the global model, the time when the first client uploads the local model, the transmission power when the first client uploads the local model, the channel gain between the first client and the server, the signal interference when the first client uploads the local model, the number of local samples of the first client, the number of CPU cycles required for the first client to train the global model once using a local sample, and the number of model parameters of the global model.

3. A federated learning method for alleviating heterogeneity problems according to claim 2, characterized in that: The step of calculating the final task amount of the first client by using the LinUCB algorithm according to the feature vector of the first client and the historical training data of the first client includes: S51: Based on the feature vector x of the first client i,t Calculate the iterative training time of the first client and the model parameter upload time of the first client using the historical training data of the first client; S52: Calculate the final task amount of the first client by using the LinUCB algorithm according to the iterative training time of the first client and the model parameter upload time of the first client.

4. A federated learning method for alleviating heterogeneity problems according to claim 3, characterized in that: The calculation step of the iterative training time of the first client and the model parameter upload time of the first client includes: S511: Calculating the iterative training time of the first client according to the number of CPU cycles required for the first client to train the global model once using a local sample and the CPU cycle frequency of the first client; S512: Calculate the model parameter upload time of the first client according to the number of model parameters of the global model and the bandwidth of the first client.

5. A federated learning method for alleviating heterogeneity problems according to claim 3, characterized in that: The step of calculating the final task amount of the first client includes: S521: judging whether the first client completes the task of the first client within a preset maximum waiting time of the server according to the time when the first client receives the global model and the time when the first client uploads the local model; S522: Calculate the initial task volume of the first client by using the LinUCB algorithm according to the task volume completion status of the first client and the feature vector of the first client; S523: Calculate the final task volume of the first client according to the initial task volume of the first client, the iterative training time of the first client, the model parameter upload time of the first client, the preset maximum waiting time of the server and the number of local samples of the first client.

6. A federated learning method for alleviating heterogeneity problems according to claim 1, characterized in that: The step of calculating the data feature of the first client includes: S611: Input the auxiliary data set into the local model uploaded by the first client to the server to calculate the loss of the local model for the samples in the auxiliary data set, and obtain the gradient vector of the weight parameters from the hidden layer to the output layer of the local model according to the loss of the local model for the samples in the auxiliary data set; S612: Calculate the ratio of local samples of each category of the first client to the total local samples of the client according to the gradient vector of the weight parameters from the hidden layer to the output layer of the local model; S613: Generate a class distribution feature of the local sample data of the first client according to the ratio of the local samples of each category of the first client to the total local samples of the first client; S614: Use PCA to perform dimensionality reduction processing on the weight parameters of the fully connected layer of the local model, and perform feature fusion on the weight parameters of the fully connected layer after the dimensionality reduction processing and the class distribution characteristics of the local sample data of the first client to obtain the data characteristics of the first client.