A personalized federated learning method and device for handling unbalanced data

By decoupling the neural network from the basic encoding layer, projection layer, and classification layer, and employing personalized federated learning and contrastive learning algorithms, the model training problem under imbalanced datasets is solved, achieving efficient and safe model training results.

CN115344883BActive Publication Date: 2026-07-03SHANGHAI UNIV OF ENG SCI

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHANGHAI UNIV OF ENG SCI
Filing Date
2022-06-29
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Existing federated learning algorithms assume that the datasets of the parties are balanced, which cannot effectively handle inconsistent data distributions. This results in poor performance of the global model on a single client, high convergence and communication costs, and an inability to meet the performance requirements of each participant.

Method used

A personalized federated learning approach is adopted to decouple the target neural network into a basic encoding layer, a projection layer, and a classification layer. The basic encoding layer model parameters are jointly trained through a federated learning framework, while each party retains its own projection layer and classification layer model parameters. The model training process is optimized through contrastive learning algorithms and weighted aggregation techniques.

Benefits of technology

While ensuring data privacy and security, the convergence rate and generalization ability of the model are improved, and the target neural network training can be adapted to imbalanced data, thereby improving training effect and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115344883B_ABST
    Figure CN115344883B_ABST
Patent Text Reader

Abstract

This invention discloses a personalized federated learning method and apparatus for processing imbalanced data, belonging to the field of machine learning technology. Specifically, it includes: a central server establishing a global network model and distributing it to clients; each client training its own network using a contrastive learning algorithm based on its private data, and returning the updated base encoding layer parameters to the central server; the central server recalculating the base encoding layer parameters of the global network model and each client's local network model based on all client parameters, and distributing these parameters to each client; each client updating its local network and iteratively training until the global network model converges or reaches a specified number of training iterations. This invention employs a model training method combining personalized federated learning and contrastive learning, ensuring the privacy and security of data from all parties while efficiently training the target network for imbalanced data, thus improving the model's convergence rate and generalization ability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine learning technology, and in particular to a personalized federated learning method and apparatus for processing imbalanced data. Background Technology

[0002] Mobile devices have become the primary computing resource for billions of users worldwide, generating vast amounts of valuable data. Organizations are using big data and artificial intelligence to optimize their processes and performance. While this wealth of data offers tremendous opportunities for AI applications, it is inherently highly sensitive and exists in the form of data silos. This is particularly relevant in the healthcare industry, where medical data is highly sensitive and often collected and resides across different healthcare facilities. Training a satisfactory model typically requires parties to share global data on servers. However, due to increasing privacy concerns and data protection regulations, parties are unable to send their private data to a central server for model training. This situation presents a significant challenge to AI adoption, as traditional AI approaches do not adequately address data privacy issues. Therefore, exploring efficient distributed machine learning systems using privacy-preserving computing techniques has become a hot topic.

[0003] Federated learning is an emerging distributed machine learning approach that leverages distributed data from multiple clients to collaboratively train a shared global model under the coordination of a central server, without sharing individual raw data. This allows federated learning to surpass traditional parallel optimization, avoiding systemic privacy risks and attracting significant attention from industry. A typical method for implementing federated learning is the federated averaging algorithm, which generates a global model by averaging the local parameters uploaded from each client. In this process, sensitive raw data from each client is not exchanged, thus protecting user privacy. In recent years, federated learning frameworks have been widely deployed in practice, such as in loan status prediction, health status assessment, and next-word prediction. Furthermore, it has been applied to many other applications, such as medical imaging, object detection, and landmark classification.

[0004] However, existing federated learning algorithms assume that the datasets of all parties are balanced. While this assumption greatly simplifies the requirements for algorithm robustness and ensures the reliability of the resulting model to some extent, in many practical applications, data may be distributed differently among the parties. For example, equipment vendors or data acquisition protocols can lead to heterogeneity in feature distribution; the appearance of histological images varies due to different staining conditions; and the feature distribution of MRI data from different hospitals changes with the characteristics associated with different scanners or imaging protocols. These situations can all result in non-independent and identically distributed data among the parties. Highly heterogeneous data leads to poor convergence throughout the training phase, high communication costs, and deteriorates the performance of the global model on a single client. It may even affect clients who are constantly affected by the collaborative training process.

[0005] The goal of traditional federated learning is to obtain a globally shared model that can be used by all participants. However, when the data distribution among participants is inconsistent, the global model cannot meet the performance requirements of each federated learning participant, and some participants may not even obtain a model that is better than the model trained using only local data.

