A two-stage personalized federated learning method
Through the two-stage personalized federated learning method, supervised comparison learning is used to construct global unbiased feature representation and personalized classifiers are constructed based on client data distribution, which solves the model deviation problem caused by coupling between representation learning and classifier learning in existing federated learning. , improves data distribution adaptability and computing resource utilization efficiency.
Patent Information
- Application Number
- CN202210152993.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-18
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2042-02-18
AI Technical Summary
In the existing personalized federated learning method, characterization learning is coupled with classifier learning, resulting in model deviation and label deviation affecting the accuracy of the global representation model, making it difficult to effectively deal with the problems of heterogeneous data distribution and computing resource limitations.
Using the two-stage personalized federated learning method, firstly, through the global representation learning stage, the global unbiased feature representation is constructed through the global representation learning stage, and the second stage is to build a personalized classifier based on the client data distribution and resource conditions, decoupling the characterization learning and classifier study.
It improves the generalization performance of federated learning on different data distributions, reduces the impact of label bias, is suitable for various data distributions and computing resource conditions, and improves recognition accuracy and flexibility.
Smart Images

Figure CN114529012B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of machine learning, mainly relates to the fields of distributed learning and privacy protection, and in particular to a two-stage personalized federated learning method. Background Art
[0002] In recent years, with the rapid development of big data technology and artificial intelligence technology, people's attention to user privacy and data security has been increasing. Data silos caused by privacy protection, computing resources and other reasons are hindering the use of big data required for training artificial intelligence models. Federated learning is currently being widely used to solve such problems. Federated learning aims to learn a global model to learn a common representation through built-in privacy protection design. However, in practical applications, decentralized data is statistically heterogeneous. In order to solve the problem of heterogeneous data, a personalized federated learning personalized for specific clients was born.
[0003] Personalized federated learning aims to find a global optimal model with a common representation, and the model should also be applicable to local data of different clients. Currently, personalized federated learning is mainly accomplished through federated meta-learning (Fallah A, Mokhtari A, Ozdaglar A. Personalized federated learning with theoretical guarantees: A model-agnostic meta-learning approach [J]. Advances in Neural Information Processing Systems, 2020, 33) and federated regularized training (Li T, Sahu AK, Zaheer M, et al. Federated optimization in heterogeneous networks [J]. arXiv preprint arXiv: 1812.06127, 2018). The former is to find a good initial condition shared among participating clients as the initial global model, and to perform personalized optimization on the client through meta-learning. The latter introduces a regularization term during training to constrain the weight difference between the personalized local model and the global model during the optimization process. Although these methods are intuitive and experimentally effective, they still have a key limitation: their representation learning is coupled with classifier learning, which causes all client classifiers and representation models to be affected by the label bias in the classification decision boundary of the local data distribution, thereby affecting the accuracy of the global representation model.
[0004] Based on this, the present invention proposes a two-stage personalized federated learning framework. In the representation learning stage, supervised contrastive learning loss is used to construct a global unbiased feature representation. At the same time, in the two-stage classifier learning stage, a personalized classifier is constructed according to the data distribution and resource conditions of the client, which better decouples representation learning and classifier learning and reduces the impact of label bias on the representation model. Summary of the invention
[0005] The purpose of the present invention is to address the problems of data privacy, uneven data distribution, and model bias caused by end-to-end classification loss in traditional federated learning, and to provide a two-stage personalized federated learning method that can improve the model bias caused by label bias training in traditional federated learning, improve the generalization performance of federated learning for various data distributions, and meet the needs of actual applications.
[0006] The present invention includes two stages: global representation learning and personalized classifier learning. The specific steps are as follows:
[0007] 1) Global representation learning stage: Perform unified federated representation learning based on different data information obtained by different clients to obtain an accurate representation mapping model from image to feature space; first perform local client learning, and then aggregate the clients into a global model on the global server;
[0008] 2) Personalized classifier learning stage: Using the representation mapping model obtained by federated learning, the personalized classifier is trained according to the data distribution of different clients.
[0009] In step 1), the global representation learning stage is used to learn distinguishable representative features of the image and eliminate the influence of label bias on the model. The specific steps of global representation learning can be: first, define the representation model of the i-th client as φ i (w i ), i = 1, 2, ..., n, where i∈[n]; the global representation model after federated learning is φ(w rep ), where w rep is the parameter representing the model; the private data owned by the i-th client is k=1,2,...,d,where k∈[d],i∈[n],D=∑ n D n It is the total collection of all client data;
[0010] For client representation learning, a supervised contrastive learning scheme is used as the baseline, that is, for each sample x k Mapped to a feature vector in the feature space through a neural network, the positive sample is defined as a sample with the same label j=1,2,...,d,the remaining samples are defined as negative samples; all samples are extracted and mapped to the feature space through a neural network; the client representation learning is to cluster the positive samples of the samples as closely as possible while being as far away from the negative samples as possible; the label is introduced to identify whether it belongs to a positive or negative sample in the feature space, and the supervised contrast representation learning loss function used is as follows:
[0011]
[0012]
[0013] Among them, z k The vector representing the output of the sample’s features through the projection head structure of the feature representation network, d yk Indicates that the label is y k The number of samples, f(·) represents the cosine similarity between two features, τ>0 represents the temperature parameter, is an indicator function, when Returns 1 when condition B is true;
[0014] Through the learning of the local client, the global server model will obtain {w rep , w1,…,w n}Representation model parameters; In order to increase the robustness of federated learning training, simulate that the clients participating in federated learning are different each time, and randomly select a small number of clients for update in each round; For the selected clients, first obtain the global representation model weights of the previous round And local representation learning training is performed locally in combination with the local distributed data set. The training process is as follows:
[0015]
[0016] in, is the learning rate at the tth round; Represents the gradient of the i-th client model on its local dataset Di; for the client model that is not selected, keep the previous model;
[0017] After completing the learning of the local client, enter the global server for client aggregation; Fedavg (McMahan B, Moore E, Ramage D, et al. Communication-efficient learning of deepnetworks from decentralized data [C] / / Artificial intelligence and statistics. PMLR, 2017: 1273-1282) is used to aggregate the global model; specifically, after the selected client in this round completes the training, the local representation model parameters are uploaded to the global server, and unified aggregation is performed through the following method to complete the first stage of the representation learning process;
[0018]
[0019] Among them, S i =max(C·n, 1) is a portion of clients randomly selected, and C is a ratio parameter of the selected clients.
[0020] In step 2), the personalized classifier learning phase is used to complete the downstream tasks of the federated learning client. After the global representation model is learned in one stage, the representation model is distributed to each client, so that the local client has the representation ability to map the image to the feature space. Based on the global representation model, a personalized classifier trained with the data of each local client is constructed; for each client i∈[n], the loss function l:y×R between the output of the linear classifier and the true label is minimized. C →R is used to train the personalized classifier; the specific training process is:
[0021]
[0022] The personalized classifier includes, but is not limited to, a logistic regression classifier, a linear classifier, a support vector machine, etc. Different local personalized classifiers have different computational loads, and a more complex classifier can achieve better classification results.
[0023] The present invention constructs a global image accurate representation model by constructing a one-stage global representation learning method, and then trains a classifier based on local data distribution by means of a local personalized classifier. Compared with the end-to-end training method based on classification loss of the common personalized federated learning method, the present invention completely decouples representation learning and classifier learning, aggregates global common feature representations, and retains local personalized classifiers.
[0024] Compared with the prior art, the innovative features of the present invention include:
[0025] (1) Different from the traditional personalized federated learning method, a novel two-stage personalized federated learning method is proposed to address the practical problems of data privacy and uneven data distribution. This method separates the representation learning and classifier learning stages, and trains a global representation model with smaller deviation and a more personalized local classifier model for the client. It can effectively utilize the data of each client to obtain a global representation model and a local personalized classifier model, thereby improving recognition accuracy.
[0026] (2) In the global representation learning stage, the present invention uses supervised contrast loss for optimization and learns a common representation model from client data with different distributions.
[0027] (3) In the personalized classifier learning stage, the present invention allows each client to learn a personalized classifier based on the globally announced representation model. This personalized classifier can benefit devices with limited computing power in practical applications.
[0028] (4) It is based on federated learning and comparative learning. It is highly practical and flexible and can meet the needs of federated learning under different data distributions and computing resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 Schematic diagram of the training process framework of an embodiment of the present invention.
[0030] Figure 2 It is a schematic diagram of the client (Client) and the global server (Server). DETAILED DESCRIPTION
[0031] In order to make the purpose, technical solutions and advantages of the present invention clearer, the embodiments of the present invention are further described in detail below:
[0032] The embodiment of the present invention includes global representation learning and personalized classifier learning, and specifically includes the following steps:
[0033] A. Global representation learning;
[0034] B. Personalized classifier learning;
[0035] In order to deal with the problem of model bias caused by end-to-end classification loss in traditional federated learning, we hope to deeply decouple the representation learning and classifier learning processes through a two-stage federated learning approach. In the representation learning stage, the goal is to obtain a global universal data representation through the heterogeneous data distribution of different clients; in the classifier stage, through the global universal representation, according to the actual data distribution of each client, learn personalized classifiers to adapt to the customized needs of different clients. Further improve the ability of federated learning to cope with different data distributions. Training frameworks such as Figure 1 In the first stage, the present invention first performs unified federated representation learning based on different data information obtained by different clients to obtain accurate representation mapping from image to feature space; then in the second stage, the representation mapping model obtained by federated learning is used to train a personalized classifier based on the data distribution of different clients. The present invention defines one round of federated learning communication and one epoch of local model training iteration.
[0036] The following is the algorithm flow of the present invention:
[0037]
[0038]
[0039] The specific steps of step A are as follows:
[0040] The global representation learning process in step A aims to learn distinguishable representative features of the image and eliminate the influence of label bias on the model. For the convenience of description and subsequent content, the present invention defines the representation model of the i-th client as φ i (w i ), i = 1, 2, ..., n, where i∈[n]. The global representation model after federated learning is φ(w rep ), where w rep is the parameter representing the model. The private data owned by the i-th client is k=1,2,...,d,where k∈[d],i∈[n],D=∑ n D n It is the total collection of all client data.
[0041] In step A, for the representation learning of the client, the present invention adopts a supervised contrastive learning scheme as a baseline, that is, for each sample x k Mapped to a feature vector in the feature space through a neural network, the positive sample is defined as a sample with the same label j=1, 2, ..., d, and the remaining samples are defined as negative samples. All samples will be extracted and mapped into the feature space through a neural network. The goal of client representation learning is to cluster the positive samples of the samples as closely as possible while being as far away from the negative samples as possible. The role of introducing labels here is only to identify whether they belong to positive and negative samples in the feature space, which is different from the commonly used neural network classification loss. The supervised contrast representation learning loss function adopted by the present invention is as follows:
[0042]
[0043]
[0044] where z k The vector representing the output of the sample’s features through the projection head structure of the feature representation network, d yk Indicates that the label is y k The number of samples, f(·) represents the cosine similarity between two features, τ>0 represents the temperature parameter, is an indicator function that returns 1 when condition B is true.
[0045] Through the learning of the local client, the global server model will obtain {w rep , w1,…,w n} Characterization model parameters. In order to increase the robustness of federated learning training, the present invention randomly selects a small number of clients for update in each round to simulate the different clients participating in federated learning each time. For the selected clients, the global characterization model weights of the previous round will be obtained first. And local representation learning training is performed locally in combination with the local distributed data set. The training process is as follows:
[0046]
[0047] in, is the learning rate at the tth round; Represents the i-th client model in its local dataset D i For client models that are not selected, the previous model will be kept.
[0048] After completing the learning of the local client, enter the global server for client aggregation. The present invention uses Fedavg (McMahan B, Moore E, Ramage D, et al. Communication-efficient learning of deep networks from decentralized data [C] / / Artificial intelligence and statistics. PMLR, 2017: 1273-1282) to aggregate the global model. Specifically, after the selected client in this round completes the training, the local representation model parameters are uploaded to the global server, and unified aggregation is performed through the following method to complete the first stage of the representation learning process.
[0049]
[0050] Where S i =max(C·n, 1) is a portion of clients randomly selected, where C is a ratio parameter of the selected clients.
[0051] The specific steps of step B are as follows:
[0052] The purpose of learning the personalized classifier in step B is to complete the downstream tasks of the federated learning client. After learning the global representation model in one stage, the representation model is distributed to each client so that the local client has the representation ability to map the image to the feature space. Build a personalized classifier h(θ) trained by each local client data i ), where θ i is the classifier parameter of the i-th client. For each client i∈[n], the present invention minimizes the loss function l between the output of the linear classifier and the true label: y×R C →R to train the personalized classifier. The specific training process of this stage is:
[0053]
[0054] In addition to being widely used in privacy protection and distributed training between institutions, federated learning is also widely used in the fields of embedded devices and the Internet of Things. In the actual application of embedded devices, the performance and resources of some devices are limited and can only support network reasoning and simple training. The two-stage local training process of the present invention can select personalized classifiers, such as logistic regression classifiers (Logistic Regression), linear classifiers (Linear Regression), and support vector machines (Support Vector Machines) according to different client conditions. Different local personalized classifiers have different computational loads, and the more complex the classifier, the better the classification effect can be achieved.
[0055] The present invention constructs a global image accurate representation model by constructing a one-stage global representation learning method, and then trains a classifier based on local data distribution by means of a local personalized classifier. Compared with the end-to-end training method based on classification loss of the common personalized federated learning method, the present invention completely decouples representation learning and classifier learning, aggregates global common feature representations, and retains local personalized classifiers.
[0056] Specific examples are given below.
[0057] In step A, the present invention sets the Backbone neural network to Resnet34, uses the Adam optimizer, and sets the weight decay to 1×10 -4 , the initial learning rate is 0.001 and the learning rate decay is set to 0.1, the temperature parameter τ is set to 0.1, a total of 100 rounds, and 1 round of local selected model iteration is 10 epochs.
[0058] In step B, the present invention sets the linear classifier as a linear network layer, trains the linear classifier under a fixed one-stage representation model, uses the Adam optimizer, sets the learning rate to 5, and trains for 100 epochs. For the SVM classifier, the SVM is set to a linear kernel and the decision mode is 'ovo'. For the logistic regression classifier, the default logistic regression parameter settings are used.
[0059] In order to verify that the present invention can learn a reasonable global representation model in one stage, the present invention uses the Cifar-10 dataset under 20 clients and adopts the above one-stage representation training method to distribute the Cifar-10 dataset to each client through Dirichlet sampling. After 100 rounds of training, TSNE (Van der Maaten L, Hinton G. Visualizing data using t-SNE [J]. Journal of machine learning research, 2008, 9 (11)) is used to draw a feature visualization diagram, as shown in FIG. Figure 2 As shown, different color points can be used to represent samples of different categories when drawing feature visualization graphs. Figure 2 Figures a, b, and c in the figure represent the local representation models of clients A, B, and C, and figure d represents the global representation model. It can be seen from the figure that the uneven feature space of the local client can obtain a better representation model after global aggregation, which well maintains the common features of the federation global.
[0060] The innovations of the present invention include: (1) Different from the traditional personalized federated learning method, the present invention proposes a novel two-stage personalized federated learning framework, which separates the representation learning and classifier learning stages, and trains a global representation model with smaller deviation and a more personalized local classifier model for the client. (2) In step A, the present invention uses supervised contrast loss for optimization and learns a common representation model from client data with different distributions. (3) In step B, the present invention allows each client to learn a personalized classifier based on the globally announced representation model. This personalized classifier can benefit devices with limited computing power in practical applications.
[0061] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A two-stage personalized federated learning method, characterized by The specific steps are as follows: 1) Global representation learning stage: Perform unified federated representation learning based on different data information obtained by different clients to obtain an accurate representation mapping model from image to feature space; first perform local client learning, and then aggregate the clients into a global model on the global server; The specific steps of the global representation learning are: first, define the representation model of the i-th client as φ i (w i ), i = 1, 2, ..., n, where i∈[n]; the global representation model after federated learning is φ(w rep ), where w rep is the parameter representing the model; the private data owned by the i-th client is where k∈[d], i∈[n], D=∑ n D n , D is the total set of all client data; For client representation learning, a supervised contrastive learning scheme is used as the baseline, that is, for each sample x k Mapped to a feature vector in the feature space through a neural network, the positive sample is defined as a sample with the same label The remaining samples are defined as negative samples; all samples are extracted and mapped into the feature space through a neural network; the supervised contrast representation learning loss function used is as follows: Among them, z k The vector representing the output of the sample's features through the projection head structure of the feature representation network. Indicates that the label is y k The number of samples, f(·) represents the cosine similarity between two features, τ>0 represents the temperature parameter, is an indicator function, when Returns 1 when condition k is true; Through the learning of the local client, the global server model will obtain {w rep , w1,…,w n }Representation model parameters; To increase the robustness of federated learning training, simulate that the clients participating in federated learning are different each time, and randomly select a small number of clients for update in each round; For the selected clients, first obtain the global representation model weights of the previous round And local representation learning training is performed locally in combination with the local distributed data set. The training process is as follows: in, is the learning rate at the tth round; Represents the i-th client model in its local dataset D i For client models that are not selected, keep the previous model; After completing the learning of the local client, enter the global server for client aggregation; use Fedavg to aggregate the global model; specifically, after the client selected in this round completes the training, upload the local representation model parameters to the global server, and perform unified aggregation through the following method to complete the first stage of the representation learning process; Among them, S i =max(C·n, 1) is the randomly selected part of the clients, and C is the proportion parameter of the selected clients; 2) Personalized classifier learning stage: Using the representation mapping model obtained by federated learning, the personalized classifier is trained according to the data distribution of different clients; The personalized classifier learning is used to complete the downstream tasks of the federated learning client. After the global representation model is learned in one stage, the representation model is distributed to each client, so that the local client has the representation ability to map the image to the feature space. Based on the global representation model, a personalized classifier trained with the data of each local client is constructed; for each client i∈[n], the loss function l: y×R between the output of the linear classifier and the true label is minimized. C →R is used to train the personalized classifier; the specific training process is:
2. A two-stage personalized federated learning method as claimed in claim 1, characterized in that In step 2), the personalized classifier includes but is not limited to a logistic regression classifier, a linear classifier, and a support vector machine.
Citation Information
Patent Citations
Multi-center brain tumor prognosis lifetime prediction method and system based on federated learning
CN113571203A
Federated learning method, device, equipment, and storage medium
WO2021115480A1