Model joint optimization method based on federal learning
Through the federated semi-supervised mutual learning algorithm FedSML, the labeled data on the server is used to train the assisted model and perform knowledge distillation on the client, which solves the problem of utilizing unlabeled data in a distributed environment and achieves efficient model training and accuracy improvement.
Patent Information
- Application Number
- CN202410739117.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-06-07
AI Technical Summary
Existing distributed machine learning methods assume that data on edge devices are labeled. However, in actual scenarios, private data is mostly unlabeled data, which is difficult to utilize. Especially when the client has limited computing power and privacy issues exist, existing methods It is difficult to achieve efficient distributed semi-supervised learning without transferring data across the network.
The federated semi-supervised mutual learning algorithm FedSML is proposed. It trains an auxiliary model with a large number of parameters on the server, and uses the model to perform knowledge distillation to train a local model on the client. The server aggregates the local models to form a global model, while using labeled Data sets learn from each other to improve the generalization ability of the model.
Without the need to transmit data across networks, the accuracy of model training on edge devices is improved, the cost of labeling data sets is reduced, the generalization ability of the model is improved, and the computing overhead of edge devices is reduced.
Smart Images

Figure CN118586522A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence technology, and specifically is a model joint optimization method based on federated learning. Background Art
[0002] There is an increasing amount of research on distributed machine learning under edge computing, which enables edge devices to collaboratively learn deep models without exchanging private data. Existing distributed learning methods assume that the private data owned by edge devices are all labeled, but in real scenarios, a large amount of available private data is unlabeled, and existing methods have difficulty in utilizing such data. To overcome this limitation, this paper proposes a federated semi-supervised learning algorithm, FedSML, which is dedicated to solving the federated semi-supervised learning problem in a challenging environment, that is, all labeled data are on the server, the client only has unlabeled data, and the client has limited computing power. FedSML makes full use of the server's computing resources to train a large-parameter auxiliary model on the labeled dataset. The client uses the auxiliary model to train a local model through unsupervised knowledge distillation and consistency regularization. After the server aggregates the received local models to obtain the global model, it trains the auxiliary model and the global model on the labeled dataset through mutual learning, so that the auxiliary model learns the knowledge of the unlabeled dataset, and the global model learns the inter-class relationship of the labeled dataset, thereby improving the generalization ability of the two models respectively.
[0003] Nowadays, machine learning applications are deployed on many edge devices (such as mobile phones or IoT devices) to provide artificial intelligence services to users. Since a large amount of data is generated at the edge, machine learning applications can use this private data to collaboratively learn models. However, labeling data is time-consuming and requires expertise, so the data generated on edge devices is usually only a small amount with labels. Therefore, it is quite important to study how to use data sets on edge devices to enhance distributed model learning in edge computing.
[0004] In a centralized computing environment, the model can be trained through a semi-supervised learning algorithm to improve the performance of the model using large-scale unlabeled data. Recently, researchers have proposed consistency regularization (Zhang B, Wang Y, Hou W, et al. FlexMatch: Boosting Semi-Supervised Learning with Curriculum PseudoLabeling [C]. In: Advances in Neural Information Processing Systems, Curran Associates, Inc., 2021. 34: 18408–18419.) to use unlabeled data for semi-supervised learning. This type of algorithm optimizes the model by training the model's output consistency for different perturbation versions of the same unlabeled sample. Self-training (Lee DH et al. Pseudo-Label: The Simple and Efficient Semi-Supervised Learning Method for Deep Neural Networks [J]. Workshop on challenges in representation learning, ICML, 3 (2): 896, 2013) is another commonly used semi-supervised learning algorithm, which uses the model's own output on unlabeled data (also called pseudo-labels) to optimize the model. These methods have achieved great success in centralized computing environments, but in distributed computing environments, due to the small number of samples on each node, the accuracy of the models trained by these methods drops sharply. Due to privacy issues, data on the device cannot be transmitted to the server for training, so it is necessary to explore how to achieve distributed semi-supervised learning without transmitting datasets across the network.
[0005] To maintain privacy and reduce transmission overhead, researchers have proposed several distributed machine learning methods, such as Federated Learning, Distributed SGD, and Gossip Learning. These methods use data on the device to train a local model for each device, and then transmit the model over the network and aggregate it with other models, while the private data is saved on each device without being transmitted over the network, and the model is optimized using global data information. However, these methods assume that the data generated on the edge device is labeled, which is unrealistic in edge computing. In order to use unlabeled data to train models on edge devices, researchers have proposed various distributed semi-supervised training methods, considering the case where there is a shared unlabeled dataset in the edge devices. These methods reduce communication overhead by transmitting only soft labels and use knowledge distillation to transfer knowledge between models. However, devices cannot apply such methods to learn models on private unlabeled datasets. In order to utilize these private data, some researchers have proposed Federated Semi-Supervised Learning (FSSL), which uses these unlabeled data on each device to train a local model through self-training or consistency regularization, and then aggregates to obtain a global model. Some existing technologies combine federated learning and semi-supervised learning algorithms, where each node trains its model using a semi-supervised learning algorithm, and then uses a federated learning algorithm for model exchange and aggregation. However, this method only uses the same global model to predict pseudo labels for unlabeled samples, which reduces the accuracy of pseudo labels generated in data heterogeneous environments. To solve this problem, some existing technologies propose to use an aggregation server to select these auxiliary models for each client, and the auxiliary models generate pseudo labels for unlabeled data. However, since the aggregation server does not have information about the distribution of the data set on each node, it is difficult to select a suitable auxiliary model for each client to generate high-precision pseudo labels.
[0006] Self-training is a simple and effective semi-supervised learning algorithm that uses pseudo-labels of unlabeled data generated by the model itself to train the model. Obviously, the accuracy of the pseudo-labels has a great impact on the convergence of semi-supervised training and the performance of the model. To this end, self-training is often integrated with other semi-supervised learning algorithms, such as consistency regularization and entropy minimization, to reduce the generation of erroneous pseudo-labels. Consistency regularization assumes that small perturbations to the data will not affect the class semantics of the data. Generally speaking, the consistency regularization algorithm in the field of image recognition (Laine S. and Aila T. Temporal Ensembling for Semi-Supervised Learning [A]. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017.) trains the model by reducing the model output differences between different data-enhanced versions of the same image. ReMixMatch (Berthelot D., Carlini N., Cubuk ED, et al. ReMixMatch: Semi-Supervised Learning with Distribution Matching and Augmentation Anchoring [A]. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020.) applies weak data augmentation to unlabeled samples to generate pseudo-labels, and applies strong data augmentation to force the model to keep the output of the two versions of the sample consistent. FixMatch simplifies the previous complex semi-supervised learning algorithm by filtering pseudo-labels using a fixed high threshold. To improve FixMatch, Dash uses a threshold that increases during training to utilize more unlabeled data, and FlexMatch uses a course pseudo-label algorithm to set a dynamic threshold for each class. Entropy minimization is another popular component of semi-supervised learning, which works by forcing the model to reduce the information entropy of the output of unlabeled data. However, these methods all require a large amount of unlabeled data to achieve optimal accuracy, which is impractical for devices in edge scenarios. In addition, these methods do not consider the data heterogeneity on the devices, which makes it impossible to achieve the original performance of these methods. Summary of the invention
[0007] In order to solve this problem, the present invention proposes a Federated Semi-Supervised Mutual Learning algorithm (FedSML) in order to improve the model performance by using unlabeled samples in this scenario. In FedSML, the server does not match an assisting model for each client, but trains a model with a large number of parameters as an assisting model on a labeled data set by making full use of the server's computing power. The client uses this assisting model to transfer knowledge to the local model with a small number of parameters through knowledge distillation. The local model also performs semi-supervised training on unlabeled samples to obtain knowledge of the unlabeled data set. After the local training is completed, the local model is uploaded back to the server for model aggregation to obtain a global model. The server trains the global model on the labeled data set so that the global model learns the knowledge of the labeled samples, and transfers the knowledge of the client's unlabeled data set held by the global model to the assisting model through knowledge distillation.
[0008] The present invention is achieved by at least one of the following technical solutions.
[0009] A model joint optimization method based on federated learning includes the following steps:
[0010] Step 1: Each edge device uses an acquisition device to collect images to form an unlabeled data set; the server uses an acquisition device to collect images and classifies the images to form a labeled data set;
[0011] Step 2: The server randomly selects an edge device and sends the global model and the assistance model to the edge device;
[0012] Step 3: The edge device uses the global model as the local model and trains the local model using unlabeled samples.
[0013] Step 4: The edge device uploads the updated local model to the server;
[0014] Step 5: The server aggregates all received local models to obtain a new global model;
[0015] Step 6: The server uses the labeled data set to learn the global model and the auxiliary model from each other;
[0016] Step 7: The server transmits the global model to the edge device, and the edge device uses the sent global model for classification.
[0017] Furthermore, each edge device c uses a camera to collect images to form an unlabeled dataset in is the i-th unlabeled sample on edge device c, is the set of all possible input images, is the total number of unlabeled samples on edge device c.
[0018] Furthermore, the server S collects images through the camera, and then manually divides the images into C categories to form a labeled data set in is the i-th image in the dataset, is the set of all possible input images, y i ∈{1,...,C} is the image x i The corresponding mark, N s is the total number of labeled samples on the server.
[0019] Furthermore, there are labeled datasets The total number of samples is much smaller than that of the unlabeled dataset Right now Where N is the total number of edge devices participating in the joint optimization, and the data on different edge devices are not independent and identically distributed.
[0020] Furthermore, the server and all edge devices use the same C-classification model structure.
[0021] Furthermore, the model on the edge device is Where L c is the local model on edge device c, and its parameters are N is the total number of edge devices participating in the joint optimization.
[0022] The global model on the server is denoted as G S , whose parameters are recorded as The assisting model is denoted as G H , whose parameters are recorded as
[0023] Furthermore, the server randomly selects a subset of edge devices {1, ..., M} participating in federated learning Where M is the total number of edge devices participating in the joint optimization, and the global model G S and assist model G H Send to these edge devices; edge device k∈K uses G S Initialize the local model L with parameters k , update the local model on the unlabeled dataset:
[0024]
[0025] in is the unsupervised loss, is the local model L kParameters, is the unlabeled dataset held by edge device k;
[0026] After the local model is updated, the edge device uploads the local model parameters to the server, and the server aggregates all the received local models to obtain a new global model:
[0027]
[0028] in is the number of unlabeled samples held by edge device k, is the global model G S Parameters.
[0029] Furthermore, the server trains the global model G using the labeled dataset S and assist model G H :
[0030]
[0031] in, are the parameters of the global model, To assist with the model parameters, is a labeled dataset on the server, There is a supervised loss. After obtaining the new global model parameters and auxiliary model, steps 2 to 6 are repeated until the global model converges.
[0032] Furthermore, the global model G is trained on the server S and assist model G H In the process, mutual learning is carried out, and the global model G S and assist model G H The loss functions are:
[0033]
[0034] in, are the parameters of the global model, To assist with the model parameters, is a labeled dataset on the server, is the global model G S In labeled datasets The enhanced cross entropy loss on To assist model G H In labeled datasets The enhanced cross entropy loss on is the global model G S To assist model G H The knowledge distillation loss is To assist model G HFor the global model G S The mutual learning is achieved by learning from each other through two models, and can learn the category information of the samples while learning the similar information between categories.
[0035] Furthermore, after the global model converges, the server will S Send it to each edge device, and the edge device uses the sent global model G S As a classification model, it is used for subsequent image classification on edge devices.
[0036] Compared with the prior art, the present invention has the following beneficial effects:
[0037] Edge devices directly use unlabeled datasets to train local models, greatly reducing the cost of labeling unlabeled datasets; edge devices use assisting models to generate pseudo labels for unlabeled datasets, improving the classification accuracy of trained local models; edge devices only train local models and do not need to train assisting models, reducing the computing overhead of edge devices; servers perform mutual learning between the global model and the assisting model on labeled datasets, improving the generalization capabilities of the global model and the assisting model. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A flowchart of a model joint optimization method based on federated learning is provided for implementing an embodiment;
[0039] Figure 2 A flowchart of training a local model for an edge device of an embodiment;
[0040] Figure 3 A flowchart of a server aggregating all received local models in an embodiment. DETAILED DESCRIPTION
[0041] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0042] like Figure 1 to Figure 3 A model joint optimization method based on federated learning is shown, comprising the following steps:
[0043] Step 1: Each edge device uses an acquisition device to collect images to form an unlabeled data set; the server uses an acquisition device to collect images and classifies the images to form a labeled data set;
[0044] This embodiment considers a monitoring scenario, in which there is a server S and N edge devices. Server S collects images through a camera, and then manually classifies the images into C categories (such as by the characters appearing in the image), thereby forming a labeled data set. where x i is a labeled sample, y i ∈{1,...,C} is a sample x i The corresponding unique hot label, N S is the total number of labeled samples on the server. Each edge device c uses a camera to collect images to form an unlabeled dataset in is the i-th unlabeled sample on edge device k, is the total number of unlabeled samples on edge device k.
[0045] Generally speaking, the total number of samples in a labeled dataset is much smaller than that in an unlabeled dataset. Moreover, the data on different edge devices are usually not independent and identically distributed.
[0046] As an example, in federated learning, the server and all edge devices use the same C classification model structure (such as LeNet5). The models on the edge devices are respectively Where L k is the local model on edge device k, and its parameters are The global model on the server is denoted as G S , whose parameters are recorded as In addition, a parameter is used on the server compared to the global model G S Larger Model G H As an auxiliary model, its parameters are recorded as
[0047] Step 2: The server randomly selects an edge device and sends the global model and the assistance model to the edge device;
[0048] The server randomly selects a subset of edge devices {1, ..., M} participating in federated learning. Where M is the total number of edge devices participating in the joint optimization, and the global model G S and assist model G H to these edge devices.
[0049] Step 3: The edge device uses the global model as the local model and trains the local model using unlabeled samples, such as Figure 2 As shown;
[0050] For all edge devices k∈K, use G S Initialize the local model L with parametersk ,Right now
[0051]
[0052] in is the local model L k Parameters, is the global model G S Parameters.
[0053] Update local model parameters on an unlabeled dataset:
[0054]
[0055] in is the unsupervised loss, is the unlabeled dataset held by edge device k.
[0056] To calculate the local model L k In the unlabeled dataset Unsupervised loss on
[0057] The first step is to use unlabeled dataset Each unlabeled sample in Perform a weak data enhancement, denoted as α(·) and a strong data enhancement as Get the corresponding enhanced samples α(u) and
[0058] As an embodiment, weak data enhancement such as random flipping, random translation, etc., and strong data enhancement such as RandAugment, CTAugment, etc.;
[0059] Step 2: Use the local model L k Predict α(u) and The probability of belonging to each category is denoted as p(α(u); L k )∈(0,1) C and The client uses p(α(u); L k ) generates a pseudo label for sample u, that is,
[0060]
[0061] where p i (α(u); L k ) is the model L k Predict the probability that α(u) belongs to the i-th class. The third step is to use the received auxiliary model G H Predict the probability p(α(u); G H)∈(0,1) C . Thus, the unsupervised loss is defined as follows:
[0062]
[0063] The loss consists of two parts. The first is the local model L k In the unlabeled dataset The consistency regularization loss on , that is:
[0064]
[0065] in,
[0066]
[0067] is the indicator function, For unlabeled datasets The sample size is τ, the preset threshold value, for For pseudo labels The second term is the cross entropy of the local model L k The auxiliary model G is trained on the unlabeled dataset after weak data augmentation. H The knowledge distillation loss is:
[0068]
[0069] where p i (α(u); G H ) is the model G H Predict the probability that α(u) belongs to the i-th class.
[0070] Calculate the local model L k In the unlabeled dataset Unsupervised loss on Afterwards, the edge device uses this loss to adjust the local model parameters Perform E rounds of gradient descent:
[0071]
[0072] Where η is the learning rate.
[0073] Step 4: The edge device uploads the updated local model to the server;
[0074] For edge device k∈K, it uses the unlabeled dataset in step 3 The local model L is trained on k Afterwards, the local model L k Upload back to server S.
[0075] Step 5: The server aggregates all received local models to obtain a new global model;
[0076] Server S receives all uploaded local models {L k} k∈K , aggregate the parameters of these local models is the new global model parameter
[0077]
[0078] in is the number of unlabeled samples held by edge device k.
[0079] Step 6: The server uses the labeled data set to learn the global model and the auxiliary model from each other;
[0080] Server S has a labeled dataset Train the global model G S and assist model G H ,Right now:
[0081]
[0082] in is the supervised loss.
[0083] To calculate the global model G S and assist model G H In the dataset The supervised loss on In the first step, server S has a labeled dataset Each sample in Perform a weak data enhancement (such as random flipping, random translation, etc., denoted as α(·)) to obtain the corresponding enhanced sample (α(x), y). The second step is to use the global model G S and assist model G H Predict the probability that α(x) belongs to each category, denoted as p(α(x); G S )∈(0,1) C and p(α(x); G H )∈(0,1) C Therefore, the global model G S and assist model G H The supervised losses are defined as follows:
[0084]
[0085] The loss consists of two parts. The first and The global model GS and assist model G H In labeled datasets The enhanced cross entropy loss on , that is:
[0086]
[0087]
[0088] Where N S For labeled datasets The total number of samples included, (x, y) is the number of samples in the data set The tuple consisting of the sample x and the corresponding unique hot label y, l CE (y,p(α(x);G S )) and l CE (y,p(α(x);G H )) respectively represent p(α(x); G S ) and p(α(x); G H ) is the cross entropy of the label y. The second term is the global model G S To assist model G H The knowledge distillation loss is To assist model G H For the global model G S The knowledge distillation loss is:
[0089]
[0090] where p i (α(x); G H ) is the model G H Predict the probability that α(x) belongs to the fth class, p i (α(x); G S ) is the model G S Predict the probability that α(x) belongs to the i-th class.
[0091] Calculate the global model G S and assist model G H In labeled datasets The supervised loss on After that, the server uses this loss to adjust the global model parameters and assist model parameters Perform E rounds of gradient descent:
[0092]
[0093] Where η is the learning rate. After obtaining the new global model parameters and auxiliary model parameters, repeat steps 2 to 6 until the global model converges.
[0094] Step 7: The server transmits the global model to the edge device, and the edge device uses the global model to perform classification.
[0095] After the global model converges, the server will S Send it to each edge device, and the edge device uses the sent global model G S As a classification model, it is used for subsequent image classification on edge devices. This reduces the classification cost of the training data set and implements the global model G S training, so that G S The images of the above C categories can be classified on each edge device.
[0096] The preferred embodiments of the present invention disclosed above are only used to help explain the present invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and use the present invention well.
Claims
1. A model joint optimization method based on federated learning, characterized in that: The following steps are involved: Step 1: Each edge device uses an acquisition device to collect images to form an unlabeled data set; the server uses an acquisition device to collect images and classifies the images to form a labeled data set; Step 2: The server randomly selects an edge device and sends the global model and the assistance model to the edge device; Step 3: The edge device uses the global model as the local model and trains the local model using unlabeled samples. Step 4: The edge device uploads the updated local model to the server; Step 5: The server aggregates all received local models to obtain a new global model; Step 6: The server uses the labeled data set to learn the global model and the auxiliary model from each other; Step 7: The server transmits the global model to the edge device, and the edge device uses the sent global model for classification.
2. The model joint optimization method based on federated learning according to claim 1, characterized in that: Each edge device c uses a camera to collect images to form an unlabeled dataset in is the i-th unlabeled sample on edge device c, is the set of all possible input images, is the total number of unlabeled samples on edge device c.
3. The model joint optimization method based on federated learning according to claim 1, characterized in that: Server S collects images through the camera, and then manually divides the images into C categories to form a labeled data set in is the i-th image in the dataset, is the set of all possible input images, y i ∈{1,...,C} is the image x i The corresponding mark, N s is the total number of labeled samples on the server.
4. The model joint optimization method based on federated learning according to claim 1, characterized in that: Labeled dataset The total number of samples is much smaller than that of the unlabeled dataset Right now Where N is the total number of edge devices participating in the joint optimization, and the data on different edge devices are not independent and identically distributed.
5. The model joint optimization method based on federated learning according to claim 1, characterized in that: The server and all edge devices use the same C-classification model structure.
6. The model joint optimization method based on federated learning according to claim 5, characterized in that: The model on the edge device is Where L c is the local model on edge device c, and its parameters are N is the total number of edge devices participating in the joint optimization; The global model on the server is denoted as G S , whose parameters are recorded as The assisting model is denoted as G H , whose parameters are recorded as 7. The model joint optimization method based on federated learning according to claim 6, characterized in that: The server randomly selects a subset of edge devices {1, ..., M} participating in federated learning. Where M is the total number of edge devices participating in the joint optimization, and the global model G S and assist model G H Send to these edge devices; edge device k∈K uses G S Initialize the local model L with parameters k , update the local model on the unlabeled dataset: in is the unsupervised loss, is the local model L k Parameters, is the unlabeled dataset held by edge device k; After the local model is updated, the edge device uploads the local model parameters to the server, and the server aggregates all the received local models to obtain a new global model: in is the number of unlabeled samples held by edge device k, is the global model G S Parameters.
8. The model joint optimization method based on federated learning according to claim 1, characterized in that: The server trains a global model G using a labeled dataset S and assist model G H : in, are the parameters of the global model, To assist with the model parameters, is a labeled dataset on the server, There is a supervised loss. After obtaining the new global model parameters and auxiliary model, steps 2 to 6 are repeated until the global model converges.
9. The model joint optimization method based on federated learning according to claim 1, characterized in that: Train the global model G on the server S and assist model G H In the process, mutual learning is carried out, and the global model G S and assist model G H The loss functions are: in, are the parameters of the global model, To assist with the model parameters, is a labeled dataset on the server, is the global model G S In labeled datasets The enhanced cross entropy loss on To assist model G H In labeled datasets The enhanced cross entropy loss on is the global model G S To assist model G H The knowledge distillation loss is To assist model G H For the global model G S The mutual learning is achieved by learning from each other through two models, and can learn the category information of the samples while learning the similar information between categories.
10. The model joint optimization method based on federated learning according to claim 1, characterized in that: After the global model converges, the server will S Send it to each edge device, and the edge device uses the sent global model G S As a classification model, it is used for subsequent image classification on edge devices.
