Federated model training method and apparatus
By receiving and training a personalized model from a central device, the target mask sequence is determined, solving the problem of high computational cost in personalized federated learning and achieving efficient personalized model training.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-18
- Publication Date
- 2026-03-17
AI Technical Summary
Personalized federated learning involves a large amount of computation for model training, resulting in low efficiency.
By receiving the personalized model sent by the central device, the model is trained and the target mask sequence is determined. The training gradient and mask sequence are then sent to achieve personalized model training, reducing the need for additional model training.
It effectively reduces the computational cost of local training in personalized federated learning, and improves the efficiency and accuracy of model training.
Smart Images

Figure CN114492837B_ABST
Abstract
Description
Technical Field
[0001] This application relates to computer technology, and more particularly to a federated model training method and apparatus. Background Technology
[0002] Building upon traditional federated learning, personalized federated learning allows local devices to have different personalized models, rather than sharing the same global model.
[0003] Currently, when implementing personalized federated learning in existing technologies, in addition to training a global model together on all local devices, each local device also trains its own local model, so that each device can have its own personalized model.
[0004] However, training an additional local model on each local device to achieve personalized federated learning can result in a large computational burden for model training. Summary of the Invention
[0005] This application provides a federated model training method and apparatus to overcome the problem of high computational cost in training personalized federated learning models.
[0006] In a first aspect, embodiments of this application provide a federated model training method, applied to participant devices, comprising:
[0007] The personalized model sent by the receiving center device has a smaller number of valid model parameters than the number of valid model parameters in the global model.
[0008] The personalized model is trained to obtain the training gradient of the personalized model, which includes the gradient of each model parameter in the personalized model.
[0009] Based on the gradient of the personalized model, the model parameters of the personalized model, and the amount of pruning, a target mask sequence is determined. The target mask sequence is used by the central device to determine the personalized model in the next round of training.
[0010] The target mask sequence and the training gradient of the personalized model are sent to the central device.
[0011] In one possible design, the target mask sequence is determined based on the gradient of the personalized model, the model parameters of the personalized model, and the pruning amount, including:
[0012] Based on the model parameters of the personalized model, determine the first mask sequence;
[0013] The second mask sequence is obtained by setting a first preset value to a portion of the mask in the first mask sequence according to the pruning amount.
[0014] The target mask sequence is obtained by setting a second preset value to a portion of the mask in the second mask sequence according to the pruning amount.
[0015] In one possible design, the first mask sequence is determined based on the model parameters of the personalized model, including:
[0016] Determine the parameter state of each model parameter in the personalized model;
[0017] The first mask sequence is determined based on the parameter state of each model parameter of the personalized model.
[0018] In one possible design, the first mask sequence is determined based on the parameter state of each model parameter of the personalized model, including:
[0019] The mask corresponding to the model parameters of the valid state is set to a second preset value, and the mask corresponding to the model parameters of the invalid state is set to a first preset value to obtain the first mask sequence.
[0020] In one possible design, the pruning amount is α, where α is an integer greater than or equal to 1; based on the pruning amount, a portion of the mask in the first mask sequence is set to a first preset value to obtain a second mask sequence, including:
[0021] The effective model parameters in the personalized model are sorted from largest to smallest according to their weights to obtain the effective model parameter sequence;
[0022] The last α effective model parameters in the effective model parameter sequence are determined as the first effective model parameters;
[0023] The mask corresponding to the first effective model parameter in the first mask sequence is set to the first preset value to obtain the second mask sequence.
[0024] In one possible design, the pruning amount is α, where α is an integer greater than or equal to 1; the target mask sequence is obtained by setting a second preset value to a portion of the mask in the second mask sequence according to the pruning amount, including:
[0025] Obtain the gradient corresponding to each first mask in the second mask sequence, where the value of the first mask is the first preset value;
[0026] Based on the gradient corresponding to each first mask in the second mask sequence, α candidate masks are determined in the first masks of the second mask sequence;
[0027] The α candidate masks in the second mask sequence are set to the second preset value to obtain the target mask sequence.
[0028] In one possible design, obtaining the gradient corresponding to each first mask in the second mask sequence includes:
[0029] Determine the model parameters corresponding to each first mask in the second mask sequence;
[0030] The gradient of the model parameters corresponding to each first mask is determined as the gradient corresponding to each first mask.
[0031] In one possible design, based on the gradient corresponding to each first mask in the second mask sequence, α candidate masks are determined from the first masks of the second mask sequence, including:
[0032] Sort the first mask in the second mask sequence according to the order of the corresponding gradient from largest to smallest;
[0033] The first α masks in the sorted first mask are determined as the α candidate masks.
[0034] In one possible design, the model training includes N iterations, where N is an integer greater than 1; training the personalized model to obtain its training gradient includes:
[0035] Obtain the N intermediate gradients corresponding to each model parameter;
[0036] The training gradient of the personalized model is determined based on the N intermediate gradients corresponding to each model parameter.
[0037] Secondly, embodiments of this application provide a federated model training method applied to a central device, comprising:
[0038] Determine the target global model;
[0039] Determine the target mask sequence corresponding to the participating device;
[0040] The model parameters of the target global model are updated according to the target mask sequence to obtain a personalized model;
[0041] The personalized model is sent to the participating device.
[0042] In one possible design, the target global model is determined, including:
[0043] If the current training is the first round of training, then the preset model will be determined as the target global model;
[0044] If the current training is the Mth round of training, then multiple training gradients sent by multiple participating devices are obtained, and the target global model is determined based on the (M-1)th global model and the multiple training gradients. The (M-1)th global model is the global model trained in the (M-1)th round, and the target global model is the Mth global model, where M is an integer greater than or equal to 2.
[0045] In one possible design, the target global model is determined based on the (M-1)th global model and the plurality of training gradients, including:
[0046] Based on the multiple training gradients, the model parameters of the (M-1)th global model are updated to obtain the target global model.
[0047] In one possible design, determining the target mask sequence corresponding to the participating devices includes:
[0048] If the current training is the first round of training, then the preset mask sequence is determined as the target mask sequence;
[0049] If the current training is the Mth round of training, then determine whether there is a mask sequence sent by the participating device. If yes, then determine the target mask sequence based on the mask sequence sent by the participating device; otherwise, determine the preset mask sequence as the target mask sequence.
[0050] In one possible design, determining the target mask sequence based on the mask sequence sent by the participating device includes:
[0051] Obtain the mask sequence last sent by the participating device;
[0052] The mask sequence last sent by the participating device is determined as the target mask sequence.
[0053] Thirdly, embodiments of this application provide a federated model training apparatus, applied to participant devices, comprising:
[0054] The receiving module is used to receive personalized models sent by the central device, wherein the number of valid model parameters in the personalized model is less than the number of valid model parameters in the global model.
[0055] The training module is used to train the personalized model and obtain the training gradient of the personalized model, wherein the training gradient includes the gradient of each model parameter in the personalized model;
[0056] The determination module is used to determine a target mask sequence based on the gradient of the personalized model, the model parameters of the personalized model, and the amount of pruning. The target mask sequence is used by the central device to determine the personalized model in the next round of training.
[0057] The sending module is used to send the target mask sequence and the training gradient of the personalized model to the central device.
[0058] In one possible design, the determining module is specifically used for:
[0059] Based on the model parameters of the personalized model, determine the first mask sequence;
[0060] The second mask sequence is obtained by setting a first preset value to a portion of the mask in the first mask sequence according to the pruning amount.
[0061] The target mask sequence is obtained by setting a second preset value to a portion of the mask in the second mask sequence according to the pruning amount.
[0062] In one possible design, the determining module is specifically used for:
[0063] Determine the parameter state of each model parameter in the personalized model;
[0064] The first mask sequence is determined based on the parameter state of each model parameter of the personalized model.
[0065] In one possible design, the determining module is specifically used for:
[0066] The mask corresponding to the model parameters of the valid state is set to a second preset value, and the mask corresponding to the model parameters of the invalid state is set to a first preset value to obtain the first mask sequence.
[0067] In one possible design, the pruning amount is α, where α is an integer greater than or equal to 1; the determining module is specifically used for:
[0068] The effective model parameters in the personalized model are sorted from largest to smallest according to their weights to obtain the effective model parameter sequence;
[0069] The last α effective model parameters in the effective model parameter sequence are determined as the first effective model parameters;
[0070] The mask corresponding to the first effective model parameter in the first mask sequence is set to the first preset value to obtain the second mask sequence.
[0071] In one possible design, the pruning amount is α, where α is an integer greater than or equal to 1; the determining module is specifically used for:
[0072] Obtain the gradient corresponding to each first mask in the second mask sequence, where the value of the first mask is the first preset value;
[0073] Based on the gradient corresponding to each first mask in the second mask sequence, α candidate masks are determined in the first masks of the second mask sequence;
[0074] The α candidate masks in the second mask sequence are set to the second preset value to obtain the target mask sequence.
[0075] In one possible design, the determining module is specifically used for:
[0076] Determine the model parameters corresponding to each first mask in the second mask sequence;
[0077] The gradient of the model parameters corresponding to each first mask is determined as the gradient corresponding to each first mask.
[0078] In one possible design, the determining module is specifically used for:
[0079] Sort the first mask in the second mask sequence according to the order of the corresponding gradient from largest to smallest;
[0080] The first α masks in the sorted first mask are determined as the α candidate masks.
[0081] In one possible design, the model training includes N iterations, where N is an integer greater than 1; the training module is specifically used for:
[0082] Obtain the N intermediate gradients corresponding to each model parameter;
[0083] The training gradient of the personalized model is determined based on the N intermediate gradients corresponding to each model parameter.
[0084] Fourthly, embodiments of this application provide a federated model training apparatus, applied to a central device, comprising:
[0085] The determination module is used to determine the target global model;
[0086] The determining module also determines the target mask sequence corresponding to the participating device;
[0087] The update module is used to update the model parameters of the target global model according to the target mask sequence to obtain a personalized model;
[0088] The sending module is used to send the personalized model to the participating device.
[0089] In one possible design, the determining module is specifically used for:
[0090] If the current training is the first round of training, then the preset model will be determined as the target global model;
[0091] If the current training is the Mth round of training, then multiple training gradients sent by multiple participating devices are obtained, and the target global model is determined based on the (M-1)th global model and the multiple training gradients. The (M-1)th global model is the global model trained in the (M-1)th round, and the target global model is the Mth global model, where M is an integer greater than or equal to 2.
[0092] In one possible design, the determining module is specifically used for:
[0093] Based on the multiple training gradients, the model parameters of the (M-1)th global model are updated to obtain the target global model.
[0094] In one possible design, the determining module is specifically used for:
[0095] If the current training is the first round of training, then the preset mask sequence is determined as the target mask sequence;
[0096] If the current training is the Mth round of training, then determine whether there is a mask sequence sent by the participating device. If yes, then determine the target mask sequence based on the mask sequence sent by the participating device; otherwise, determine the preset mask sequence as the target mask sequence.
[0097] In one possible design, the determining module is specifically used for:
[0098] Obtain the mask sequence last sent by the participating device;
[0099] The mask sequence last sent by the participating device is determined as the target mask sequence.
[0100] Fifthly, embodiments of this application provide a federated model training device, comprising:
[0101] Memory, used to store programs;
[0102] A processor is configured to execute the program stored in the memory, wherein, when the program is executed, the processor is configured to perform the method described in the first aspect and various possible designs of the first aspect, or in the second aspect and various possible designs of the second aspect.
[0103] In a sixth aspect, embodiments of this application provide a computer-readable storage medium including instructions that, when executed on a computer, cause the computer to perform the methods described in the first aspect and various possible designs of the first aspect, or in the second aspect and any of the various possible designs of the second aspect.
[0104] In a seventh aspect, embodiments of this application provide a computer program product, including a computer program, which, when executed by a processor, implements the methods described in the first aspect and various possible designs of the first aspect, or in the second aspect and various possible designs of the second aspect.
[0105] This application provides a federated model training method and apparatus. The method includes: receiving a personalized model sent by a central device, wherein the number of effective model parameters in the personalized model is less than the number of effective model parameters in the global model; training the personalized model to obtain the training gradient of the personalized model, which includes the gradient of each model parameter in the personalized model; determining a target mask sequence based on the gradient of the personalized model, the model parameters of the personalized model, and the pruning amount, the target mask sequence being used by the central device to determine the personalized model in the next round of training; sending the target mask sequence and the training gradient of the personalized model to the central device. By determining the mask sequence corresponding to each participating device and determining the personalized model corresponding to each participating device based on the mask sequence, the participating devices can train the personalized model. Then, the training gradient of the personalized model is sent to the central device so that the central device can aggregate the models, thereby effectively realizing personalized federated learning model training. The personalized processing relies on the mask sequence, eliminating the need to train additional models, thus effectively reducing the computational cost of local training in personalized federated learning. Attached Figure Description
[0106] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0107] Figure 1 A schematic diagram illustrating the principle of federated learning provided for an embodiment of this application;
[0108] Figure 2 A flowchart of the federated model training method provided in the embodiments of this application;
[0109] Figure 3The flowchart of the federated model training method provided in the embodiments of this application Figure 2 ;
[0110] Figure 4 A schematic diagram illustrating the implementation of the first mask sequence provided in an embodiment of this application;
[0111] Figure 5 A schematic diagram illustrating the implementation of determining a valid model parameter sequence provided in an embodiment of this application;
[0112] Figure 6 A schematic diagram illustrating the implementation of determining the second mask sequence provided in an embodiment of this application;
[0113] Figure 7 A schematic diagram illustrating the implementation of determining the target mask sequence provided in an embodiment of this application;
[0114] Figure 8 The flowchart of the federated model training method provided in the embodiments of this application Figure 3 ;
[0115] Figure 9 The flowchart of the federated model training method provided in the embodiments of this application Figure 4 ;
[0116] Figure 10 A schematic diagram illustrating the implementation of the federated model training method provided in this application embodiment;
[0117] Figure 11 A schematic diagram illustrating the implementation of the personalized federated learning algorithm provided in this application embodiment;
[0118] Figure 12 Schematic diagram of the structure of the federated model training device provided in the embodiments of this application Figure 1 ;
[0119] Figure 13 Schematic diagram of the structure of the federated model training device provided in the embodiments of this application Figure 2 ;
[0120] Figure 14 This is a schematic diagram of the hardware structure of the federated model training device provided in an embodiment of this application. Detailed Implementation
[0121] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0122] To better understand the technical solution of this application, the relevant technologies involved in this application will be further described in detail below.
[0123] In recent years, data privacy and security have received increasing attention. Based on this, governments have formulated new data security management regulations, such as the EU General Data Protection Regulation (GDPR).
[0124] Against this backdrop, acquiring labeled data for training traditional machine learning models has become increasingly difficult. Federated learning, as a privacy-preserving distributed training paradigm, has been proposed. Federated learning allows local devices to train models locally using their own data, with a central server then aggregating the models. In this process, local devices do not need to transmit their own data to the central server or other nodes; they only need to transmit the trained model, thereby reducing the risk of data leakage.
[0125] The following is a brief explanation of federated learning. With the continuous development of network technology, technologies such as machine learning and model training based on big data are constantly evolving in many fields. By mining big data, a wealth of valuable information can be obtained. As technology advances, the sources of raw data are becoming increasingly diverse, even involving cross-domain collaborations.
[0126] In some business scenarios, multiple business platforms collect their own business data. This business data is valuable and is usually stored as private information by each business platform. Each platform does not expect to share its raw business data with other platforms. However, in some situations, multiple business platforms desire to perform collaborative computations without disclosing their respective business data to improve processing capabilities. Based on this, methods such as federated machine learning have emerged.
[0127] Federated Machine Learning, also known as Federated Learning, enables collaborative data use and modeling among various parties without requiring the data to leave the local machine, and is gradually becoming a common method in privacy-preserving computing.
[0128] In the process of federated learning, the privacy of participants' data can be protected through parameter exchange under an encrypted mechanism. The data itself is not transmitted, and participants do not need to expose the data they possess to other participants, nor can they infer the data of other participants. Therefore, federated learning can effectively protect user privacy and ensure data security, and can solve the problem of data silos.
[0129] Depending on the dataset, federated learning can be divided into horizontal federated learning, vertical federated learning, and federated transfer learning. Many machine learning algorithms can be used in federated learning, including but not limited to neural networks and random forests.
[0130] Figure 1 This is a schematic diagram illustrating the principle of federated learning, provided as an embodiment of this application. Figure 1 As shown, a server and k client terminals can participate in the federated learning process. During federated learning, the server distributes a global model to each client terminal. Each client terminal trains the global model using its local data, uploads the trained local model to the server, and the server aggregates the models uploaded by each client terminal to obtain an updated global model. This process is repeated until the aggregated global model converges.
[0131] Based on the above method, each client terminal has its own training samples. By using local training samples to train the local model, the model training can be completed without leaving the local area.
[0132] The goal of traditional federated learning is to solve the problem shown in Formula 1 below:
[0133]
[0134] In Formula 1, w represents the model trained by federated learning, K represents the number of devices participating in federated learning training, and k represents the index of a particular device. P represents the empirical loss of all data within a local device. k Let x represent the training data of the k-th device. i y i ) represents a data point from the training data, where x i This represents the characteristic of the data, y i The label representing this data. Function This represents the cross-entropy loss function. `st` indicates a constraint on (subjectto).
[0135] Solving the problem shown in Formula 1 above mainly consists of the following four steps:
[0136] 1. The central server distributes the same global model to multiple local devices.
[0137] 2. The local device uses its own data to train the distributed model and then re-uploads the trained model to the central server.
[0138] 3. The central server aggregates the uploaded models and repeats step 1 for the next iteration of training until the model converges.
[0139] However, the heterogeneity of local training data (i.e., non-independent and identically distributed data distributions) can slow down the model's convergence speed and reduce the accuracy of the final model training. Furthermore, traditional federated learning only trains a single global model for deployment. In cases of high data heterogeneity, a single global model often cannot be applied to different data distributions. Therefore, training multiple deployable models for different data distributions is a direction that can be optimized.
[0140] Therefore, based on traditional federated learning, personalized federated learning is proposed. Personalized federated learning emphasizes that the training objective is to deploy multiple high-precision models onto the local devices participating in the training, enabling the deployed models to improve the inference accuracy of the local devices on their own data. For example, the problem to be solved in personalized federated learning can be constructed in the form shown in Formula 2 below:
[0141]
[0142] Where w * It is the optimal solution to the traditional federated learning problem P1, v k Personalized model parameters deployed on different local devices, F k (v k ) is model v k The empirical loss function is used. The solution form of this method is similar to traditional federated learning. The difference lies in that in each round of local training, the local device not only uses local data to train the distributed global model, but also maintains a personalized model (using v...). k (as parameters), and in local training, the personalized model is trained using local data according to the loss function in P2.
[0143] Based on the above introduction, it can be determined that, in order to address the existing limitations of federated learning, personalized federated learning allows local devices to have different personalized models, rather than sharing the same global model. To achieve personalization, local devices must find a way to effectively exchange global information and incorporate it into their personalized models.
[0144] In one possible implementation, the model can be layered in a personalized manner. For example, the global model layer can be divided into shared layers and personalized layers. For the shared layers, Federated Averaging (FAvg) is used for weight averaging, while for the personalized layers, the model is trained locally only and not exchanged with other devices. In this way, each device has its own personalized model, where the local network layers are fine-tuned using local data, unaffected by models from other devices. Furthermore, a local feature extractor and a shared classifier can be learned.
[0145] Similarly, another representation-based algorithm, FedRep, proposes learning a shared feature extractor and a personalized classifier. This method of personalized federated learning based on model hierarchies is less robust to different model architectures. It requires designing specific personalized and shared layer partitions for each model, which is not conducive to large-scale, widespread application.
[0146] Another idea for personalized federated learning is to use a proximal operator to make the local model as "close" to the global model as possible. For example, a local model and a global model can be maintained simultaneously. Specifically, training the two models can be achieved through two training phases: 1) training a global model and a local model based on the FedAvg concept; 2) fine-tuning the local model on each local device based on the global model trained above. During their fine-tuning phase, a proximal term is applied between the local and global models.
[0147] Another meta-learning-based algorithm applies a similar idea based on proximal terms. The difference lies in treating the global model as the average of all local models; therefore, the global model evolves gradually with local fine-tuning. This personalized federated learning scheme based on proximal operators often requires training multiple models simultaneously, often necessitating additional computational investment for model training.
[0148] Model interpolation is another way to implement personalized federated learning. For example, linear interpolation weights of the (global) model and the local model can be used as the personalized model. In this approach, the three components (global model, local model, and interpolation weights) need to be optimized alternately; that is, while optimizing one, the other two are fixed. Furthermore, some implementations use similar interpolation ideas, the only difference being that their global model is optimized using a generic FedAvg algorithm, so the existence of the local model is not considered during its optimization process. Similarly, implementing personalized federated learning based on interpolation requires additional computation because these methods need to alternately optimize the global and local models.
[0149] Based on the problems in the prior art described above, this application proposes the following technical concept: to provide a personalized federated learning mechanism for multi-model deployment by constructing a personalized sparsity model, which can significantly improve the convergence speed of the model, the amount of local training computation, and the final inference accuracy compared with existing solutions.
[0150] Based on the above introduction, the federated model training method provided in this application will be described in detail below with reference to specific embodiments. It should be understood that the federated model training method in this application involves the actions of two devices: one is the participating device, namely the local device described above, and the other is the central device, namely the central server described above. The implementation of the federated model training method for each of these two devices will be described below.
[0151] For example, we can first combine Figure 2 The method for training the federated model of the participating devices is described below. Figure 2 is a flowchart of the federated model training method provided in the embodiment of this application.
[0152] like Figure 2 As shown, the method includes:
[0153] S201. Receive the personalized model sent by the central device. The number of valid model parameters in the personalized model is less than the number of valid model parameters in the global model.
[0154] Based on the above introduction, it can be determined that in federated learning, the central server sends the model to each participating device so that each participating device can train the model. The following is an example of any participating device.
[0155] In this embodiment, the central server sends personalized models to the participating devices, wherein the number of valid model parameters in the personalized models is less than the number of valid model parameters in the global models.
[0156] This section first introduces the global model and the personalized model. The global model is the model that the central server needs to train. In normal federated learning, the central server distributes the global model to each participating device. It's also understood that the global model contains multiple model parameters. In one possible implementation, this embodiment can, for example, mask the multiple model parameters of the global model. Masking can invalidate some model parameters while keeping others valid. Therefore, after masking the multiple model parameters of the global model, the personalized model can be effectively obtained.
[0157] It is understandable that by masking the model parameters of the global model, some model parameters are rendered invalid, thus resulting in the personalized model. Furthermore, it is understandable that all model parameters in the global model are valid. Therefore, the number of valid model parameters in the personalized model is less than the number of valid model parameters in the global model.
[0158] Based on the above description, the central device in this embodiment can send the personalized model to the participating device after determining the personalized model corresponding to the participating device. Therefore, the participating device in this embodiment can receive the personalized model sent by the central device.
[0159] S202. Train the personalized model to obtain the training gradient of the personalized model. The training gradient includes the gradient of each model parameter in the personalized model.
[0160] After receiving the personalized model, the participating device can train the personalized model to obtain the training gradient of the personalized model. In this embodiment, the training gradient includes the gradient of each model parameter in the personalized model.
[0161] The specific implementation of training personalized models to obtain training gradients can be found in the relevant technical descriptions, and will not be elaborated here.
[0162] S203. Based on the gradient of the personalized model, the model parameters of the personalized model, and the amount of pruning, determine the target mask sequence. The target mask sequence is used by the central device to determine the personalized model in the next round of training.
[0163] It is understood that this embodiment requires personalized processing for participating devices. Therefore, it is necessary to determine a corresponding mask sequence for each participating device, where the mask sequence is used for the mask processing described above.
[0164] The mask sequence is a sequence of 0s and 1s. More specifically, each model parameter is assigned a corresponding 0 or 1 to form the mask sequence. When a 0 is applied to a model parameter, it indicates that the model parameter is invalid; when a 1 is applied to a model parameter, it indicates that the model parameter is valid, thus achieving the masking process described above.
[0165] Therefore, after determining the gradient of the personalized model, the gradient, model parameters, and pruning amount of the personalized model can be pre-processed to determine the target sequence. The target mask sequence is used by the central device to determine the personalized model parameters for the next round of training.
[0166] The pruning amount is used to indicate how many model parameters are set to invalid when determining the target mask sequence. The specific setting of the pruning amount can be selected and set according to actual needs.
[0167] S204. Send the target mask sequence and the training gradient of the personalized model to the central device.
[0168] Once the participating device determines the target mask sequence for the personalized model used in the next round of training, it can send the target mask sequence to the central device so that the central model can determine the personalized model of the participating device in the next round of training.
[0169] Furthermore, participating devices can also send personalized model training gradients to the central device, enabling the central device to aggregate models based on the training gradients sent by each participating device, thereby achieving training of the global model.
[0170] The federated model training method provided in this application includes: receiving a personalized model sent by a central device, wherein the number of effective model parameters in the personalized model is less than the number of effective model parameters in the global model; training the personalized model to obtain the training gradient of the personalized model, which includes the gradient of each model parameter in the personalized model; determining a target mask sequence based on the gradient of the personalized model, the model parameters of the personalized model, and the pruning amount, wherein the target mask sequence is used by the central device to determine the personalized model in the next round of training; sending the target mask sequence and the training gradient of the personalized model to the central device. By determining the mask sequence corresponding to each participating device and determining the personalized model corresponding to each participating device based on the mask sequence, the participating devices can train the personalized model, and then send the training gradient of the personalized model to the central device so that the central device can aggregate the models, thereby effectively realizing the model training of personalized federated learning. The personalized processing relies on the mask sequence and does not require training an additional model, thus effectively reducing the computational cost of local training in personalized federated learning.
[0171] Based on the above embodiments, the following is combined with Figures 3 to 7 The federated model training method provided by the participating devices will be further detailed. Figure 3 The flowchart of the federated model training method provided in the embodiments of this application Figure 2 , Figure 4 This is a schematic diagram illustrating the implementation of the first mask sequence provided in an embodiment of this application. Figure 5 This is a schematic diagram illustrating the implementation of determining a valid model parameter sequence provided in an embodiment of this application. Figure 6This is a schematic diagram illustrating the implementation of determining the second mask sequence provided in an embodiment of this application. Figure 7 This is a schematic diagram illustrating the implementation of determining the target mask sequence provided in an embodiment of this application.
[0172] like Figure 3 As shown, the method includes:
[0173] S301, Receive the personalized model sent by the central device. The number of valid model parameters in the personalized model is less than the number of valid model parameters in the global model.
[0174] The implementation of S301 is similar to that of S201, and will not be repeated here.
[0175] Furthermore, in this embodiment, when the central device sends a personalized model to the participating devices, it may send sparse parameters, for example. To the participating party's equipment.
[0176] Where, m k,t It is the personalized mask corresponding to the current participant device k in the t-th round of training, and w t Let m be the model parameters of the global model in the t-th training round, and ⊙ represents element-wise multiplication at corresponding positions. k,t ⊙w t This means multiplying each model parameter of the global model by its corresponding mask to obtain the coefficient parameters of the current participant device k in the t-th round of training. The sparse parameters are the personalized models sent by the central server to the participating devices.
[0177] S302. Train the personalized model to obtain the training gradient of the personalized model, which includes the gradient of each model parameter in the personalized model.
[0178] When training a personalized model and determining its training gradient, one can use a method such as stochastic gradient descent (SGD) to train the personalized model. SGD is a widely used method for updating neural networks.
[0179] In the implementation of SGD, for example, the personalized model can be trained N times to obtain N intermediate gradients corresponding to each model parameter. Then, the training gradient of the personalized model can be determined based on the N intermediate gradients corresponding to each model parameter.
[0180] After determining the gradients corresponding to each model parameter, the training gradient of the personalized model in this embodiment can be obtained. The specific implementation of determining the training gradient of the personalized model can be referred to the introduction of SGD in related technologies, which will not be repeated here.
[0181] S303. Determine the parameter status of each model parameter in the personalized model.
[0182] Furthermore, in this embodiment, the target mask sequence needs to be determined based on the gradient of the personalized model, the model parameters of the personalized model, and the amount of pruning. Therefore, the specific implementation process for determining the target mask sequence is described below.
[0183] In this embodiment, the personalized mask is a vector that can only take the values 1 or 0. By multiplying this mask with model parameters, multiple personalized models can be obtained for deployment on different local devices. Therefore, in this embodiment, the personalized mask of the participating device is applied to the global model to obtain the personalized model of that participating device. Thus, the number of effective model parameters in the personalized model is less than the number of effective model parameters in the global model.
[0184] More specifically, in personalized models, because some model parameters are masked, some model parameters become invalid, while the remaining model parameters are valid. Furthermore, based on the above, it can be determined that when the central server sends personalized models to participating devices, it may send sparse parameters, for example. The data is then transmitted to the participating device. However, for the participating device, it only obtains the coefficient parameters, not the mask sequence.
[0185] Because the current mask sequence is needed to determine the mask sequence for the next processing step, the parameter state of each model parameter in the personalized model can be determined based on the personalized model.
[0186] For example, you can refer to Figure 4 To understand this, let's assume that the current personalized model exists. Figure 4 The five model parameters shown are a, b, c, d, and e. Parameter a is valid, parameter b is invalid, parameter c is valid, parameter d is invalid, and parameter e is valid.
[0187] It should be noted that in this embodiment, "parameter state valid" means that the parameter is not covered by a mask, and "parameter state invalid" means that the parameter is covered by a mask.
[0188] The above Figure 4This is merely an illustrative introduction to the parameter states. In actual implementation, the parameter states of each model parameter can be selected and set according to actual needs, and this embodiment does not limit this.
[0189] S304. Set the mask corresponding to the model parameters of the valid state to a second preset value, and set the mask corresponding to the model parameters of the invalid state to a first preset value, so as to obtain a first mask sequence.
[0190] After determining the parameter states of each model parameter, the first mask sequence can be determined based on the parameter states of each model parameter.
[0191] Based on the above introduction, it can be determined that the personalized mask is a sequence of 0s and 1s. When the mask is 0, the corresponding model parameter is covered, which means that the model parameter is invalid; and when the mask is 1, the corresponding model parameter is not covered, which means that the model parameter is valid.
[0192] Therefore, the first mask sequence can be determined based on the parameter states of each model parameter. In one possible implementation, for example, the mask corresponding to a valid model parameter state can be set to a second preset value, where the second preset value is a preset value used to indicate that the model parameter state is valid; for example, the second preset value can be 1. Alternatively, the mask corresponding to an invalid model parameter state can be set to a first preset value, where the first preset value is a preset value used to indicate that the model parameter state is invalid; for example, the first preset value can be 0. By setting the first and second preset values, the first mask sequence can be obtained.
[0193] For example, you can refer to Figure 4 To understand this, the parameter states of model parameters a, b, c, d, and e are, in sequence, valid, invalid, valid, invalid, valid. For example, the first preset value can be 0, and the second preset value can be 1. Figure 4 In the example, determining the first mask sequence based on the parameter states of each model parameter in the personalized model can be... Figure 4 The number 10101 shown in the diagram.
[0194] It should also be noted that, in one possible implementation, the first mask sequence in this embodiment can be the initial mask sequence. That is, for the mask sequence set for the first time by the participating device, the initial mask sequence set for the first time is unknown to the participating device. Therefore, the participating device needs to determine the first mask sequence based on the implementation process described above.
[0195] In initializing the mask sequence to obtain the first mask sequence, the ERK (Erdós-Rényi Kernel) method can be used, for example, to calculate the sparse allocation of each layer of the convolutional network to determine the mask for each model parameter, thus obtaining the initialized first mask sequence. Specifically, this allows the number of sparse parameters to vary with the input and output channels. These initialization methods essentially ensure that layers with more parameters have a higher pruning rate. In the federated learning setting of this embodiment, each participating device has the same randomly initialized first mask sequence based on the sparse allocation calculated according to ERK. ERK is a method for initializing the sparsity ratio of a neural network and is widely used in dynamic sparse training techniques.
[0196] Furthermore, in another possible implementation, the first mask sequence in this embodiment may not be the initial mask sequence. That is, for the second and subsequent mask sequences of the participating device, it can be understood that, apart from the first initial mask sequence, the subsequent mask sequences are actually the target mask sequences determined by the participating device itself.
[0197] So when the first mask sequence is not the initial mask sequence, for example, the first mask sequence can be determined in the same way as described above. Alternatively, since the mask sequence is determined by the participating device itself, the participating device may not perform the above operation, but directly obtain the target mask sequence determined in the current round of training.
[0198] S305. Sort the effective model parameters in the personalized model from largest to smallest to obtain the effective model parameter sequence.
[0199] Since it is necessary to determine the target mask sequence for the next round of training, in this embodiment, for example, the model parameters can be pruned first, and then the model parameters can be restored to obtain the target mask sequence for the next round of training.
[0200] When pruning model parameters, for example, the effective model parameters in the personalized model can be sorted in descending order of their weights to obtain a sequence of effective model parameters, where the weights of each effective model parameter in the effective model sequence decrease sequentially.
[0201] The following examples can be combined Figure 5 To understand, refer to Figure 5 Assuming the current personalized model exists Figure 5 The multiple model parameters shown are model parameters a, b, c, d, e, f, g, h, i, and j, and their weights can be found in [reference needed]. Figure 5 .exist Figure 5 In the example, the smaller the weight value, the larger the weight. For example, the weight of model parameter 'a' is 1, which is the largest weight among all model parameters.
[0202] Furthermore, the effective model parameters include model parameters a, c, e, f, g, and j. Therefore, by sorting these effective model parameters from largest to smallest according to their weights, we can obtain... Figure 5 The effective model parameter sequence shown is: a→e→c→g→f→j.
[0203] In actual implementation, the specific implementation of the model parameter weights can be selected and set according to actual needs, and this embodiment does not impose any special restrictions on this.
[0204] S306. The last α effective model parameters in the effective model parameter sequence are determined as the first effective model parameters.
[0205] In this embodiment, for example, a pruning amount α can be set, where α is an integer greater than or equal to 1. After determining the effective model parameter sequence, the weights of each model parameter in the effective model parameter sequence decrease sequentially. Therefore, when implementing parameter pruning, for example, the last α effective model parameters in the effective model parameter sequence can be determined as the first effective model parameters.
[0206] Assuming the pruning amount α equals 3, then in the above... Figure 5 In the example, for instance, the last three valid model parameters in the valid model parameter sequence a→e→c→g→f→j can be identified as the first valid model parameters, namely model parameter g, model parameter f, and model parameter j. In this embodiment, the first valid model parameters are the valid model parameters that require parameter pruning.
[0207] In actual implementation, the specific setting of the pruning amount can be selected according to actual needs, and this embodiment does not impose any restrictions on it.
[0208] S307. Set the mask corresponding to the first effective model parameter in the first mask sequence to the first preset value to obtain the second mask sequence.
[0209] It is understood that the parameter pruning in this embodiment is actually setting the parameter state of the first valid model parameter determined above to be invalid. For example, the mask corresponding to the first valid model parameter in the first mask sequence can be set to a first preset value to obtain the second mask sequence. The second mask sequence is the mask sequence that implements the setting of the parameter state of the first valid model parameter to an invalid state.
[0210] For example, it can be combined Figure 6To understand this, let's assume the above continues. Figure 5 For example, the model parameters of the current personalized model include model parameters a, b, c, d, e, f, g, h, i, j, of which the effective model parameters include a, c, e, f, g, j. Therefore, in the current example, the first mask sequence is as follows: Figure 6 As shown, the first mask sequence is 1010111001.
[0211] Based on the above description, the three first valid model parameters at the end are model parameter g, model parameter f, and model parameter j. The masks corresponding to these three model parameters are set to a first preset value. In this embodiment, the first preset value can be 0, thus obtaining... Figure 6 The second mask sequence shown is 1010100000.
[0212] It is understandable that, compared to the first mask sequence, the second mask sequence essentially prunes the α most effective model parameters with the smallest weights, setting them as invalid model parameters. This can also be expressed using the following formula.
[0213] In the parameter pruning phase, parameters considered unimportant are typically removed. A very intuitive idea is to prune the weights with the smallest absolute values. Therefore, in the parameter pruning phase, this embodiment proposes using the absolute value of the personalized weights of the participating devices (i.e., w) k,t,N (This serves as the standard for pruning.)
[0214] Typically, a model includes multiple network structure layers, such as convolutional layers, pooling layers, etc., and it is certain that each network structure layer includes multiple model parameters. In one possible implementation, for example, a specific network structure layer can be indexed by j, and the parameter pruning implementation can be represented as shown in Equation 4 below:
[0215]
[0216] in, It is the mask of the current participant device k in the j-th network structure layer during the t-th round of training. It is the local weight of the current participant device k in the j-th network structure layer during the t-th round of training, and α t Let represent the amount of pruning in the t-th round of training, where It is a function. This function returns the mask of the j-th pruned network structure layer. Specifically, α t The smallest unpruned weight will be pruned to 0.
[0217] And in one possible implementation, the pruning amount α in this embodiment t For example, the cosine annealing method can be used, which decays as the number of training epochs t progresses.
[0218] S308. Obtain the gradient corresponding to each first mask in the second mask sequence. The value of the first mask is a first preset value.
[0219] The above describes the implementation of parameter pruning. In this embodiment, after pruning and deleting some model parameters during the pruning stage, the same number of pruned model parameters must be restored to ensure that the sparsity (or density) of the trained neural network remains unchanged throughout the training process.
[0220] In one possible implementation, this embodiment can reconstruct the pruned model parameters based on their gradient information. It should be noted that the pruned model parameters described here are actually the model parameters with a mask of 0.
[0221] Therefore, in this embodiment, the gradient corresponding to each first mask in the second mask sequence can be obtained, wherein the value of the first mask is a first preset value.
[0222] The second mask sequence is the mask sequence obtained after parameter pruning as described above. In this embodiment, the first preset value can be 0. In this embodiment, the mask with a mask value of 0 in the second mask sequence can be determined as the first mask, and the model parameters corresponding to each first mask can be determined. The gradient of the model parameters corresponding to each first mask can be determined as the gradient corresponding to each first mask.
[0223] Assuming we continue with the example above, the second mask sequence we obtain could be, for example, 1010100000. We can then define the mask with a value of 0 as the first mask, and define the gradient of the model parameters corresponding to each first mask as the gradient of that first mask. This can be understood by referring to Figure 7, where the masks corresponding to the model parameters b, d, f, g, h, i, and j are all 0. Therefore, the current second mask sequence includes seven first masks, and the gradients of the model parameters b, d, f, g, h, i, and j corresponding to these seven first masks can be defined as the gradients of each first mask.
[0224] S309. Sort the first mask in the second mask sequence according to the order of the corresponding gradient from large to small.
[0225] After determining the gradient corresponding to each of the first masks, for example, the first masks in the second mask can be sorted in descending order of their corresponding gradients.
[0226] S310. Determine the first α masks in the sorted first mask as α candidate masks.
[0227] After sorting the first masks, since the α model parameters were pruned as described above, it is now necessary to restore the α model parameters. Therefore, in this embodiment, the first α masks in the sorted first masks can be determined as candidate masks to obtain α candidate masks.
[0228] Assuming we continue with the example above, the current pruning amount α is 3, and assuming that the first 3 masks in the sorted first mask are the masks corresponding to model parameter b, model parameter i, and model parameter j, then for example, we can determine the masks corresponding to these 3 model parameters as candidate masks, thereby determining 3 candidate masks.
[0229] S311. Set the α candidate masks in the second mask sequence to the second preset value to obtain the target mask sequence.
[0230] Then, the α candidate masks in the second mask sequence can be set to the second preset value to obtain the target mask sequence. In this embodiment, the target mask sequence is used by the central device to determine the personalized model in the next round of training.
[0231] In one possible implementation, the second preset value in this embodiment could be, for example, 1. Continuing with the above example, refer to... Figure 7 The aforementioned α candidate masks are the masks corresponding to model parameter b, model parameter i, and model parameter j. For example, based on the second mask sequence, the masks corresponding to model parameter b, model parameter i, and model parameter j can be set to 1, thereby obtaining the target mask sequence 1110100011. Comparing the target mask sequence with the aforementioned first mask sequence, it can be determined that the mask sequence used for model training in this embodiment always maintains the same sparsity.
[0232] In one possible implementation, the parameter restoration process described above can be represented as, for example, by the following formula five:
[0233] Specifically, we restore the pruned weights by making the following updates to the personalized mask:
[0234]
[0235] in, It is the stochastic gradient of the j-th layer of the neural network. It is a function. It returns a mask. Corresponding to having top-α t The pruned parameters of the gradient will be restored to their unpruned state. Intuitively, in this embodiment, it is assumed that if the gradient of a certain model parameter is large during local training, it should not be pruned to 0, but should be restored to its normal state.
[0236] In this embodiment, the model parameter update requires obtaining an iterative mask for model updates. Based on the above description, it can be determined that this embodiment uses a dynamic sparse training method for iterative mask search. Dynamic sparse training maintains the same sparsity throughout the training process, thereby reducing the training overhead in the aforementioned local training process.
[0237] S312. Send the target mask sequence and the training gradient of the personalized model to the central device.
[0238] After determining the target mask sequence and the training gradients of the personalized model, the participating devices can send these to the central server. The central server then aggregates the training gradients of the personalized model, completing one round of model training. At the end of one round of training, in the next round, the central server can determine the personalized model to be sent to the participating devices based on the target mask sequence. This process is repeated until the preset number of training rounds is reached, resulting in a fully trained model.
[0239] The federated model training method provided in this application determines the target mask sequence corresponding to each participating device. This target mask sequence is used to determine the personalized model of the current participating device. Based on the mask, it can simply and effectively determine the personalized model for each participating device. After each round of training, the participating devices send the training gradients of their personalized models to the central device, allowing the central device to aggregate the gradients from each participating device. This enables effective personalized federated learning based on the personalized masks of each participating device, thereby improving the training accuracy of federated learning. Furthermore, using masks to personalize the model avoids the additional overhead caused by model layering or training additional models. When determining the personalized mask for each participating device, parameter pruning and parameter restoration are performed on the mask from the current round of training to obtain the personalized mask for the next round of training. Therefore, the personalized mask effectively ensures personalized processing for the current participating device, and parameter pruning and parameter restoration effectively maintain the model sparsity throughout the training process, thereby reducing the training overhead in the aforementioned local training process.
[0240] The above describes the implementation process of the federated model training method executed by the participating devices. The following section will introduce the implementation process of the federated model training method executed by the central device, with reference to specific embodiments.
[0241] First, combine Figure 8 To explain, Figure 8 The flowchart of the federated model training method provided in the embodiments of this application Figure 3 .
[0242] like Figure 8 As shown, the method includes:
[0243] S801. Determine the target global model.
[0244] In this embodiment, the central device can determine the target global model, which is the global model that the central device needs to train, or it can be the global model during the training process.
[0245] S802. Determine the target mask sequence corresponding to the participating device.
[0246] Furthermore, the central device can also determine the target mask sequence corresponding to the participating devices. Based on the above description, it can be determined that the participating devices can send target mask sequences to the central device. Therefore, in this embodiment, the central device can determine the target mask sequence corresponding to each participating device based on the target mask sequences sent by each participating device. Specifically, the target mask sequence corresponding to each participating device is personalized.
[0247] S803. Update the model parameters of the global model of the target according to the target mask sequence to obtain the personalized model.
[0248] After determining the target mask sequence for each participating device, the model parameters of the target global model can be updated based on the target mask sequence. This means setting some parameters in the target global model to an invalid state while keeping the remaining parameters valid. After updating the model parameters of the target global model, the personalized model corresponding to each participating device can be obtained.
[0249] S804, Send personalized models to participating devices.
[0250] After the personalized model is determined, it can be sent to the participating device. Then, the participating device can train the model based on the personalized model. The model training process of the participating device can be referred to the description in the above embodiment, and will not be repeated here.
[0251] After a round of model training is completed on a participating device, the target mask sequence and training gradient of the personalized model determined by the participating device for the next round of training can be sent to the central device. This allows the central device to aggregate the training gradients of the personalized models of each participating device, thus completing one round of model training. The central device then performs the next round of model training based on the target mask sequence of each participating device until the final model training is completed.
[0252] The federated model training method provided in this application includes: determining a target global model; determining a target mask sequence corresponding to each participating device; updating the model parameters of the target global model according to the target mask sequence to obtain a personalized model; and sending the personalized model to each participating device. By determining the target mask sequence corresponding to each participating device, it is possible to obtain a personalized model for each participating device based on its personalized mask sequence, and then send the personalized model to the participating devices to achieve model training. The personalization process relies on the mask sequence and does not require training an additional model, thereby effectively reducing the computational cost of local training in personalized federated learning.
[0253] Based on the above embodiments, the following is combined with Figure 9 The training method for the federated model on the central device side is further described in detail. Figure 9 The flowchart of the federated model training method provided in the embodiments of this application Figure 4 .
[0254] like Figure 9 As shown, the method includes:
[0255] S901. If the current training is the first round of training, then the preset model will be determined as the target global model.
[0256] In this embodiment, the central device needs to acquire the target global model, and the model training in this embodiment will undergo multiple rounds. In one possible implementation, if the current training is the first round, then for example, a preset model can be used as the target global model. Here, the preset model is the model to be trained by the central device.
[0257] S902. If the current training is the Mth round of training, then obtain multiple training gradients sent by multiple participating devices, and update the model parameters of the (M-1)th global model according to the multiple training gradients to obtain the target global model.
[0258] In another possible implementation, if the current training is not the first round of training, but the Mth round of training, then the target global model in this embodiment can be the global model in training.
[0259] The central device can, for example, acquire multiple training gradients sent by multiple participating devices, and update the model parameters of the (M-1)th global model based on these gradients, thus determining the target global model to be used in the Mth training round. Here, the (M-1)th global model is the global model trained in the (M-1)th round, and the target global model is the Mth global model, where M is an integer greater than or equal to 2.
[0260] S903. If the current training is the first round of training, then the preset mask sequence will be determined as the target mask sequence.
[0261] In this embodiment, the central device also needs to determine the target mask sequence corresponding to each participating device. The implementation method for determining the target mask sequence varies depending on the number of training rounds. It should be noted that in this embodiment, the central device determines the target mask sequence corresponding to each participating device, and the implementation method for determining the target mask sequence for each participating device is similar. Therefore, the following description uses any one participating device as an example, and the others will not be elaborated upon.
[0262] In one possible implementation, if the current training is the first round of training, a preset mask sequence can be determined as the target mask sequence. The preset mask sequence can be the initial mask sequence described in the above embodiments, that is, the mask sequence set for the first time for the participating device. Therefore, for example, the preset mask sequence can be determined by using the ERK algorithm for mask initialization, thereby determining the target mask sequence in the first round of training.
[0263] S904. If the current training is the Mth round of training, determine whether there is a mask sequence sent by the participating device. If yes, execute S905; otherwise, execute S907.
[0264] In another possible implementation, if the current training is not the first round of training, but the Mth round, the central device can, for example, determine whether a mask sequence has been sent by a participating device. Based on the above embodiments, it can be determined that, except for the mask sequence for the first training round which is determined by the central device, subsequent mask sequences are determined by the participating devices themselves, and after determining the target mask sequence, the participating devices will send the determined target mask sequence to the central device.
[0265] It should also be noted that in one possible implementation, during each round of model training, the central device may select a subset of participating devices from among multiple participating devices to participate in the current round of model training, rather than requiring every participating device to participate. This means that in each round of model training, the central device can select a subset of participating devices and send a personalized model to these selected devices.
[0266] Therefore, it can be determined that each participating device will participate in a portion of the model training rounds. If a participating device participates in model training, it will generate the target mask sequence for the next round during the training process and send it to the central device. Similarly, if a participating device has never participated in model training, even if it is currently in the Mth round of model training, its target mask sequence will still be the initialized preset mask sequence. Therefore, this embodiment needs to determine whether a mask sequence has been sent by a participating device.
[0267] S905, Obtain the mask sequence last sent by the participating device.
[0268] In one possible implementation, if the central device determines that a participating device has sent a mask sequence, it indicates that the participating device has previously participated in model training, and therefore will send its generated target mask sequence to the central device. It can also be determined that the participating device may participate in multiple rounds of model training. In each round of training, the participating device sends a target mask sequence to the central device. When determining the mask sequence to use, the most recently sent mask sequence from the participating device is actually needed. Therefore, the last mask sequence sent by the participating device can be obtained.
[0269] S906. Determine the target mask sequence as the mask sequence last sent by the participating device.
[0270] After obtaining the mask sequence last sent by the participating device, the mask sequence last sent by the participating device can be determined as the target mask sequence.
[0271] To illustrate this, let's consider a specific example. Suppose we're currently in the 5th training round, and participant device A participated in the 2nd and 3rd training rounds. In the 2nd round, participant device A sent a target mask sequence to the central device, and in the 3rd round, participant device B also sent a target mask sequence to the central device. In the current 5th training round, when determining the target mask sequence for each participant device, we can ascertain the existence of a mask sequence sent by that participant device. The central device can then obtain the last mask sequence sent by the participant device, which was sent in the 3rd round, and identify that mask sequence as the target mask sequence.
[0272] S907. Determine the preset mask sequence as the target mask sequence.
[0273] In another possible implementation, if it is determined that there is no mask sequence sent by the participating device, it means that although this is not the first round of training, the participating device has not participated in model training before. Therefore, for the participating device, the target mask sequence is still the initial mask sequence, so the preset mask sequence can be determined as the target mask sequence.
[0274] S908. Update the model parameters of the global model of the target according to the target mask sequence to obtain the personalized model.
[0275] S909, Send personalized models to participating devices.
[0276] The implementation methods of S908 and S909 are similar to those of S803 and S804 mentioned above, and will not be repeated here.
[0277] The federated model training method provided in this application effectively achieves model training based on federated learning by determining a preset model as the target global model during the first round of model training and updating the parameters of the previous round's global model based on the training gradients sent by participating devices in subsequent rounds of model training. Furthermore, when determining the target mask sequence for each participating device, if it is the first time the participating device is participating in model training, the initialized preset mask sequence is determined as the target mask sequence; otherwise, if it is not the first time the participating device is participating in model training, the most recently sent personalized mask sequence is determined as the target mask sequence. This ensures that a personalized mask sequence can be effectively determined each time the participating device participates in model training. Based on the target global model and the personalized mask sequence, a personalized model for the participating device can be determined and then sent to the participating device, thus enabling precise and simple personalized federated learning based on masks.
[0278] The above describes the federated model training method for both participating devices and central devices. Based on the above embodiments, the following will further combine... Figure 10 This application provides a further systematic introduction to the federated model training method. Figure 10 This is a schematic diagram illustrating the implementation of the federated model training method provided in this application embodiment.
[0279] Reference Figure 10 The server is the central device described above, and the local device is the participating device described above. Figure 10 Each round of training will include the following steps:
[0280] 1) The server sparsifies the global model based on a dynamic mask and then distributes the sparse model to local devices.
[0281] 2) After receiving the sparse parameters, the local device uses its own local data to train the model. The training process maintains the same sparsity.
[0282] 3) After training is completed, the local device sends the training gradient and target mask sequence of the trained personalized model to the server so as to re-upload the sparse model parameter updates to the server.
[0283] 4) The server performs aggregate updates on the global model based on the collected sparse updates.
[0284] Repeat the above training process until the preset number of training rounds is reached, thereby completing the model training.
[0285] Furthermore, it should be noted that the federated model training method provided in this application is designed to address the problem of loss minimization in personalized sparse federated learning as follows:
[0286]
[0287] In Formula 6 above, w represents the model trained by federated learning, K represents the number of devices participating in federated learning training, and k represents the index of a particular device. This represents the optimal personalized mask for the k-th local device. The personalized mask is a vector that can only take the values 1 or 0. By multiplying this mask by the model parameters, we can obtain multiple personalized models for deployment on different local devices. This is the local data distribution, where (x, y) represents a data point sampled from the local data distribution, where x represents the feature of this data point and y represents the label of this data point. Finally, It is the expected loss function of the k-th local device (here, the function) (This represents the cross-entropy loss function). The overall loss function is the function that reduces the average expected loss across all local devices.
[0288] For the problem shown in Formula 6 above, this application, based on the idea of data-parallel stochastic gradient descent, can provide, for example, the following model parameter update method:
[0289]
[0290] Where, ξ k,t It is a batch of data, randomly sampled from the data distribution of the local device. η is the learning rate for local training. It is based on the sparse parameters of the optimal personalized mask.
[0291] However, since the optimal mask is unknown, we temporarily assume there is another solution that iteratively finds the optimal personalized mask. Based on this, we can rewrite the above model parameter update scheme:
[0292]
[0293] Where m k,tThis is a personalized mask obtained through iteration. It's worth noting that because some parameters are covered by the mask to be 0, only a portion of the parameters participate in the forward propagation of the neural network during this update process, which reduces the computational complexity of training to some extent. Furthermore, during gradient backpropagation, since the backpropagated gradients are multiplied by the personalized mask vector, only a portion of the gradients need to be backpropagated, further reducing the computational complexity of training. In addition, because the uploaded updates are sparse, this update method can further reduce the communication overhead of aggregation and synchronization.
[0294] In the above update scheme, the global model w t Updates and synchronization must be performed after each SGD step, and this is in the case of full participation. In federated learning, to further reduce communication overhead, we typically employ 1) local SGD, which involves multiple local steps of SGD updates before synchronization; that is, each participating device performs SGD locally to train its personalized model. And 2) partial participation, where only a small subset of local devices perform local training. This is the approach described above, where a subset of participating devices are selected to participate in the model training for each round.
[0295] Based on this, we will rewrite the data-parallel SGD solution in the same way. Let Let the weights before the (τ+1)th step of local SGD be represented. (This means that local weights will synchronize with global weights when τ = 0). In our joint adaptation solution, for τ ∈ {0, ..., N-1}, each local device k ∈ S t Perform the following local SGD on its model:
[0296]
[0297] Where ξ k,t,τ This represents a batch of data sampled at step τ in round t. After local training, the local device transmits the sparse parameter updates to the server for aggregation. Specifically, this process can be described as follows:
[0298]
[0299] Among them, S t It is a set of randomly selected local devices, S = |S t | represents the number of devices that need to be selected in each round.
[0300] Based on the above introduction, the federated model training method in this embodiment can be further summarized as follows: Figure 11 The algorithm flow is shown below. Figure 11This is a schematic diagram illustrating the implementation of the personalized federated learning algorithm provided in this application embodiment.
[0301] like Figure 11 As shown:
[0302] 1. Set hyperparameters: training model learning rate η, number of devices selected per round S, number of local training rounds N, number of global communication rounds T.
[0303] The server's main process performs the following operations:
[0304] 2. Randomly initialize the global model parameters w0;
[0305] 3. Call the mask search algorithm to determine the initial mask sequence m. k,0 ;
[0306] 4. When the training rounds t = 0, 1, ..., T-1, execute:
[0307] 5. Sampling selects S participating devices to enter set S t ;
[0308] 6. For each participating device, if participating device k does not belong to set S t
[0309] 7. Then set the next round mask sequence m for the participating device k. k,t+1 =m k,t ;
[0310] 8. For each participating device, if participating device k belongs to set S t
[0311] 9. Then send sparse parameters. To device k;
[0312] 10. Call the device's main process to obtain the update gradient U k,t and the mask m for the next round k,t+1 ;
[0313] 11. The server-side aggregates and updates the model parameters to obtain the target global model.
[0314] It is understandable that after each round of model training, t is incremented by 1. When t is greater than or equal to T, it can be determined that the model training has ended.
[0315] Afterwards, the server can output the trained sparse personalized parameters m to the participating device k. k,T ⊙w T .
[0316] The above describes the server-side main process. Based on this, it can be determined that the server-side main process can call the device-side main process to obtain the update gradient U. k,t and the mask m for the next round k,t+1 Next, we will introduce the implementation of the device-side main process.
[0317] 12. When the local training rounds τ = 0, 1, ..., N-1, execute:
[0318] 13. Randomly sample a batch of data, denoted as ξ. k,t,τ
[0319] 14. Calculate the gradient of the loss function after propagation:
[0320] 15. Perform the following calculations:
[0321] 16. Calculate the cumulative gradient update after τ steps.
[0322] 15. Set the next mask sequence m using the mask search algorithm Next_Masks(·). k,t+1 =Next_Masks(·);
[0323] 16. Send cumulative gradient update U k,t and the next mask sequence m k,t+1 To the server.
[0324] It is understandable that steps 12-16 above are actually the process of local SGD.
[0325] Furthermore, the mask search algorithm Next_Masks(·) also needs to be introduced:
[0326] 17. Set hyperparameters: initial pruning rate per round α0
[0327] 18. The mask initialization method for the first mask setting is as follows:
[0328] Calculate the sparsity ratio of the neural network using ERK. Randomly initialize the mask m according to the sparsity ratio. k,0 ;
[0329] Return initialization mask m k,0
[0330] 19. Except for the initial mask setting, the mask is determined by searching for the next mask using the algorithm Next_Masks(·), where Next_Masks(·):
[0331] 20. Decrease the amount of pruning per round based on α0;
[0332] 21. Randomly sample a batch of data, denoted as ξ. k,t,N
[0333] 22. Calculate the gradient of the backpropagation loss function:
[0334] 23. When the network structure layer index j belongs to the network structure layer set At that time, execute:
[0335] 24. Some parameters for pruning:
[0336] 25. Restore some parameters:
[0337] 26. Return to the next mask
[0338] The above describes the overall implementation algorithm flow of the federated model training method executed by the central device and participating devices. The specific implementation of each step can be referred to the above embodiment, and will not be repeated here.
[0339] Regarding the above techniques, we present the following convergence conclusion. This convergence conclusion guarantees that the personalized model generated by the method of this application converges to the vicinity of the minimum extreme point, thus proving the effectiveness of the proposed method.
[0340] Under the assumptions of continuity, bounded variance, bounded gradient, and bounded device gradient differences, the learning rate is assumed to be... And all optimal personalized masks satisfy the same sparsity condition, namely The following convergence conclusions are drawn from this application:
[0341]
[0342] Among them, intermediate results
[0343] Intermediate results
[0344]
[0345] Intermediate results
[0346] β represents the number of parameters that need to be sparsified.
[0347] B is a constant in the gradient bounded assumption, i.e.
[0348] G is a constant in the bounded gradient assumption of the device, i.e.
[0349] σ 2 It is a constant in the bounded gradient variance assumption, i.e.
[0350] d represents the dimension of the model parameters.
[0351] k′ and k are the indices for the summation. ∑ k and ∑ k′ Let k' represent the summation over k = 1, 2, ..., K and k' = 1, 2, ..., K.
[0352] dist(m1, m2) represents the Hamming distance between masks m1 and m2.
[0353] Based on the above introduction, it is understandable that traditional federated learning single-model deployment has limitations in improving overall accuracy. The technical solution of this application allows multiple personalized models to be deployed on different local devices, thus overcoming the constraints of single-model deployment.
[0354] Furthermore, personalized federated learning using model hierarchies suffers from poor robustness and generalization. The technical solution in this application does not require personalized model hierarchies; all optimization hyperpartitions are independent of the specific model implementation.
[0355] Furthermore, personalized federated learning using proximal operators and model interpolation requires additional training overhead to train a local model. The technical solution in this application eliminates the need to train a separate local model. Personalization is achieved by training a personalized mask. Compared to training a personalized model, finding the personalized mask requires negligible additional computational overhead.
[0356] Furthermore, regarding existing schemes that use personalized model compression, the technical solution of this application guarantees that the entire training process is based on a sparse model. In contrast, the technical solution of this application 1) can significantly reduce training computational overhead because training is always performed on a sparse model, and 2) real-data experiments demonstrate that it has better performance in terms of convergence speed and model accuracy. 3) it provides an upper bound on the convergence rate of the technical solution of this application in the non-convex case, that is, the model deployed by this scheme can converge to a better point with an upper bound on the gradient.
[0357] In summary, the technical solution of this application is a personalized federated learning training algorithm based on sparse training. It is the first to propose applying dynamic sparse training technology to personalized federated learning training. Specifically, considering the characteristics of sparse training and personalized federated learning, a systematic model parameter update and aggregation scheme is proposed. Specifically, the technical solution of this application proposes for the first time to maintain the same model sparsity during local training in federated learning. During global aggregation, instead of directly aggregating model parameters, it aggregates the updated parameters of the sparse model.
[0358] Furthermore, considering the characteristics of personalized federated learning, this application improves the optimal mask-finding algorithm for sparse training. Specifically, we propose for the first time to apply a global model to warm-start the mask-finding process for sparse training. In addition, this application provides an upper bound on the convergence speed of the sparse personalized algorithm. Through error analysis, we theoretically explain why the algorithm in this application achieves better convergence and inference performance even with highly heterogeneous data.
[0359] Figure 12 Schematic diagram of the structure of the federated model training device provided in the embodiments of this application Figure 1 .like Figure 12 As shown, the device 120 includes: a receiving module 1201, a training module 1202, a determining module 1203, and a sending module 1204.
[0360] The receiving module 1201 is used to receive a personalized model sent by the central device, wherein the number of valid model parameters in the personalized model is less than the number of valid model parameters in the global model.
[0361] The training module 1202 is used to train the personalized model and obtain the training gradient of the personalized model, wherein the training gradient includes the gradient of each model parameter in the personalized model.
[0362] The determination module 1203 is used to determine a target mask sequence based on the gradient of the personalized model, the model parameters of the personalized model, and the pruning amount. The target mask sequence is used by the central device to determine the personalized model in the next round of training.
[0363] The sending module 1204 is used to send the target mask sequence and the training gradient of the personalized model to the central device.
[0364] In one possible design, the determining module 1203 is specifically used for:
[0365] Based on the model parameters of the personalized model, determine the first mask sequence;
[0366] The second mask sequence is obtained by setting a first preset value to a portion of the mask in the first mask sequence according to the pruning amount.
[0367] The target mask sequence is obtained by setting a second preset value to a portion of the mask in the second mask sequence according to the pruning amount.
[0368] In one possible design, the determining module 1203 is specifically used for:
[0369] Determine the parameter state of each model parameter in the personalized model;
[0370] The first mask sequence is determined based on the parameter state of each model parameter of the personalized model.
[0371] In one possible design, the determining module 1203 is specifically used for:
[0372] The mask corresponding to the model parameters of the valid state is set to a second preset value, and the mask corresponding to the model parameters of the invalid state is set to a first preset value to obtain the first mask sequence.
[0373] In one possible design, the pruning amount is α, where α is an integer greater than or equal to 1; the determining module 1203 is specifically used for:
[0374] The effective model parameters in the personalized model are sorted from largest to smallest according to their weights to obtain the effective model parameter sequence;
[0375] The last α effective model parameters in the effective model parameter sequence are determined as the first effective model parameters;
[0376] The mask corresponding to the first effective model parameter in the first mask sequence is set to the first preset value to obtain the second mask sequence.
[0377] In one possible design, the pruning amount is α, where α is an integer greater than or equal to 1; the determining module 1203 is specifically used for:
[0378] Obtain the gradient corresponding to each first mask in the second mask sequence, where the value of the first mask is the first preset value;
[0379] Based on the gradient corresponding to each first mask in the second mask sequence, α candidate masks are determined in the first masks of the second mask sequence;
[0380] The α candidate masks in the second mask sequence are set to the second preset value to obtain the target mask sequence.
[0381] In one possible design, the determining module 1203 is specifically used for:
[0382] Determine the model parameters corresponding to each first mask in the second mask sequence;
[0383] The gradient of the model parameters corresponding to each first mask is determined as the gradient corresponding to each first mask.
[0384] In one possible design, the determining module 1203 is specifically used for:
[0385] Sort the first mask in the second mask sequence according to the order of the corresponding gradient from largest to smallest;
[0386] The first α masks in the sorted first mask are determined as the α candidate masks.
[0387] In one possible design, the model training includes N iterations, where N is an integer greater than 1; the training module 1202 is specifically used for:
[0388] Obtain the N intermediate gradients corresponding to each model parameter;
[0389] The training gradient of the personalized model is determined based on the N intermediate gradients corresponding to each model parameter.
[0390] The apparatus provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effects are similar, and will not be described again here.
[0391] Figure 13 Schematic diagram of the structure of the federated model training device provided in the embodiments of this application Figure 2 As shown in Figure 13, the device 130 includes: a determination module 1301, an update module 1302, and a sending module 1303.
[0392] Module 1301 is used to determine the target global model;
[0393] The determining module 1301 further determines the target mask sequence corresponding to the participating device;
[0394] Update module 1302 is used to update the model parameters of the target global model according to the target mask sequence to obtain a personalized model;
[0395] The sending module 1303 is used to send the personalized model to the participating device.
[0396] In one possible design, the determining module 1301 is specifically used for:
[0397] If the current training is the first round of training, then the preset model will be determined as the target global model;
[0398] If the current training is the Mth round of training, then multiple training gradients sent by multiple participating devices are obtained, and the target global model is determined based on the (M-1)th global model and the multiple training gradients. The (M-1)th global model is the global model trained in the (M-1)th round, and the target global model is the Mth global model, where M is an integer greater than or equal to 2.
[0399] In one possible design, the determining module 1301 is specifically used for:
[0400] Based on the multiple training gradients, the model parameters of the (M-1)th global model are updated to obtain the target global model.
[0401] In one possible design, the determining module 1301 is specifically used for:
[0402] If the current training is the first round of training, then the preset mask sequence is determined as the target mask sequence;
[0403] If the current training is the Mth round of training, then determine whether there is a mask sequence sent by the participating device. If yes, then determine the target mask sequence based on the mask sequence sent by the participating device; otherwise, determine the preset mask sequence as the target mask sequence.
[0404] In one possible design, the determining module 1301 is specifically used for:
[0405] Obtain the mask sequence last sent by the participating device;
[0406] The mask sequence last sent by the participating device is determined as the target mask sequence.
[0407] The apparatus provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effects are similar, and will not be described again here.
[0408] Figure 14 As shown in Figure 14, the hardware structure of the federated model training device 140 provided in this embodiment includes a processor 1401 and a memory 1402; wherein
[0409] Memory 1402 is used to store computer-executed instructions;
[0410] The processor 1401 is used to execute computer execution instructions stored in memory to implement the various steps performed by the federated model training method in the above embodiments. For details, please refer to the relevant descriptions in the foregoing method embodiments.
[0411] Alternatively, the memory 1402 can be either standalone or integrated with the processor 1401.
[0412] When the memory 1402 is set up independently, the federated model training device also includes a bus 1403 for connecting the memory 1402 and the processor 1401.
[0413] This application also provides a computer-readable storage medium storing computer-executable instructions. When a processor executes the computer-executable instructions, it implements the federated model training method executed by the federated model training device described above.
[0414] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or modules, and may be electrical, mechanical, or other forms.
[0415] The integrated modules implemented as software functional modules described above can be stored in a computer-readable storage medium. These software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of this application.
[0416] It should be understood that the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly manifested as execution by a hardware processor, or execution by a combination of hardware and software modules within the processor.
[0417] The memory may include high-speed RAM, and may also include non-volatile memory (NVM), such as at least one disk storage device, and may also be a USB flash drive, external hard drive, read-only memory, disk or optical disc, etc.
[0418] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0419] The aforementioned storage medium can be implemented from any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium can be any available medium accessible to general-purpose or special-purpose computers.
[0420] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0421] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A federated model training method, characterized in that, The method applied to a participant device comprises: receiving a personalized model sent by a center device, the number of effective model parameters of the personalized model being less than the number of effective model parameters of a global model; training the personalized model to obtain a training gradient of the personalized model, the training gradient including gradients of each model parameter in the personalized model; determining a first mask sequence according to model parameters of the personalized model; According to the pruning amount, a part of the first mask sequence is set to a first preset value to obtain a second mask sequence; the pruning amount is , the is an integer greater than or equal to 1; obtaining a gradient corresponding to each first mask in the second mask sequence, the value of the first mask being the first preset value; determining a first mask in the second mask sequence according to a gradient corresponding to each first mask in the second mask sequence candidate masks The second mask sequence The candidate masks are set to a second preset value to obtain a target mask sequence, which is used by the central device to determine the personalized model in the next round of training. sending the target mask sequence and the training gradient of the personalized model to the center device.
2. The method of claim 1, wherein, The method comprises: determining a parameter state of each model parameter of the personalized model; determining the first mask sequence according to the parameter state of each model parameter of the personalized model.
3. The method of claim 2, wherein, The method comprises: setting a mask corresponding to an effective model parameter to a second preset value and setting a mask corresponding to an invalid model parameter to a first preset value to obtain the first mask sequence.
4. The method according to any one of claims 1 to 3, characterized in that, The pruning amount is , the is an integer greater than or equal to 1; The method comprises: sorting effective model parameters in the personalized model according to their weights from large to small to obtain an effective model parameter sequence; The end of the effective model parameter sequence The first effective model parameter is determined as one of the effective model parameters. setting a mask corresponding to the first effective model parameter in the first mask sequence to the first preset value to obtain the second mask sequence.
5. The method of claim 1, wherein, The method comprises: determining a model parameter corresponding to each first mask in the second mask sequence; determining a gradient of the model parameter corresponding to each first mask as a gradient corresponding to each first mask.
6. The method of claim 1, wherein, determining a first mask in the second mask sequence according to a gradient corresponding to each first mask in the second mask sequence a candidate mask, comprising: The method comprises: The first mask in the sorted first mask is determined as the candidate mask. candidate mask.
7. The method of claim 6, wherein, sorting first masks in the second mask sequence in an order of corresponding gradients from large to small; the model training comprises N iterations, N being an integer greater than 1; The method comprises: obtaining N intermediate gradients corresponding to each model parameter; 8. A federated model training method, characterized in that, determining the training gradient of the personalized model according to the N intermediate gradients corresponding to each model parameter. The method applied to a center device comprises: determining a target global model; determining a target mask sequence corresponding to a participant device; The personalized model is sent to the participating device so that the participating device can train the personalized model to obtain the training gradient of the personalized model. The training gradient includes the gradient of each model parameter in the personalized model. The number of effective model parameters in the personalized model is less than the number of effective model parameters in the global model. Based on the model parameters of the personalized model, a first mask sequence is determined. A second mask sequence is obtained by setting a portion of the mask in the first mask sequence to a first preset value according to a pruning amount. The pruning amount is... The The value is an integer greater than or equal to 1; the gradient corresponding to each first mask in the second mask sequence is obtained, and the value of the first mask is the first preset value; based on the gradient corresponding to each first mask in the second mask sequence, the first mask in the second mask sequence is determined. A candidate mask; the second mask sequence contains... The candidate masks are set to a second preset value to obtain the target mask sequence, which is used by the central device to determine the personalized model in the next round of training.
9. The method of claim 8, wherein, updating model parameters of the target global model according to the target mask sequence to obtain a personalized model; The method comprises: if the current training is the first round of training, determining a preset model as the target global model; if the current training is the Mth round of training, obtaining a plurality of training gradients sent by a plurality of participant devices, and determining the target global model according to an (M-1)th global model and the plurality of training gradients, the (M-1)th global model being a global model of the (M-1)th round of training, the target global model being an Mth global model, and M being an integer greater than or equal to 2.
10. The method of claim 9, wherein, According to the M-1th global model and the plurality of training gradients, the target global model is determined, comprising: According to the plurality of training gradients, the model parameters of the M-1th global model are updated to obtain the target global model.
11. The method according to any one of claims 8-10, characterized in that, The target mask sequence corresponding to the participant device is determined, comprising: If the current training is the first round of training, the preset mask sequence is determined as the target mask sequence; If the current training is the Mth round of training, it is judged whether there is a mask sequence sent by the participant device, if yes, the target mask sequence is determined according to the mask sequence sent by the participant device; if no, the preset mask sequence is determined as the target mask sequence.
12. The method of claim 11, wherein, According to the mask sequence sent by the participant device, the target mask sequence is determined, comprising: The mask sequence sent by the participant device last time is acquired; The mask sequence sent by the participant device last time is determined as the target mask sequence.
13. A federated model training apparatus, comprising: Applied to a participant device, the device comprises: A receiving module is configured to receive a personalized model sent by a center device, wherein the number of effective model parameters of the personalized model is less than the number of effective model parameters of a global model; A training module is configured to perform model training on the personalized model to obtain a training gradient of the personalized model, wherein the training gradient includes the gradient of each model parameter in the personalized model; The determining module is used to determine a first mask sequence based on the model parameters of the personalized model; and to set a portion of the mask in the first mask sequence to a first preset value according to the pruning amount, thereby obtaining a second mask sequence; the pruning amount is... The The value is an integer greater than or equal to 1; the gradient corresponding to each first mask in the second mask sequence is obtained, and the value of the first mask is the first preset value; based on the gradient corresponding to each first mask in the second mask sequence, the first mask in the second mask sequence is determined. A candidate mask; the second mask sequence contains... The candidate masks are set to a second preset value to obtain a target mask sequence, which is used by the central device to determine the personalized model in the next round of training. A sending module is configured to send the target mask sequence and the training gradient of the personalized model to the center device.
14. A federated model training apparatus, comprising: Applied to a center device, the device comprises: A determining module is configured to determine a target global model; The determining module is further configured to determine a target mask sequence corresponding to a participant device; An updating module is configured to update the model parameters of the target global model according to the target mask sequence to obtain a personalized model; A sending module is configured to send the personalized model to the participating device, enabling the participating device to train the personalized model and obtain its training gradient. The training gradient includes the gradients of each model parameter in the personalized model. The number of effective model parameters in the personalized model is less than the number of effective model parameters in the global model. Based on the model parameters of the personalized model, a first mask sequence is determined. A second mask sequence is obtained by setting a portion of the mask in the first mask sequence to a first preset value based on a pruning amount. The pruning amount is... The The value is an integer greater than or equal to 1; the gradient corresponding to each first mask in the second mask sequence is obtained, and the value of the first mask is the first preset value; based on the gradient corresponding to each first mask in the second mask sequence, the first mask in the second mask sequence is determined. A candidate mask; the second mask sequence contains... The candidate masks are set to a second preset value to obtain the target mask sequence, which is used by the central device to determine the personalized model in the next round of training.
15. A federated model training device, comprising: Comprise: A memory is configured to store a program; A processor is configured to execute the program stored in the memory, and when the program is executed, the processor is configured to execute the method in any one of claims 1 to 7 or claims 8-12.
16. A computer-readable storage medium, characterized in that, The computer program causes the computer to execute the method in any one of claims 1 to 7 or claims 8-12 when it is run on the computer.
17. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the method in any one of claims 1 to 7 or claims 8-12. The computer program is executed by the processor to implement the method in any one of claims 1 to 7 or claims 8-12.
Citation Information
Patent Citations
Flexible deep learning network model compression method based on channel gradient pruning
CN112396179A
Data security exchange method and device based on knowledge federation and storage medium
CN112560088A
Communication efficient federated learning
CN113837357A