[0006] Meanwhile, existing federated learning methods cannot achieve good performance on image datasets with deep learning models. Summary of the Invention

[0007] The technical problem to be solved by this invention is to provide a model training method based on personalized federated learning. This method decouples the basic encoding layer, projection layer and classification layer of the target neural network and applies a federated learning framework for joint training. This method can efficiently train the models of each party while ensuring the privacy and security of the data of each party.

[0008] To solve the above-mentioned technical problems, the present invention adopts the following technical solution: a personalized federated learning method for processing imbalanced data, comprising:

[0009] (1) The central server establishes and initializes a global network model, which is a deep neural network model, including a basic encoding layer, a projection layer and a classification layer. The central server distributes the global network model to all clients to initialize it into a client local network model, a comparison model and a global network model.

[0010] (2) The central server randomly selects a certain number of clients to participate in training. The clients participating in training are trained using a contrastive learning algorithm based on their private data, and the updated client local network model basic coding layer parameters are returned to the central server.

[0011] (3) The central server receives the basic coding layer parameters of all clients participating in the training, calculates and updates the basic coding layer parameters of the global network model and the basic coding layer parameters of all clients participating in the training, and selects the comparison model for each client participating in the training, and sends the updated basic coding layer parameters of the global network model, the basic coding layer parameters of the client local network model, and the basic coding layer parameters of the selected comparison model to each client participating in the training.

[0012] (4) The client participating in the training updates the client's local network model, comparison model and global network model according to the model parameters sent by the server, and then returns to step 2 until the global network model of the central server converges or reaches the specified number of training times.

[0013] Furthermore, the comparison model is a model of client j randomly selected by the central server for client i participating in the training, wherein the similarity between the models of client i and client j is lower than a set threshold.

[0014] Furthermore, the contrastive learning algorithm in step 2 includes:

[0015] (2.1) Construct a model comparison loss function based on the client local network model, the global model, and the comparison model;

[0016] (2.2) The client calculates the total loss function using the cross-entropy loss function and the model comparison loss function;

[0017] (2.3) Based on the client's private data, train the client's local network model according to the principle of minimizing the total loss function, and obtain updated client local network model parameters.

[0018] Furthermore, the model's contrastive loss function is:

[0019]

[0020] in: This represents the output feature representation of the projection layer of the client's local network model; This represents the output feature representation of the global model projection layer; Let τ represent the output feature representation of the projection layer of the comparison model, where τ represents the temperature parameter and P(·) represents the output of the projection layer.

[0021] Furthermore, the total loss function is:

[0022]

[0023] Where: x represents the input data. This represents the client-local network model of client i in round t, i.e. l sup Let l represent the cross-entropy loss function. con Let μ represent the contrastive loss function of the model, where μ is a hyperparameter that controls the weights of the contrastive loss.

[0024] Furthermore, in step 3, the update of the basic coding layer parameters of the global network model adopts the average aggregation method, and its formula is:

[0025]

[0026] Where: t represents the t-th round of training; These are the base coding layer parameters of the client's local network model in round t for client i. is the basic encoding layer parameter of the global network model in round t+1, and N is the number of clients participating in the training.

[0027] Furthermore, in step 3, the update of the client-side local network model basic coding layer parameters adopts a weighted aggregation method, the specific process of which includes:

[0028] (3.1) The central server establishes a parameter dictionary for each client, stores the model parameters uploaded by each client, and updates the parameter dictionary in each iteration based on the latest received data;

[0029] (3.2) The central server constructs a similarity matrix dictionary to store the similarity values ​​between the clients. Based on the basic coding layer model parameters of each client participating in training, the central server calculates the similarity value between every two clients participating in training using the cosine similarity formula, and uses it as a weight coefficient ξ. ij Update the similarity matrix dictionary;

[0030] (3.3) For the client i, the central server weighted and aggregated the basic coding layer parameters uploaded by other clients j participating in the training according to the similarity matrix dictionary to obtain the latest basic coding layer parameters of the client i, and sent them to the client i.

[0031] Furthermore, the cosine similarity formula in step (3.2) is as follows:

[0032]

[0033] in: This represents the basic encoding layer parameters used in training client i. This represents the basic coding layer parameters of the comparison model;

[0034] The similarity matrix is ​​normalized using the softmax function, and the formula is as follows:

[0035]

[0036] Where ξ ij It is the weight coefficient value in the i-th row and j-th column of the similarity matrix, and exp(·) represents e x The exponential function, exp(ξ) ik ) represents the values ​​of other elements in the i-th row of the similarity matrix.

[0037] Furthermore, the weighted aggregation formula in step (3.3) is as follows:

