Federated learning method and related apparatus
By performing parameter aggregation and knowledge distillation training on models with different network structures in federated learning, the problem of model aggregation in heterogeneous model scenarios is solved and the prediction accuracy is improved.
Patent Information
- Application Number
- PCT/CN2024/075124
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-31
- Filing Date
- 2024-02-01
- Publication Date
- 2024-10-03
AI Technical Summary
Existing federated learning methods cannot achieve model aggregation in scenarios with heterogeneous models. Especially when models trained on different clients have different network structures, it is difficult to achieve effective aggregation of models, resulting in reduced prediction accuracy.
By dividing models with the same network structure into the same group on the aggregation node for parameter aggregation, and performing knowledge distillation training on each aggregation model, experience transfer and knowledge integration between models with different network structures are achieved, and the prediction of the model is improved. Accuracy.
It realizes the aggregation of different network structure models, ensures the prediction accuracy of the aggregated model, and solves the problem of model aggregation in heterogeneous model scenarios.
Smart Images

Figure CN2024075124_03102024_PF_FP_ABST
Abstract
Description
A federated learning method and related device
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on March 31, 2023, with application number 202310377345.8 and invention name “A Federated Learning Method and Related Devices”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of artificial intelligence (AI) technology, and in particular to a federated learning method and related devices. Background Art
[0003] As users increasingly prioritize protecting their personal privacy, data owners are unable to communicate with each other, creating data silos of varying sizes. These silos pose a new challenge to artificial intelligence (AI), which relies on massive amounts of data. Specifically, they face the challenge of training machine learning models without access to sufficient training data.
[0004] Federated learning has emerged to address the challenges posed by data silos. It effectively enables clients to jointly train and build shared machine learning models without sharing data resources (meaning training data doesn't leave the client's local machine). During the local training phase, each client trains a local model based on the training data. During the model aggregation phase, each client uploads the local model to the cloud server, which aggregates the local models to create a global model and distributes it. Clients then use the training data to update the global model to create a new local model. This process repeats until the global model converges.
[0005] Current federated learning methods require that each client train a model with the same structure, so that the central node can aggregate the models uploaded by multiple clients through parameter averaging. However, in some cases, the models trained on different clients may have different structures. Therefore, existing federated learning methods cannot be applied to scenarios with heterogeneous models, making it difficult to achieve model aggregation.
[0006] Summary of the Invention
[0007] This application provides a federated learning method that can aggregate models with different network structures and ensure the prediction accuracy of the models obtained after aggregation.
[0008] In a first aspect, the present application provides a federated learning method for use in the field of artificial intelligence technology. The method includes: an aggregation node obtains multiple models, where the multiple models are obtained from multiple nodes. Furthermore, the multiple models obtained by the aggregation node are used to perform the same processing task, for example, multiple models are used to perform image processing tasks or natural language processing tasks.
[0009] Then, according to the network structures of the multiple models, the aggregation node divides the multiple models into multiple groups, wherein each of the multiple groups includes at least one model, and the models in the same group have the same network structure;
[0010] Next, the aggregation node aggregates the parameters of the models within each of the multiple groups to obtain multiple aggregated models. Models within the same group are aggregated to form a single aggregated model, and multiple aggregated models correspond to multiple groups. Specifically, the network structure of each aggregated model is identical to the network structure of the models within its corresponding group, and the weight parameters within each aggregated model are obtained by weighted summing the weight parameters of one or more models within the same group.
[0011] After obtaining multiple aggregation models, the aggregation node uses the multiple models as teacher models and performs knowledge distillation training on each of the multiple aggregation models to obtain multiple trained models.
[0012] Finally, the aggregation node sends multiple trained models to multiple nodes.
[0013] In this scheme, when the aggregation node obtains models with different network structures, the models with the same network structure are divided into the same group, and the parameters of the models in the same group are aggregated to obtain multiple aggregation models with different network structures; and for each aggregation model, knowledge distillation training is performed on each aggregation model based on the original multiple models obtained to achieve experience transfer between models with different network structures, thereby integrating the knowledge and experience of models with various network structures and improving the prediction accuracy of the model.
[0014] By aggregating parameters of models with the same network structure and performing knowledge distillation on the aggregated models based on models with various network structures, we can combine the advantages of parameter aggregation and knowledge distillation in integrating model experience, achieve the aggregation of models with different network structures, and ensure the prediction accuracy of the models obtained after aggregation.
[0015] In one possible implementation, the process of performing knowledge distillation training on each of multiple aggregation models by the aggregation node may specifically include: the aggregation node inputs the training samples into the first aggregation model and multiple models respectively to obtain a target prediction result and multiple prediction results, wherein the first aggregation model is any one of the multiple aggregation models, the target prediction result corresponds to the first aggregation model, and the multiple prediction results correspond to the multiple models; the aggregation node trains the first aggregation model based on a loss function to obtain the trained first aggregation model, and the loss function is obtained based on the difference between the target prediction result and the multiple prediction results.
[0016] In this scheme, by constructing a distillation loss function based on the difference between the prediction results of the original multiple models and the prediction results of the aggregated model, it is possible to support the experience transfer between models with different network structures in a knowledge distillation-based manner, so that the aggregated model can further aggregate the knowledge and experience under various network structures and improve the prediction accuracy of the aggregated model.
[0017] In one possible implementation, the loss function used to train the first aggregation model is obtained based on the difference between the target prediction result and each of the multiple prediction results; or, the loss function is obtained based on the difference between the target prediction result and the weighted average of the multiple prediction results.
[0018] In one possible implementation, the loss function used to train the first aggregation model includes a first sub-loss function and a second sub-loss function, where the first sub-loss function is obtained based on the difference between the target prediction result and the multiple prediction results, and the second sub-loss function is obtained based on the difference between the true label of the training sample and the target prediction result.
[0019] In this scheme, a distillation loss function is constructed based on the difference between the prediction results of the original multiple models and the prediction results of the aggregated model, and a label loss function is constructed based on the true labels of the training samples. This can support the experience transfer between models of different network structures based on knowledge distillation under the constraints of the label loss function, so that the aggregated model can effectively aggregate the knowledge and experience under various network structures and improve the prediction accuracy of the aggregated model.
[0020] In one possible implementation, the method further includes: based on the training data, the aggregation node determines a target model from multiple trained models; using the multiple trained models as teacher models, the aggregation node performs knowledge distillation training on the target model to obtain an updated target model, and the updated target model is used to perform reasoning tasks based on local data.
[0021] In this solution, after the aggregation node obtains the target model based on the local training data screening, it performs knowledge distillation training on the target model using the original received model as the teacher model. This can ensure that the target model does not forget the original experience on the basis of considering the personalized fine-tuning performed on the local data of the first node, and effectively avoid the drastic fluctuations in the prediction accuracy of the target model due to the poor quality of the local data of the first node (that is, avoid the phenomenon of overfitting of the target model).
[0022] In one possible implementation, the aggregation node determines a target model from a plurality of trained models based on the training data, specifically including: the aggregation node inputs the training data into each of the plurality of models respectively, and determines the prediction accuracy of each model based on the prediction result output by each model; the aggregation node determines the target model based on the prediction accuracy of each model, and the target model includes one or more models with the highest prediction accuracy from the plurality of trained models.
[0023] In this solution, the prediction accuracy of each model is determined based on the local data of the node, and the degree of adaptation of each model to the local data is measured, ensuring that the node can select the target model with the best performance when processing the local data of the node from multiple models.
[0024] In one possible implementation, an aggregation node determines a target model from multiple trained models based on training data. Specifically, the aggregation node inputs the training data into a gating network to obtain multiple weight values output by the gating network. The multiple weight values correspond one-to-one with the multiple trained models, and the multiple weight values are used to represent the weights of the output results of the multiple trained models in the weighted summation process. The gating network is a pre-trained network. In other words, the multiple trained models cooperate with the gating network to process the training data. The gating network is used to output a weight value corresponding to each of the multiple trained models based on the training data. After each trained model outputs an output result corresponding to the training data, the multiple output results are weightedly summed according to the weight value corresponding to each trained model to obtain the final output result.
[0025] The aggregation node determines a target model based on multiple weight values. The target model includes one or more models with the highest corresponding weight values among the multiple trained models. In other words, the first node can use the weight value corresponding to each trained model to measure the degree of adaptation of each trained model to the local data of the first node, and then select the one or more models with the highest degree of adaptation (i.e., the target model) from the multiple trained models.
[0026] In this solution, the gate network is trained to output the weight value corresponding to each model, thereby measuring the degree of adaptation of each model to the local data and ensuring that the node can select the target model with the best performance when processing the node's local data from multiple models.
[0027] In one possible implementation, the aggregation node sends multiple trained models to multiple nodes, specifically including: the aggregation node determines a partially trained model from multiple trained models based on target data, where the target data is data obtained from the first node, and the partially trained model is a model with the best performance among the multiple trained models when processing the target data; the aggregation node sends the partially trained model to the first node.
[0028] In one possible implementation, parameters of models in each of multiple groups are aggregated to obtain multiple aggregate models, including: weighted summing of weight parameters of multiple models in a first group to obtain a first aggregate model; wherein the first group belongs to multiple groups, and the first aggregate model belongs to multiple aggregate models.
[0029] A second aspect of the present application provides a federated learning method, comprising:
[0030] Receive multiple models from the aggregation node, the network structures of the multiple models are different, and the multiple models are obtained by the aggregation node aggregating models on different nodes;
[0031] Based on the training data, determine the target model among multiple models;
[0032] Using multiple models as teacher models, knowledge distillation training is performed on the target model to obtain the trained target model.
[0033] In one possible implementation, a target model is determined from multiple models based on training data, including:
[0034] Inputting the training data into each of the multiple models, and determining the prediction accuracy of each model based on the prediction results output by each model;
[0035] The target model is determined based on the prediction accuracy of each model. The target model is one or more models with the highest prediction accuracy among the multiple models.
[0036] In one possible implementation, a target model is determined from multiple models based on training data, including:
[0037] Inputting training data into the gating network to obtain multiple weight values output by the gating network, wherein the multiple weight values correspond one-to-one to the multiple trained models, and the multiple weight values are respectively used to represent the weights of the output results of the multiple trained models in the weighted summation process, and the gating network is a pre-trained network;
[0038] A target model is determined according to multiple weight values, where the target model includes one or more models with the highest corresponding weight values among the multiple models.
[0039] In one possible implementation, multiple models are obtained by an aggregation node aggregating parameters of models with the same network structure after receiving models on different nodes and performing knowledge distillation training on the aggregated models based on the models on different nodes.
[0040] A third aspect of the present application provides a federated learning device, comprising:
[0041] The acquisition module is used to obtain multiple models, which are obtained from multiple nodes;
[0042] The processing module is further configured to divide the multiple models into multiple groups according to the network structures of the multiple models, wherein each of the multiple groups includes at least one model, and the models in the same group have the same network structure;
[0043] The processing module is further configured to aggregate parameters of the models in each of the plurality of groups to obtain a plurality of aggregate models, wherein the models in the same group are aggregated to obtain one aggregate model, and the plurality of aggregate models correspond to the plurality of groups;
[0044] The processing module is further configured to use the multiple models as teacher models and perform knowledge distillation training on each of the multiple aggregate models to obtain multiple trained models;
[0045] The sending module is used to send multiple trained models to multiple nodes.
[0046] In a possible implementation, the processing module is further configured to:
[0047] Inputting the training samples into the first aggregation model and the multiple models respectively to obtain a target prediction result and multiple prediction results, wherein the first aggregation model is any one of the multiple aggregation models, the target prediction result corresponds to the first aggregation model, and the multiple prediction results correspond to the multiple models;
[0048] The first aggregation model is trained based on a loss function to obtain a trained first aggregation model, where the loss function is obtained based on a difference between a target prediction result and the plurality of prediction results.
[0049] In one possible implementation, the loss function is based on the difference between the target prediction result and each of the multiple prediction results;
[0050] Alternatively, the loss function is based on the difference between the target prediction and a weighted average of multiple predictions.
[0051] In one possible implementation, the loss function includes a first sub-loss function and a second sub-loss function, where the first sub-loss function is obtained based on the difference between the target prediction result and multiple prediction results, and the second sub-loss function is obtained based on the difference between the true label of the training sample and the target prediction result.
[0052] In a possible implementation, the processing module is further configured to:
[0053] Based on the training data, a target model is determined among multiple trained models;
[0054] Using multiple trained models as teacher models, knowledge distillation training is performed on the target model to obtain an updated target model. The updated target model is used to perform reasoning tasks based on local data.
[0055] In a possible implementation, the processing module is further configured to:
[0056] Inputting the training data into each of the multiple models, and determining the prediction accuracy of each model based on the prediction results output by each model;
[0057] A target model is determined based on the prediction accuracy of each model, where the target model includes one or more models with the highest prediction accuracy among the multiple trained models.
[0058] In a possible implementation, the processing module is further configured to:
[0059] Inputting training data into the gating network to obtain multiple weight values output by the gating network, wherein the multiple weight values correspond one-to-one to the multiple trained models, and the multiple weight values are respectively used to represent the weights of the output results of the multiple trained models in the weighted summation process, and the gating network is a pre-trained network;
[0060] A target model is determined based on multiple weight values, where the target model includes one or more models with the highest corresponding weight values among the multiple trained models.
[0061] In one possible implementation,
[0062] The processing module is further configured to determine, based on target data, a partially trained model from a plurality of trained models, where the target data is the data obtained from the first node, and the partially trained model is a model having the best performance among the plurality of trained models when processing the target data;
[0063] The sending module is also used to send the partially trained model to the first node.
[0064] In a possible implementation, the processing module is further configured to perform weighted summation on weight parameters of multiple models in the first group to obtain a first aggregate model;
[0065] The first group belongs to the multiple groups, and the first aggregation model belongs to the multiple aggregation models.
[0066] A fourth aspect of the present application provides a federated learning device, comprising:
[0067] A receiving module is used to receive multiple models from an aggregation node. The multiple models have different network structures and are obtained by the aggregation node aggregating models on different nodes.
[0068] A processing module, configured to determine a target model among multiple models based on training data;
[0069] The processing module is also used to perform knowledge distillation training on the target model using multiple models as teacher models to obtain a trained target model.
[0070] In a possible implementation, the processing module is further configured to:
[0071] Inputting the training data into each of the multiple models respectively, and determining the prediction accuracy of each model based on the prediction results output by each model;
[0072] The target model is determined based on the prediction accuracy of each model, and the target model is one or more models with the highest prediction accuracy among the multiple models.
[0073] In a possible implementation, the processing module is further configured to:
[0074] Inputting the training data into a gating network to obtain a plurality of weight values output by the gating network, wherein the plurality of weight values correspond one-to-one to the plurality of trained models, and the plurality of weight values are respectively used to represent weights of output results of the plurality of trained models in a weighted summation process, wherein the gating network is a pre-trained network;
[0075] The target model is determined according to the multiple weight values, and the target model includes one or more models with the highest corresponding weight values among the multiple models.
[0076] In one possible implementation, the multiple models are obtained by the aggregation node aggregating parameters of models with the same network structure after receiving models on different nodes and performing knowledge distillation training on the aggregated models based on the models on the different nodes.
[0077] In a fifth aspect, the present application provides a federated learning device, which may include a processor coupled to a memory, wherein the memory stores program instructions. When the program instructions stored in the memory are executed by the processor, the method of any implementation of the first or second aspects described above is implemented. For details regarding the processor executing the steps in each possible implementation of the first or second aspects, please refer to the first or second aspects and will not be repeated here.
[0078] In a sixth aspect, the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer-readable storage medium is run on a computer, the computer executes the method of any implementation of the first or second aspect.
[0079] In a seventh aspect, the present application provides a circuit system, which includes a processing circuit, and the processing circuit is configured to execute a method implemented in any one of the first or second aspects.
[0080] In an eighth aspect, the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the method implemented in any one of the first or second aspects.
[0081] In a ninth aspect of the present application, a chip system is provided, which includes a processor for supporting a server or a threshold value acquisition device to implement the functions involved in any of the implementations of the first or second aspects above, for example, sending or processing the data and / or information involved in the above method. In one possible design, the chip system also includes a memory for storing program instructions and data necessary for the server or communication device. The chip system can be composed of a chip, or it can include a chip and other discrete devices.
[0082] The beneficial effects of the second to ninth aspects mentioned above can be referred to the introduction of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] FIG1 is a schematic diagram of a federated learning scenario provided in an embodiment of the present application;
[0084] FIG2 is a schematic diagram of an execution process of federated learning in related art;
[0085] FIG3 is a schematic diagram of the structure of a convolutional neural network provided in an embodiment of the present application;
[0086] FIG4 is a schematic diagram of the structure of another convolutional neural network provided in an embodiment of the present application;
[0087] FIG5 is a schematic diagram of a system architecture 500 provided in an embodiment of the present application;
[0088] FIG6 is a schematic diagram of a system architecture 600 provided in an embodiment of the present application;
[0089] FIG7 is a flow chart of a federated learning method provided in an embodiment of the present application;
[0090] FIG8 is a schematic diagram of an aggregation node receiving multiple models provided by an embodiment of the present application;
[0091] FIG9 is a schematic diagram of grouping multiple models and aggregating parameters according to an embodiment of the present application;
[0092] FIG10 is a schematic diagram of performing knowledge distillation on multiple aggregation models according to an embodiment of the present application;
[0093] FIG11 is a schematic diagram of an aggregation node sending a trained model to each node according to an embodiment of the present application;
[0094] FIG12A is a schematic diagram of a screening target model provided in an embodiment of the present application;
[0095] FIG12B is a schematic diagram of a screening target model provided in an embodiment of the present application;
[0096] FIG13 is a schematic diagram of another screening target model provided in an embodiment of the present application;
[0097] FIG14 is a flow chart of another federated learning method provided in an embodiment of the present application;
[0098] FIG15 is a schematic diagram of the structure of a federated learning device provided in an embodiment of the present application;
[0099] FIG16 is a schematic diagram of the structure of a federated learning device provided in an embodiment of the present application;
[0100] FIG17 is a schematic diagram of a structure of an execution device provided in an embodiment of the present application;
[0101] FIG18 is a schematic structural diagram of a chip provided in an embodiment of the present application;
[0102] FIG19 is a schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION
[0103] In order to make the purpose, technical solutions and advantages of this application more clear, the embodiments of this application are described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only embodiments of a part of this application, rather than all embodiments. It is known to those skilled in the art that with the emergence of new application scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0104] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the descriptions used in this way can be interchangeable where appropriate so that the embodiments can be implemented in a sequence other than that illustrated or described in this application. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules clearly listed, but may include other steps or modules that are not clearly listed or that are inherent to these processes, methods, products or devices. The naming or numbering of steps in this application does not mean that the steps in the method flow must be executed in the time / logical sequence indicated by the naming or numbering. The named or numbered process steps can change the execution order according to the technical purpose to be achieved, as long as the same or similar technical effects can be achieved. The division of units in this application is a logical division. In actual application, there may be other division methods. For example, multiple units can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, and the indirect coupling or communication connection between units can be electrical or other similar forms, which are not limited in this application. Moreover, the units or sub-units described as separate components may or may not be physically separated, may or may not be physical units, or may be distributed into multiple circuit units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this application.
[0105] To facilitate understanding, some technical terms involved in the embodiments of this application are first introduced below.
[0106] (1) Federated Learning
[0107] Federated learning is essentially a model training method that enables data sharing and collaborative model building while ensuring data privacy, security, and legal compliance. The core concept of federated learning is that when multiple data sources participate in model training, joint model training occurs only through the exchange of intermediate model parameters, without the need for raw data transfer. This approach achieves a balance between data privacy protection and data sharing and analysis, creating a data application model where "data is available but not visible."
[0108] For example, please refer to Figure 1, which is a schematic diagram of a federated learning scenario provided in an embodiment of the present application. The federated learning scenario may include multiple client nodes and a central node, wherein the multiple client nodes and the central node may be any node that supports data transmission (such as a network node). For example, the client node may be a mobile terminal or a personal computer. The central node may be a server, or a cluster server. In some embodiments, the client node may be referred to as the owner of the training data, and the central node may also be referred to as the coordinator of the federated learning process.
[0109] The central node maintains the federated model. Client nodes can obtain the federated model from the central node and perform local training on it using local training data to generate a local model. After training the local model, the client node can send it to the central node, which then updates or optimizes the federated model. This process repeats over multiple rounds until the federated model converges or a pre-defined stopping condition is met.
[0110] The general process of federated learning will be described below with reference to Figure 2. As shown in Figure 2, the execution process of federated learning includes the following steps 201-205.
[0111] Step 201: The central node builds a federation model.
[0112] The central node can build a general machine learning model or a specific one based on demand. For example, for image recognition tasks, the central node can build a convolutional neural network (CNN) as the federated model.
[0113] In step 202 , a plurality of client nodes obtain or receive a federated model from a central node.
[0114] Multiple client nodes can obtain or receive the same federated model from a central node. For example, in one implementation, a client node can proactively request the central node to send the federated model. Alternatively, in another implementation, the central node proactively sends the federated model to the client node. For example, if the client node is a personal computer and the central node is a server, the personal computer can download the federated model from the server.
[0115] In step 203 , the plurality of client nodes train the federated model using the local training data to obtain a local model.
[0116] Specifically, multiple client nodes can use the federated model as the initial model of the local model, and then use local training data to train the initial model in one or more steps to obtain the local model.
[0117] Since different client nodes have different local training data, different client nodes can train different local models based on the same federated model.
[0118] In step 204, multiple client nodes upload the trained local models to the central node.
[0119] In step 205 , the central node aggregates multiple local models to obtain an updated federated model.
[0120] For example, in one implementation, the central node may perform a weighted summation on the parameters of the local models of multiple client nodes, and use the result of the weighted summation as the updated federated model.
[0121] It should be noted that the process described in steps 201-205 can be considered as an iteration in the federated learning process. The central node and the client node can repeatedly execute steps 201-205 until the federated model converges or achieves the preset effect.
[0122] Generally speaking, federated learning can be used to train machine learning models. The most common machine learning model is a neural network. The following section explains the concepts behind neural networks.
[0123] (2) Neural Network
[0124] A neural network can be composed of neural units. A neural unit can refer to an operation unit that takes xs (i.e., input data) and intercept 1 as input. The output of the operation unit can be:
[0125] Where s = 1, 2, ... n, n is a natural number greater than 1, Ws is the weight of xs, and b is the bias of the neural unit. f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal of the neural unit into the output signal. The output signal of the activation function can be used as the input of the next convolutional layer, and the activation function can be a sigmoid function. A neural network is a network formed by connecting multiple single neural units mentioned above, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field. The local receptive field can be an area composed of several neural units.
[0126] (3) Deep Neural Networks
[0127] Deep Neural Network (DNN), also known as multi-layer neural network, can be understood as a neural network with many hidden layers. There is no special metric for "many" here. Based on the position of different layers in DNN, the neural network inside DNN can be divided into three categories: input layer, hidden layer, and output layer. Generally speaking, the first layer is the input layer, the last layer is the output layer, and the layers in between are all hidden layers. The layers are fully connected, that is, any neuron in the i-th layer must be connected to any neuron in the i+1-th layer. Although DNN looks complicated, the work of each layer is actually not complicated. Simply put, it is the following linear relationship expression: in, is the input vector, is the output vector, is the offset vector, W is the weight matrix (also called coefficient), and α() is the activation function. Each layer is just an input vector After such a simple operation, the output vector
[0128] Since there are many DNN layers, the coefficient W and the offset vector The definition of these parameters in DNN is as follows: Take the coefficient W as an example: Assume that in a three-layer DNN, the linear coefficient from the 4th neuron in the second layer to the 2nd neuron in the third layer is defined as The superscript 3 represents the layer number of the coefficient W, while the subscript corresponds to the output of the third layer index 2 and the input of the second layer index 4. In summary, the coefficient from the kth neuron in the L-1th layer to the jth neuron in the Lth layer is defined as It's important to note that the input layer has no W parameter. In deep neural networks, more hidden layers allow the network to better capture complex real-world situations. Theoretically, a model with more parameters has higher complexity and greater "capacity," meaning it can handle more complex learning tasks. Training a deep neural network is essentially the process of learning the weight matrix, with the ultimate goal of obtaining the weight matrices for all layers of a trained deep neural network (a weight matrix formed by the vectors W across many layers).
[0129] (4) Convolutional Neural Network (CNN)
[0130] A convolutional neural network is a deep neural network with a convolutional architecture. It includes a feature extractor consisting of a convolutional layer and a subsampling layer. This feature extractor can be viewed as a filter, and the convolution process can be thought of as convolving an input image or feature map with a trainable filter. A convolutional layer refers to the layer of neurons in a convolutional neural network that performs convolution processing on the input signal (e.g., the first and second convolutional layers in this embodiment). Within a convolutional layer of a convolutional neural network, a neuron may only be connected to some of the neurons in adjacent layers. A convolutional layer typically contains several feature planes, each of which can be composed of a number of rectangularly arranged neural units. Neural units in the same feature plane share weights, which are referred to as the convolution kernel. Shared weights can be understood as the way image information is extracted, regardless of position. The underlying principle is that the statistical information of one part of an image is the same as that of another part. This means that image information learned in one part can also be applied to another part. Therefore, the same learning can be used to obtain image information at all positions in the image. In the same convolutional layer, multiple convolution kernels can be used to extract different image information. Generally speaking, the more convolution kernels there are, the richer the image information reflected by the convolution operation.
[0131] Convolution kernels can be initialized as matrices of random size, and during the training process of the convolutional neural network, the convolution kernels can be learned to obtain reasonable weights. In addition, the direct benefit of shared weights is that they reduce the number of connections between the layers of the convolutional neural network, while also reducing the risk of overfitting.
[0132] Specifically, as shown in FIG3 , a convolutional neural network (CNN) 100 may include an input layer 110 , a convolutional layer / pooling layer 120 , wherein the pooling layer is optional, and a neural network layer 130 .
[0133] Among them, the structure composed of the convolution layer / pooling layer 120 and the neural network layer 130 can be the first convolution layer and the second convolution layer described in this application, the input layer 110 is connected to the convolution layer / pooling layer 120, the convolution layer / pooling layer 120 is connected to the neural network layer 130, the output of the neural network layer 130 can be input to the activation layer, and the activation layer can perform nonlinear processing on the output of the neural network layer 130.
[0134] Convolutional layer / pooling layer 120. Convolutional layer: As shown in FIG3 , convolutional layer / pooling layer 120 may include layers 121-126, for example. In one implementation, layer 121 is a convolutional layer, layer 122 is a pooling layer, layer 123 is a convolutional layer, layer 124 is a pooling layer, layer 125 is a convolutional layer, and layer 126 is a pooling layer. In another implementation, layers 121 and 122 are convolutional layers, layer 123 is a pooling layer, layers 124 and 125 are convolutional layers, and layer 126 is a pooling layer. That is, the output of a convolutional layer can serve as the input to a subsequent pooling layer, or as the input to another convolutional layer to continue the convolution operation.
[0135] Taking convolution layer 121 as an example, convolution layer 121 can include multiple convolution operators, also known as kernels. In image processing, a convolution operator acts as a filter that extracts specific information from the input image matrix. A convolution operator is essentially a weight matrix, which is typically predefined. During the convolution operation, the weight matrix is typically applied horizontally to the input image, pixel by pixel (or two pixels by two pixels, depending on the stride), to extract specific features from the image. The size of the weight matrix should be related to the image size. It is important to note that the depth dimension of the weight matrix is the same as the depth dimension of the input image. During the convolution operation, the weight matrix extends to the entire depth of the input image. Therefore, convolution with a single weight matrix produces a convolution output with a single depth dimension. However, in most cases, a single weight matrix is not used, and multiple weight matrices of the same dimension are applied. The outputs of each weight matrix are stacked to form the depth dimension of the convolved image. Different weight matrices can be used to extract different features in the image. For example, one weight matrix is used to extract image edge information, another weight matrix is used to extract specific colors of the image, and another weight matrix is used to blur unwanted noise in the image... The multiple weight matrices have the same dimensions, and the feature maps extracted by the multiple weight matrices with the same dimensions also have the same dimensions. The multiple feature maps with the same dimensions extracted are then merged to form the output of the convolution operation.
[0136] The weight values in these weight matrices need to be obtained through a lot of training in practical applications. The weight matrices formed by the weight values obtained through training can extract information from the input image, thereby helping the convolutional neural network 100 to make correct predictions.
[0137] When the convolutional neural network 100 has multiple convolutional layers, the initial convolutional layer (for example, 121) often extracts more general features, which can also be called low-level features. As the depth of the convolutional neural network 100 increases, the features extracted by the later convolutional layers (for example, 126) become more and more complex, such as high-level semantic features. Features with higher semantics are more suitable for the problem to be solved.
[0138] Pooling layer: Since it is often necessary to reduce the number of training parameters, it is often necessary to periodically introduce a pooling layer after the convolution layer, that is, as shown in the example 120 in Figure 3, each layer 121-126 can be a convolution layer followed by a pooling layer, or multiple convolution layers can be followed by one or more pooling layers.
[0139] Neural network layer 130: After being processed by the convolution layer / pooling layer 120, the convolution neural network 100 is not sufficient to output the required output information. Because as before, the convolution layer / pooling layer 120 only extracts features and reduces the parameters brought by the input image. However, in order to generate the final output information (the required class information or other relevant information), the convolution neural network 100 needs to use the neural network layer 130 to generate one or a group of outputs of the required number of classes. Therefore, the neural network layer 130 may include multiple hidden layers (131, 132 to 13n as shown in Figure 3) and an output layer 140. The parameters contained in the multiple hidden layers can be pre-trained based on relevant training data of a specific task type. For example, the task type may include image recognition, image classification, image super-resolution reconstruction, etc.
[0140] After the multiple hidden layers in the neural network layer 130, that is, the last layer of the entire convolutional neural network 100 is the output layer 140. The output layer 140 has a loss function similar to the classification cross entropy, which is specifically used to calculate the prediction error. Once the forward propagation of the entire convolutional neural network 100 (as shown in Figure 4, the propagation from 110 to 140 is forward propagation) is completed, the back propagation (as shown in Figure 4, the propagation from 140 to 110 is back propagation) will begin to update the weight values and biases of the aforementioned layers to reduce the loss of the convolutional neural network 100 and the error between the result output by the convolutional neural network 100 through the output layer and the ideal result.
[0141] It should be noted that the convolutional neural network 100 shown in Figure 3 is only an example of a convolutional neural network. In specific applications, the convolutional neural network can also exist in the form of other network models. For example, as shown in Figure 4, multiple convolutional layers / pooling layers are run in parallel, and the extracted features are input into the full neural network layer 130 for processing.
[0142] (5) Loss function
[0143] During neural network training, because we want the output of the neural network to be as close as possible to the desired predicted value, we can compare the current network's predicted value with the desired target value and then update the weight vectors of each layer of the neural network based on the difference between the two. (Of course, before the first update, there is usually an initialization process, which pre-configures the parameters of each layer in the neural network.) For example, if the network's prediction is too high, the weight vector is adjusted to make it predict a lower value. This adjustment is continued until the neural network can predict the desired target value or a value very close to the desired target value. Therefore, it is necessary to predefine "how to compare the difference between the predicted value and the target value." This is the loss function (or objective function), which is an important equation used to measure the difference between the predicted value and the target value. For example, the loss function output value (loss) indicates a greater difference, so neural network training becomes a process of minimizing this loss.
[0144] (6) Backpropagation algorithm
[0145] Neural networks can use the back propagation (BP) algorithm to correct the initial model parameters during training, reducing the model's error loss. Specifically, forward propagation of the input signal to the output generates error loss. This error loss information is then backpropagated to update the initial model parameters, thereby converging the error loss. The BP algorithm is a backpropagation process driven by error loss, aiming to optimize model parameters, such as the weight matrix.
[0146] (7) Non-IID (non-independent and identically distributed)
[0147] In probability theory and statistics, independent and identically distributed (IID) refers to a set of random variables whose probability distribution is identical and whose random variables are independent of each other. The fact that a set of random variables is independent and identically distributed does not mean that every event in their sample space has the same probability of occurring. For example, the sequence of outcomes from rolling uneven dice is independent and identically distributed, but the probability of each face landing on the same side is not the same.
[0148] So, Non-IID means that the variables are not independent, or not identically distributed. In federated learning, Non-IID generally refers to situations where the data do not conform to the same distribution. This is because the data distributions are certainly independent, but they do not necessarily follow the same sampling method. For example, if there are 100 categories of images in the entire data set, and one device only has landscape images, while another device only has people and plants images, the former has one distribution (1 / 100), while the latter has another distribution (2 / 100). Conversely, if the same 100 categories of images are present on one device and also on other devices, then they are identically distributed.
[0149] (8) Modality
[0150] From a data perspective, modality refers to data types such as images or text, and data of different modalities refers to different types of data.
[0151] From the perspective of the model, modality refers to the type of model, and models of different modalities are different models trained based on a variety of different data.
[0152] (9) Knowledge Transfer
[0153] Knowledge transfer refers to improving modeling capabilities in a target domain by transferring existing knowledge to another domain. Model-based knowledge transfer can be simply understood as transfer learning based on model parameters, which aims to enable the constructed model to learn common knowledge between domains.
[0154] (10) Knowledge Distillation
[0155] Knowledge distillation is a method used in transfer learning. It uses the output of a pre-trained model as a supervisory signal to train another network. Simply put, knowledge distillation uses a pre-trained network as the teacher network and the network to be trained as the student network. Under the guidance of the teacher network, the student network is trained to achieve the same or similar data processing capabilities as the teacher network. Typically, the teacher network can be a complex model, while the student network can be a simpler one. Through knowledge distillation, the feature representation knowledge learned by the complex network can be transferred to the simpler model.
[0156] (11) Experience Transfer
[0157] Experience transfer can refer to a node recording its data pattern information in the form of a model or data, and passing it to another node for training the model, thereby realizing the mutual transfer of experience between nodes.
[0158] Current federated learning methods require that the models trained on each client be of the same structure, so that the central node can aggregate the models uploaded by multiple clients through parameter averaging. However, in some cases, the local data held by different clients may often be of different modalities, meaning that the data on different clients is not independent and identically distributed. Therefore, to maximize the adaptability of the local data, the models trained on different clients may have different structures. As a result, existing federated learning methods cannot be applied to scenarios with heterogeneous models, making it difficult to achieve model aggregation.
[0159] In view of this, the present application provides a federated learning method. When the aggregation node obtains models of different network structures, the models of the same network structure are divided into the same group, and the parameters of the models of the same group are aggregated to obtain multiple aggregation models with different network structures; and, for each aggregation model, knowledge distillation training is performed on each aggregation model based on the original multiple models obtained to realize the experience transfer between models of different network structures, thereby integrating the knowledge and experience of models of various network structures and improving the prediction accuracy of the model.
[0160] In this way, by aggregating parameters of models with the same network structure and performing knowledge distillation on the aggregated models based on models with various network structures, the advantages of parameter aggregation and knowledge distillation in integrating model experience can be combined to achieve the aggregation of models with different network structures and ensure the prediction accuracy of the models obtained after aggregation.
[0161] For ease of understanding, the following first introduces the system architecture used by the federated learning method provided in the embodiment of the present application.
[0162] Please refer to Figure 5, which is a schematic diagram of a system architecture 500 provided in an embodiment of the present application. As shown in Figure 5, in this system architecture 500, an aggregation node 501 is implemented by one or more servers. Optionally, the aggregation node 501 can be coordinated with other computing devices, such as data storage, routers, and load balancers. The aggregation node 501 can be deployed at a single physical site or distributed across multiple physical sites.
[0163] Users can operate their respective user devices (e.g., client node 511, client node 512, ..., client node 51n) to interact with the aggregation node 501. Each client node can represent any computing device, such as a personal computer, server, computer workstation, smartphone, tablet computer, smart camera, smart car or other type of cellular phone, media consumption device, wearable device, set-top box, game console, etc.
[0164] Each client node may interact with the aggregation node 501 via a communication network with any communication mechanism / communication standard. The communication network may be a wide area network, a local area network, a point-to-point connection, or any combination thereof.
[0165] In the specific implementation process, the aggregation node 501 acts as a central node, responsible for receiving models uploaded by each client node. The network structure of the models uploaded by different client nodes may be different. Therefore, the aggregation node 501 aggregates the models based on the federated learning method provided in this embodiment and then returns the aggregated model to each client node.
[0166] Specifically, the system architecture introduced in Figure 5 is a centralized system architecture, in which a unified central node is responsible for aggregating the models on each client node.
[0167] Please refer to Figure 6, which is a schematic diagram of a system architecture 600 provided in an embodiment of the present application. As shown in Figure 6, system architecture 600 includes distributed nodes 601 to 608. Each node in system architecture 600 can represent any computing device, such as a server, a personal computer, a computer workstation, a smartphone, a tablet computer, a smart camera, a smart car or other type of cellular phone, a media consumption device, a wearable device, a set-top box, a game console, etc.
[0168] Nodes 601 and 602 may be nodes with stronger computing capabilities (e.g., servers), meaning that the computing capabilities of nodes 601 and 602 may be stronger than those of nodes 603-608. Therefore, in system architecture 600, nodes with relatively weaker computing capabilities can send models to nearby nodes with stronger computing capabilities, allowing these nodes with stronger computing capabilities to receive models sent by multiple nearby nodes. Furthermore, the network structures of the models sent by different nodes may be different. For example, nodes 603-606 send models to nearby node 601; nodes 605-608 send models to nearby node 602.
[0169] In this way, after receiving multiple models, the node with stronger computing power can aggregate the models based on the federated learning method provided in this embodiment, and then return the aggregated model to each node with weaker computing power.
[0170] Specifically, the system architecture described in FIG6 is a decentralized distributed system architecture, in which some nodes in the system architecture can receive models sent by other nodes, thereby achieving model aggregation. The nodes responsible for model aggregation can be determined based on various methods, such as determining nodes with strong computing power to be responsible for model aggregation, or determining nodes that are close to multiple nodes to be responsible for model aggregation. This embodiment does not limit the nodes responsible for model aggregation in the distributed system architecture.
[0171] The above describes the method used in the method provided in the embodiment of the present application. The following details the execution process of the method provided in the embodiment of the present application. Please refer to Figure 7, which is a flowchart of a federated learning method provided in the embodiment of the present application. As shown in Figure 7, the federated learning method includes the following steps 701-708.
[0172] In step 701, the aggregation node obtains multiple models, and the multiple models are obtained from multiple nodes.
[0173] In this embodiment, the aggregation node may obtain multiple models from multiple nodes to aggregate the models deployed on the multiple nodes. Each of the multiple nodes may send one or more models to the aggregation node so that the aggregation node can obtain the aforementioned multiple models.
[0174] The model obtained by the aggregation node may be a model obtained by other nodes after training based on local data, and the aggregation node further aggregates these models.
[0175] Optionally, the aggregation node can be a central node in a centralized system architecture, solely responsible for aggregating models acquired from other nodes. Alternatively, the aggregation node can be a node in a distributed system architecture, responsible for aggregating models acquired from other nodes, and the aggregation node can also have models deployed on it for processing local data on the aggregation node. Therefore, when the aggregation node is a node in a distributed system architecture, the multiple models acquired by the aggregation node may also include models deployed on the aggregation node, i.e., models local to the aggregation node.
[0176] For example, as shown in Figure 7, when the aggregation node is a central node in a centralized system architecture, the aggregation node can obtain the above-mentioned multiple models from the first node to the Nth node; when the aggregation node is a central node in a distributed system architecture, the aggregation node can obtain the above-mentioned multiple models from the aggregation node itself and the first node to the Nth node.
[0177] It should be noted that the multiple models acquired by the aggregation node are used to perform the same processing task, for example, multiple models are used to perform image processing tasks or natural language processing tasks. Among them, image processing tasks may include image classification tasks, image recognition tasks, and image enhancement tasks. Natural language processing tasks may include text recognition tasks, text generation tasks, speech recognition tasks, text translation tasks, and other tasks.
[0178] The same network structure of two models may mean that the neural network layers included in the two models are the same, and the connection relationships between the neural network layers in the models are also the same. However, the weight parameters of the neural network layers included in the models with the same network structure may be different. For example, taking multiple models for performing image classification tasks as an example, the multiple models can all be convolutional neural network structures, and some models have the same convolutional neural network structure, while some models have different convolutional neural network structures.
[0179] In step 702 , the aggregation node divides the multiple models into multiple groups according to the network structures of the multiple models, wherein each of the multiple groups includes at least one model, and the models in the same group have the same network structure.
[0180] Since the aggregator receives multiple models from multiple different nodes, and the network structures of the models sent to the aggregator by different nodes may be the same or different, the multiple models received by the aggregator may correspond to multiple network structures. In other words, different models may have different network structures.
[0181] For example, please refer to Figure 8, which is a schematic diagram of an aggregation node receiving multiple models provided in an embodiment of the present application. As shown in Figure 8, the aggregation node receives models from nodes 1 to n, where node 1 sends model 2 to the aggregation node, node 2 sends model 3 to the aggregation node, and node n sends model n to the aggregation node. Model 1 sent by node 1 and model 3 sent by node 3 have the same network structure, model 2 sent by node 2 and model n sent by node n have the same network structure, and model 1 and model 2 have different network structures.
[0182] In this embodiment, the aggregation node can be used to divide the multiple models into multiple groups based on the network structure of each model. During the grouping process, models with the same network structure are divided into the same group, and models with different network structures are divided into different groups. Therefore, each of the multiple groups includes at least one model, and the models in the same group have the same network structure.
[0183] For example, please refer to Figure 9, which is a schematic diagram of grouping and parameter aggregation of multiple models provided in an embodiment of the present application. As shown in Figure 9, Model 1-Model n acquired by the aggregation node corresponds to M types of network structures, so the aggregation node can be divided into M groups (i.e., Group 1-Group M) based on the network structure of Model 1-Model n. Among them, Model 1 and Model 3 with the same network structure are divided into Group 1, and Model 2 and Model n with the same network structure are divided into Group 2. Of course, Group 1 may also include other models with the same network structure as Model 1 and Model 3; Group 2 may also include other models with the same network structure as Model 2 and Model n, and this embodiment does not make specific limitations on this.
[0184] In step 703 , the aggregation node aggregates parameters of the models in each of the multiple groups to obtain multiple aggregate models, wherein the models in the same group are aggregated to obtain one aggregate model, and the multiple aggregate models correspond to the multiple groups.
[0185] In this embodiment, since models within the same group have the same network structure, they often include the same number of weight parameters. Therefore, the aggregation node can aggregate the parameters of multiple models within the same group to obtain an aggregate model. In this way, the aggregation node aggregates the parameters of the models within each of the multiple groups to obtain multiple aggregate models, each of which corresponds to a group. In other words, the multiple aggregate models correspond one-to-one to the multiple groups. Furthermore, the network structure of each aggregate model is identical to the network structure of the models within its corresponding group.
[0186] Taking the first group among multiple groups as an example, the process of parameter aggregation of the models in the first group can specifically include: performing weighted summation on the weight parameters of the multiple models in the first group to obtain a first aggregate model; wherein the first group belongs to multiple groups, and the first aggregate model belongs to multiple aggregate models. Since the multiple models in the first group have the same network structure, the network structure positions with weight parameters in the multiple models are also the same, and the network structure positions with weight parameters in the first aggregate model obtained by aggregating the multiple models are also the same. Therefore, the weight parameter value at any network structure position in the first aggregate model can be obtained by weighted summation of the weight parameters of multiple models at that network structure position.
[0187] For example, assuming that the network structure positions with weight parameters on multiple models in the first group include positions 1 to M, since the first aggregate model and the multiple models in the first group have the same network structure, the network structure positions with weight parameters on the first aggregate model also include positions 1 to M. Furthermore, the weight parameter at position 1 of the first aggregate model is obtained by taking the weighted sum of the weight parameters at positions 1 of the multiple models; the weight parameter at position 2 of the first aggregate model is obtained by taking the weighted sum of the weight parameters at positions 2 of the multiple models; and so on, the weight parameter at each position in the first aggregate model is obtained by taking the weighted sum of the weight parameters at the same position of the multiple models.
[0188] In general, the network structure of each aggregate model is the same as the network structure of the model in its corresponding group, and the weight parameters in each aggregate model can be obtained by weighted summation of the weight parameters of one or more models in the same group.
[0189] For example, as shown in Figure 9, Model 1 and Model 3 in Group 1 are aggregated to obtain Aggregate Model 1, wherein the network structure of Aggregate Model 1 is the same as the network structure of Model 1 and Model 3, and the weight parameters of Aggregate Model 1 are obtained by weighted summing the weight parameters of Model 1 and Model 3. Model 2 and Model n in Group 2 are aggregated to obtain Aggregate Model 2, wherein the network structure of Aggregate Model 2 is the same as the network structure of Model 2 and Model n, and the weight parameters of Aggregate Model 2 are obtained by weighted summing the weight parameters of Model 2 and Model n.
[0190] In step 704 , the aggregation node performs knowledge distillation training on each of the multiple aggregation models using the multiple models as teacher models to obtain multiple trained models.
[0191] Since each aggregate model is obtained by aggregating models with the same network structure in the same group, each aggregate model actually only integrates the knowledge learned by models with the same network structure, and does not integrate the knowledge of models with different network structures.
[0192] Therefore, in this embodiment, the multiple models originally received by the aggregation node are used as teacher models. Knowledge distillation training is performed on each aggregated model to achieve knowledge transfer between models with different network structures, ensuring that each aggregated model can learn the knowledge of other models with different network structures during knowledge distillation training. In this way, the trained model obtained by performing knowledge distillation training on the aggregated model actually integrates the knowledge and experience of models with different network structures, which can effectively improve the prediction accuracy of the trained model.
[0193] For ease of understanding, the following will take the example of an aggregation node performing knowledge distillation training on the first aggregation model among multiple aggregation models to introduce in detail the process of knowledge distillation training performed on the aggregation model.
[0194] Specifically, during knowledge distillation training of the first aggregation model, training samples are first input into the first aggregation model and multiple models, respectively, to obtain a target prediction result and multiple prediction results. The first aggregation model can be any one of the multiple aggregation models, the target prediction result is the prediction result output by the first aggregation model, and the multiple prediction results are the prediction results output by each of the multiple models. The training samples can be local data and / or public data available on the aggregation node.
[0195] Then, based on the target prediction result output by the first aggregate model and the multiple prediction results output by the multiple models, a loss function can be constructed. The loss function can be obtained based on the difference between the target prediction result and the multiple prediction results. In this way, the first aggregate model is trained based on the loss function to obtain a trained first aggregate model.
[0196] In this scheme, by constructing a distillation loss function based on the difference between the prediction results of the original multiple models and the prediction results of the aggregated model, it is possible to support the experience transfer between models with different network structures in a knowledge distillation-based manner, so that the aggregated model can further aggregate the knowledge and experience under various network structures and improve the prediction accuracy of the aggregated model.
[0197] Optionally, the loss function includes a first sub-loss function and a second sub-loss function, where the first sub-loss function is based on the difference between the target prediction result and the multiple prediction results, and the second sub-loss function is based on the difference between the true labels of the training samples and the target prediction result. For example, assuming that the first aggregation model is used to perform an image classification task, the training samples are images, the true labels of the training samples are the actual categories of the training samples, and the target prediction result is the category prediction result output by the first aggregation model.
[0198] In addition, the loss function can be obtained by weighted summing the first sub-loss function and the second sub-loss function. The weights of the first sub-loss function and the second sub-loss function can be determined or adjusted according to the actual training situation of the model, and this embodiment does not specifically limit this.
[0199] In this scheme, a distillation loss function is constructed based on the difference between the prediction results of the original multiple models and the prediction results of the aggregated model, and a label loss function is constructed based on the true labels of the training samples. This can support the experience transfer between models of different network structures based on knowledge distillation under the constraints of the label loss function, so that the aggregated model can effectively aggregate the knowledge and experience under various network structures and improve the prediction accuracy of the aggregated model.
[0200] The first loss function can be constructed in a variety of ways.
[0201] In one possible implementation, the first loss function is obtained based on the difference between the target prediction result and each of the multiple prediction results. In other words, the first loss function can actually be obtained by weighted summing multiple difference values, where the multiple difference values include the difference between the target prediction result and each of the multiple prediction results.
[0202] In another possible implementation, the first loss function is obtained based on the difference between the target prediction result and the weighted average of the multiple prediction results. That is, after obtaining the multiple prediction results, the multiple prediction results can be weighted and summed first, and the weight corresponding to each prediction result is the same, thereby obtaining the weighted average of the multiple prediction results. In this way, the difference between the target prediction result and the weighted average of the multiple prediction results is obtained to obtain the first loss function. For example, when the first aggregation model is used to perform an image classification task, the multiple prediction results output by the multiple models are actually prediction probabilities for each category (that is, each prediction result includes the prediction probability under each category), so the process of weighted summing the multiple prediction results is actually weighted summing the prediction probability values of each category, thereby obtaining the weighted sum probability value under each category.
[0203] For example, please refer to Figure 10, which is a schematic diagram of performing knowledge distillation on multiple aggregate models provided in an embodiment of the present application. As shown in Figure 10, the aggregation node obtains aggregate model 1-aggregate model M with different network structures based on the originally received models 1-model n. Furthermore, for each aggregate model in aggregate model 1-aggregate model M, the aggregation node performs knowledge distillation on each aggregate model based on the originally received models 1-model n, thereby obtaining trained models 1-trained models M.
[0204] Step 705: The aggregation node sends multiple trained models to multiple nodes.
[0205] After the aggregator node performs knowledge distillation training on each aggregated model, it can obtain multiple trained models. These multiple trained models are actually the result of integrating models based on different network structures. Therefore, the aggregator node can send multiple trained models to multiple nodes, allowing them to select one or more of these models to continue local training.
[0206] Exemplarily, as shown in FIG10 , after the aggregation point performs knowledge distillation on each aggregation model, it obtains trained model 1 - trained model M, and sends trained model 1 - trained model M to each node in node 1 - node n.
[0207] It is understandable that since the aggregator node aggregates the models uploaded by each node, it still obtains multiple models with different network structures (i.e., the multiple trained models mentioned above). Therefore, if the aggregator node sends multiple trained models to each node, the data communication volume may be high. Especially in the scenario of federated learning, the aggregator node and other nodes often need to exchange models multiple times, further increasing the data communication volume.
[0208] Based on this, the aggregation node can pre-acquire part of the data owned by each node or obtain data similar to the local data on each node, and then filter part of the model for each node based on this data to avoid sending too many models to each node.
[0209] For example, the aggregator node may determine a portion of trained models from multiple trained models based on target data and send the portion of trained models to the first node. The target data is data obtained by the aggregator node from the first node, the first node is one of the multiple nodes, and the portion of trained models is the model with the best performance when processing the target data among the multiple trained models. The number of the portion of trained models may be determined or adjusted based on the processing capacity of the first node and is not specifically limited herein.
[0210] Specifically, the first node may preselect a portion of data from the local data as target data and send the target data to the aggregation node. The target data selected by the first node may be typical data on the first node and can effectively characterize the characteristics of the local data on the first node.
[0211] Alternatively, if the first node does not wish to transmit its actual data to the aggregator, the first node can train a data generator based on its local data. This data generator can output data similar to the first node's local data without input. In this way, after the first node sends the data generator to the aggregator, the aggregator can generate the target data described above based on the data generator.
[0212] For example, please refer to Figure 11, which is a schematic diagram of an aggregation node sending a trained model to each node provided in an embodiment of the present application. As shown in Figure 11, the aggregation node may be a node that obtains data from each node in advance and filters a portion of the trained model for each node based on the data from each node, and then sends the portion of the trained model obtained after filtering to the node, without sending all the trained models to each node. For example, the aggregation node only sends trained model 1 and trained model 2 to node 1, and the aggregation node only sends trained model 2 and trained model n to node 2.
[0213] In step 706 , the first node receives a plurality of trained models from the aggregation node.
[0214] The first node is one of the plurality of nodes mentioned above. The network structures of the plurality of trained models are different, and the plurality of models are obtained by aggregating the models on different nodes by the aggregating node.
[0215] Specifically, the multiple trained models are obtained by the first node aggregating parameters of models with the same network structure after receiving models on different nodes and performing knowledge distillation on the aggregated models based on the models on different nodes.
[0216] Step 707: The first node determines a target model from a plurality of trained models based on the training data.
[0217] Since the first node receives multiple trained models from the aggregation node, and the processing performance of the multiple trained models for the training data in the first node is different, the first node can determine the target model suitable for processing the local data of the first node from the multiple trained models based on the local training data (that is, screen the target model that is adapted to the local data of the first node).
[0218] The target model determined by the first node may include one or more trained models. If the processing capability of the first node is relatively low, the first node may determine one trained model as the target model; if the processing capability of the first node is relatively high, the first node may determine multiple trained models as the target model.
[0219] Specifically, there may be multiple ways for the first node to determine the target model among multiple trained models.
[0220] In one possible implementation, the first node can input training data into the gating network, obtaining multiple weight values output by the gating network. The multiple weight values correspond one-to-one to multiple trained models, and the multiple weight values are used to represent the weights of the output results of the multiple trained models in the weighted summation process. In other words, the multiple trained models cooperate with the gating network to process the training data. The gating network is configured to output a weight value corresponding to each of the multiple trained models based on the training data. After each trained model outputs an output result corresponding to the training data, the multiple output results can be weighted summed according to the weight value corresponding to each trained model to obtain the final output result.
[0221] The gating network can be a network pre-trained based on the local data of the first node. During gating network training, the first node can simultaneously input local data into the gating network and multiple trained models, with the gating network outputting weight values corresponding to each trained model. Thus, after each trained model outputs an output result corresponding to the training data, the multiple output results can be weighted and summed according to the weight values corresponding to each trained model to obtain a final output result. Therefore, the weight values output by the gating network can reflect the performance of the multiple trained models for the local data of the first node. For any trained model, a higher weight value output by the gating network for that trained model indicates better performance of the trained model in processing the local data of the first node, i.e., a better fit of the trained model to the local data of the first node. A lower weight value output by the gating network for that trained model indicates worse performance of the trained model in processing the local data of the first node, i.e., a less fit of the trained model to the local data of the first node.
[0222] In this way, the first node can determine a target model based on the multiple weight values output by the gate network, where the target model includes one or more models with the highest corresponding weight values among the multiple trained models. In other words, the first node can use the weight values corresponding to each trained model to measure the degree of adaptation of each trained model to the local data of the first node, and then select the one or more models with the highest degree of adaptation (i.e., the target model) among the multiple trained models.
[0223] For example, please refer to Figures 12A and 12B, Figure 12A is a schematic diagram of a screening target model provided in an embodiment of the present application; Figure 12B is a schematic diagram of a screening target model provided in an embodiment of the present application. As shown in Figures 12A and 12B, after the first node obtains the trained model 1-trained model M, it can construct an overall model based on the gate network and the trained model 1-trained model M, wherein the input data is simultaneously input into the gate network and the trained model 1-trained model M, and the gate network outputs the weight value corresponding to the trained model 1-trained model M, and then the output results of each trained model are weighted summed based on the weight value to obtain the final output result.
[0224] In Figure 12A , after the gate network is trained based on the local data of the first node, the target model can be screened based on the weight values output by the gate network to obtain Model 1 to Model K. That is, in Figure 12A , the target model can include multiple models.
[0225] In Figure 12B , after the gate network is trained based on the local data of the first node, the target model can be screened based on the weight values output by the gate network to obtain model K. That is, in Figure 12B , the target model may include only one model.
[0226] In this solution, the gate network is trained to output the weight value corresponding to each model, thereby measuring the degree of adaptation of each model to the local data and ensuring that the node can select the target model with the best performance when processing the node's local data from multiple models.
[0227] In another possible implementation, the first node may input the training data into each of the multiple trained models, and determine the prediction accuracy of each trained model based on the prediction results output by each trained model. For example, the first node may prepare multiple training samples and input each of the multiple training samples into the multiple trained models, thereby obtaining the prediction accuracy of each trained model based on the prediction accuracy statistics of each training sample from the multiple trained models.
[0228] Then, the first node determines a target model based on the prediction accuracy of each trained model, where the target model is one or more models with the highest prediction accuracy among the multiple trained models.
[0229] For example, please refer to Figure 13, which is a schematic diagram of another method for selecting target models according to an embodiment of the present application. As shown in Figure 13, after obtaining trained models 1 through M, the first node can input training data into each trained model to obtain the prediction accuracy corresponding to each trained model. The target model can then be selected based on the model's prediction accuracy to obtain model K with the highest prediction accuracy.
[0230] In this solution, the prediction accuracy of each model is determined based on the local data of the node, and the degree of adaptation of each model to the local data is measured, ensuring that the node can select the target model with the best performance when processing the local data of the node from multiple models.
[0231] In step 708 , the first node uses the multiple trained models as teacher models and performs knowledge distillation training on the target model to obtain a trained target model.
[0232] The process of the first node performing knowledge distillation training on the target model is similar to the process of the aggregation node performing knowledge distillation training on the aggregation model in step 704 above. The difference is that the first node performs knowledge distillation training on the target model using local data on the first node, while the aggregation node performs knowledge distillation training on the aggregation model using local data on the aggregation node and / or public data obtained by the aggregation node. For details, please refer to step 704 above and will not be repeated here.
[0233] Furthermore, if the target model includes multiple models, the target model also needs to cooperate with the gate network to perform data processing. Therefore, during the knowledge distillation training of the target model, the gate network corresponding to the target model is also trained so that the gate network can correctly output the weight values corresponding to each model in the target model.
[0234] In this embodiment, after the first node obtains the trained target model, the trained target model can be deployed on the first node to perform inference tasks based on local data on the first node.
[0235] Exemplarily, as shown in FIG12A and FIG12B , after determining the target model, knowledge distillation training can be performed on the target model based on the local data of the first node (ie, the target model is fine-tuned based on the local data) to achieve further training of the target model.
[0236] In this solution, after the first node obtains the target model through screening, it uses the originally received model as the teacher model to perform knowledge distillation training on the target model. This ensures that the target model does not forget the original experience while considering the personalized fine-tuning performed on the local data of the first node, and effectively avoids the sharp fluctuations in the prediction accuracy of the target model due to the poor quality of the local data of the first node (i.e., avoids the phenomenon of overfitting of the target model).
[0237] It is understood that steps 701-708 above actually describe one iteration of the federated learning process. In practical applications, the federated learning process can include multiple iterations. Specifically, after each node obtains the target model through training, it sends the trained target model to the aggregation node, which then aggregates the models uploaded by each node, thus executing a new iteration.
[0238] The above describes how the aggregation node aggregates the models uploaded by each node, sends the aggregated model to each node, and each node further screens and trains the aggregated model.
[0239] In a distributed system architecture, since the aggregator node itself also has models deployed and requires models to process local data, in some embodiments, after aggregating multiple models, the aggregator node can filter out a model suitable for the aggregator node and further train the filtered model.
[0240] For example, please refer to Figure 14, which is a flowchart of another federated learning method provided in an embodiment of the present application. As shown in Figure 14, the federated learning method includes the following steps 1401-1407.
[0241] In step 1401 , the aggregation node obtains multiple models, where the multiple models are obtained from multiple nodes.
[0242] In this embodiment, the aggregation node is a node in a distributed system architecture, and a model is deployed on the aggregation node. Therefore, the multiple models acquired by the aggregation node also include the model deployed on the aggregation node.
[0243] In step 1402 , the aggregation node divides the multiple models into multiple groups according to the network structures of the multiple models, wherein each of the multiple groups includes at least one model, and the models in the same group have the same network structure.
[0244] In step 1403 , the aggregation node aggregates parameters of the models in each of the multiple groups to obtain multiple aggregate models, wherein the models in the same group are aggregated to obtain one aggregate model, and the multiple aggregate models correspond to the multiple groups.
[0245] In step 1404 , the aggregation node performs knowledge distillation training on each of the multiple aggregation models using the multiple models as teacher models to obtain multiple trained models.
[0246] Step 1405: The aggregation node sends multiple trained models to multiple nodes.
[0247] Among them, steps 1401-1405 are similar to the above steps 701-705. Please refer to the above steps 701-705 for details, and will not be repeated here.
[0248] In step 1406 , the aggregation node determines a target model from the plurality of trained models based on the training data.
[0249] Since the aggregation node itself also needs to process the local data on the aggregation node based on the model, the aggregation node can also determine the target model from multiple trained models based on the training data on the aggregation node.
[0250] In step 1407 , the aggregation node uses the multiple trained models as teacher models and performs knowledge distillation training on the target model to obtain a trained target model.
[0251] Similarly, the process of the aggregation node determining the target model and performing knowledge distillation training on the target model is similar to the above steps 707-708. For details, please refer to the process of the first node determining the target model and performing knowledge distillation training on the target model in the above steps 707-708, which will not be repeated here.
[0252] The above describes in detail the method provided by the embodiment of the present application. Next, the device provided by the embodiment of the present application for executing the above method will be introduced.
[0253] Please refer to Figure 15, which is a schematic diagram of the structure of a federated learning device provided in an embodiment of the present application. As shown in Figure 15, the federated learning device is an aggregation node and includes:
[0254] An acquisition module 1501 is used to acquire multiple models, where the multiple models are acquired from multiple nodes;
[0255] The processing module 1502 is further configured to divide the multiple models into multiple groups according to the network structures of the multiple models, wherein each of the multiple groups includes at least one model, and the models in the same group have the same network structure;
[0256] The processing module 1502 is further configured to aggregate parameters of the models in each of the plurality of groups to obtain a plurality of aggregate models, wherein the models in the same group are aggregated to obtain one aggregate model, and the plurality of aggregate models correspond to the plurality of groups;
[0257] The processing module 1502 is further configured to use the multiple models as teacher models and perform knowledge distillation training on each of the multiple aggregate models to obtain multiple trained models;
[0258] The sending module 1503 is used to send multiple trained models to multiple nodes.
[0259] In a possible implementation, the processing module 1502 is further configured to:
[0260] Inputting the training samples into the first aggregation model and the multiple models respectively to obtain a target prediction result and multiple prediction results, wherein the first aggregation model is any one of the multiple aggregation models, the target prediction result corresponds to the first aggregation model, and the multiple prediction results correspond to the multiple models;
[0261] The first aggregation model is trained based on a loss function to obtain a trained first aggregation model, where the loss function is obtained based on a difference between a target prediction result and the plurality of prediction results.
[0262] In one possible implementation, the loss function is based on the difference between the target prediction result and each of the multiple prediction results;
[0263] Alternatively, the loss function is based on the difference between the target prediction and a weighted average of multiple predictions.
[0264] In one possible implementation, the loss function includes a first sub-loss function and a second sub-loss function, where the first sub-loss function is obtained based on the difference between the target prediction result and multiple prediction results, and the second sub-loss function is obtained based on the difference between the true label of the training sample and the target prediction result.
[0265] In a possible implementation, the processing module 1502 is further configured to:
[0266] Based on the training data, a target model is determined among multiple trained models;
[0267] Using multiple trained models as teacher models, knowledge distillation training is performed on the target model to obtain an updated target model. The updated target model is used to perform reasoning tasks based on local data.
[0268] In a possible implementation, the processing module 1502 is further configured to:
[0269] Inputting the training data into each of the multiple models, and determining the prediction accuracy of each model based on the prediction results output by each model;
[0270] A target model is determined based on the prediction accuracy of each model, where the target model includes one or more models with the highest prediction accuracy among the multiple trained models.
[0271] In a possible implementation, the processing module 1502 is further configured to:
[0272] Inputting training data into the gating network to obtain multiple weight values output by the gating network, wherein the multiple weight values correspond one-to-one to the multiple trained models, and the multiple weight values are respectively used to represent the weights of the output results of the multiple trained models in the weighted summation process, and the gating network is a pre-trained network;
[0273] A target model is determined based on multiple weight values, where the target model includes one or more models with the highest corresponding weight values among the multiple trained models.
[0274] In one possible implementation,
[0275] The processing module 1502 is further configured to determine, based on target data, a partially trained model from the plurality of trained models, where the target data is the data obtained from the first node, and the partially trained model is a model having the best performance among the plurality of trained models when processing the target data;
[0276] The sending module 1503 is further configured to send the partially trained model to the first node.
[0277] In a possible implementation, the processing module 1502 is further configured to perform weighted summation on the weight parameters of the multiple models in the first group to obtain a first aggregate model;
[0278] The first group belongs to the multiple groups, and the first aggregation model belongs to the multiple aggregation models.
[0279] Please refer to Figure 16, which is a schematic diagram of the structure of a federated learning device provided in an embodiment of the present application. As shown in Figure 16, the federated learning device includes:
[0280] The receiving module 1601 is configured to receive multiple models from an aggregation node, where the multiple models have different network structures and are obtained by the aggregation node aggregating models on different nodes.
[0281] A processing module 1602 is configured to determine a target model from among multiple models based on the training data;
[0282] The processing module 1602 is further used to perform knowledge distillation training on the target model using multiple models as teacher models to obtain a trained target model.
[0283] In a possible implementation, the processing module 1602 is further configured to:
[0284] Inputting the training data into each of the multiple models respectively, and determining the prediction accuracy of each model based on the prediction results output by each model;
[0285] The target model is determined based on the prediction accuracy of each model, and the target model is one or more models with the highest prediction accuracy among the multiple models.
[0286] In a possible implementation, the processing module 1602 is further configured to:
[0287] Inputting the training data into a gating network to obtain a plurality of weight values output by the gating network, wherein the plurality of weight values correspond one-to-one to the plurality of trained models, and the plurality of weight values are respectively used to represent weights of output results of the plurality of trained models in a weighted summation process, wherein the gating network is a pre-trained network;
[0288] The target model is determined according to the multiple weight values, and the target model includes one or more models with the highest corresponding weight values among the multiple models.
[0289] In one possible implementation, the multiple models are obtained by the aggregation node aggregating parameters of models with the same network structure after receiving models on different nodes and performing knowledge distillation training on the aggregated models based on the models on the different nodes.
[0290] Please refer to Figure 17, which is a structural diagram of an execution device provided in an embodiment of the present application. The execution device 1700 can be specifically manifested as a mobile phone, a tablet, a laptop computer, a smart wearable device, a server, etc., which is not limited here. Specifically, the execution device 1700 includes: a receiver 1701, a transmitter 1702, a processor 1703 and a memory 1704 (wherein the number of processors 1703 in the execution device 1700 can be one or more, and Figure 17 takes one processor as an example), wherein the processor 1703 may include an application processor 17031 and a communication processor 17032. In some embodiments of the present application, the receiver 1701, the transmitter 1702, the processor 1703 and the memory 1704 may be connected via a bus or other means.
[0291] Memory 1704 may include read-only memory and random access memory, and provides instructions and data to processor 1703. A portion of memory 1704 may also include non-volatile random access memory (NVRAM). Memory 1704 stores processor and operation instructions, executable modules, or data structures, or subsets or extended sets thereof. The operation instructions may include various operation instructions for implementing various operations.
[0292] Processor 1703 controls the operation of the execution device. In specific applications, the various components of the execution device are coupled together via a bus system. In addition to a data bus, the bus system may also include a power bus, a control bus, and a status signal bus. However, for clarity, all bus systems are referred to as a bus system in the figure.
[0293] The methods disclosed in the above embodiments of the present application can be applied to or implemented by processor 1703. Processor 1703 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits or software instructions in processor 1703. The above processor 1703 can be a general-purpose processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, and may further include an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware components. The processor 1703 can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in conjunction with the embodiments of the present application can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in memory 1704, and processor 1703 reads the information in memory 1704 and, in conjunction with its hardware, completes the steps of the above method.
[0294] Receiver 1701 can be used to receive input digital or character information and generate signal input related to executing device-related settings and function control. Transmitter 1702 can be used to output digital or character information through the first interface. Transmitter 1702 can also be used to send instructions to the disk pack through the first interface to modify data in the disk pack. Transmitter 1702 can also include a display device such as a display screen.
[0295] The electronic device provided in the embodiments of the present application may specifically be a chip, and the chip includes: a processing unit and a communication unit. The processing unit may be, for example, a processor, and the communication unit may be, for example, an input / output interface, a pin, or a circuit. The processing unit may execute computer-executable instructions stored in the storage unit so that the chip in the execution device executes the method described in the above embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit may also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
[0296] Specifically, see Figure 18 , which is a schematic diagram of the structure of a chip provided in an embodiment of the present application. The chip can be represented as a neural network processor NPU 1800. NPU 1800 is mounted on the host CPU (host CPU) as a coprocessor and is assigned tasks by the host CPU. The core of the NPU is arithmetic circuit 1803, which is controlled by controller 1804 to extract matrix data from memory and perform multiplication operations.
[0297] In some implementations, the arithmetic circuit 1803 includes multiple processing units (PEs). In some implementations, the arithmetic circuit 1803 is a two-dimensional systolic array. The arithmetic circuit 1803 can also be a one-dimensional systolic array or other electronic circuitry capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 1803 is a general-purpose matrix processor.
[0298] For example, assume there are input matrix A, weight matrix B, and output matrix C. The arithmetic circuit retrieves the corresponding data of matrix B from weight memory 1802 and caches it on each PE in the arithmetic circuit. The arithmetic circuit retrieves the data of matrix A from input memory 1801 and performs a matrix operation on matrix B. The partial or final matrix result is stored in accumulator 1808.
[0299] Unified memory 1806 is used to store input and output data. Weight data is directly transferred to weight memory 1802 through the Direct Memory Access Controller (DMAC) 1805. Input data is also transferred to unified memory 1806 through the DMAC.
[0300] BIU stands for Bus Interface Unit 1810 , which is used for interaction between the AXI bus and the DMAC and the Instruction Fetch Buffer (IFB) 1809 .
[0301] The bus interface unit 1810 (BIU) is used for the instruction fetch memory 1809 to obtain instructions from the external memory, and is also used for the storage unit access controller 1805 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
[0302] DMAC is mainly used to move input data in the external memory DDR to the unified memory 1806 or to move weight data to the weight memory 1802 or to move input data to the input memory 1801.
[0303] The vector calculation unit 1807 includes multiple operation processing units. When necessary, it further processes the output of the operation circuit 1803, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional / fully connected layer network calculations in neural networks, such as batch normalization, pixel-level summation, and upsampling of feature planes.
[0304] In some implementations, the vector calculation unit 1807 can store the processed output vector in the unified memory 1806. For example, the vector calculation unit 1807 can apply a linear function or a nonlinear function to the output of the operation circuit 1803, such as linear interpolation of the feature plane extracted by the convolution layer, or accumulate a vector of values to generate an activation value. In some implementations, the vector calculation unit 1807 generates a normalized value, a pixel-level summed value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 1803, for example, for use in subsequent layers in a neural network.
[0305] An instruction fetch buffer 1809 connected to the controller 1804 is used to store instructions used by the controller 1804;
[0306] Unified memory 1806, input memory 1801, weight memory 1802, and instruction fetch memory 1809 are all on-chip memories. External memories are private to the NPU hardware architecture.
[0307] The processor mentioned in any of the above places can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the above program.
[0308] Please refer to Figure 19, which is a schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of the present application. The present application also provides a computer-readable storage medium. In some embodiments, the method disclosed in Figure 6 above can be implemented as computer program instructions encoded in a machine-readable format on a computer-readable storage medium or on other non-transitory media or products.
[0309] 19 schematically illustrates a conceptual partial view of an example computer-readable storage medium including a computer program for executing a computer process on a computing device, arranged in accordance with at least some embodiments presented herein.
[0310] In one embodiment, computer readable storage medium 1900 is provided using signal bearing medium 1901. Signal bearing medium 1901 may include one or more program instructions 1902 that, when executed by one or more processors, may provide the functionality or portions of the functionality described above with respect to FIG.
[0311] In some examples, the signal bearing medium 1901 may include a computer readable medium 1903 such as, but not limited to, a hard drive, a compact disk (CD), a digital video disk (DVD), a digital tape, a memory, a ROM or RAM, and the like.
[0312] In some embodiments, the signal-bearing medium 1901 may include a computer-recordable medium 1904, such as, but not limited to, a memory, a read / write (R / W) CD, a R / W DVD, or the like. In some embodiments, the signal-bearing medium 1901 may include a communication medium 1905, such as, but not limited to, a digital and / or analog communication medium (e.g., a fiber optic cable, a waveguide, a wired communication link, a wireless communication link, or the like). Thus, for example, the signal-bearing medium 1901 may be communicated via a wireless form of the communication medium 1905 (e.g., a wireless communication medium conforming to the IEEE 802.X standard or other transmission protocol).
[0313] The one or more program instructions 1902 may be, for example, computer-executable instructions or logic-implemented instructions. In some examples, the computing device may be configured to provide various operations, functions, or actions in response to the program instructions 1902 communicated to the computing device via one or more of computer-readable media 1903, computer-recordable media 1904, and / or communication media 1905.
[0314] It should also be noted that the device embodiments described above are merely illustrative, in which the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the device embodiments provided in this application, the connection relationship between the modules indicates that there is a communication connection between them, which can be specifically implemented as one or more communication buses or signal lines.
[0315] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course can also be implemented by special hardware including application-specific integrated circuits, special CPUs, special memories, special components, etc. In general, all functions performed by computer programs can be easily implemented with corresponding hardware, and the specific hardware structures used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits, etc. However, for the present application, software program implementation is a better implementation method in most cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer's floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., and includes a number of instructions to enable a computer device (which can be a personal computer, training equipment, or network equipment, etc.) to execute the methods of each embodiment of the present application.
[0316] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0317] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, a computer, a training device or a data center by wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode to another website, computer, training device or data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a training device, a data center that includes one or more available media integrations. Available media can be magnetic media, (such as floppy disks, hard disks, tapes), optical media (such as DVDs), or semiconductor media (such as solid-state drives (SSDs)).
Claims
1. A federated learning method, It is characterized in that include: Acquire multiple models, where the multiple models are acquired from multiple nodes; Dividing the multiple models into multiple groups according to the network structures of the multiple models, wherein each of the multiple groups includes at least one model, and the models in the same group have the same network structure; Aggregating parameters of the models in each of the multiple groups to obtain multiple aggregate models, wherein the models in the same group are aggregated to obtain one aggregate model, and the multiple aggregate models correspond to the multiple groups; Using the multiple models as teacher models, respectively perform knowledge distillation training on each of the multiple aggregate models to obtain multiple trained models; The multiple trained models are sent to the multiple nodes.
2. The method according to claim 1, It is characterized in that The method of using the multiple models as teacher models and performing knowledge distillation training on each of the multiple aggregate models to obtain multiple trained models includes: Input the training samples into the first aggregation model and the multiple models respectively to obtain a target prediction result and multiple prediction results, wherein the first aggregation model is any one of the multiple aggregation models, the target prediction result corresponds to the first aggregation model, and the multiple prediction results correspond to the multiple models; The first aggregation model is trained based on a loss function to obtain a trained first aggregation model, wherein the loss function is obtained based on a difference between the target prediction result and the multiple prediction results.
3. The method according to claim 2, It is characterized in that The loss function is obtained based on the difference between the target prediction result and each prediction result of the plurality of prediction results; Alternatively, the loss function is obtained based on the difference between the target prediction result and the weighted average of the multiple prediction results.
4. The method according to claim 2 or 3, It is characterized in that The loss function includes a first sub-loss function and a second sub-loss function, wherein the first sub-loss function is obtained based on the difference between the target prediction result and the multiple prediction results, and the second sub-loss function is obtained based on the difference between the true label of the training sample and the target prediction result.
5. The method according to any one of claims 1 to 4, It is characterized in that The method further comprises: Based on the training data, determining a target model among the plurality of trained models; The multiple trained models are used as teacher models, and knowledge distillation training is performed on the target model to obtain an updated target model, where the updated target model is used to perform reasoning tasks based on local data.
6. The method according to claim 5, It is characterized in that The step of determining a target model from among the plurality of trained models based on the training data comprises: Inputting the training data into each model of the multiple models respectively, and determining the prediction accuracy of each model based on the prediction results output by each model; The target model is determined based on the prediction accuracy of each model, and the target model includes one or more models with the highest prediction accuracy among the multiple trained models.
7. The method according to claim 5, It is characterized in that The step of determining a target model from among the plurality of trained models based on the training data comprises: Inputting the training data into a gate network to obtain a plurality of weight values output by the gate network, wherein the plurality of weight values correspond one-to-one to the plurality of trained models, and the plurality of weight values are respectively used to represent the weights of the output results of the plurality of trained models in a weighted summation process, and the gate network is a pre-trained network; The target model is determined according to the multiple weight values, and the target model includes the one with the lowest corresponding weight value among the multiple trained models. One or more models of height.
8. The method according to any one of claims 1 to 7, It is characterized in that The sending the plurality of trained models to the plurality of nodes comprises: Determine, according to target data, a partially trained model from the multiple trained models, wherein the target data is data acquired from the first node, and the partially trained model is a model having the best performance among the multiple trained models when processing the target data; Send the partially trained model to the first node.
9. The method according to any one of claims 1 to 8, It is characterized in that The step of aggregating parameters of the models in each of the plurality of groups to obtain a plurality of aggregated models includes: Performing weighted summation on weight parameters of multiple models in the first group to obtain a first aggregate model; The first group belongs to the multiple groups, and the first aggregation model belongs to the multiple aggregation models.
10. A federated learning method, It is characterized in that include: Receiving multiple models from an aggregation node, the multiple models have different network structures, and the multiple models are obtained by the aggregation node aggregating models on different nodes; Based on the training data, determining a target model among the multiple models; The multiple models are used as teacher models, and knowledge distillation training is performed on the target model to obtain a trained target model.
11. The method according to claim 10, It is characterized in that The step of determining a target model from among the multiple models based on the training data comprises: Inputting the training data into each model of the multiple models respectively, and determining the prediction accuracy of each model based on the prediction results output by each model; The target model is determined based on the prediction accuracy of each model, and the target model is one or more models with the highest prediction accuracy among the multiple models.
12. The method according to claim 10, It is characterized in that The step of determining a target model from among the multiple models based on the training data comprises: Inputting the training data into a gate network to obtain a plurality of weight values output by the gate network, wherein the plurality of weight values correspond one-to-one to the plurality of trained models, and the plurality of weight values are respectively used to represent the weights of the output results of the plurality of trained models in a weighted summation process, and the gate network is a pre-trained network; The target model is determined according to the multiple weight values, and the target model includes one or more models with the highest corresponding weight values among the multiple models.
13. The method according to any one of claims 10 to 12, It is characterized in that The multiple models are obtained by the aggregation node, after receiving the models on different nodes, aggregating parameters of the models with the same network structure and performing knowledge distillation training on the aggregated models based on the models on the different nodes.
14. A federated learning device, It is characterized in that include: An acquisition module, used for acquiring multiple models, wherein the multiple models are acquired from multiple nodes; The processing module is further used to divide the multiple models into multiple groups according to the network structures of the multiple models, wherein each of the multiple groups includes at least one model, and the models in the same group have the same network structure; The processing module is further used to aggregate parameters of the models in each of the multiple groups to obtain multiple aggregate models, wherein the models in the same group are aggregated to obtain one aggregate model, and the multiple aggregate models correspond to the multiple groups; The processing module is further configured to use the multiple models as teacher models and to perform Perform knowledge distillation training to obtain multiple trained models; A sending module is used to send the multiple trained models to the multiple nodes.
15. The device according to claim 14, It is characterized in that The processing module is further used for: Input the training samples into the first aggregation model and the multiple models respectively to obtain a target prediction result and multiple prediction results, wherein the first aggregation model is any one of the multiple aggregation models, the target prediction result corresponds to the first aggregation model, and the multiple prediction results correspond to the multiple models; The first aggregation model is trained based on a loss function to obtain a trained first aggregation model, wherein the loss function is obtained based on a difference between the target prediction result and the multiple prediction results.
16. The device according to claim 15, It is characterized in that The loss function is obtained based on the difference between the target prediction result and each prediction result of the plurality of prediction results; Alternatively, the loss function is obtained based on the difference between the target prediction result and the weighted average of the multiple prediction results.
17. The device according to claim 15 or 16, It is characterized in that The loss function includes a first sub-loss function and a second sub-loss function, wherein the first sub-loss function is obtained based on the difference between the target prediction result and the multiple prediction results, and the second sub-loss function is obtained based on the difference between the true label of the training sample and the target prediction result.
18. The device according to any one of claims 14 to 17, It is characterized in that The processing module is further used for: Based on the training data, determining a target model among the plurality of trained models; The multiple trained models are used as teacher models, and knowledge distillation training is performed on the target model to obtain an updated target model, where the updated target model is used to perform reasoning tasks based on local data.
19. The device according to claim 18, It is characterized in that The processing module is further used for: Inputting the training data into each model of the multiple models respectively, and determining the prediction accuracy of each model based on the prediction results output by each model; The target model is determined based on the prediction accuracy of each model, and the target model includes one or more models with the highest prediction accuracy among the multiple trained models.
20. The device according to claim 18, It is characterized in that The processing module is further used for: Inputting the training data into a gate network to obtain a plurality of weight values output by the gate network, wherein the plurality of weight values correspond one-to-one to the plurality of trained models, and the plurality of weight values are respectively used to represent the weights of the output results of the plurality of trained models in a weighted summation process, and the gate network is a pre-trained network; The target model is determined according to the multiple weight values, and the target model includes one or more models with the highest corresponding weight values among the multiple trained models.
21. The device according to any one of claims 14 to 20, It is characterized in that The processing module is further used to determine a partially trained model from the multiple trained models according to target data, the target data being data acquired from the first node, and the partially trained model being a model having the best performance among the multiple trained models when processing the target data; The sending module is also used to send the partially trained model to the first node.
22. A federated learning device, It is characterized in that include: A receiving module, used for receiving a plurality of models from an aggregation node, wherein the plurality of models have different network structures and are obtained by the aggregation node aggregating models on different nodes; A processing module, configured to determine a target model among the plurality of models based on the training data; The processing module is also used to perform knowledge distillation training on the target model using the multiple models as teacher models to obtain a trained target model.
23. A federated learning device, It is characterized in that The device comprises a memory and a processor; the memory stores codes, the processor is configured to execute the codes, and when the codes are executed, the device executes the method according to any one of claims 1 to 13.
24. A computer storage medium, It is characterized in that The computer storage medium stores instructions, which, when executed by a computer, cause the computer to implement the method of any one of claims 1 to 13.
25. A computer program product, It is characterized in that The computer program product stores instructions, which, when executed by a computer, cause the computer to implement the method according to any one of claims 1 to 13.
Citation Information
Patent Citations
A federated learning method and related apparatus
CN116468114B
Federated learning method and system for protecting user privacy, image classification method for protecting user privacy for and terminal
CN111477290A
Information processing method and system
CN113222175A
Federal model generation method and device, electronic equipment and storage medium
CN113408743A
Federal learning method and related device
CN116468114A
Cited By
Lightweight heterogeneous federated distillation training method and system oriented to edge intelligence
CN122819374A
