Personalized federated learning method, system and storage medium for data heterogeneity
Through local iterative training and data distribution similarity clustering methods in personalized federated learning, the problems of data heterogeneity and privacy protection are solved, and efficient federated learning model training is achieved.
Patent Information
- Application Number
- CN202311035140.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-16
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2043-08-16
AI Technical Summary
Personalized federated learning violates privacy protection requirements when sharing part of the data, and data heterogeneity interferes with federated learning model training.
The server sends the pre-built initial learning model and initialization parameters to the client. The client performs local iterative training and uploads the training gradient and update parameters. The server clusters the client according to the data distribution similarity and generates a similarity network diagram, updates the model weight parameters, and realizes personalized training.
It effectively solves the problem of data distribution heterogeneity interferes with federated learning model training, and meets the needs of client data privacy protection.
Smart Images

Figure CN116933866B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of federated learning, and specifically relates to a personalized federated learning method, system and storage medium for data heterogeneity. Background Art
[0002] Federated learning refers to the task of training models on multiple isolated island data sets. Under the increasingly stringent privacy policy requirements, the traditional centralized method of aggregating data from multiple data islands for data mining has become infeasible. The effective data of a single data island is insufficient, and data-driven modeling and data mining are restricted. This is when federated learning can play a role. General federated learning means that all clients jointly train a consensus model without sharing data to learn as much knowledge as possible from multiple client data. The steps of general federated learning mainly include: client selection, model distribution, model training and model aggregation, and an aggregated consensus model is obtained through iteration until convergence.
[0003] Since the data of each client node in federated learning is not visible to each other, not only the data volume is different, but also the data distribution is heterogeneous. Under this condition, the global model obtained by direct aggregation training cannot meet the personalized needs of the client, resulting in poor performance in some client applications. Personalized federated learning allows personalized training based on the local characteristics of a single or multiple clients on the basis of training the global model, thereby reducing the interference of data heterogeneity on federated learning.
[0004] Personalized federated learning provides solutions for privacy protection and solving the problem of data heterogeneity. The mainstream methods include two categories. One is to optimize from the data input layer, and process the data of each client through data preprocessing (such as removing extreme data samples or smoothing samples), so as to improve the distribution similarity of the clients; the other method is to establish a data sharing pool and collect data from multiple clients for training to deal with heterogeneity. However, these two methods have difficult problems to solve in practical applications. For example, medical imaging data involves a large amount of user private information, and the preprocessing method will interfere with the accuracy of the imaging data, while sharing part of the data violates the need for privacy protection. Summary of the invention
[0005] The present invention provides a personalized federated learning method, system and storage medium for data heterogeneity, so as to solve the problem that personalized federated learning violates the privacy protection requirement due to sharing part of the data.
[0006] In a first aspect, the present invention provides a personalized federated learning method for data heterogeneity, the method comprising the following steps:
[0007] The server sends a pre-built initial learning model and initialization parameters of the initial learning model to multiple clients participating in federated learning, wherein the initial learning model includes a feature extraction layer and a classifier layer, and the initialization parameters include a first weight parameter of the feature extraction layer and a second weight parameter of the classifier layer;
[0008] The server clusters the clients according to the similarity of data distribution of all the clients, and generates a similarity network graph of the clients;
[0009] The client automatically performs local iterative training on the initial learning model based on the first weight parameter and using the local data of the client to obtain a training gradient and a first update parameter after the first weight parameter is trained and updated, and uploads the training gradient and the first update parameter to the server;
[0010] The server calculates an average value of the first update parameters uploaded by all the clients to obtain a first average update parameter;
[0011] The server automatically updates and iterates the initial learning model in combination with the similarity network graph and the training gradients uploaded by all the clients, and obtains a second update parameter after the second weight parameter is updated;
[0012] The server updates the initial learning model by using the first average update parameter and the second update parameter;
[0013] The server sends the updated initial learning model to all the clients again, and repeats the steps of the clients performing the local iterative training until the loss function of the initial learning model converges, thereby obtaining a federated learning model.
[0014] Optionally, the server clusters the clients according to the data distribution similarity of all the clients to generate a similarity network graph of the clients, including the following steps:
[0015] The server sends the pre-built data distribution similarity evaluation model to all the clients;
[0016] The client calculates a local data distribution similarity coefficient by combining the data distribution similarity evaluation model and the local data of the client, and uploads the local data distribution similarity coefficient to the server;
[0017] The server clusters the clients based on the local data distribution similarity coefficient and through the KNN algorithm to generate a similarity network graph of the clients.
[0018] Optionally, the client calculates a local data distribution similarity coefficient by combining the data distribution similarity evaluation model and the local data of the client, and uploads the local data distribution similarity coefficient to the server, including the following steps:
[0019] The client receives the data distribution similarity evaluation model;
[0020] The client inputs a preset standard data set and the local data of the client into the data distribution similarity evaluation model;
[0021] The client performs covariance calculation through the data distribution similarity evaluation model to obtain a local data distribution similarity coefficient, and uploads the local data distribution similarity coefficient to the server.
[0022] Optionally, the server clusters the clients based on the local data distribution similarity coefficient and uses a KNN algorithm to generate a similarity network graph of the clients, including the following steps:
[0023] The server calculates the Euclidean distance between the client and a plurality of preset classified points based on the local data distribution similarity coefficient;
[0024] The server arranges the multiple classified points in ascending order according to the corresponding Euclidean distances, and takes the first K classified points as target classified points;
[0025] The server counts the number of occurrences of the target categories to which all the target classification points belong;
[0026] The server uses the target category with the highest number of occurrences as the target category of the client;
[0027] The server performs clustering according to the target categories of all the clients to generate a similarity network graph of the clients.
[0028] Optionally, the client automatically performs local iterative training on the initial learning model based on the first weight parameter and using local data of the client to obtain a first updated parameter after the training gradient and the first weight parameter are trained and updated, and uploading the training gradient and the first updated parameter to the server includes the following steps:
[0029] The client automatically performs local iterative training on the initial learning model based on the first weight parameter and using the local data of the client, and calculates the training gradient using the gradient descent method based on the loss function of the initial learning model;
[0030] The client automatically updates the first weight parameter in combination with the initial learning model and the training gradient to obtain a first updated parameter;
[0031] The client uploads the training gradient and the first update parameter to the server.
[0032] Optionally, a calculation formula for the first update parameter is as follows:
[0033]
[0034] Where: η t represents the learning rate, M represents the feature extraction layer, represents the training gradient of the tth round of the i-th client, x t represents the value obtained through the tth round of training, and x represents the value of the variable solution.
[0035] Optionally, the server automatically updates and iterates the initial learning model in combination with the similarity network graph and the training gradients uploaded by all the clients, and obtains the second update parameter after the second weight parameter is updated, including the following steps:
[0036] The server automatically updates and iterates the initial learning model according to the training gradients uploaded by all the clients;
[0037] The server updates the second weight parameter in combination with the similarity network graph and the updated initial learning model to obtain a second updated parameter.
[0038] Optionally, a calculation formula for the second update parameter is as follows:
[0039]
[0040] Where: η t represents the learning rate, N represents the classifier layer, Z t represents the value obtained through the tth round of training, Z represents the value of the variable solution, Q represents the similarity network diagram, λ represents the adjustment factor, p represents the p-norm, F represents the F-norm, T represents the matrix transpose, represents the training gradient of the tth round of the i-th client, and I represents the number of the clients.
[0041] In a second aspect, the present invention also provides a personalized federated learning system for data heterogeneity, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect when executing the computer program.
[0042] In a third aspect, the present invention further provides a computer storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method described in the first aspect.
[0043] The beneficial effects of the present invention are:
[0044] The present invention provides a personalized federated learning method for data heterogeneity. The method utilizes a global model including personalized features and generalized features to train the generalized model through a global task sub-model; utilizes the data distribution similarity of the clients to automatically generate a client similarity network diagram with similar data distribution, and performs local personalized training on the clients with similar data distribution, thereby effectively solving the interference problem of data distribution heterogeneity on the training of the federated learning model, and the local personalized training of the clients is performed locally on the clients, thereby also meeting the needs of client data privacy protection. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 Schematic diagram of the process of the personalized federated learning method for data heterogeneity in the present invention. DETAILED DESCRIPTION
[0046] The present invention discloses a personalized federated learning method targeting data heterogeneity.
[0047] Reference Figure 1 ,The personalized federated learning method for data heterogeneity specifically includes the following steps:
[0048] S101. The server sends a pre-built initial learning model and initialization parameters of the initial learning model to multiple clients participating in federated learning.
[0049] Among them, the initial learning model sent by the server to each client can be expressed by the following formula:
[0050]
[0051] Where: represents the initial learning model sent to the i-th client, M represents the feature extraction layer of the neural network. Taking the DenseNet network as an example, M can represent the convolution layer and the normalization layer in the DenseNet network, N represents the classifier layer of the neural network, and in another embodiment, N can also represent the fully connected layer of the neural network. and These are all initialization parameters. is the first weight parameter of the feature extraction layer M, is the second weight parameter of the classifier layer N. The "first" and "second" in the first weight parameter and the second weight parameter are only used to distinguish technical features and do not represent any other meanings.
[0052] S102. The server clusters the clients according to the similarity of data distribution of all the clients, and generates a similarity network graph of the clients.
[0053] Among them, clients can be clustered based on data distribution similarity and through the KNN (K-Nearest Neighbor) algorithm to generate a client similarity network graph. It can also be implemented using algorithms such as DenseNet and Cov. The similarity network graph can also be expressed in matrix form. Assuming there are 5 clients in total, the similarity network graph is a 5*5 matrix. Client nodes with similarity are marked as 1, and other client nodes are marked as 0.
[0054] S103. The client automatically performs local iterative training on the initial learning model based on the first weight parameter and using the client's local data, obtains the first update parameter after the training gradient and the first weight parameter are trained and updated, and uploads the training gradient and the first update parameter to the server.
[0055] Among them, the training gradient of this round of local iterative training is obtained according to the loss function of the initial learning model, and the loss function can be a cross entropy loss function.
[0056] S104. The server calculates the average value of the first update parameters uploaded by all clients to obtain a first average update parameter.
[0057] The first average update parameter can be obtained by dividing the sum of the first update parameters uploaded by all clients by the number of clients.
[0058] S105. The server automatically updates the iterative initial learning model based on the similarity network graph and the training gradients uploaded by all clients, and obtains the second updated parameter after the second weight parameter is updated.
[0059] When updating the second weight parameter, the matrix form of the similarity network graph is introduced for calculation, and then the training gradients uploaded by all clients are combined to realize the adaptive update of the server.
[0060] S106. The server updates the initial learning model using the first average update parameter and the second update parameter.
[0061] The server updates the initial learning model by using the first average update parameter and the second update parameter, and obtains the updated initial learning model as follows:
[0062] yt+1 =Mx t+1 +Nz t+1
[0063] Where: y t+1 represents the initial learning model after this round of update iteration, M represents the feature extraction layer of the neural network, N represents the classifier layer of the neural network, and x t+1 represents the first average update parameter, Z t+1 Represents the second update parameter.
[0064] S107. The server sends the updated initial learning model to all clients again, and repeats the above steps of the client performing local iterative training until the loss function of the initial learning model converges to obtain a federated learning model.
[0065] After the server sends the updated initial learning model to all clients again, steps S103 to S107 are repeated until the loss function of the initial learning model converges. The convergence of the loss function indicates that the loss function tends to be stable and no longer changes. The loss function is used to evaluate the degree to which the predicted value of the model is different from the true value. The better the loss function, the better the performance of the model.
[0066] The implementation principle of this embodiment is:
[0067] Using a global model that includes personalized features and generalized features, the generalized model is trained through the global task sub-model. The similarity of client data distribution is used to automatically generate a client similarity network diagram with similar data distribution, and local personalized training is performed on clients with similar data distribution. This effectively solves the interference problem of data distribution heterogeneity on the training of the federated learning model. The local personalized training of the client is performed locally on the client, thus meeting the needs of client data privacy protection.
[0068] In one embodiment, step S102, i.e., the server clusters the clients according to the data distribution similarity of all the clients, and generates a similarity network diagram of the clients, specifically includes the following steps:
[0069] The server sends the pre-built data distribution similarity assessment model to all clients;
[0070] The client calculates the local data distribution similarity coefficient by combining the data distribution similarity evaluation model and the local data of the client, and uploads the local data distribution similarity coefficient to the server;
[0071] The server clusters the clients based on the local data distribution similarity coefficient and uses the KNN algorithm to generate a similarity network graph of the clients.
[0072] In this implementation, the server may also cluster the clients based on the local data distribution similarity coefficient and the K-Means clustering method.
[0073] In one implementation, the client calculates the local data distribution similarity coefficient by combining the data distribution similarity evaluation model and the local data of the client, and uploads the local data distribution similarity coefficient to the server, which specifically includes the following steps:
[0074] The client receives the data distribution similarity evaluation model;
[0075] The client inputs the preset standard data set and the client's local data into the data distribution similarity evaluation model;
[0076] The client performs covariance calculation through the data distribution similarity evaluation model to obtain the local data distribution similarity coefficient, and uploads the local data distribution similarity coefficient to the server.
[0077] In this embodiment, the distance measurement between two points in the sample space represents the similarity between the two sample points. When calculating the distance, different distance measurement methods can be used, such as Euclidean distance, Manhattan distance, etc. The smaller the distance, the higher the similarity; conversely, the larger the distance, the lower the similarity. Covariance is used to characterize the correlation between inputs. Covariance is only a method in this embodiment. Other calculation methods can also be used in other embodiments.
[0078] The covariance is defined as follows:
[0079] X and Y are two random variables, and the covariance cov(X, Y) of X and Y can be expressed as:
[0080] cov(X,Y)=E[(X-μ x )(Y-μ y )]
[0081] Where E(X) = μ x , E(Y)=μ y .
[0082] The covariance matrix is defined as follows:
[0083] The covariance matrix obtained by arranging the data in the matrix by rows and columns is different. It can be assumed that the data is arranged by rows. That is, each row is a dimension, and each column is a random variable. The elements on the covariance diagonal represent the variance. The above matrix can be expressed as:
[0084]
[0085] Then the covariance matrix can be expressed as:
[0086]
[0087] In one implementation manner, the server clusters the clients based on the local data distribution similarity coefficient and uses the KNN algorithm to generate a similarity network diagram of the clients, specifically including the following steps:
[0088] The server calculates the Euclidean distance between the client and multiple preset classified points based on the local data distribution similarity coefficient;
[0089] The server arranges multiple classified points in ascending order according to the corresponding Euclidean distance, and takes the first K classified points as the target classification points;
[0090] The server counts the number of occurrences of the target categories to which all target classification points belong;
[0091] The server uses the target category with the highest number of occurrences as the client's target category;
[0092] The server clusters all clients according to their target categories and generates a similarity network graph for the clients.
[0093] In one embodiment, step S103, i.e., the client automatically performs local iterative training on the initial learning model based on the first weight parameter and using the local data of the client, obtains the first updated parameter after the training gradient and the first weight parameter are trained and updated, and uploads the training gradient and the first updated parameter to the server, specifically includes the following steps:
[0094] The client automatically performs local iterative training on the initial learning model based on the first weight parameter and using the local data of the client, and calculates the training gradient using the gradient descent method based on the loss function of the initial learning model;
[0095] The client automatically updates the first weight parameter by combining the initial learning model and the training gradient to obtain a first updated parameter;
[0096] The client uploads the training gradient and the first updated parameters to the server.
[0097] In this implementation, the calculation formula of the first update parameter is as follows:
[0098]
[0099] Where: η t represents the learning rate, M represents the feature extraction layer, represents the training gradient of the tth round of the i-th client, x t represents the value obtained through the tth round of training, and x represents the value of the variable solution.
[0100] In one embodiment, step S105, i.e., the server automatically updates the iterative initial learning model in combination with the similarity network graph and the training gradients uploaded by all clients, and obtains the second updated parameter after the second weight parameter is updated, specifically includes the following steps:
[0101] The server automatically updates and iterates the initial learning model based on the training gradients uploaded by all clients;
[0102] The server updates the second weight parameter based on the similarity network graph and the updated initial learning model to obtain a second updated parameter.
[0103] In this implementation, the calculation formula of the second update parameter is as follows:
[0104]
[0105] Where: η t represents the learning rate, N represents the classifier layer, Z t represents the value obtained through the tth round of training, Z represents the value of the variable solution, Q represents the similarity network diagram, λ represents the adjustment factor, p represents the p-norm, F represents the F-norm, T represents the matrix transpose, represents the training gradient of the tth round of the i-th client, and I represents the number of the clients.
[0106] The present invention also discloses a personalized federated learning system for data heterogeneity, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the personalized federated learning method for data heterogeneity as described in the above-mentioned embodiment.
[0107] The implementation principle of this embodiment is:
[0108] By calling the program, we can use the global model that contains personalized features and generalized features, and train the generalized model through the global task sub-model; use the similarity of client data distribution to automatically generate a client similarity network diagram with similar data distribution, and perform local personalized training on clients with similar data distribution, which effectively solves the interference problem of data distribution heterogeneity on federated learning model training, and the local personalized training of the client is performed locally on the client, thus meeting the needs of client data privacy protection.
[0109] The present invention also discloses a computer storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the personalized federated learning method for data heterogeneity in the above-mentioned embodiment are implemented.
[0110] The implementation principle of this embodiment is:
[0111] By calling the program, we can use the global model that contains personalized features and generalized features, and train the generalized model through the global task sub-model; use the similarity of client data distribution to automatically generate a client similarity network diagram with similar data distribution, and perform local personalized training on clients with similar data distribution, which effectively solves the interference problem of data distribution heterogeneity on federated learning model training, and the local personalized training of the client is performed locally on the client, thus meeting the needs of client data privacy protection.
[0112] A person skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of protection of the present application is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of different aspects of one or more embodiments of the present application as above, which are not provided in detail for the sake of simplicity.
[0113] One or more embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the present application. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present application should be included in the protection scope of the present application.
Claims
1. A personalized federated learning method for data heterogeneity, which violates the privacy protection requirement by sharing part of the data. The method is characterized by: The steps include: The server sends a pre-built initial learning model and initialization parameters of the initial learning model to multiple clients participating in federated learning, wherein the initial learning model includes a feature extraction layer and a classifier layer, and the initialization parameters include a first weight parameter of the feature extraction layer and a second weight parameter of the classifier layer, wherein the client stores private data to be trained, wherein the private data is medical imaging data; The server clusters the clients according to the similarity of data distribution of all the clients, and generates a similarity network graph of the clients; The client automatically performs local iterative training on the initial learning model based on the first weight parameter and using the local data of the client to obtain a training gradient and a first update parameter after the first weight parameter is trained and updated, and uploads the training gradient and the first update parameter to the server; The server calculates an average value of the first update parameters uploaded by all the clients to obtain a first average update parameter; The server automatically updates and iterates the initial learning model in combination with the similarity network graph and the training gradients uploaded by all the clients, and obtains a second update parameter after the second weight parameter is updated; The server updates the initial learning model by using the first average update parameter and the second update parameter; The server sends the updated initial learning model to all the clients again, and repeats the above-mentioned step of the client performing the local iterative training until the loss function of the initial learning model converges, thereby obtaining a federated learning model; The server clusters the clients according to the data distribution similarity of all the clients, and generates a similarity network diagram of the clients, which includes the following steps: the server sends a pre-built data distribution similarity evaluation model to all the clients; the clients calculate the local data distribution similarity coefficient by combining the data distribution similarity evaluation model and the local data of the clients, and upload the local data distribution similarity coefficient to the server; the server clusters the clients based on the local data distribution similarity coefficient and uses the KNN algorithm to generate a similarity network diagram of the clients, wherein the similarity network diagram is in a matrix form; The client calculates the local data distribution similarity coefficient by combining the data distribution similarity evaluation model and the local data of the client, and uploads the local data distribution similarity coefficient to the server, including the following steps: the client receives the data distribution similarity evaluation model; the client inputs a preset standard data set and the local data of the client into the data distribution similarity evaluation model; The client performs covariance calculation through the data distribution similarity evaluation model to obtain a local data distribution similarity coefficient, and uploads the local data distribution similarity coefficient to the server.
2. The personalized federated learning method for data heterogeneity according to claim 1, characterized in that: The server clusters the clients based on the local data distribution similarity coefficient and uses the KNN algorithm to generate a similarity network graph of the clients, including the following steps: The server calculates the Euclidean distance between the client and a plurality of preset classified points based on the local data distribution similarity coefficient; The server arranges the multiple classified points in ascending order according to the corresponding Euclidean distances, and takes the first K classified points as target classified points; The server counts the number of occurrences of the target categories to which all the target classification points belong; The server uses the target category with the highest number of occurrences as the target category of the client; The server performs clustering according to the target categories of all the clients to generate a similarity network graph of the clients.
3. The personalized federated learning method for data heterogeneity according to claim 1, characterized in that: The client automatically performs local iterative training on the initial learning model based on the first weight parameter and using the local data of the client to obtain a training gradient and a first update parameter after the first weight parameter is trained and updated, and uploads the training gradient and the first update parameter to the server, including the following steps: The client automatically performs local iterative training on the initial learning model based on the first weight parameter and using the local data of the client, and calculates the training gradient using the gradient descent method based on the loss function of the initial learning model; The client automatically updates the first weight parameter in combination with the initial learning model and the training gradient to obtain a first updated parameter; The client uploads the training gradient and the first update parameter to the server.
4. The personalized federated learning method for data heterogeneity according to claim 3, characterized in that: The calculation formula of the first update parameter is as follows: Where: η t represents the learning rate, M represents the feature extraction layer, represents the training gradient of the tth round of the i-th client, x t represents the value obtained through the tth round of training, and x represents the value of the variable solution.
5. The personalized federated learning method for data heterogeneity according to claim 1, characterized in that: The server automatically updates and iterates the initial learning model in combination with the similarity network graph and the training gradients uploaded by all the clients, and obtains the second update parameter after the second weight parameter is updated, including the following steps: The server automatically updates and iterates the initial learning model according to the training gradients uploaded by all the clients; The server updates the second weight parameter in combination with the similarity network graph and the updated initial learning model to obtain a second updated parameter.
6. The personalized federated learning method for data heterogeneity according to claim 5, characterized in that: The calculation formula of the second update parameter is as follows: Where: η t represents the learning rate, N represents the classifier layer, Z t represents the value obtained through the tth round of training, Z represents the value of the variable solution, Q represents the similarity network diagram, λ represents the adjustment factor, p represents the p-norm, F represents the F-norm, T represents the matrix transpose, represents the training gradient of the tth round of the i-th client, and I represents the number of the clients.
7. A personalized federated learning system for data heterogeneity, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.
8. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Privacy protection advertisement click rate prediction method and device, server and storage medium
CN113487351A
Federal learning method based on dynamic affinity polymerization and related equipment
CN116306986A
Cited By
Personalized federated learning model training and analysis method based on residual decoupling
CN121902920A