[0038]

[0039] Where t represents the t-th iteration. These are the base coding layer parameters of the client's local network model in round t for client j. This represents the base coding layer parameters of the client's local network model in round t+1.

[0040] The present invention also provides a personalized federated learning apparatus for processing imbalanced data, comprising a memory, a processor, and a computer program stored in and executable on the memory, wherein the processor executes the computer program to implement the personalized federated learning method for processing imbalanced data as described above.

[0041] The beneficial effects of this invention are:

[0042] The present invention proposes a model training method based on personalized federated learning and contrastive learning. By decoupling the target neural network into three components: a base encoding layer, a projection layer, and a classification layer, each party jointly trains the base encoding layer model parameters, while each party retains its own classification layer model parameters. This reduces the problem dimensionality, and each client can perform many local updates in each round of communication. This is beneficial for learning from its own local data. While ensuring the privacy and security of the data of each party, the method efficiently trains the target neural network for imbalanced data, improving the model's convergence rate and generalization ability. Attached Figure Description

[0043] Figure 1 This is a schematic diagram of a personalized federated learning method for processing imbalanced data according to an embodiment of the present invention.

[0044] Figure 2 This is a schematic diagram of the client process in an embodiment of the present invention.

[0045] Figure 3 This is a schematic diagram of a personalized federated learning method for processing imbalanced data according to an embodiment of the present invention. Detailed Implementation

[0046] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. These embodiments are based on the technical solution of the present invention and provide detailed implementation methods and specific operating procedures. However, the scope of protection of the present invention is not limited to the following embodiments.

[0047] This invention presents a model training method based on personalized federated learning and contrastive learning, used to simultaneously achieve parameterized training for at least one target neural network. Each target network consists of three components: a base encoding layer, a projection layer, and a classification layer. Each component jointly trains the base encoding layer model parameters using a federated learning framework, while retaining its own projection layer and classification layer model parameters. In practical applications, the target neural network can be either a prediction neural network or a classification neural network.

[0048] like Figure 1 The diagram illustrates a central server and various client worker nodes. Assume there are N clients in the system, with m different tasks running on the network (N >> m). Each client lacks information about the central server, does not communicate with other clients, and is unaware of other clients' task data. The central server has no access to the clients' training data samples, and the amount of data stored by different clients may vary. There is a certain correlation between the tasks. The federated learning framework can achieve better training results and faster convergence speeds than clients training on their own data individually.

[0049] Suppose there are N clients participating in the training, denoted as P1, ..., P2. n Client P i There is a local dataset Without exchanging the original data, in the dataset The above jointly learns a machine learning model ω with the goal of solving the following problem:

[0050]

[0051] in, It is client P i The expected loss. i and θ i Let be the error function and the learning model for the i-th client, respectively. Let be the space of feasible sets of n models.

[0052] To minimize f i The i-th client starts from D iAccess M i Labeled samples The dataset is used for training. In federated learning settings, most clients lack sufficient local data, and clients may not be able to obtain the expected low-risk solution through fully local training. Therefore, joint learning is needed to learn the model using the accumulated data from all clients. In fact, in the presence of data heterogeneity, the error function f i There will be different forms, and their minimizers are different.

[0053] Furthermore, we consider setting up a basic coding layer representation. The data points are mapped to a lower k-dimensional space through the projection head. Map features to label space, then use a classifier. This maps the label space to the real labels. Therefore, the deep neural network model is decoupled as follows:

[0054] The client-side model is the composition and representation of the client's local parameters:

[0055]

[0056] This embodiment provides a personalized federated learning method for processing imbalanced data, including inputting image data with imbalanced data into an imbalanced recognition network to obtain classification results, and simultaneously performing digital training of individual target neural networks according to the following steps S101 to S104.

[0057] S101. The central server establishes and initializes a global network model, which is a deep neural network model, including a basic encoding layer, a projection layer, and a classification layer. The central server distributes the global network model to all clients to initialize it into a client-side local network model, a comparison model, and a global network model.

[0058] The deep neural network model is initialized and divided into a basic encoding layer, a projection layer, and a classification layer. The basic encoding layer extracts feature representations from the network input. These feature representations implicitly contain rich sample information. By weighted aggregation of feature representations from different clients, better joint learning is achieved. The projection layer maps the feature representation of each target network to a fixed-dimensional space and calculates the similarity between each client model. Higher similarity results in larger weight coefficients and better joint learning performance. The classification layer adapts to the category of each client's data sample, generating a predicted value for each category.

