Model training method and apparatus
By using the first threshold sent by the first node to constrain the local model training set loss of the target node in distributed learning, the overfitting problem of the local model of the second node is solved and the generalization ability of the model is improved.
Patent Information
- Application Number
- PCT/CN2025/083153
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-03-28
- Filing Date
- 2025-03-18
- Publication Date
- 2025-10-02
AI Technical Summary
In distributed learning, the local model of the second node is prone to overfitting, resulting in poor generalization ability of the global model.
A first threshold is determined and sent through the first node to constrain the local model training set loss of the target node to be near a constant value, thereby preventing the model from perfectly memorizing the training samples, and using a loss function with the first threshold for training.
It effectively alleviates the problem of model overfitting and improves the generalization ability of the model.
Smart Images

Figure CN2025083153_02102025_PF_FP_ABST
Abstract
Description
Model training method and device
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 28, 2024, with application number 202410384325.8 and application name “A Model Training Method and Device”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of artificial intelligence, and in particular to a model training method and device. Background Art
[0003] Distributed learning, a neural network training method that has gained popularity in recent years, inherently protects user data privacy. In distributed learning, training typically involves a central computing node (i.e., the first node, such as a central server) and multiple distributed computing nodes (i.e., the second node, such as terminal devices). The user's raw data resides locally on the terminal device, and the user collaborates with the central computing node to complete training by uploading neural network parameters. This effectively avoids direct sharing of raw data, thereby protecting the privacy of user data.
[0004] Among them, federated learning is an important framework in distributed learning. In federated learning, one or more second nodes train local models on their local data, and the first node is responsible for aggregating the model parameters of the local models to build a global model. For machine learning, it is not only required that the trained model has a good fitting result for the training data set, but also that the trained model has a good fitting result (generalization ability) for unknown data sets (i.e., validation data sets). However, when the second node has less training data, the local model trained by the second node is prone to overfitting, that is, the local model finally trained fits the local training set too well and has poor generalization ability, which in turn leads to overfitting of the global model aggregated by the first node, and ultimately leads to poor performance of the global model. Summary of the Invention
[0005] This application provides a model training method and device for alleviating the problem of model overfitting and improving the generalization ability of the model.
[0006] In order to achieve the above objectives, this application adopts the following technical solutions.
[0007] In a first aspect, an embodiment of the present application provides a model training method, which is applied to a first node, and the first node is used to train a global model. The method includes: determining a first threshold, which is a threshold of the loss value used to train a local model of a target node, and the training of the local model of the target node depends on the model parameters of the global model; sending the first threshold to the target node.
[0008] In the above method, the training of the local model of the target node depends on the model parameters of the global model, which means that the target node is a node that participates in distributed training together with the first node, that is, the target node refers to a distributed edge device or computing node with local data samples. Since the first threshold here is the threshold of the loss value of the local model used to train the target node, after the first node sends the first threshold to the target node, it can constrain the training set loss of the model (local model, global model) to be near a constant value, so that the training set loss of the model will not drop to 0, and the model will not perfectly memorize the training samples, effectively alleviating the problem of model overfitting and improving the generalization ability of the model.
[0009] In one implementation, the target node is one of K second nodes, where K is a positive integer; determining the first threshold includes: receiving second thresholds respectively fed back by N second nodes, where N is a positive integer less than or equal to K, and the second threshold is used to reflect the loss value of the target local model of the second node, the target local model is the local model when the first condition is satisfied, or the target local model is determined based on the model parameters of the global model when the first condition is satisfied, and the first condition is that the validation set loss of the model no longer decreases; aggregating the N second thresholds to obtain the first threshold.
[0010] In the above implementation, the second threshold is used to reflect the loss value of the target local model of the second node, which means that the second threshold can be the training set loss of the target local model of the second node, or it can be the loss value obtained by scaling the training set loss of the target local model of the second node. The first node, through collaboration with the target node, aggregates the second thresholds of N second nodes to determine a more accurate first threshold, thereby more effectively alleviating the overfitting problem of the local model of the second node and improving the model training effect. This means that the local model of the second node that receives the first threshold can more fully learn the change patterns between the training samples in its local training set, rather than perfectly memorizing the training samples, and thus the training set loss of the subsequent global model of the first node will not drop to 0, thereby effectively alleviating the problem of model overfitting and improving the model generalization ability.
[0011] In one implementation, before receiving the second threshold values fed back by the N second nodes respectively, the method further includes: sending scaling parameters to the K second nodes respectively.
[0012] In the above implementation, the first node sends a scaling parameter to K second nodes, so that the second nodes scale the training set loss of the target local model. In this way, the received second thresholds can be directly summed up later to reduce the computational overhead and improve the efficiency of determining the first threshold.
[0013] In one implementation, the scaling parameter includes at least one of a first parameter or a second parameter, the first parameter being a weight configured for the second node, and the second parameter being a scaling factor set for the second node.
[0014] In the above implementation, the weight here can be used to flexibly represent the importance of each second node relative to the first node. For example, the weight here can be the proportion of the local data set of the second node in the total data set. The second node scales the loss value of its target local model through these two types of scaling parameters, so that the second threshold received by the first node can more accurately reflect the loss value of its target local model.
[0015] In one implementation, before receiving the second threshold value fed back by N second nodes respectively, the method further includes: sending a first instruction to K second nodes respectively, the first instruction being used to instruct the second node to determine the second threshold value based on the initial model parameters sent by the first node, or being used to instruct the second node to determine the second threshold value based on the aggregated model parameters sent by the first node, the initial model parameters being the model parameters of an untrained global model, and the aggregated model parameters being obtained by aggregating the model parameters of the received local models of the second nodes.
[0016] In the above implementation, the first node flexibly determines the way in which the second node determines the second threshold by sending instructions to the second node. For example, if the first instruction is used to instruct the second node to determine the second threshold based on the initial model parameters sent by the first node, the second node can determine the second threshold before the start of distributed training; if the first instruction is used to instruct the second node to determine the second threshold based on the aggregated model parameters sent by the first node, the second node can determine the second threshold during the distributed training process, thereby effectively reducing the computational overhead of the second node.
[0017] In one implementation, the target local model is a local model that satisfies the first condition. Before receiving the second threshold values fed back by the N second nodes respectively, the method further includes: sending a public verification set to the K second nodes.
[0018] In the above implementation, the first node sends a public verification set to the second node, so that the second node determines the verification set loss of the local model based on the public verification set. Since the public verification set has more diverse data and wider coverage than the local verification set of the second node, the second threshold fed back by the public verification set is more accurate and has better effect.
[0019] In one implementation, the target local model is determined based on the model parameters of the global model when the first condition is met. Before receiving the second threshold value fed back by N second nodes, the method further includes: determining the validation set loss of the global model Hi and the validation set loss of the global model Hi-1 respectively, where i is used to represent the number of times the global model is updated, and i is a positive integer; if the validation set loss of the global model Hi is less than the validation set loss of the global model Hi-1, the model parameters of the global model Hi are sent to the K second nodes, and the model parameters of the global model Hi are used to instruct the second nodes to reinitialize the local model.
[0020] In one implementation, the method further includes: if the validation set loss of the global model Hi is greater than or equal to the validation set loss of the global model Hi-1, generating a second instruction; sending the model parameters of the global model Hi-1 and the second instruction to the K second nodes respectively, the second instruction being used to instruct the second nodes to determine a second threshold based on the model parameters of the global model Hi-1.
[0021] In the above implementation, the first node can update the global model using the aggregated model parameters (i.e., the model parameters obtained by aggregating the model parameters of the received local models that meet the second condition). When the validation set loss of the global model Hi is less than the validation set loss of the global model Hi-1, it means that the validation set loss of the global model is still decreasing. At this time, it is necessary to instruct the second node to continue to perform distributed training on its local model. When the validation set loss of the global model Hi is greater than or equal to the validation set loss of the global model Hi-1, it means that the validation set loss of the global model no longer decreases. At this time, the first node can send a second instruction to the target node to instruct the target node to determine the target threshold. During the entire training process, the first node is required to calculate the validation set loss of the global model, while the second node does not need to calculate the validation set loss of its local model, thereby effectively reducing the computational overhead of the second node. In addition, since the second node does not need to calculate the validation set loss, this means that the first node of the embodiment of the present application does not need to send a public validation set to the second node, and the second node does not need to store the public validation set, thereby effectively reducing the transmission overhead and storage overhead of the second node.
[0022] In the second aspect, an embodiment of the present application provides a model training method, which is applied to a target node, and the target node is used to train a local model. The method includes: receiving first information sent by a first node, and the first node is used to train a global model; based on the first information, obtaining a threshold value of a loss value for training the local model of the target node, and determining the obtained threshold value as a first threshold value; based on the first threshold value, training the local model of the target node to obtain a first local model; sending model parameters of the first local model to the first node, and the model parameters of the first local model are used to update the global model.
[0023] In the above method, when training the local model, the target node does not use the traditional loss function for distributed training, but instead uses a loss function with a first threshold for distributed training. This can effectively prevent the training set loss of the local model of the target node from falling close to 0, so that the local model can more fully learn the change rules between the training samples in the local training set, rather than perfectly memorizing the training samples. As a result, the training set loss of the subsequent first node's global model will not fall to 0, thereby effectively alleviating the problem of model overfitting and improving the model generalization ability.
[0024] In one implementation, the target node is one of K second nodes, where K is a positive integer. Before receiving the first information sent by the first node, the method further includes: receiving the second information sent by the first node; determining the target local model based on the second information; determining the target threshold corresponding to the target local model based on the local training set of the target node, where the target threshold is used to reflect the loss value of the target local model of the target node; and sending the target threshold to the first node so that the first node determines the first threshold based on the target threshold.
[0025] In the above implementation, since the target threshold can be used to reflect the loss value of the target local model of the target node, that is, it is obtained by learning the change law between the training samples in its local training set, then when the target node sends the target threshold to the first node, the first threshold determined by the first node is more accurate, so that when the target node subsequently adopts the loss function with the first threshold to train the local model, it can more effectively alleviate the overfitting problem of the local model of the target node and improve the training effect of the local model.
[0026] In one implementation, the second information includes a first instruction, which is used to instruct the target node to determine the target threshold based on the initial model parameters sent by the first node, or to instruct the target node to determine the target threshold based on the aggregated model parameters sent by the first node, where the initial model parameters are model parameters of an untrained global model, and the aggregated model parameters are obtained by aggregating the model parameters of the local model received from the second node.
[0027] In the above implementation, the target node can flexibly determine the target threshold based on the first instruction included in the second information. For example, if the first instruction is used to instruct the target node to determine the target threshold based on the initial model parameters sent by the first node, the target node can determine the target threshold before the start of distributed training; if the first instruction is used to instruct the target node to determine the target threshold based on the aggregated model parameters sent by the first node, the target node can determine the target threshold during the distributed training process, thereby effectively reducing the computational overhead of the target node.
[0028] In one implementation, the second information includes initial model parameters and a first instruction, the first instruction is used to instruct the target node to determine a target threshold based on the initial model parameters; based on the second information, determining the target local model, including: initializing the local model of the target node based on the second information to obtain a local model M0; training the local model M0 based on the local training set of the target node, and determining the local model M0 trained for the jth time as the local model Mj, where j is a positive integer; respectively determining the validation set loss of the local model Mj and the validation set loss of the local model Mj-1; if the validation set loss of the local model Mj is greater than or equal to the validation set loss of the local model Mj-1, then determining the local model Mj-1 as the target local model.
[0029] In the above implementation, the target node determines the target threshold before the start of distributed training through the first instruction sent by the second information, that is, it is necessary to record the validation set loss of the local model trained using the traditional loss function. When the validation set loss of the local model no longer decreases, that is, the validation set loss of the local model Mj is greater than or equal to the validation set loss of the local model Mj-1, the target local model is determined. The target local model is the local model with the minimum validation set loss in the current training process, so that the target threshold subsequently determined based on the target local model can more accurately reflect the loss value of its local model.
[0030] In one implementation, the second information includes a first instruction, which is used to instruct the target node to determine a target threshold based on the aggregated model parameters sent by the first node; based on the second information, determining the target local model, including: configuring the local model of the target node based on the second information; upon receiving the first aggregated model parameters sent by the first node, determining the local model of the target node as the second local model; the first aggregated model parameters are determined by the first node after aggregating the received local model parameters, and the local model parameters are model parameters of the local model in the second node that meets the second condition, and the second condition is a condition for indicating the uploaded model parameters; based on the first aggregated model parameters, the local model of the target node is reinitialized to obtain a third local model; the validation set loss of the second local model and the validation set loss of the third local model are determined respectively; if the validation set loss of the third local model is greater than or equal to the validation set loss of the second local model, the second local model is determined as the target local model.
[0031] In the above implementation, the target node determines the target threshold during the distributed training process through the first instruction sent by the second information, that is, by comparing the current local model of the target node (that is, the second local model) and the local model after reinitializing the local model using the aggregated model parameters (that is, the third local model). The validation set loss is used to determine the local model with the minimum validation set loss (that is, the target local model). During the entire process, the target node does not need to perform additional calculations before the start of distributed training, which can effectively reduce the computational overhead of the target node.
[0032] In one implementation, the second information includes a public validation set, where the public validation set is used to instruct the target node to determine a validation set loss of the local model.
[0033] In the above implementation, the public validation set has more diverse data and wider coverage than the local validation set of the second node. This means that using the public validation set to calculate the validation set loss during distributed training is more effective, and the target threshold fed back by the target node is more accurate.
[0034] In one implementation, determining a target local model based on the second information includes: configuring a local model of the target node based on the second information; receiving feedback information sent by the first node; if the feedback information includes second aggregate model parameters and a second instruction, reinitializing the local model of the target node based on the second aggregate model parameters; the second aggregate model parameters are model parameters of the global model determined by the first node when a first condition is met, and the first condition is that the validation set loss of the model no longer decreases; based on the second instruction, determining the reinitialized local model as the target local model.
[0035] In this implementation, the target node can directly reinitialize its local model based on the second aggregated model sent by the first node and determine the initialized local model as the target local model. During this process, there is no need to receive or store the public validation set sent by the first node, thereby effectively reducing the target node's transmission and storage overhead. Furthermore, the target node does not need to train its local model, which greatly reduces the target node's computational overhead.
[0036] In one implementation, the second information includes a scaling parameter, the scaling parameter includes at least one of a first parameter or a second parameter, the first parameter is a weight configured for the target node, and the second parameter is a scaling factor set for the target node.
[0037] The weight here can be used to accurately represent the importance of the target node relative to the first node. For example, the weight here can be the proportion of the local data set of the second node in the total data set. This weight can be applied to the loss function of the target node for training the local model. Through these two types of scaling parameters, the target node can better train its local model.
[0038] In one implementation, if the second information includes a scaling parameter, the target threshold is a loss value obtained by scaling the training set loss corresponding to the target local model based on the scaling parameter, where the training set loss is the model of the target local model on the local training set.
[0039] In the above implementation, when the second information includes a scaling parameter, the target node can scale the training set loss of the target local model based on the scaling parameter, so that the target threshold determined by the target node can more accurately reflect the loss value of its target local model.
[0040] In a third aspect, an embodiment of the present application provides a model training device, comprising: a processing unit for determining a first threshold, the first threshold being a threshold of a loss value used to train a local model of a target node, and the training of the local model of the target node depends on the model parameters of the global model; and a transceiver unit for sending the first threshold to the target node.
[0041] In one implementation, the target node is one of K second nodes, where K is a positive integer; the processing unit is used to determine the first threshold, including: a transceiver unit, specifically used to receive second thresholds respectively fed back by N second nodes, where N is a positive integer less than or equal to K, and the second threshold is used to reflect the loss value of the target local model of the second node, the target local model is the local model when the first condition is met, or the target local model is determined based on the model parameters of the global model when the first condition is met, and the first condition is that the validation set loss of the model no longer decreases; the processing unit is specifically used to aggregate the N second thresholds to obtain the first threshold.
[0042] In one implementation, the transceiver unit is further configured to send the scaling parameter to each of the K second nodes.
[0043] In one implementation, the scaling parameter includes at least one of a first parameter or a second parameter, the first parameter being a weight configured for the second node, and the second parameter being a scaling factor set for the second node.
[0044] In one implementation, the transceiver unit is further used to send a first instruction to K second nodes respectively, where the first instruction is used to instruct the second node to determine a second threshold based on the initial model parameters sent by the first node, or to instruct the second node to determine the second threshold based on the aggregated model parameters sent by the first node, where the initial model parameters are model parameters of an untrained global model, and the aggregated model parameters are obtained by aggregating the model parameters of the local models received from the second nodes.
[0045] In one implementation, the target local model is a local model that satisfies the first condition, and the transceiver unit is further configured to send a public verification set to the K second nodes.
[0046] In one implementation, the target local model is determined based on the model parameters of the global model when the first condition is met. The processing unit is further used to respectively determine the validation set loss of the global model Hi and the validation set loss of the global model Hi-1, where i is used to represent the number of times the global model is updated, and i is a positive integer. The transceiver unit is further used to send the model parameters of the global model Hi to K second nodes if the validation set loss of the global model Hi is less than the validation set loss of the global model Hi-1. The model parameters of the global model Hi are used to instruct the second nodes to reinitialize the local model.
[0047] In one implementation, the processing unit is further used to generate a second instruction if the validation set loss of the global model Hi is greater than or equal to the validation set loss of the global model Hi-1; the transceiver unit is further used to send the model parameters of the global model Hi-1 and the second instruction to the K second nodes respectively, and the second instruction is used to instruct the second nodes to determine the second threshold based on the model parameters of the global model Hi-1.
[0048] In a fourth aspect, an embodiment of the present application provides a model training device, comprising: a transceiver unit for receiving first information sent by a first node, the first node being used to train a global model; a processing unit for obtaining a threshold value of a loss value for training a local model of a target node based on the first information, and determining the obtained threshold value as a first threshold value; the processing unit is also used to train the local model of the target node based on the first threshold value to obtain a first local model; the transceiver unit is also used to send model parameters of the first local model to the first node, and the model parameters of the first local model are used to update the global model.
[0049] In one implementation, the target node is one of K second nodes, K is a positive integer, and the transceiver unit is further used to receive second information sent by the first node; the processing unit is further used to determine the target local model based on the second information; the processing unit is further used to determine the target threshold corresponding to the target local model based on the local training set of the target node, and the target threshold is used to reflect the loss value of the target local model of the target node; the transceiver unit is further used to send the target threshold to the first node, so that the first node determines the first threshold based on the target threshold.
[0050] In one implementation, the second information includes a first instruction, which is used to instruct the target node to determine the target threshold based on the initial model parameters sent by the first node, or to instruct the target node to determine the target threshold based on the aggregated model parameters sent by the first node, where the initial model parameters are model parameters of an untrained global model, and the aggregated model parameters are obtained by aggregating the model parameters of the local model received from the second node.
[0051] In one implementation, the second information includes initial model parameters and a first instruction, the first instruction is used to instruct the target node to determine a target threshold based on the initial model parameters; the processing unit also determines the target local model based on the second information, including: a processing unit, specifically used to initialize the local model of the target node based on the second information to obtain a local model M0; a processing unit, specifically used to train the local model M0 based on the local training set of the target node, and determine the local model M0 trained for the jth time as the local model Mj, where j is a positive integer; the processing unit, specifically used to determine the validation set loss of the local model Mj and the validation set loss of the local model Mj-1, respectively; the processing unit, specifically used to determine the local model Mj-1 as the target local model if the validation set loss of the local model Mj is greater than or equal to the validation set loss of the local model Mj-1.
[0052] In one implementation, the second information includes a first instruction, which is used to instruct the target node to determine a target threshold based on the aggregated model parameters sent by the first node; the processing unit is also used to determine the target local model based on the second information, including: a processing unit, specifically used to configure the local model of the target node based on the second information; the processing unit is specifically used to determine the local model of the target node as the second local model when receiving the first aggregated model parameters sent by the first node; the first aggregated model parameters are determined by the first node after aggregating the received local model parameters, and the local model parameters are model parameters of the local model in the second node that meets the second condition, and the second condition is a condition for indicating the uploaded model parameters; the processing unit is specifically used to reinitialize the local model of the target node based on the first aggregated model parameters to obtain a third local model; the processing unit is specifically used to determine the validation set loss of the second local model and the validation set loss of the third local model respectively; the processing unit is specifically used to determine the second local model as the target local model if the validation set loss of the third local model is greater than or equal to the validation set loss of the second local model.
[0053] In one implementation, the second information includes a public validation set, where the public validation set is used to instruct the target node to determine a validation set loss of the local model.
[0054] In one implementation, the processing unit is further used to determine the target local model based on the second information, including: a processing unit, specifically used to configure the local model of the target node based on the second information; a transceiver unit, configured to receive feedback information sent by the first node; a processing unit, specifically used to reinitialize the local model of the target node based on the second aggregate model parameters if the feedback information includes second aggregate model parameters and a second instruction; the second aggregate model parameters are model parameters of the global model determined by the first node when the first condition is met, and the first condition is that the validation set loss of the model no longer decreases; the processing unit, specifically used to determine the reinitialized local model as the target local model based on the second instruction.
[0055] In one implementation, the second information includes a scaling parameter, the scaling parameter includes at least one of a first parameter or a second parameter, the first parameter is a weight configured for the target node, and the second parameter is a scaling factor set for the target node.
[0056] In one implementation, if the second information includes a scaling parameter, the target threshold is a loss value obtained by scaling the training set loss corresponding to the target local model based on the scaling parameter, where the training set loss is the model of the target local model on the local training set.
[0057] In a fifth aspect, an embodiment of the present application provides a model training system, which includes various modules for executing the model training method in the first aspect or any possible implementation of the first aspect, and the second aspect or any possible implementation of the second aspect.
[0058] The model training system has the function of implementing the methods of the first and second aspects above. The functions can be implemented through hardware or through hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions. In one possible design, the model training system includes: a first node and K second nodes; the first node determines a first threshold, which is a threshold for the loss value of the local model used to uniformly train each second node, and the training of the local model of each second node depends on the model parameters of the global model of the first node. The first node determines first information based on the first threshold, and the first node sends the first information to the K second nodes respectively, and the K second nodes include a target node; when the target node receives the first information, it obtains the threshold for the loss value of the local model used to train the target node, and determines the obtained threshold as the first threshold; the target node trains the local model of the target node based on the first threshold to obtain a first local model corresponding to the target node, and the target node sends the model parameters of the first local model to the first node; when the first node receives the model parameters sent by M second nodes respectively, it aggregates the M model parameters to obtain aggregated model parameters, and the aggregated model parameters are used to update the global model, where M is a positive integer less than or equal to K.
[0059] In a sixth aspect, an embodiment of the present application provides a model training device, comprising a memory and a processor, the memory being used to store computer instructions, and the processor being used to call and execute computer instructions from the memory to implement a method as in the first aspect or any one of the implementations of the first aspect, or to implement a method as in the second aspect or any one of the implementations of the second aspect.
[0060] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, which stores instructions. When the instructions are executed on a processor, the method of the first aspect or any one of the implementation methods of the first aspect is implemented, or the method of the second aspect or any one of the implementation methods of the second aspect is implemented.
[0061] In an eighth aspect, an embodiment of the present application provides a computer program product, which includes instructions. When the instructions are executed on a processor, the computer program product is used to implement a method as in the first aspect or any one of the implementations of the first aspect, or to implement a method as in the second aspect or any one of the implementations of the second aspect.
[0062] The technical effects produced by any implementation method in the above-mentioned second to eighth aspects and each aspect can refer to the above-mentioned first aspect and the corresponding implementation method in the first aspect, and the repetitions will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] FIG1 is a schematic diagram of a network architecture provided in an embodiment of the present application;
[0064] FIG2 is a schematic diagram of a system framework for performing distributed training provided in an embodiment of the present application;
[0065] FIG3 is an interactive diagram of a method for model training provided in an embodiment of the present application;
[0066] FIG4 is a second interactive diagram of a method for model training provided in an embodiment of the present application;
[0067] FIG5 is an interactive diagram of a method for model training provided in an embodiment of the present application;
[0068] FIG6 is a schematic diagram of a method for model training provided in an embodiment of the present application;
[0069] FIG7 is a second schematic diagram of a method for model training provided in an embodiment of the present application;
[0070] FIG8 is a structural diagram of a model training device according to an embodiment of the present application;
[0071] FIG9 is a second structural diagram of a model training device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0072] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. In order to facilitate the clear description of the technical solutions in the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish between identical or similar items with substantially the same functions and effects. Those skilled in the art will understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit differences. At the same time, in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or design solutions. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete way for easy understanding.
[0073] To facilitate understanding of the technical solutions provided by the embodiments of the present application, the following terms related to artificial intelligence involved in the embodiments of the present application are first introduced:
[0074] 1. Artificial Intelligence (AI)
[0075] Artificial intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. AI also involves studying the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.
[0076] Artificial intelligence (AI) technology is a comprehensive discipline encompassing a wide range of fields, encompassing both hardware and software technologies. Foundational AI technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, big data processing, pre-trained models, operating / interaction systems, and mechatronics. Pre-trained models, also known as large models or basic models, can be fine-tuned and widely applied to downstream tasks across various AI disciplines. AI software technologies primarily encompass computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0077] 2. Machine Learning (ML)
[0078] Machine learning is a multidisciplinary field, encompassing probability theory, statistics, approximation theory, convex analysis, and algorithmic complexity theory. It specifically studies how computers simulate or implement human learning behaviors to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is at the core of artificial intelligence and the fundamental path to computer intelligence. Its applications span all areas of AI, including data mining, data classification, computer vision, natural language processing, biometric recognition, search engines, medical diagnostics, credit card fraud detection, securities market analysis, DNA sequencing, speech and handwriting recognition, strategic gaming, and robotics. Deep neural networks (DNNs) are a specific implementation of machine learning. According to the universal approximation theorem, neural networks can theoretically approximate any continuous function, enabling them to learn arbitrary mappings. Based on their construction method, DNNs can be categorized as feedforward neural networks (FNNs), convolutional neural networks (CNNs), and recurrent neural networks (RNNs).
[0079] 3. Centralized training
[0080] The machine learning model and training data are centralized on a single compute node, which performs all training steps.
[0081] 4. Distributed Training
[0082] Distributed training, also known as distributed learning, refers to algorithms and systems that utilize multiple computing nodes for machine learning or deep learning. For ease of explanation, in this embodiment of the application, the central computing node in distributed machine learning may be referred to as the first node, and the distributed edge devices or computing nodes with local data samples may be referred to as the second node.
[0083] 5. Federated Learning
[0084] Federated learning integrates computing and communication technologies to create a simple and effective distributed training framework. The data distribution of each second node in federated learning can differ. The training process of federated learning is as follows: First, at the beginning of training, the first node sends the initial model parameters of the global model to all second nodes. Each second node then trains the local model for multiple rounds using local training data. A round refers to a complete pass through all available local data. The second node then sends the model parameters of the trained local model to the first node, allowing the first node to aggregate the received model parameters to obtain aggregated model parameters. After aggregation is complete, the first node can update the global model based on the aggregated model parameters. If the updated global model converges, training ends. If the updated global model does not converge, the aggregated model parameters are shared with all second nodes, allowing them to continue training the local model based on the aggregated model parameters.
[0085] To facilitate understanding of the technical solutions provided by the embodiments of the present application, a brief introduction to the relevant technologies of the embodiments of the present application is given.
[0086] In current technical solutions, distributed machine learning aims to achieve high-performance machine learning models during the communication between the second node and the first node. Federated learning, as an important distributed learning framework, enables training of machine learning models while protecting the data privacy of the second node. To achieve high-performance machine learning models, deep neural networks are often used for training, and regularization methods are added to the local training process of the second node to combat overfitting.
[0087] 1) L2 regularization, also known as weight decay regularization: adding an additional loss term to the loss function To reduce overfitting;
[0088] 2) Dropout regularization: randomly dropping some neurons during training to reduce overfitting;
[0089] 3) Batch Normalization: Normalize the output of one or more layers of a neural network;
[0090] The second node can use the above regularization method to perform local training. After local training is complete, the second node sends the trained model parameters to the first node. The first node aggregates the model parameters of the second node and feeds the aggregated model parameters back to the second node until the first node's global model converges. However, because the local model of the second node is usually large and the amount of local data is small, even if traditional regularization methods are added to the local training of the second node, the training loss will inevitably drop rapidly to near zero. In other words, the neural network perfectly memorizes all local training samples, resulting in overfitting of the local model and, in turn, overfitting of the global model. Therefore, how to overcome the overfitting caused by the model loss dropping to near zero is an urgent problem that needs to be solved.
[0091] To solve the above problems, an embodiment of the present application provides a new model training method, in which a first node used to train a global model can determine a first threshold and send the first threshold to a target node. The first threshold is a threshold of the loss value of the local model used to train the target node. The training of the local model of the target node depends on the model parameters of the global model, that is, the target node here can be a distributed edge device or computing node with local data, that is, any second node that participates in the distributed training together with the first node.
[0092] In an embodiment of the present application, the training of the local model of the target node depends on the model parameters of the global model, which means that the target node is a node that participates in the distributed training together with the first node, that is, the target node refers to a distributed edge device or computing node with a local data sample. Since the first threshold here is the threshold of the loss value of the local model used to train the target node, after the first node sends the first threshold to the target node, the training set loss of the model (local model, global model) can be constrained to be near a constant value, so that the training set loss of the model will not drop to 0, and the model will not perfectly memorize the training samples, which effectively alleviates the problem of model overfitting and improves the generalization ability of the model.
[0093] For ease of distinction, in the embodiments of the present application, the information associated with the first threshold sent by the central node may be referred to as the first information, and the information containing model configuration information sent by the central node before the start of distributed training may be referred to as the second information. The first information may be the first threshold, or information obtained by quantizing the first threshold (e.g., an index number), which will not be limited here.
[0094] The initial local model, the first local model, the second local model, the third local model, the fourth local model, and the target local model in the embodiments of the present application all refer to the local models corresponding to the same second node at different times, that is, the network structures of these models are the same, but the model parameters are different. Among them, the initial local model refers to the local model obtained after initializing the local model of the target node based on the second information; the first local model refers to the local model trained using the loss function with the first threshold, and the trained local model meets the second condition; the second local model refers to the current local model of the target node when it receives the first aggregated model parameters (the model parameters of the local model of the second node received are aggregated by the first node); the third local model refers to the local model obtained after the target node reinitializes the local model based on the first aggregated model parameters; the target local model refers to the local model when the first condition is met, or the target local model is determined based on the model parameters of the global model when the first condition is met.
[0095] The first condition refers to the model's validation set loss no longer decreasing. The validation set loss refers to the model loss on the public validation set / local validation set. The second condition here is a condition for indicating the upload of model parameters. For example, the second condition can be that the number of updates t is a multiple of a constant T, where T is any positive integer, such as 10. The second condition can also be a model-related condition, for example, the difference between the updated model and the model parameters fed back by the central node is greater than a pre-set threshold.
[0096] The following describes the network architecture of the model training method provided by the embodiment of the present application:
[0097] The network architecture can be applied to a distributed AI training system, which may include a first node and K second nodes, where K is a positive integer, wherein each of the K second nodes can be connected to the first node through a network connection, so that each second node can exchange data with the first node through the network connection. The network connection here does not limit the connection method, and can be directly or indirectly connected through a wired communication method, directly or indirectly connected through a wireless communication method, or through other methods, which are not limited in this application.
[0098] To facilitate understanding of the network architecture of the distributed AI training system, please refer to Figure 1, which is a structural diagram of a network architecture provided in an embodiment of the present application. As shown in Figure 1, the network architecture includes a network device 100 and a terminal device cluster. The network device 100 refers to an entity on the network side for transmitting or receiving signals, such as a base station or a server having a network connection relationship with a base station. When the network device 100 is a server, the server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. Among them, the embodiment of the present application will not limit the number of servers. The network device 100 generally includes a sending module, a receiving module, a computing and processing module, a storage module, and the like.
[0099] The terminal device cluster may include one or more terminal devices, and the number of terminal devices is not limited here. The terminal device refers to an entity on the user side for receiving or transmitting signals, and generally includes a transmitting module, a receiving module, a computing and processing module, and a storage module. As shown in Figure 1, the number of terminal devices in the terminal device cluster can be four, for example, and specifically may include terminal device 111, terminal device 112, terminal device 113, and terminal device 114. As shown in Figure 1, terminal device 111, terminal device 112, terminal device 113, and terminal device 114 can each establish a network connection with the network device 100, so that each terminal device can exchange data with the network device 100 through the network connection. The network connection here does not limit the connection method and can be directly or indirectly connected via wired communication, directly or indirectly connected via wireless communication, or through other methods, which are not limited in this application. Each terminal device in the terminal device cluster may include: a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, a car terminal, a smart TV, and other smart terminals with data processing capabilities.
[0100] In one possible implementation, network device 100 can be the first node for training the global model, and each terminal device in the terminal device cluster can be the second node participating in distributed training. That is, the training of the local model of each terminal device depends on the model parameters of the global model. In this case, network device 100, terminal device 111, terminal device 112, terminal device 113, and terminal device 114 can form a distributed AI training system.
[0101] It is understood that the network device 100 and the above-mentioned terminal device may further include a processing module based on a machine learning model, such as a neural network module. The processing module based on the machine learning model can implement feature extraction, feature analysis, classification, and regression based on the machine learning algorithm. The machine learning model trained by the entire distributed AI training system can be for non-wireless communication services, such as image recognition and natural language processing, or for wireless communication services, such as beam selection based on environmental information.
[0102] For network device 100, the processing module based on the machine learning model can be located in network device 100 or separated from network device 100, and this is not limited here. For terminal devices (such as terminal device 111), the processing module based on the machine learning model can be located in terminal device 111 or separated from terminal device 111, and the processing module based on the machine learning model can access user local data.
[0103] It should be understood that in traditional distributed learning, the first node and the second node cooperate to minimize the loss function L(w) of the global model of the first node. That is, the optimization problem solved traditionally can be referred to in the following formula (1):
[0104] Where K is used to represent the number of second nodes; p k It is used to represent the weight configured by the first node for the kth second node. The weight is used to characterize the importance of the kth second node relative to the first node. The weight here can be the ratio of the amount of data in the local data set of the kth second node to the total amount of data (for example, ), it can also be determined based on the available computing resources of the k-th second node, or based on the number of model training times of the k-th second node. The method of determining the weight is not limited here; L k (w) loss function for representing the local model of the k-th second node; D k It is used to represent the local data set of the k-th second node; w is used to represent the model parameters.
[0105] In order to avoid the problem of the model loss value dropping to 0, which causes the model to perfectly memorize the training samples, the embodiment of the present application proposes a method to limit the size of the AI model loss value, that is, constraining the training loss L(w) to be near a constant value (represented by b), thereby ensuring that the training loss does not drop to 0. Specifically, the optimization problem shown in the above formula (1) can be modified, and the modified optimization problem can be referred to the following formula (2):
[0106] Among them, b>0 is called the first threshold (that is, the threshold of the loss value used to train the local model of the second node).
[0107] Analyzing the above formula (2), we can see that:
[0108] From formula (3), we can see that the second node optimization|(p k L k (w; D k )-p k b)|+p k b, can be minimized and minimize The purpose of To optimize, it is necessary to determine the threshold b.
[0109] Based on this, the embodiment of the present application can use any one of the K second nodes as a target node to illustrate the method for mitigating distributed AI overfitting involved in the embodiment of the present application. Specifically, the first node can determine a first threshold and then send the first threshold to the target node. The first threshold can be a threshold of the loss value used to train the local model of the target node.
[0110] Specifically, when the second node trains the local model, the loss function with the first threshold used can be specifically referred to in the following formulas (4)-(5):
[0111] The first threshold may be determined independently by the first node, or may be determined jointly by the first node and a plurality of second nodes in collaboration. The method for determining the first threshold is not limited here.
[0112] For example, the first threshold is obtained by aggregating the second threshold received from the first node. The second threshold here is used to reflect the loss value of the target local model of the second node. That is, the second threshold can be the model loss of the target local model of the second node during local training (i.e., the training set loss of the target local model), or can be the loss value obtained by scaling the training set loss of the target local model of the second node.
[0113] The data transmitted between the first node and the second node can be carried on a physical channel, for example, a physical downlink control channel (PDCCH), a physical downlink shared channel (PDSCH), a physical uplink shared channel (PUSCH) or a physical uplink control channel (PUCCH), and for example, a physical sidelink control channel (PSCCH) or a physical sidelink shared channel (PSSCH).
[0114] The data sent by the second node to the first node may include node characteristic information (for example, the number of local data sets, node identification, etc.), model parameters of the local model, feedback amount containing its status information (for example, available computing resources, second threshold), etc.
[0115] The data sent by the first node to the second node may include model configuration information, model training information, a public verification set, a threshold determination strategy (which may include scaling parameters), instructions for instructing the second node to determine a second threshold, the first threshold, model parameters of the global model, etc.
[0116] The model configuration information can be used to instruct the second node to configure the local model. The model configuration information includes but is not limited to: the type of the second node machine learning model (for example, DNN, CNN, Transformer, etc.), structural information (for example, the number of hidden layers of DNN, the number of neurons in each layer or part of the layer and the activation function), and initial model parameters. Among them, the type and structural data of the machine learning model sent can be reflected in the form of configuration text, or it can be a code script that can compile the corresponding machine learning model. The model parameters are generated by the first node through a certain strategy, including but not limited to random generation, pre-training generation, or acquisition from other third-party entities. Among them, the model configuration information received by each computing node can be the same or different, and it will not be limited here.
[0117] For example, when the global model trained by the first node (for example, including two task branches of image recognition and image cutting) is of a multi-task type, the central node can select a part of the K second nodes and send the model configuration information associated with the image recognition task branch (for example, model configuration information 1) to them respectively, so that the second nodes that receive the model configuration information 1 are configured with the neural network model associated with the image recognition task branch; and send the model configuration information associated with the image cutting task branch (for example, model configuration information 2) to the remaining second nodes respectively, so that the second nodes that receive the model configuration information 2 are configured with the neural network model associated with the image cutting task branch. Of course, when the global model trained by the first node is of a single-task type, the first node can also send model configuration information that matches its computing power to different second nodes.
[0118] The model training information includes the optimizer used by the second node to perform gradient updates, a regularization penalty term (e.g., an L2 penalty term), an initial learning rate, a gradient update batch size, and one or more data augmentation methods. The optimizer may include stochastic gradient descent (SGD), root mean square propagation (RMSprop), and adaptive momentum estimation (Adam).
[0119] The threshold determination strategy is used to instruct the second node to determine the second threshold. Taking node k as an example, the specific method for node k to determine the second threshold can refer to any one of the following formulas (6)-(9): k =a k (6) b k =a k ×τ k (7) b k =a k ×p k (8) b k =a k ×τ k ×p k (9)
[0120] Among them, a k It is used to represent the training set loss of the target local model determined by a second node (for example, node k), that is, the model loss of the target local model of node k on its local training set; τ k It is used to indicate that the first node is a pre-set scaling factor for node k, τ k ∈(0,1);pk The weight configured by the first node for node k is used to represent the importance of node k relative to the first node. The weight here can be determined based on the available computing resources of node k, or based on the number of model training times of node k, or the ratio of the data volume of the local data set of node k to the total data volume of the K second nodes (for example, ), the method of determining the weight will not be limited here.
[0121] The instruction for instructing the second node to determine the second threshold may include a first instruction and a second instruction. The first instruction may be used to instruct the second node to determine the second threshold based on initial model parameters sent by the first node, or may be used to instruct the second node to determine the second threshold based on aggregated model parameters sent by the first node, where the initial model parameters are model parameters of an untrained global model, and the aggregated model parameters are obtained by aggregating model parameters of the local model received from the second node. The first instruction may be sent along with model configuration information, model training information, etc.
[0122] The second instruction here is an instruction generated by the first node when it determines that the global model meets the first condition. The second instruction can be sent together with the model parameters of the global model that meets the first condition.
[0123] To facilitate understanding of the implementation method of the first node and multiple second nodes collaboratively determining the first threshold, further, please refer to Figure 2, which is a schematic diagram of a system framework for distributed training provided in an embodiment of the present application. As shown in Figure 2, the distributed AI training system provided in an embodiment of the present application may include a central node (i.e., a first node) for training a global model and K distributed computing nodes (i.e., second nodes), and these K second nodes may specifically include node 1, node 2, ..., node K.
[0124] As shown in FIG2 , the embodiment of the present application can use the global model trained by the central node to replace the neural network model f(·,w c ), the local model H1 trained by node 1 is represented by the neural network model f(·,w1), and so on, the local model H trained by node K is represented by K Using the neural network model f(·,w K ) to indicate.
[0125] The distributed AI training system may include the following steps:
[0126] 1) The central node first needs to send the following second information to each of the K second nodes: model configuration information (including initial model parameters), model training information, and threshold determination strategy. Optionally, the central node can also send the first instruction or public verification set to the K second nodes.
[0127] 2) After receiving the second information sent by the central node, each second node can determine its target local model based on the second information, and then determine the second threshold corresponding to the target local model based on the threshold determination strategy (i.e., the loss value of the target local model of the second node), and feedback the second threshold to the central node. For example, taking node 1 as an example, if the second information received by node 1 includes a first instruction, and the first instruction is used to instruct node 1 to determine the second threshold based on the initial model parameters, then after receiving the second information, node 1 can initialize the local model H1 of node 1 to obtain the initial local model, and then train the initial local model based on the local training set D1 until the validation set loss of the trained initial local model no longer decreases. Node 1 can determine the local model H1 with the minimum validation set loss during the training process as the target local model, and then determine the second threshold corresponding to the target local model of node 1 based on the threshold determination strategy (for example, the threshold b1 shown in Figure 2), and send the threshold b1 to the central node. Similarly, node K can refer to the above-mentioned threshold determination method of node 1 to determine the second threshold corresponding to the target local model of node K (for example, the threshold b1 shown in Figure 2). K ), which will not be described in detail here.
[0128] 3) The central node may receive the second thresholds fed back by N second nodes respectively, and then aggregate the received second thresholds to obtain a first threshold (for example, threshold b shown in FIG2 ), where N is a positive integer less than or equal to K.
[0129] 4) The central node may send the threshold value b to each of the K second nodes respectively.
[0130] 5) After receiving the threshold value b, each second node can refer to the above formula (4) or formula (5) to train its local model until the trained local model meets the second condition, and determine the local model that meets the second condition as the first local model. As shown in Figure 2, the model parameter W1 is the model parameter of the first local model of node 1, and so on. K are the model parameters of the first local model of node K.
[0131] 6) Each second node sends the model parameters of its first local model to the central node.
[0132] 7) The central node aggregates the model parameters of the received local model to obtain the aggregated model parameters (for example, the model parameters W shown in FIG2 c ), and then the global model of the central node can be updated based on the aggregate model parameters until the updated global model converges.
[0133] 8) If the updated global model has not converged, send the model parameters W to the K second nodes respectively. c .
[0134] 9) Each second node receives the model parameter W c Afterwards, we can use the model parameters W c , reinitialize its local model and continue with step 5 above.
[0135] It can be seen that the embodiment of the present application realizes a model training method for slowing down the overfitting of distributed AI through the collaboration between the central node and multiple second nodes. By using the first threshold to train the local model of the target node (for example, using a loss function with a first threshold to perform local training), the model loss value of the AI model can be limited to effectively avoid the problem of the loss value dropping to 0, which causes the model to perfectly memorize the training samples.
[0136] Further, please refer to Figure 3, which is an interactive diagram of a method for model training provided by an embodiment of the present application. As shown in Figure 3, the method can be jointly executed by a first node and a target node, wherein the first node can be a computing node for training a global model, and the target node can be a distributed edge device or computing node with local data samples. The method can include at least steps S301-S316:
[0137] Step S301: The first node sends second information to the target node.
[0138] Among them, the second information here may include model configuration information, model training information, a threshold determination strategy and a first instruction, and the first instruction is used to instruct the target node to determine the target threshold based on the initial model parameters sent by the first node. The threshold determination strategy can be any one of the above formulas (6)-(9), which will not be limited here.
[0139] It can be understood that if the threshold determination strategy is the strategy shown in the above formula (6), the first node does not need to send the scaling parameter to the target node. In this way, when the target node determines the target local model, it can directly use the training set loss of the target local model as the second threshold, which not only reduces the computational overhead of the target node, but also improves the feedback efficiency, thereby improving the efficiency of the first node in determining the first threshold. If the threshold determination strategy is any of the threshold determination strategies shown in the above formulas (7)-(9), this means that the first node needs to send the scaling parameter to the second node so that the second node can subsequently reflect the loss value of its target local model more accurately based on the scaling parameter. The scaling parameter here can include at least one of the first parameter or the second parameter, wherein the first parameter here is the weight configured for the second node, and the second parameter is the scaling factor set for the second node.
[0140] Step S302: The target node initializes the local model of the target node based on the second information to obtain an initial local model.
[0141] The initial local model here can be represented by the local model M0.
[0142] Step S303: The target node trains the local model of the target node based on the local training set.
[0143] The target node can train the local model M0 based on the local training set, and determine the local model M0 trained for the jth time as the local model M j For example, during the jth iteration, the target node can randomly select a batch of training data from the local training set. Among them, x ) Used to represent the i-th training sample, y i It is used to represent the label corresponding to the i-th training sample, and B is used to represent the training data S randomly selected this time. j Then, the target node can take the training data S j Each training sample in is input to the local model M j-1 , by the local model M j-1 Output the predicted value corresponding to each training sample Furthermore, the target node can be based on the model loss function Determine the local model M of the target node j-1 The training set loss and the gradient of the model loss function with respect to the parameter w are calculated: Then, the target node can adjust the mode based on the parameter w j =w j-1 -λg j-1, the local model M of the target node j-1 The model parameters are updated, and then the updated local model is replaced by the local model M j express.
[0144] It can be understood that the target node can record the validation set loss of the local model during the training process. If the second information includes a public validation set, the validation set loss here can be the model loss of the local model of the target node on the public validation set. If the second information does not include a public validation set, the validation set loss here can be the model loss of the local model of the target node on the local validation set.
[0145] Step S304: The target node determines whether the trained local model meets the first condition.
[0146] The first condition here is that the validation set loss of the model no longer decreases. Specifically, the target node can determine the local model M j The validation set loss and the local model M j-1 The validation set loss of the two local models with adjacent iterations can be compared. If the local model M j The validation set loss is greater than or equal to the local model M j-1 The validation set loss of , means that the validation set loss of the local model of the target node no longer decreases. At this time, the target node can determine the local model M j-1 Determine the local model that meets the first condition. j-1 is the local model with the minimum validation set loss during training. j The validation set loss is less than that of the local model M j-1 If the validation set loss of the target node's local model is still decreasing, the target node can jump to step S303 and continue to validate the local model M. j Conduct training.
[0147] Step S305: The target node determines the local model that meets the first condition as the target local model.
[0148] For example, after initializing its local model, the target node may record the validation set loss of the initial local model, i.e., the validation set loss of local model M0. During the first iterative update, the target node may refer to the training method described in step S303 above, adjust the model parameters of local model M0 based on the local training set, obtain local model M1, and record the validation set loss of local model M1. The target node may then compare the validation set loss of local model M0 with the validation set loss of local model M1.
[0149] If the validation set loss of the local model M1 is greater than or equal to the validation set loss of the local model M0, the target node may determine the local model M0 as the target local model.
[0150] If the validation set loss of local model M1 is less than the validation set loss of local model M0, the target node can proceed to step S303, i.e., adjust the model parameters of local model M1 based on the local training set to obtain local model M2, and record the validation set loss of local model M2. The target node can then compare the validation set loss of local model M2 with the validation set loss of local model M1 until a local model with no longer decreasing validation set loss is identified, and this local model is used as the target local model.
[0151] Step S306 : The target node determines a target threshold corresponding to the target local model based on the training set loss of the target local model.
[0152] Specifically, the target node can determine the model loss of the target local model on the local training set as the training set loss, and then determine the threshold (i.e., the second threshold) used to reflect the loss value of the target local model of the second node based on the threshold determination strategy in the second information and the training set loss. In this embodiment of the present application, the second threshold determined by the target node can be referred to as the target threshold.
[0153] Step S307: The target node sends third information to the first node.
[0154] The third information here may be a target threshold, or may be information obtained by quantifying the target threshold, which will not be limited here.
[0155] For example, the first node and the target node may both pre-store a table related to the threshold value, and the table may be included in the second information sent by the first node to the target node. Further, please refer to Table 1, which is a schematic table for finding the threshold value provided in an embodiment of the present application. As shown in Table 1:
[0156] Table 1
[0157] Among them, Table 1 records X thresholds. After the target node determines the target threshold, it can search for the threshold closest to the target threshold in Table 1 (for example, threshold 1). At this time, the target node does not need to directly feedback the target threshold to the first node, but can feedback the index number corresponding to the found threshold (for example, index number 1) to the first node, thereby reducing the transmission overhead between the first node and the target node and improving transmission efficiency.
[0158] Step S308: The first node aggregates the received second thresholds to obtain a first threshold.
[0159] Specifically, in order to avoid the first node from waiting indefinitely for feedback from the second node, an embodiment of the present application can set a condition (i.e., a third condition) for indicating the execution of a threshold aggregation operation, wherein the third condition here can be that the sending timestamp of the second information and the current timestamp reach a certain time threshold (for example, 1 minute), or it can be that the number of second thresholds currently received reaches a quantity threshold (for example, 2 / 3K). The third condition will not be limited here. When the first node meets the third condition, the first node does not need to wait for feedback from all second nodes, but can directly aggregate the second thresholds that have been received to obtain the first threshold.
[0160] Specifically, the way in which the first node aggregates the second threshold value can be referred to the following formula (10):
[0161] Here, N may be used to represent the number of second thresholds received by the first node.
[0162] Step S309: The first node sends first information to the target node.
[0163] The first information here may be the first threshold value, or information obtained by quantizing the first threshold value, which is not limited here. The manner in which the first node sends the first information to the target node can refer to the specific implementation of step S307 above, which will not be described in detail here.
[0164] In step S310 , the target node obtains a threshold of a loss value for training a local model of the target node based on the first information, and determines the obtained threshold as a first threshold.
[0165] The first information here may further include a third instruction, which is used to instruct the target node to reinitialize its local model based on the model training information and model configuration information in the second information.
[0166] In step S311, the target node may train the local model of the target node based on the first threshold until the trained local model meets the second condition, and determine the local model meeting the second condition as the first local model.
[0167] Specifically, the target node can reinitialize the local model of the target node based on the third instruction to obtain an initial local model, and then use the loss function with the first threshold shown in the above formula (4) or formula (5) to train the initial local model until the trained local model meets the second condition, and the local model that meets the second condition is determined as the first local model.
[0168] Step S312: The target node sends the model parameters of the first local model to the first node.
[0169] In step S313 , the first node aggregates the received model parameters to obtain aggregated model parameters, and updates the global model based on the aggregated model parameters.
[0170] In step S314 , the first node determines whether the updated global model has converged.
[0171] If the updated global model has not converged, execute step S315 to send the model parameters of the updated global model to the target node, so that the target node reinitializes the local model of the target node based on the model parameters of the updated global model, and then continues to execute step S311; if the updated global model converges, jump to step S316 to end distributed training.
[0172] In an embodiment of the present application, the target node can use the initial model parameters sent by the first node to determine the target threshold before the distributed training of the local model begins. After receiving the second thresholds respectively fed back by multiple second nodes, the first node can aggregate the received second thresholds to obtain a unified first threshold. Then, the first threshold can be used to constrain the training set loss of the model (including the local model of the second node and the global model of the first node) to be near a constant value, so that the training set loss of the model will not drop to 0, the model will not perfectly memorize the training samples, effectively alleviating the problem of model overfitting and improving the generalization ability of the model.
[0173] Further, please refer to Figure 4, which is an interactive diagram of a method for model training provided by an embodiment of the present application. As shown in Figure 4, the method can be jointly executed by a first node and a target node, wherein the first node can be a computing node for training a global model, and the target node can be a distributed edge device or computing node with local data samples. The method can include at least steps S401-S422:
[0174] Step S401: The first node sends second information to the target node.
[0175] Among them, the second information here may include model configuration information, model training information, a threshold determination strategy and a first instruction, and the first instruction is used to instruct the target node to determine the target threshold based on the aggregated model parameters sent by the first node. The threshold determination strategy can be any one of the above formulas (6)-(9), which will not be limited here.
[0176] Step S402: The target node configures a local model of the target node based on the second information.
[0177] Step S403: The target node performs distributed training on the local model based on the local training set.
[0178] Step S404: The target node determines whether the local model after distributed training meets the second condition.
[0179] Step S405: The target node sends the model parameters of the local model that meets the second condition to the first node.
[0180] Step S406: The first node aggregates the received model parameters to obtain first aggregated model parameters.
[0181] Step S407: The first node sends the first aggregation model parameters to the target node.
[0182] Step S408: The target node determines a second local model.
[0183] Step S409: The target node reinitializes the local model based on the first aggregate model parameters to obtain a third local model.
[0184] Step S410: The target node determines whether the reinitialized local model meets a first condition.
[0185] In step S411 , the target node determines a local model that meets a first condition as a target local model.
[0186] Exemplarily, upon receiving the second information, the target node may initialize the local model of the target node based on the model configuration information and model training information in the second information to obtain an initial local model, and may then record the validation set loss of the initial local model. The target node may perform distributed training on the initial local model based on the local training set until the distributed trained local model satisfies the second condition. The target node may then determine the model parameters of the local model that satisfies the second condition as the local model parameters and send the local model parameters to the first node.
[0187] When receiving multiple local model parameters, the first node may aggregate the received local model parameters, determine the aggregated model parameters as first aggregated model parameters, and send the first aggregated model parameters to the target node.
[0188] Upon receiving the first aggregated model parameters, the target node may determine the current local model (i.e., the initial local model) as the second local model, and reinitialize the target node's local model based on the first aggregated model parameters to obtain a third local model, and record the validation set loss of the third local model. Furthermore, the target node may compare the validation set loss of the second local model with the validation set loss of the third local model.
[0189] If the validation set loss of the third local model is less than the validation set loss of the second local model, it means that the validation set loss of the local model of the target node is still decreasing. At this time, the target node jumps to step S403 to continue distributed training of the third local model based on the local training set. If the validation set loss of the third local model is greater than or equal to the validation set loss of the second local model, it means that the validation set loss of the local model of the target node is no longer decreasing. At this time, the target node can determine the second local model as the local model that meets the first condition (i.e., the target local model).
[0190] In step S412 , the target node determines a target threshold corresponding to the target local model based on the training set loss of the target local model.
[0191] Step S413: The target node sends third information to the first node.
[0192] Step S414: The first node aggregates the received second thresholds to obtain a first threshold.
[0193] Step S415: The first node sends first information to the target node.
[0194] In step S416, the target node obtains a threshold of a loss value for training a local model of the target node based on the first information, and determines the obtained threshold as a first threshold.
[0195] In step S417, the target node may train the local model of the target node based on the first threshold until the trained local model meets the second condition.
[0196] Step S418: The target node sends the model parameters of the local model that meets the second condition to the first node.
[0197] In step S419 , the first node aggregates the received model parameters to obtain third aggregated model parameters, and updates the global model based on the third aggregated model parameters.
[0198] In step S420 , the first node determines whether the updated global model has converged.
[0199] If the updated global model has not converged, execute step S421 to send the model parameters of the updated global model (i.e., the third aggregate model parameters) to the target node, so that the target node reinitializes the local model of the target node based on the third aggregate model parameters, and then continues to execute step S417; if the updated global model converges, jump to step S422 to end the distributed training.
[0200] The specific implementation of steps S412-S422 can be found in the description of steps S306-S316 in the embodiment corresponding to FIG3 above, and will not be repeated here.
[0201] In an embodiment of the present application, the target node can use the aggregated model parameters sent by the first node to determine the target threshold value during the distributed training process of the local model. Compared with the model training method shown in Figure 3 above, the target node of the embodiment of the present application does not need to perform calculations before the start of distributed training, thereby effectively reducing the target node calculation overhead. In addition, after receiving the second threshold values fed back by multiple second nodes, the first node can aggregate the received second threshold values to obtain a unified first threshold value, and then the first threshold value can be used to constrain the training set loss of the model (including the local model of the second node and the global model of the first node) to be near a constant value, so that the training set loss of the model will not drop to 0, and the model will not perfectly memorize the training samples, effectively alleviating the problem of overfitting of the model and improving the generalization ability of the model.
[0202] Further, please refer to Figure 5, which is an interactive diagram of a method for model training provided by an embodiment of the present application. As shown in Figure 5, the method can be jointly executed by a first node and a target node, wherein the first node can be a computing node for training a global model, and the target node can be a distributed edge device or computing node with local data samples. The method can include at least steps S501-S524:
[0203] Step S501: The first node sends second information.
[0204] The second information here may include model configuration information, model training information and a threshold determination strategy. The threshold determination strategy may be any one of the above formulas (6)-(9), which will not be limited here.
[0205] Step S502: The target node configures a local model of the target node based on the second information.
[0206] Step S503: The target node performs distributed training on the local model based on the local training set.
[0207] Step S504: The target node determines whether the local model after distributed training meets the second condition.
[0208] Step S505: The target node sends the model parameters of the local model that meets the second condition to the first node.
[0209] Step S506: The first node aggregates the received model parameters to obtain first aggregated model parameters.
[0210] The specific implementation of steps S502-S506 can be found in the description of steps S402-S406 in the embodiment corresponding to FIG4 above, and will not be repeated here.
[0211] Step S507: The first node performs a global model H based on the first aggregate model parameter. i-1 Update and get the global model H i , record the global model H i The validation set loss.
[0212] Step S508: The first node determines the global model H i Is the validation set loss greater than or equal to the global model H? i-1 The validation set loss.
[0213] Specifically, if the global model H i The validation set loss is less than the global model H i-1 If the validation set loss is less than 0.00, it means that the validation set loss of the global model of the first node is still decreasing. At this time, the first node can execute step S509 to send the global model H to the target node. i The target node then receives the model parameters (i.e., the first aggregated model parameters) and executes step S510 to reinitialize the local model based on the received model parameters. At this point, the target node can proceed to step S503 to continue distributed training on the reinitialized local model based on the local training set.
[0214] Exemplarily, the global model H0 is used to represent the global model obtained after initializing the global model, the global model H1 is used to represent the global model obtained after adjusting the model parameters of the global model H0 based on the aggregated model parameters, the global model H2 is used to represent the global model obtained after adjusting the model parameters of the global model H1 based on the aggregated model parameters, and so on.
[0215] Optionally, if the global model H i The validation set loss is greater than or equal to the global model H i-1 The validation set loss of , means that the validation set loss of the global model of the first node no longer decreases. At this time, the global model H i-1 The global model that satisfies the first condition is determined, and then the model parameters of the global model that satisfies the first condition can be determined as the second aggregate model parameters. Then, the first node can execute step S511.
[0216] Step S511: The first node generates a second instruction.
[0217] Step S512: The first node sends the global model H to the target node.i-1 The model parameters and the second instruction.
[0218] In step S513 , the target node reinitializes the local model of the target node based on the second aggregate model parameters, and determines the reinitialized local model as the target local model based on the second instruction.
[0219] In step S514 , the target node determines a target threshold corresponding to the target local model based on the training set loss of the target local model.
[0220] Step S515: The target node sends third information to the first node.
[0221] Step S516: The first node aggregates the received second thresholds to obtain a first threshold.
[0222] Step S517: The first node sends first information to the target node.
[0223] In step S518, the target node obtains a threshold of a loss value for training a local model of the target node based on the first information, and determines the obtained threshold as a first threshold.
[0224] In step S519, the target node may train the local model of the target node based on the first threshold until the trained local model meets the second condition.
[0225] Step S520: The target node sends the model parameters of the local model that meets the second condition to the first node.
[0226] In step S521 , the first node aggregates the received model parameters to obtain third aggregated model parameters, and updates the global model based on the third aggregated model parameters.
[0227] Step S522: The first node determines whether the updated global model has converged.
[0228] If the updated global model has not converged, execute step S523 and send the model parameters of the updated global model (i.e., the third aggregate model parameters) to the target node, so that the target node reinitializes the local model of the target node based on the third aggregate model parameters, and then continues to execute step S519; if the updated global model converges, jump to step S524 to end the distributed training.
[0229] The specific implementation of steps S514-S524 can be found in the description of steps S306-S316 in the embodiment corresponding to FIG3 , and will not be repeated here.
[0230] In an embodiment of the present application, the first node can update the global model using the aggregated model parameters (i.e., the model parameters obtained by aggregating the model parameters of the received local models that meet the second condition). When the validation set loss of the global model no longer decreases, the first node can send a second instruction to the target node to instruct the target node to determine the target threshold. During the entire training process, the target node does not need to calculate the validation set loss of the local model before the start of distributed training or during the distributed training process, thereby effectively reducing the computational overhead of the target node. Since the target node does not need to calculate the validation set loss, this means that the first node of the embodiment of the present application does not need to send a public validation set to the target node, and the target node does not need to store the public validation set, thereby effectively reducing the transmission overhead and storage overhead of the target node. In addition, the first node can also receive the second threshold values fed back by multiple second nodes respectively, and aggregate the received second threshold values to obtain a unified first threshold value, and then the first threshold value can be used to constrain the training set loss of the model (including the local model of the second node and the global model of the first node) to be near a constant value, so that the training set loss of the model will not drop to 0, and the model will not perfectly memorize the training samples, effectively alleviating the problem of model overfitting and improving the generalization ability of the model.
[0231] The following describes the method provided in the embodiment of the present application from the perspective of a single network device in conjunction with the accompanying drawings.
[0232] Further, please refer to Figure 6, which is a schematic diagram of a method for model training provided by an embodiment of the present application. As shown in Figure 6, the method can be applied to a first node, which is used to train a global model, wherein the first node can be the network device 100 shown in Figure 1 above, or the central node shown in Figure 2 above, which will not be limited here. The method can at least include steps S601-S602:
[0233] Step S601: determine a first threshold.
[0234] The first threshold here is a threshold of the loss value used to train the local model of the target node, and the training of the local model of the target node depends on the model parameters of the global model.
[0235] The first threshold may be independently determined by the first node.
[0236] For example, when the first node is the network device 100 shown in FIG1 above, the user (for example, an experienced expert) can perform a comprehensive assessment based on the business situation to obtain a threshold value of the loss value for training the local model of the second node. The user then inputs the threshold value through the visual interface provided by the network device 100. When the user performs an input confirmation operation (i.e., a trigger operation for indicating that the input is completed), the network device 100 can respond to the input confirmation operation and determine the threshold value input by the user as the first threshold value. The trigger operation may include contact operations such as clicking and long pressing, or non-contact operations such as voice and gestures, which will not be limited here. Furthermore, the network device 100 can send the first threshold value to each of the four terminal devices shown in FIG1 above, so that the terminal device (for example, terminal device 111) that receives the first threshold value performs local training using a loss function with the first threshold value to constrain the training set loss of its local model to be near a constant value, thereby preventing the training set loss from falling close to 0, thereby alleviating the problem of model overfitting and enhancing the generalization ability of the model.
[0237] Optionally, the first threshold may also be jointly determined by the first node and multiple second nodes in collaboration. For details, please refer to the description of the embodiments corresponding to Figures 3, 4 or 5 above.
[0238] For another example, since the target node is any one of the K second nodes, K is a positive integer, in order to avoid the first node waiting indefinitely for feedback from the second node, the embodiment of the present application can set a condition (i.e., the third condition) for indicating the execution of the threshold aggregation operation, wherein the third condition here can be that the sending timestamp of the second information and the current timestamp reach a certain time threshold (for example, 1 minute), or it can be that the number of currently received second thresholds reaches a quantity threshold (for example, 2 / 3K). The third condition will not be limited here. When the first node meets the third condition, the first node does not need to wait for feedback from all second nodes, but can directly aggregate the second thresholds that have been received from N second nodes to obtain the first threshold, where N is a positive integer less than or equal to K.
[0239] Among them, the second threshold here is used to reflect the loss value of the target local model of the second node, where the target local model is the local model when the first condition is met, or the target local model is determined based on the model parameters of the global model when the first condition is met, and the first condition is that the validation set loss of the model no longer decreases.
[0240] It is understood that before the first node receives the N second thresholds, the first node may further send a scaling parameter to each of the K second nodes, so that the received second nodes scale the training set loss of their target local models, thereby reducing the computational overhead of the first node. The scaling parameter may include at least one of a first parameter or a second parameter, where the first parameter is a weight configured for the second node and the second parameter is a scaling factor set for the second node.
[0241] In addition, before the first node receives N second thresholds, the first node can also send a public verification set to K second nodes respectively, so that the second nodes that receive the public verification set determine the verification set loss of the local model based on the public verification set. Since the public verification set has more diverse data and wider coverage than the local verification set of the second node, the target threshold fed back by the public verification set is more accurate and the effect is better.
[0242] Of course, the first threshold may be determined in other ways, which will not be limited here.
[0243] Step S602: Send a first threshold to the target node.
[0244] The first information here may be the first threshold, or may be information obtained by quantifying the first threshold, which will not be limited here.
[0245] In an embodiment of the present application, since the first threshold here is the threshold of the loss value used to train the local model of the target node, when the target node receives the first threshold, it can use the first threshold to train the local model of the target node (for example, using a loss function with the first threshold to perform local training), thereby avoiding the training set loss of the local model of the target node from falling to close to 0. This means that the local model of the target node can more fully learn the change patterns between the training samples in the local training set, rather than perfectly memorizing the training samples, and thus the training set loss of the subsequent global model of the first node will not fall to 0, thereby effectively alleviating the problem of model overfitting and improving the model generalization ability.
[0246] Further, please refer to Figure 7, which is a second schematic diagram of a method for model training provided by an embodiment of the present application. As shown in Figure 7, the method can be applied to a target node, which is used to train a local model, wherein the target node can be any one of the K second nodes shown in Figure 2 above, and will not be limited here. The method can include at least steps S701-S704:
[0247] Step S701: Receive first information sent by a first node.
[0248] The first node may be a central node in a distributed training system for training a global model.
[0249] Step S702: Based on the first information, a threshold of the loss value of the local model used to train the target node is obtained, and the obtained threshold is determined as the first threshold.
[0250] Specifically, if the first information here is an index number, the target node can search for the index number in the first information in the threshold table (as shown in Table 1 above) sent in advance by the first node. When there is an index number (for example, index number 1) in the threshold table that matches the index number in the first information, the target node determines the threshold 1 corresponding to index number 1 as the threshold of the loss value for training the local model of the target node (i.e., the first threshold). When there is no index number matching the index number in the first information in the threshold table, the target node can request the first threshold and the index number corresponding to the first threshold from the first node again. At the same time, the target node can also update Table 1 above based on the requested index number and threshold.
[0251] Step S703: Based on the first threshold, the local model of the target node is trained to obtain a first local model.
[0252] Specifically, the target node can use a loss function with a first threshold, for example, the loss function shown in the above formula (4) or formula (5), to train the local model of the target node until the trained local model meets the second condition, and the local model that meets the second condition is determined as the first local model.
[0253] Step S704: Send model parameters of the first local model to the first node.
[0254] The model parameters of the first local model are used to update the global model. For example, when a first node receives model parameters of the first local model respectively transmitted by multiple second nodes, the first node may aggregate the received model parameters to obtain aggregated model parameters, and then update the model parameters of the global model with the aggregated model parameters to obtain a new global model.
[0255] The specific implementation of steps S701-S704 can refer to the description of steps S309-S316 in the embodiment corresponding to FIG3 above, and will not be repeated here.
[0256] In an embodiment of the present application, when training the local model, the target node does not use the traditional loss function for distributed training, but uses a loss function with a first threshold for distributed training. This can effectively prevent the training set loss of the local model of the target node from falling close to 0, so that the local model can more fully learn the change rules between the training samples in the local training set, rather than perfectly memorizing the training samples, and thus the training set loss of the subsequent first node's global model will not fall to 0, thereby effectively alleviating the problem of model overfitting and improving the model generalization ability.
[0257] Further, please refer to Figure 8, which is a structural diagram of a model training device provided in an embodiment of the present application. As shown in Figure 8, the model training device 1 may include at least one of a processing unit 801 and a transceiver unit 802. These units can perform the corresponding functions of the various devices in the above method embodiments.
[0258] In a possible implementation, the model training device 1 can be used to implement the function of a first node (eg, the central node shown in FIG2 ).
[0259] Specifically, the processing unit 801 is used to determine a first threshold, which is a threshold of the loss value used to train the local model of the target node. The training of the local model of the target node depends on the model parameters of the global model; the transceiver unit 802 is used to send the first threshold to the target node.
[0260] In one implementation, the target node is one of K second nodes, where K is a positive integer; the processing unit 801 is used to determine the first threshold, including: a transceiver unit 802, specifically used to receive second thresholds respectively fed back by N second nodes, where N is a positive integer less than or equal to K, and the second threshold is used to reflect the loss value of the target local model of the second node, the target local model is the local model when the first condition is met, or the target local model is determined based on the model parameters of the global model when the first condition is met, and the first condition is that the validation set loss of the model no longer decreases; the processing unit 801 is specifically used to aggregate the N second thresholds to obtain the first threshold.
[0261] In one implementation, the transceiver unit 802 is further configured to send the scaling parameter to each of the K second nodes.
[0262] In one implementation, the scaling parameter includes at least one of a first parameter or a second parameter, the first parameter being a weight configured for the second node, and the second parameter being a scaling factor set for the second node.
[0263] In one implementation, the transceiver unit 802 is also used to send a first instruction to K second nodes respectively, where the first instruction is used to instruct the second node to determine a second threshold based on the initial model parameters sent by the first node, or to instruct the second node to determine the second threshold based on the aggregated model parameters sent by the first node, where the initial model parameters are model parameters of an untrained global model, and the aggregated model parameters are obtained by aggregating the model parameters of the received local models of the second nodes.
[0264] In one implementation, the target local model is a local model that satisfies the first condition, and the transceiver unit 802 is further configured to send a public verification set to the K second nodes.
[0265] In one implementation, the target local model is determined based on the model parameters of the global model when the first condition is satisfied. The processing unit 801 is further configured to determine the global model H and H respectively. i The validation set loss and the global model H i-1 The validation set loss is , i is used to represent the number of times the global model is updated, i is a positive integer; the transceiver unit 802 is also used if the global model H i The validation set loss is less than the global model H i-1 The validation set loss is , then the global model H is sent to the K second nodes i Model parameters of the global model H i The model parameters are used to instruct the second node to reinitialize the local model.
[0266] In one implementation, the processing unit 801 is further configured to: i The validation set loss is greater than or equal to the global model H i-1 The verification set loss is , then a second instruction is generated; the transceiver unit 802 is also used to send the global model H to the K second nodes respectively. i-1 The model parameters and the second instruction are used to instruct the second node to be based on the global model H i-1 The model parameters determine the second threshold.
[0267] The specific implementation of the processing unit 801 and the transceiver unit 802 can be found in the description of steps S601 to S604 in the embodiment corresponding to FIG6 , which will not be described in detail here. In addition, the description of the beneficial effects of the same method will not be described in detail either.
[0268] In another possible implementation, the model training device 1 can be used to implement the function of a target node (for example, any one of the K second nodes shown in FIG. 2 ).
[0269] Specifically, the transceiver unit 802 is used to receive the first information sent by the first node, and the first node is used to train the global model; the processing unit 801 is used to obtain a threshold value of the loss value used to train the local model of the target node based on the first information, and determine the obtained threshold value as the first threshold value; the processing unit 801 is also used to train the local model of the target node based on the first threshold value to obtain the first local model; the transceiver unit 802 is also used to send the model parameters of the first local model to the first node, and the model parameters of the first local model are used to update the global model.
[0270] In one implementation, the target node is one of K second nodes, K is a positive integer, and the transceiver unit 802 is further used to receive second information sent by the first node; the processing unit 801 is further used to determine the target local model based on the second information; the processing unit 801 is further used to determine the target threshold corresponding to the target local model based on the local training set of the target node, and the target threshold is used to reflect the loss value of the target local model of the target node; the transceiver unit 802 is further used to send the target threshold to the first node, so that the first node determines the first threshold based on the target threshold.
[0271] In one implementation, the second information includes a first instruction, which is used to instruct the target node to determine the target threshold based on the initial model parameters sent by the first node, or to instruct the target node to determine the target threshold based on the aggregated model parameters sent by the first node, where the initial model parameters are model parameters of an untrained global model, and the aggregated model parameters are obtained by aggregating the model parameters of the local model received from the second node.
[0272] In one implementation, the second information includes initial model parameters and a first instruction, the first instruction being used to instruct the target node to determine a target threshold based on the initial model parameters; the processing unit 801 further determines a target local model based on the second information, including: the processing unit 801 is specifically used to initialize the local model of the target node based on the second information to obtain a local model M0; the processing unit 801 is specifically used to train the local model M0 based on the local training set of the target node, and determine the local model M0 trained for the jth time as the local model M j , j is a positive integer; processing unit 801 is specifically used to determine the local model M j The validation set loss and the local model M j-1 The validation set loss; Processing unit 801 is specifically used for if the local model M j The validation set loss is greater than or equal to the local model M j-1 The validation set loss is , then the local model M j-1 Identify the target local model.
[0273] In one implementation, the second information includes a first instruction, the first instruction being used to instruct the target node to determine a target threshold based on the aggregated model parameters sent by the first node; the processing unit 801 is further used to determine a target local model based on the second information, including: the processing unit 801 is specifically used to configure the local model of the target node based on the second information; the processing unit 801 is specifically used to determine the local model of the target node as the second local model upon receiving the first aggregated model parameters sent by the first node; the first aggregated model parameters are determined by the first node after aggregating the received local model parameters, the local model parameters are model parameters of the local model in the second node that meets the second condition, and the second condition is a condition for indicating the uploaded model parameters; the processing unit 801 is specifically used to reinitialize the local model of the target node based on the first aggregated model parameters to obtain a third local model; the processing unit 801 is specifically used to determine the validation set loss of the second local model and the validation set loss of the third local model respectively; the processing unit 801 is specifically used to determine the second local model as the target local model if the validation set loss of the third local model is greater than or equal to the validation set loss of the second local model.
[0274] In one implementation, the second information includes a public validation set, where the public validation set is used to instruct the target node to determine a validation set loss of the local model.
[0275] In one implementation, the processing unit 801 is further used to determine the target local model based on the second information, including: the processing unit 801 is specifically used to configure the local model of the target node based on the second information; the transceiver unit 802 is used to receive feedback information sent by the first node; the processing unit 801 is specifically used to reinitialize the local model of the target node based on the second aggregate model parameters if the feedback information includes second aggregate model parameters and a second instruction; the second aggregate model parameters are model parameters of the global model determined by the first node when the first condition is met, and the first condition is that the validation set loss of the model no longer decreases; the processing unit 801 is specifically used to determine the reinitialized local model as the target local model based on the second instruction.
[0276] In one implementation, the second information includes a scaling parameter, the scaling parameter includes at least one of a first parameter or a second parameter, the first parameter is a weight configured for the target node, and the second parameter is a scaling factor set for the target node.
[0277] In one implementation, if the second information includes a scaling parameter, the target threshold is a loss value obtained by scaling the training set loss corresponding to the target local model based on the scaling parameter, where the training set loss is the model of the target local model on the local training set.
[0278] The specific implementation of the transceiver unit 802 and the processing unit 801 can be found in the description of steps S701 to S704 in the embodiment corresponding to FIG7 , which will not be described in detail here.
[0279] Further, please refer to Figure 9, which is a second structural diagram of a model training device provided in an embodiment of the present application. As shown in Figure 9, specifically, the model training device 2 can be used to implement the function of a first node (for example, the central node shown in Figure 2), or the model training device 2 can be used to implement the function of a target node (for example, any one of the K second nodes shown in Figure 2).
[0280] 9 , the model training device 2 includes: a processor 901, a communication interface 902, and all or part of the hardware in a memory 903. The number of processors 901 in the model training device 2 can be one or more, and FIG9 takes one processor as an example. In an embodiment of the present application, the processor 901, the communication interface 902, and the memory 903 can be connected via a bus system or other means, wherein FIG9 takes the connection via a bus system 904 as an example.
[0281] The processor 901 may be a central processor unit (CPU), a network processor (NP), or a combination of a CPU and an NP. The processor 901 may also include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0282] The communication interface 902 is used to receive and send data. Specifically, the communication interface 902 may include a receiving interface and a sending interface. The receiving interface may be used to receive data, and the sending interface may be used to send data. The number of the communication interface 902 may be one or more.
[0283] Memory 903 may include volatile memory, such as random-access memory (RAM); memory 3003 may also include non-volatile memory, such as flash memory, hard disk drive (HDD) or solid-state drive (SSD); memory 903 may also include a combination of the above types of memory.
[0284] Optionally, the memory 903 stores an operating system and programs, executable modules or data structures, or subsets thereof, or extended sets thereof, wherein the programs may include various operating instructions for implementing various operations. The operating system may include various system programs for implementing various basic services and processing hardware-based tasks. The processor 901 may read the programs in the memory 903 to implement the methods provided in the embodiments of the present application.
[0285] The memory 903 may be a storage device in the model training device 2 , or a storage device independent of the model training device 2 .
[0286] Bus system 904 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. Bus system 3004 may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, FIG9 shows only one thick line, but this does not mean that there is only one bus or only one type of bus.
[0287] In some possible embodiments, the above-mentioned model training device can be implemented as a virtualized device. For example, the virtualized device can be a virtual machine (VM) that runs a program with a model training function, and the virtual machine is deployed on a hardware device (for example, a physical server). A virtual machine refers to a complete computer system with complete hardware system functions simulated by software and running in a completely isolated environment. The virtual machine can be configured as a model training device. For example, the functions of the model training device can be implemented based on a general physical server in combination with network function virtualization (NFV) technology. Those skilled in the art can virtualize a model training device with the above-mentioned functions on a general physical server in combination with NFV technology by reading this application, and will not go into details here.
[0288] It should be noted that the model training device mentioned in the embodiments of the present application can be a terminal device, a distributed edge device, a network device (for example, a distributed edge device, a server, or a base station, etc.), or a chip for implementing the method of the present application. The embodiments of the present application do not specifically limit this. When the model training device is a chip, the interface circuit in the chip can be used to perform the receiving or sending operation in the model training device, and the processor in the chip can be used to perform the processing operation.
[0289] In a specific implementation, an embodiment of the present application further provides a chip including a processor and an interface circuit, the interface circuit being configured to receive instructions and transmit them to the processor; and the processor being configured to execute the operations of each model training device in the aforementioned model training method. The processor is coupled to a memory, the memory being configured to store programs or instructions. When the programs or instructions are executed by the processor, the chip implements the method in any of the aforementioned method embodiments.
[0290] Optionally, there may be one or more processors in the chip. The processor may be implemented in hardware and / or software. When implemented in hardware, the processor may be a logic circuit, an integrated circuit, etc. When implemented in software, the processor may be a general-purpose processor implemented by reading software code stored in a memory.
[0291] Optionally, the chip may include one or more memories. The memory may be integrated with the processor or may be provided separately from the processor, which is not limited in this application. For example, the memory may be a non-transient processor, such as a read-only memory (ROM), which may be integrated with the processor on the same chip or provided on separate chips. This application does not specifically limit the type of memory or the configuration of the memory and the processor.
[0292] Exemplarily, the chip may be a field programmable gate array (FPGA), an application-specific integrated circuit (ASIC), a system on chip (SoC), a central processor unit (CPU), a network processor (NP), a digital signal processor (DSP), a microcontroller unit (MCU), a programmable logic device (PLD), or other integrated chips.
[0293] An embodiment of the present application also provides a computer-readable storage medium, including instructions or computer programs, which, when run on a processor, enable the processor to execute the model training method provided in the above embodiments.
[0294] An embodiment of the present application also provides a computer program product comprising instructions or a computer program, which, when executed on a processor, enables a model training device to execute the model training method provided in the above embodiment.
[0295] The terms "first," "second," "third," "fourth," and the like (if any) in the specification and claims of this application and in the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or sequential sequence. It should be understood that the terms used in this manner are interchangeable where appropriate so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" and "having," and any variations thereof, are intended to cover non-exclusive inclusions, e.g., a process, method, system, product, or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0296] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0297] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of units is only a logical business division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0298] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present application.
[0299] Those skilled in the art will appreciate that, in one or more of the examples above, the services described herein may be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these services may be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any medium that facilitates the transmission of computer programs from one location to another. Storage media may be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0300] The above specific implementation methods further describe in detail the purpose, technical solutions and beneficial effects of this application. It should be understood that the above are only specific implementation methods of this application.
[0301] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A model training method, characterized in that: Applied to a first node, the first node being used to train a global model, the method comprising: Determining a first threshold, where the first threshold is a threshold of a loss value for training a local model of the target node, where the training of the local model of the target node depends on model parameters of the global model; The first threshold is sent to the target node.
2. The method according to claim 1, characterized in that The target node is one of the K second nodes, where K is a positive integer; The determining of the first threshold comprises: receiving a second threshold value fed back respectively by N second nodes, where N is a positive integer less than or equal to K, the second threshold value being used to reflect a loss value of a target local model of the second node, the target local model being a local model when a first condition is satisfied, or the target local model being determined based on model parameters of a global model when the first condition is satisfied, where the first condition is that the validation set loss of the model no longer decreases; Aggregate the N second thresholds to obtain a first threshold.
3. The method according to claim 2, characterized in that Before receiving the second thresholds respectively fed back by the N second nodes, the method further includes: The scaling parameters are respectively sent to the K second nodes.
4. The method according to claim 3, characterized in that The scaling parameter includes at least one of a first parameter or a second parameter, the first parameter being a weight configured for the second node, and the second parameter being a scaling factor set for the second node.
5. The method according to any one of claims 2 to 4, characterized in that: Before receiving the second thresholds respectively fed back by the N second nodes, the method further includes: A first instruction is sent to each of the K second nodes, where the first instruction is used to instruct the second node to determine the second threshold based on the initial model parameters sent by the first node, or to instruct the second node to determine the second threshold based on the aggregated model parameters sent by the first node, where the initial model parameters are model parameters of an untrained global model, and the aggregated model parameters are obtained by aggregating the model parameters of the local models received from the second nodes.
6. The method according to any one of claims 2 to 5, characterized in that: The target local model is a local model that satisfies the first condition. Before receiving the second threshold values fed back by the N second nodes, the method further includes: Send a public verification set to K second nodes.
7. The method according to any one of claims 2 to 6, characterized in that: The target local model is determined based on model parameters of the global model when the first condition is satisfied. Before receiving the second threshold values fed back by the N second nodes, the method further includes: Determine the global model H i The validation set loss and the global model H i-1 The validation set loss is , i is used to represent the number of times the global model is updated, i is a positive integer; If the global model H i The validation set loss is less than that of the global model H i-1 The validation set loss is , then the global model H is sent to K second nodes i The model parameters of the global model H i The model parameters are used to instruct the second node to reinitialize the local model.
8. The method according to claim 7, characterized in that The method further comprises: If the global model H i The validation set loss is greater than or equal to the global model H i-1 If the validation set loss is , the second instruction is generated; Send the global model H to K second nodes respectively i-1 The model parameters and the second instruction are used to instruct the second node to be based on the global model H i-1 The model parameters determine the second threshold.
9. A model training method, characterized in that: Applied to a target node, the target node being used to train a local model, the method comprising: receiving first information sent by a first node, where the first node is used to train a global model; Based on the first information, obtaining a threshold of a loss value for training a local model of the target node, and determining the obtained threshold as a first threshold; Based on the first threshold, training the local model of the target node to obtain a first local model; The model parameters of the first local model are sent to the first node, where the model parameters of the first local model are used to update the global model.
10. The method according to claim 9, characterized in that The target node is one of the K second nodes, where K is a positive integer. Before receiving the first information sent by the first node, the method further includes: receiving second information sent by the first node; determining a target local model based on the second information; Determining a target threshold corresponding to the target local model based on a local training set of the target node, where the target threshold is used to reflect a loss value of the target local model of the target node; The target threshold is sent to the first node, so that the first node determines the first threshold based on the target threshold.
11. The method according to claim 10, characterized in that The second information includes a first instruction, which is used to instruct the target node to determine the target threshold based on the initial model parameters sent by the first node, or to instruct the target node to determine the target threshold based on the aggregated model parameters sent by the first node, the initial model parameters are model parameters of an untrained global model, and the aggregated model parameters are obtained by aggregating the model parameters of the local model received from the second node.
12. The method according to claim 10 or 11, characterized in that The second information includes initial model parameters and a first instruction, where the first instruction is used to instruct the target node to determine the target threshold based on the initial model parameters; The determining a target local model based on the second information includes: Initializing the local model of the target node based on the second information to obtain a local model M0; Based on the local training set of the target node, the local model M0 is trained, and the local model M0 trained for the jth time is determined as the local model M j , j is a positive integer; Determine the local model M respectively j The validation set loss and the local model M j-1 The validation set loss of If the local model M j The validation set loss is greater than or equal to the local model M j-1 The validation set loss is j-1 Identify the target local model.
13. The method according to claim 10 or 11, characterized in that The second information includes a first instruction, where the first instruction is used to instruct the target node to determine the target threshold based on the aggregation model parameters sent by the first node; The determining a target local model based on the second information includes: configuring a local model of the target node based on the second information; Upon receiving the first aggregated model parameters sent by the first node, determining the local model of the target node as the second local model; the first aggregated model parameters are determined by the first node after aggregating the received local model parameters, and the local model parameters are model parameters of the local model of the second node that meets a second condition, where the second condition is a condition for indicating uploading model parameters; reinitializing the local model of the target node based on the first aggregation model parameters to obtain a third local model; Determine the validation set loss of the second local model and the validation set loss of the third local model respectively; If the validation set loss of the third local model is greater than or equal to the validation set loss of the second local model, the second local model is determined as the target local model.
14. The method according to any one of claims 10 to 13, characterized in that: The second information includes a public validation set, where the public validation set is used to instruct the target node to determine a validation set loss of a local model.
15. The method according to claim 10, characterized in that The determining a target local model based on the second information includes: configuring a local model of the target node based on the second information; receiving feedback information sent by the first node; If the feedback information includes second aggregate model parameters and a second instruction, reinitializing the local model of the target node based on the second aggregate model parameters; the second aggregate model parameters are model parameters of the global model determined by the first node when a first condition is satisfied, where the first condition is that the validation set loss of the model no longer decreases; Based on the second instruction, the reinitialized local model is determined as the target local model.
16. The method according to any one of claims 10 to 15, characterized in that: The second information includes a scaling parameter, and the scaling parameter includes at least one of a first parameter or a second parameter, the first parameter is a weight configured for the target node, and the second parameter is a scaling factor set for the target node.
17. The method according to any one of claims 10 to 16, characterized in that: If the second information includes a scaling parameter, the target threshold is a loss value obtained by scaling the training set loss corresponding to the target local model based on the scaling parameter, and the training set loss is a model of the target local model on the local training set.
18. A model training device, characterized in that: The method comprises modules for implementing the method according to any one of claims 1 to 8.
19. A model training device, characterized in that: The method comprises modules for implementing the method according to any one of claims 9 to 17.
20. A model training device, characterized in that: The system comprises a memory and a processor, wherein the memory is used to store computer instructions, and the processor is used to call and execute the computer instructions from the memory to implement the method according to any one of claims 1 to 8, or to implement the method according to any one of claims 9 to 17.
21. A computer-readable storage medium, characterized in that The computer-readable storage medium stores instructions, and when the instructions are executed on a processor, the method according to any one of claims 1 to 8 or the method according to any one of claims 9 to 17 is implemented.
22. A computer program product, characterized in that The computer program product comprises instructions, and when the instructions are run on a computer, the computer is caused to perform the method according to any one of claims 1 to 8, or the method according to any one of claims 9 to 17.
Citation Information
Patent Citations
Blockchain-based transverse federated learning model construction method
CN113194126A
Federal learning method and device, equipment and storage medium
CN115841133A
Federal domain generalization fault diagnosis method and system based on global robust weighting
CN115952442A
Methods and apparatus to train a machine learning model
US20220284353A1