[0059] In this example, the basic coding layer uses a ResNet-50 architecture as the backbone network. Initially, the central server distributes the global network model to all participating clients. After the clients initialize three models: the client's local network model, the comparison model, and the global network model, in subsequent iterations, the central server and the clients only transmit the basic coding layer parameters of the model.

[0060] S102. The central server randomly selects a certain number of clients to participate in training. The clients participating in the training are trained using a contrastive learning algorithm based on their private data, and the updated basic coding layer parameters of the client's local network model are returned to the central server.

[0061] The client executes the local private data model training process as follows;

[0062] Step a1: Construct the model comparison loss function

[0063] Suppose the client is performing local training on the input image sample x. The local client loss consists of two parts. The first part is a typical loss term in supervised learning, such as cross-entropy loss, denoted as l. sup The second part is the model contrast loss term proposed in this invention, denoted as l. con .

[0064] For each input x, the client-side local network model The output features of the projection layer are represented as follows Extracting x from the global model w t Output feature representation of the projection layer This represents the feature representation of the projection layer output of the contrastive model, where P(·) represents the projection layer output, τ represents the temperature parameter, and the contrastive loss function of the model is:

[0065]

[0066] Step a2: Calculate the total loss function;

[0067]

[0068] Where: x represents the input data. This represents the client-local network model of client i in round t, i.e. μ is a hyperparameter that controls the weights of the contrastive loss in the model.

[0069] Step a3: Following the principle of minimizing the total loss function, train the local network model on the client side. The goal of the local client is to minimize:

[0070]

[0071] The updated client-side local network model base coding layer parameters are returned to the central server.

[0072] S103. The central server receives the basic coding layer parameters of all participating clients, calculates and updates the basic coding layer parameters of the global network model and the basic coding layer parameters of all participating client local network models. Simultaneously, it selects a comparison model for each participating client and sends the updated basic coding layer parameters of the global network model, the client local network model, and the selected comparison model to each participating client.

[0073] The central server executes the central server training process according to steps b1 to b4 as follows.

[0074] Step b1: For each of the n participating clients, the central server assigns a number to the participating client and creates a corresponding client parameter dictionary to store the parameters transmitted by each client. In each iteration, the parameter dictionary is updated based on the latest received data.

[0075] Step b2: The central server constructs a similarity matrix dictionary, initializes the similarity matrix (n rows and n columns), where each element represents the similarity weight coefficient between any two clients. The similarity between each pair of clients is calculated using the cosine similarity formula, and the similarity matrix is ​​updated.

[0076] For each client The central server communicates with other clients j (j≠i) through this client i. The similarity value is used as the weight coefficient ξ ij Update the similarity matrix dictionary. The formula is as follows:

[0077]

[0078] in: This represents the basic encoding layer parameters of client i participating in the training. This represents the parameters of the basic encoding layer of the comparison model; the similarity matrix is ​​normalized using the softmax function, and its formula is:

[0079]

[0080] Where ξ ij It is the weight coefficient value in the i-th row and j-th column of the similarity matrix, and exp(·) represents e x The exponential function, exp(ξ) ik ) represents the values ​​of other elements in the i-th row of the similarity matrix.

[0081] Step b3: For client i, the central server uses the weight coefficient ξ from the dictionary. ij The central server weights and aggregates the basic coding layer parameters uploaded by other clients j to obtain the latest basic coding layer for client i, and then sends it to client i. The formula for the central server to update the basic coding layer model parameters for client i is as follows:

[0082]

[0083] Where t represents the t-th iteration. These are the base coding layer parameters of the client's local network model in round t for client j. This represents the base coding layer parameters of the client's local network model in round t+1.

[0084] Step b4: The central server selects a contrast model for each client participating in training, and then distributes the updated global network model base coding layer parameters, the client's local network model base coding layer parameters, and the selected contrast model base coding layer parameters to each client participating in training.

[0085] S104. The client participating in the training updates its local network model, comparison model, and global network model according to the model parameters sent by the server, and then returns to step 102 until the global network model of the central server converges or reaches the specified number of training iterations.

[0086] This embodiment also provides a personalized federated learning method for processing imbalanced data, including a memory and a processor; the memory is used to store a computer program; the processor is used to implement the above-described personalized federated learning method for imbalanced data when the computer program is executed.

[0087] The preferred embodiments of the present invention have been described in detail above. It should be understood that those skilled in the art can make numerous modifications and variations based on the concept of the present invention without creative effort. Therefore, all technical solutions that can be obtained by those skilled in the art based on the concept of the present invention through logical analysis, reasoning, or limited experimentation on the basis of existing technology should be within the scope of protection defined by the claims.

Claims

1. A personalized federated learning method for handling unbalanced data, characterized in that, Includes the following steps: (1) The central server establishes and initializes a global network model, which is a deep neural network model, including a basic encoding layer, a projection layer and a classification layer. The central server distributes the global network model to all clients to initialize it into a client local network model, a comparison model and a global network model. (2) The central server randomly selects a certain number of clients to participate in training. The clients participating in the training are trained using a contrastive learning algorithm based on their private data, and the updated client local network model basic coding layer parameters are returned to the central server. (2.1) Construct a model contrast loss function based on the client local network model, the global network model, and the contrast model; (2.2) The client calculates the total loss function using the cross-entropy loss function and the model comparison loss function; (2.3) Based on the client's private data, and following the principle of minimizing the total loss function, train the client's local network model to obtain updated client local network model parameters; (3) The central server receives the basic coding layer parameters of all clients participating in the training, calculates and updates the basic coding layer parameters of the global network model and the basic coding layer parameters of all clients participating in the training, and selects the comparison model for each client participating in the training, and sends the updated basic coding layer parameters of the global network model, the basic coding layer parameters of the client local network model, and the basic coding layer parameters of the selected comparison model to each client participating in the training. The comparison model is the model of client j randomly selected by the central server for client i participating in the training, wherein the similarity between the models of client i and client j is lower than a set threshold; (4) The client participating in the training updates the client's local network model, comparison model and global network model according to the model parameters sent by the server, and then returns to step (2) until the global network model of the central server converges or reaches the specified number of training times.

2. The personalized federated learning method for handling imbalanced data according to claim 1, wherein, The model comparison loss function is: Where: x represents the input data. For the client local network model Output feature representation of the projection layer; For the global network model Output feature representation of the projection layer; For the comparison model The output feature representation of the projection layer, Indicates temperature parameter, This indicates the output of the projection layer.

3. The personalized federated learning method for handling imbalanced data according to claim 2, wherein, The total loss function is: wherein: x represents input data, represents the client-local network model of client i at round t, i.e. , represents the cross-entropy loss function, represents the model contrastive loss function, is a hyperparameter controlling the model contrastive loss weight, represents the base encoding layer parameters of participating training client i at round t.

4. The personalized federated learning method for handling imbalanced data according to claim 1, wherein, The update of the basic coding layer parameters of the global network model in step (3) adopts the average aggregation method, and its formula is: Where: t represents the t-th round of training; These are the base coding layer parameters of the client's local network model in round t for client i. is the basic encoding layer parameter of the global network model in round t+1, and N is the number of clients participating in the training.

5. The personalized federated learning method for handling imbalanced data according to claim 1, wherein, The update of the client local network model basic coding layer parameters in step (3) adopts a weighted aggregation method, and the specific process includes: (3.1) The central server establishes a parameter dictionary for each client, stores the model parameters uploaded by each client, and updates the parameter dictionary in each iteration based on the latest received data; (3.2) The central server constructs a similarity matrix dictionary to store the similarity values ​​between the clients. The central server calculates the similarity value between every two clients participating in training using the cosine similarity formula based on the basic coding layer model parameters of each client participating in training, and uses it as a weight coefficient. Update the similarity matrix dictionary; (3.3) For the client i, the central server weighted and aggregated the basic coding layer parameters uploaded by other clients j participating in the training according to the similarity matrix dictionary to obtain the latest basic coding layer parameters of the client i, and sent them to the client i.

6. The personalized federated learning method for handling imbalanced data according to claim 5, wherein, The cosine similarity formula in step (3.2) is as follows: wherein: denotes the base encoding layer parameters of the client i participating in the training at round t, denotes the base encoding layer parameters of the client j at round t; The similarity matrix is normalized by a softmax function, and the formula is as follows: wherein: is a weight coefficient value of the similarity matrix in the ith row and jth column, is an exponential function representing represents other element values of the similarity matrix in the ith row.​ 7. A personalized federated learning method for processing imbalanced data according to claim 5, characterized in that, The weighted aggregation formula in the step (3.3) is as follows: where t represents the tth iteration number of the round, is the client-local network model base encoding layer parameter of the client j at the tth round, represents the client-local network model base encoding layer parameter of the client i at the t+1th round.

8. An apparatus for personalized federated learning for handling unbalanced data, comprising a memory, a processor, and a computer program stored in the memory and executable on the memory, characterized in that: The processor implements the personalized federated learning method for processing unbalanced data according to any one of claims 1-7 when executing the computer program.