Apparatus, method and readable storage medium for model training
By aggregating intermediate models based on their weights and statistics during neural network training, the apparatus improves the generalization performance of neural networks and enhances training efficiency and accuracy.
Patent Information
- Application Number
- PCT/CN2023/119135
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-09-15
- Publication Date
- 2025-03-20
AI Technical Summary
Neural network models often output high accuracy inference results for part of the input data but low accuracy for another part, leading to poor generalization performance due to suboptimal model parameters obtained through high-dimensional space search during iteration training.
An apparatus, method, and readable storage medium that perform N iteration training on a first model, obtain M intermediate models, and aggregate them into a second model based on their weights and statistics, thereby combining the performance of multiple intermediate models to improve generalization performance.
The aggregated model combines the performance of multiple intermediate models, leading to improved generalization performance of the neural network model, and dynamically updating the loss function with a regularization term enhances the converging speed and accuracy of the training result.
Smart Images

Figure CN2023119135_20032025_PF_FP_ABST
Abstract
Description
APPARATUS, METHOD AND READABLE STORAGE MEDIUM FOR MODEL TRAININGTECHNICAL FIELD
[0001] The present disclosure relates to the field of artificial intelligence, and particularly to an apparatus, method and readable storage medium for model training.BACKGROUND
[0002] Neural network models are generally obtained by performing multiple iteration training based on training data. During each iteration training, a training apparatus (e.g., a server) may first input the features in the training data into a neural network model to obtain an inference result. The training apparatus then determines a loss function based on the inference result and the tag in the training data. Finally, the training apparatus can adjust the model parameters of the neural network model according to the loss function. If the condition for terminating the training (for example, reaching the preset number of iterations, the value of the loss function reaching the preset value, the loss function is converged, etc. ) is satisfied after a certain iteration training, the training apparatus terminates the iteration training and adopts the model parameter obtained by the last iteration training as the training result of the neural network model.
[0003] Since the number of model parameters is usually large, the iteration training process corresponds to a process of searching the optimal value of the model parameters in the high-dimensional space. However, the optimal value is generally unsolvable in the high-dimensional space. Therefore, the model parameters obtained by the last iteration training is generally a suboptimal value of the model parameters. Hence, the neural network model may output a high accuracy inference results for a part of the input data, while a low accuracy inference results for another part of input data, resulting in a poor generalization performance of the neural network model.SUMMARY
[0004] The present disclosure disclosed an apparatus, method, and readable storage medium for model training.
[0005] One or more embodiments can include an apparatus. The apparatus comprising: a memory for storing instructions; one or more processors for executing the instructions to cause the apparatus to: perform N iteration training on the first model, wherein N is an integer greater than 1; obtain M intermediate models in the N iteration training processes, and aggregate the M intermediate models to a second model, wherein M is an integer greater than 1; wherein aggregate the M intermediate models to obtain a second model comprising: aggregate the M intermediate models based on M model weights and M statistics corresponding to the M intermediate models.
[0006] In some implements of the apparatus, the weights in the second model is aggregated with the M model weights in the M intermediate models, while the statistics in the second model is aggregated with the M statistics in the M intermediate models. Hence the second model may combine the performance of the M intermediate models, which is beneficial to improving the generalization performance of the trained neural network model.
[0007] One or more embodiments can include an apparatus, wherein: perform N iteration training on the first model comprising: aggregate the preceding K intermediate models of the M intermediate models to obtain a Kth aggregated model; update the model weights and the statistics of the Kth aggregated model to the first model; determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model.
[0008] In some implements of the apparatus, the (K+1) th intermediate model is obtained perform at least one iteration training on the updated first model with the model weights and the statistics of the Kth aggregated model, which benefiting the converging speed of the iteration training.
[0009] One or more embodiments can include an apparatus, wherein: aggregate the preceding K intermediate models of the M intermediate models to obtain a Kth aggregated model comprising: obtain a (K-1) th aggregated model determined by aggregation of the Kth intermediate model and the preceding (K-1) intermediate models; determine a third value corresponding to the model weight in the Kth aggregated model based on performing weighted summation on a first value of the model weight in the Kth intermediate model and a second value of the model weight in the Kth aggregated model, and determine a sixth value corresponding to the statistics in the Kth aggregated model based on performing weighted summation on a fourth value of the statistics in the Kth intermediate model and a fifth value of the statistics in the Kth aggregated model.
[0010] In some implements of the apparatus, the loss function in the first model is dynamically updated by a regularization term based on the aggregated model and the intermediate model, which is beneficial to improving the converging speed of the training of the neural network model and the accuracy of the training result.
[0011] One or more embodiments can include an apparatus, wherein: determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model comprising: determine a regularization term based on the Kth intermediate model and the Kth aggregated model; update the loss function corresponding to the first model based on the regularization term; determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model based on the updated loss function.
[0012] One or more embodiments can include an apparatus, wherein the first model comprises P layers, the model weight comprises a plurality of weights, and P is natural number; and determine a regularization term based on the Kth intermediate model and the Kth aggregated model comprising: determine gradient of each weights by inputting first data to the Kth aggregated model; determine the contribution of each layer to the loss function corresponding to the first model based on the gradient of each of the weights in each layer; determine the regularization term based on the contribution to the loss function corresponding to the first model of each layer, the first value of the model weight, and the third value of the model weight.
[0013] One or more embodiments can include an apparatus, wherein: determine the contribution of each layer to the loss function corresponding to the first model based on the gradient of each of the weights in each layer comprising: determine first norm corresponding to the gradient of weights in the Qth layer, and second norm corresponding to the gradient of all weights in the first model, wherein Q is a natural number less than or equal to P; determine the quotient of the first norm divided by the second norm as the contribution to the loss function corresponding to the first model of the Qth layer.
[0014] One or more embodiments can include an apparatus, wherein: determine the regularization term based on the contribution to the loss function corresponding to the first model of each layer, the first value of the model weight, and the third value of the model weight comprising: determine the regularization term according to the formula: R=∑αQ×ΔQ; wherein R is the regularization term, αQ is the contribution to the loss function corresponding to the first model of Qth layer, ΔQ is the difference between the data corresponding to the Qth layer network in the first value and the data corresponding to the Qth layer network in the third value.
[0015] One or more embodiments can include an apparatus, wherein: aggregate the M intermediate models based on M model weights and M statistics corresponding to the M intermediate models comprising: determine the first intermediate model of the M intermediate models as the initial model of the second model; aggregate the second intermediate model to the Mth intermediate model of the M intermediate models to the second model one by one; wherein the Pth intermediate model of the M intermediate models is aggregated to the second model by: obtaining the Pth intermediate model, wherein the Pth intermediate model comprises a seventh value of the model weight and an eighth value of the statistics, 1<P≤M; updating the model weight in the second model to a ninth value, and updating the statistics in the second model to a tenth value, wherein the ninth value is the weighted sum of the seventh value and the current value of the model weight in the second model, the tenth value is the weighted sum of the eighth value and the current value of the statistics in the second model.
[0016] One or more embodiments can include a method. The method comprising: perform N iteration training on the first model, wherein N is an integer greater than 1; obtain M intermediate models in the N iteration training processes, and aggregate the M intermediate models to a second model, wherein M is an integer greater than 1; wherein aggregate the M intermediate models to obtain a second model comprising: aggregate the M intermediate models based on M model weights and M statistics corresponding to the M intermediate models.
[0017] One or more embodiments can include a method, wherein: perform N iteration training on the first model comprising: aggregate the preceding K intermediate models of the M intermediate models to obtain a Kth aggregated model; update the model weights and the statistics of the Kth aggregated model to the first model; determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model.
[0018] In some implements of the method, the weights in the second model is aggregated with the M model weights in the M intermediate models, while the statistics in the second model is aggregated with the M statistics in the M intermediate models. Hence the second model may combine the performance of the M intermediate models, which is beneficial to improving the generalization performance of the trained neural network model.
[0019] One or more embodiments can include a method, wherein: aggregate the preceding K intermediate models of the M intermediate models to obtain a Kth aggregated model comprising: obtain a (K-1) th aggregated model determined by aggregation of the Kth intermediate model and the preceding (K-1) intermediate models; determine a third value corresponding to the model weight in the Kth aggregated model based on performing weighted summation on a first value of the model weight in the Kth intermediate model and a second value of the model weight in the Kth aggregated model, and determine a sixth value corresponding to the statistics in the Kth aggregated model based on performing weighted summation on a fourth value of the statistics in the Kth intermediate model and a fifth value of the statistics in the Kth aggregated model.
[0020] One or more embodiments can include a method, wherein: determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model comprising: determine a regularization term based on the Kth intermediate model and the Kth aggregated model; update the loss function corresponding to the first model based on the regularization term; determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model based on the updated loss function.
[0021] One or more embodiments can include a method, wherein the first model comprises P layers, the model weight comprises a plurality of weights, and P is natural number; and determine a regularization term based on the Kth intermediate model and the Kth aggregated model comprising: determine gradient of each weights by inputting first data to the Kth aggregated model; determine the contribution of each layer to the loss function corresponding to the first model based on the gradient of each of the weights in each layer; determine the regularization term based on the contribution to the loss function corresponding to the first model of each layer, the first value of the model weight, and the third value of the model weight.
[0022] One or more embodiments can include a method, wherein: determine the contribution of each layer to the loss function corresponding to the first model based on the gradient of each of the weights in each layer comprising: determining first norm corresponding to the gradient of weights in the Qth layer, and second norm corresponding to the gradient of all weights in the first model, wherein Q is a natural number less than or equal to P; determining the quotient of the first norm divided by the second norm as the contribution to the loss function corresponding to the first model of the Qth layer; wherein the regularization term is determined according to the formula: R=∑αQ×ΔQ, wherein R is the regularization term, αQ is the contribution to the loss function corresponding to the first model of Qth layer, ΔQ is the difference between the data corresponding to the Qth layer network in the first value and the data corresponding to the Qth layer network in the third value.
[0023] One or more embodiments can include a method, wherein: determine the regularization term based on the contribution to the loss function corresponding to the first model of each layer, the first value of the model weight, and the third value of the model weight comprising: determine the regularization term according to the formula: R=∑αQ×ΔQ; wherein R is the regularization term, αQ is the contribution to the loss function corresponding to the first model of Qth layer, ΔQ is the difference between the data corresponding to the Qth layer network in the first value and the data corresponding to the Qth layer network in the third value.
[0024] One or more embodiments can include a method, wherein: aggregate the M intermediate models based on M model weights and M statistics corresponding to the M intermediate models comprising: determine the first intermediate model of the M intermediate models as the initial model of the second model; aggregate the second intermediate model to the Mth intermediate model of the M intermediate models to the second model one by one; wherein the Pth intermediate model of the M intermediate models is aggregated to the second model by: obtaining the Pth intermediate model, wherein the Pth intermediate model comprises a seventh value of the model weight and an eighth value of the statistics, 1<P≤M; updating the model weight in the second model to a ninth value, and updating the statistics in the second model to a tenth value, wherein the ninth value is the weighted sum of the seventh value and the current value of the model weight in the second model, the tenth value is the weighted sum of the eighth value and the current value of the statistics in the second model.
[0025] One or more embodiments can include a machine-readable storage medium. The machine-readable storage medium storing instructions, wherein the instructions when executed by one or more processors of a machine, cause the machine to: perform N iteration training on the first model, wherein N is an integer greater than 1; obtain M intermediate models in the N iteration training processes, and aggregate the M intermediate models to a second model, wherein M is an integer greater than 1; wherein aggregate the M intermediate models to obtain a second model comprising: aggregate the M intermediate models based on M model weights and M statistics corresponding to the M intermediate models.
[0026] In some implements of the machine-readable storage medium, the weights in the second model is aggregated with the M model weights in the M intermediate models, while the statistics in the second model is aggregated with the M statistics in the M intermediate models. Hence the second model may combine the performance of the M intermediate models, which is beneficial to improving the generalization performance of the trained neural network model.
[0027] One or more embodiments can include a machine-readable storage medium, wherein: perform N iteration training on the first model comprising: aggregate the preceding K intermediate models of the M intermediate models to obtain a Kth aggregated model; update the model weights and the statistics of the Kth aggregated model to the first model; determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model.
[0028] One or more embodiments can include a machine-readable storage medium, wherein: aggregate the preceding K intermediate models of the M intermediate models to obtain a Kth aggregated model comprising: obtain a (K-1) th aggregated model determined by aggregation of the Kth intermediate model and the preceding (K-1) intermediate models; determine a third value corresponding to the model weight in the Kth aggregated model based on performing weighted summation on a first value of the model weight in the Kth intermediate model and a second value of the model weight in the Kth aggregated model, and determine a sixth value corresponding to the statistics in the Kth aggregated model based on performing weighted summation on a fourth value of the statistics in the Kth intermediate model and a fifth value of the statistics in the Kth aggregated model.
[0029] One or more embodiments can include a machine-readable storage medium, wherein: determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model comprising: determine a regularization term based on the Kth intermediate model and the Kth aggregated model; update the loss function corresponding to the first model based on the regularization term; determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model based on the updated loss function.
[0030] One or more embodiments can include a machine-readable storage medium, wherein the first model comprises P layers, the model weight comprises a plurality of weights, and P is natural number; and determine a regularization term based on the Kth intermediate model and the Kth aggregated model comprising: determine gradient of each weights by inputting first data to the Kth aggregated model; determine the contribution of each layer to the loss function corresponding to the first model based on the gradient of each of the weights in each layer; determine the regularization term based on the contribution to the loss function corresponding to the first model of each layer, the first value of the model weight, and the third value of the model weight.
[0031] One or more embodiments can include a machine-readable storage medium, wherein: determine the contribution of each layer to the loss function corresponding to the first model based on the gradient of each of the weights in each layer comprising: determine first norm corresponding to the gradient of weights in the Qth layer, and second norm corresponding to the gradient of all weights in the first model, wherein Q is a natural number less than or equal to P; determine the quotient of the first norm divided by the second norm as the contribution to the loss function corresponding to the first model of the Qth layer.
[0032] One or more embodiments can include a machine-readable storage medium, wherein: determine the regularization term based on the contribution to the loss function corresponding to the first model of each layer, the first value of the model weight, and the third value of the model weight comprising: determine the regularization term according to the formula: R=∑αQ×ΔQ; wherein R is the regularization term, αQ is the contribution to the loss function corresponding to the first model of Qth layer, ΔQ is the difference between the data corresponding to the Qth layer network in the first value and the data corresponding to the Qth layer network in the third value.
[0033] One or more embodiments can include a machine-readable storage medium, wherein: aggregate the M intermediate models based on M model weights and M statistics corresponding to the M intermediate models comprising: determine the first intermediate model of the M intermediate models as the initial model of the second model; aggregate the second intermediate model to the Mth intermediate model of the M intermediate models to the second model one by one; wherein the Pth intermediate model of the M intermediate models is aggregated to the second model by: obtaining the Pth intermediate model, wherein the Pth intermediate model comprises a seventh value of the model weight and an eighth value of the statistics, 1<P≤M; updating the model weight in the second model to a ninth value, and updating the statistics in the second model to a tenth value, wherein the ninth value is the weighted sum of the seventh value and the current value of the model weight in the second model, the tenth value is the weighted sum of the eighth value and the current value of the statistics in the second model.
[0034] One or more embodiments can include an apparatus. The apparatus comprising: a memory for storing instructions; one or more processors for executing the instructions to cause the apparatus to: obtain a Kth intermediate model by performing iteration training on the first model with a loss function; determine a regulation term based on the Kth intermediate model and a (K-1) th intermediate model; update the regulation term into the loss function and perform iteration training on the first model based on the updated loss function.
[0035] One or more embodiments can include an apparatus, wherein the first model comprises P layers and a plurality of weights, the value of the weights in the Kth intermediate model is a first value, the value of the weights in the (K-1) th intermediate model is a second value, and P is natural number; and determine a regulation term based on the Kth intermediate model and a (K-1) th intermediate model comprising: determine gradient of each weights by inputting first data to the Kth intermediate model; determine the contribution of each layer to the loss function based on the gradients of weights in each layer; determine the regularization term based on the contribution of each layer to the loss function, the first value and the second value.
[0036] One or more embodiments can include an apparatus, wherein: determine the regularization term based on the contribution of each layer to the loss function, the first value and the second value comprising: determine first norm corresponding to the gradient of weights in the Qth layer, and second norm corresponding to the gradient of all weights in the first model, wherein Q is a natural number less than or equal to P; determine the quotient of the first norm divided by the second norm as the contribution to the loss function corresponding to the first model of the Qth layer.
[0037] One or more embodiments can include an apparatus, wherein: determine the regularization term based on the contribution of each layer to the loss function, the first value and the second value comprising: determine the regularization term according to the formula: R=∑αQ×ΔQ; wherein R is the regularization term, αQ is the contribution to the loss function corresponding to the first model of Qth layer, ΔQ is the difference between the data corresponding to the Qth layer network in the first value and the data corresponding to the Qth layer network in the second value.BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The foregoing summary, as well as the following detailed description of the exemplary embodiments, will be better understood when read in conjunction with the appended drawings. For the purpose of illustrating the present disclosure, there are shown in the drawings embodiments, which are presently preferred. However, the present disclosure is not limited to the precise arrangements and instrumentalities shown.
[0039] FIG. 1 shows a schematic diagram of inference results of input data by a plurality of intermediate models according to some embodiments of the present disclosure;
[0040] FIG. 2 shows a schematic structural diagram of a model training apparatus 10 according to some embodiments of the present disclosure;
[0041] FIG. 3 shows a schematic process for a stabilization module 12 to update an aggregated model according to some embodiments of the present disclosure.
[0042] FIG. 4 shows a flow diagram of a model training method according to some embodiments of the present disclosure;
[0043] FIG. 5 shows a process diagram of a model training apparatus 10 implementing the model training method shown in FIG. 4, according to some embodiments of the present disclosure;
[0044] FIG. 6 shows a process diagram of a model training apparatus 10 determining regularization terms based on an aggregated model and an intermediate model, according to some embodiments of the present disclosure;
[0045] FIG. 7 shows a flow diagram of a model training method according to some embodiments of the present disclosure;
[0046] FIG. 8 shows a process diagram of a model training apparatus 10 dynamically updating regularization terms based on an intermediate model, according to some embodiments of the present disclosure;
[0047] FIG. 9 shows a flow diagram of another model training method according to some embodiments of the present disclosure;
[0048] FIG. 10 shows a schematic structural diagram of an electronic device 100 according to some embodiments of the present disclosure.DETAILED DESCRIPTION
[0049] Illustrative embodiments of the present disclosure include, but are not limited to apparatus, method, and readable storage media for model training.
[0050] As previously mentioned, if the model parameters obtained by the last iteration training are directly adopted as the training result of the neural network model, the neural network model may output a high accuracy inference results for a part of the input data, while a low accuracy inference results for another part of input data, resulting in a poor generalization performance of the neural network model.
[0051] For example, when training data is sparse and irregular (e.g., when training data includes point cloud data collected in the autopilot field) , the neural network model converges to different sub-optimal results (i.e., different intermediate models are obtained) during iteration training. If the sub-optimal result is adopted as the training result of the neural network model, the neural network model may output a high accuracy inference results for a part of the input data, while a low accuracy inference results for another part of input data.
[0052] Illustratively, it is assumed that the correct inference results corresponding to the data set D1, the data set D2, and the data set D3 are the result R1, the result R2, and the result R3, respectively.
[0053] Referring to FIG. 1, intermediate models including intermediate model SM1, intermediate model SM2, and intermediate model SM3 are obtained during iteration training of the neural network model. The intermediate model SM1 outputs correct inference result for the data set D2 and the data set D3, while the inference result for the data set D1 is incorrect. The intermediate model SM2 outputs correct inference result for the data set D1 and the data set D3, while the inference result for the data set D2 is the incorrect. The intermediate model SM3 outputs correct inference result for the data set D1 and the data set D2, while the inference result for the data set D3 is incorrect. Therefore, adopting any one of the three intermediate models above as the training result causes the neural network model to be able to infer the correct result for only part of the input data, which affects the generalization performance of the neural network model.
[0054] In order to improve the generalization performance of a neural network model, the present disclosure provides a model training apparatus. The model training apparatus may determine an aggregated model by aggregating values of model parameters in a plurality of intermediate models (hereinafter referred to as intermediate model parameters) obtained during iteration training of a neural network model. And the model training apparatus may adopt the aggregated model as the training result of the neural network model. In some embodiments, the model parameters may include but not be limited to model weights and statistics.
[0055] For example, each time an intermediate model is obtained by the model training apparatus, the value of each model parameter in the intermediate model may be weighted summed with the value of corresponding model parameter in the aggregated model obtained last time to obtain the value of each model parameter in the new aggregated model (hereinafter referred to as the aggregated model parameter) (e.g., the value of one model parameter in the intermediate model and the value of the corresponding model parameter in the aggregated model obtained last time are respectively multiplied by the corresponding weighting coefficients and then added) . Then, the model training apparatus may adopt the last updated aggregated model as the training result of the neural network model after the iteration training is completed.
[0056] In this way, since the values of the model parameters in the aggregated model are obtained by weighted summation based on the values of the model parameters in the multiple intermediate models, even if each intermediate model is a sub-optimal result, the trained model can take the performance of different sub-optimal results into account, which is beneficial to improving the generalization performance of the trained neural network model.
[0057] In some embodiments, the model weights are parameters updated by backpropagation in iteration training. For example, convolution weight of convolution layer, weight of each neuron in fully connected layer, and the like.
[0058] In some embodiments, the statistics are model parameters that are updated during iteration training, but not by back propagation. For example, running_mean parameters and running_std parameters in batch normalization layer are both statistics. Another example of this kind of statistic is adaptive dropout probability parameters in the dropout layer.
[0059] For ease of description, in the following embodiments, the model weights in the intermediate model parameters are referred to as intermediate weights, the statistics in the intermediate model parameters are referred to as intermediate statistics, the model weights in the aggregated model are referred to as aggregated weights, and the statistics in the aggregated model parameters are referred to as aggregation statistics.
[0060] In some embodiments, the model training apparatus may update the aggregated model multiple times during iteration training. Hence, the aggregated model may take into account the performance of more sub-optimal solutions, which further improves the generalization performance of the trained neural network model.
[0061] In some embodiments, after obtaining an aggregated model, the model training apparatus may update model parameters in the aggregated model (hereinafter referred to as aggregated model parameters, e.g., aggregated weights, aggregated statistics, etc. ) into the neural network model. In this way, the model training apparatus may perform iteration training with the aggregated model parameter as the initial value of the corresponding model parameters in subsequent iteration training, which facilitating increasing the converging speed of the neural network model and improving the accuracy of the training result.
[0062] In some embodiments, the model training apparatus may also determine a regularization term based on the aggregated model and the intermediate model. The regularization term can be added to the loss function of the subsequent iteration training of the neural network model by means of over-addition, weighted summation, and the like. So as to further improve the performance of the neural network model obtained during the subsequent iteration training and avoid over-fitting.
[0063] Illustratively, FIG. 2 shows a schematic structural diagram of model training apparatus 10 in accordance with some embodiments of the present disclosure.
[0064] As shown in FIG. 2, the model training apparatus 10 includes a training module 11 and a stabilization module 12.
[0065] The training module 11 is configured to perform iteration training on the input neural network model according to the input training data to obtain intermediate models. For example, the training module 11 may input the features in the training data into the neural network model to obtain an inference result corresponding to each feature. The training module 11 may then determine a loss function based on the inference results and tags corresponding to the features, and adjust the parameters of the neural network model based on the loss function.
[0066] In some embodiments, the training module 11 may adjust parameters of the neural network model through a backpropagation algorithm.
[0067] In some embodiments, the features in the training data are adopted as input data to the neural network model, and the tags in the training data are adopted as reference inference results for the corresponding features.
[0068] The stabilization module 12 is configured to obtain intermediate model determined by the training module 11 and aggregate the obtained intermediate model with a previously determined aggregated model to obtain a new aggregated model.
[0069] For example, FIG. 3 shows a schematic process diagram of a stabilization module 12 updating an aggregated model according to some embodiments of the present disclosure.
[0070] As shown in FIG. 3:
[0071] In the first round of aggregation training, the stabilization module 12 adopted the intermediate model IK determined in the Kth iteration training as the aggregated model A1. Wherein K is a natural number.
[0072] In the second round of aggregation training, the stabilization module 12 obtains the intermediate model IK+M determined in the (K+M) th iteration training. Then the intermediate model IK+M and the aggregated model A1 may be aggregated to obtain the aggregated model A2. Wherein M is a natural number.
[0073] For example, in some embodiments, assuming that the intermediate weight in the intermediate model IK+M is IWK+M, the intermediate statistics is ISK+M, the aggregation weight of the aggregated model A1 is AW1, and the aggregation statistics is AS1, the aggregation weight of the aggregated model A2 is AW2=a×IWK+M+ (1-a) ×AW1, and the aggregation statistics is AS2==b×ISK+M+ (1-b) ×AS1. Wherein a and b are positive numbers less than 1.
[0074] In the third round of aggregation training, the stabilization module 12 obtains the intermediate model IK+M+N determined in the (K+M+N) th iteration training. Then the intermediate model IK+M+N and the aggregated model A2 may be aggregated to obtain the aggregated model A3. Wherein N is a natural number.
[0075] By analogy, in the Qth round of aggregation training, the stabilization module 12 obtains the intermediate model IK+M+N+P determined in the (K+M+N+P) th iteration training. Then the intermediate model IK+M+N+P and the aggregated model AQ-1 may be aggregated to obtain the aggregated model AQ. Wherein P is a natural number.
[0076] In some embodiments, the stabilization module 12 may also be configured to determine a regularization term based on the intermediate model parameters and the resulting aggregated model. The regularization term may be used for subsequent iteration training of the neural network model.
[0077] For example, for the case shown in FIG. 3, after obtaining the aggregated model A2, the stabilization module 12 may obtain regularization term R based on the intermediate model parameters in the the intermediate model IK+M and the aggregated model parameters in aggregated model A2. Assuming that the loss function adopted for the (K+M) th iteration training in the training module 11 is L1=F+R0, where R0 is the regularization term in the loss function L1, the training module 11 may train the neural network model with the loss function λ1×F+λ2×R during the (K+M+1) th iteration training to the (K+M+N) th iteration training. The determination of the regularization term R will be described later.
[0078] In some embodiments, the stabilization module 12 may send the aggregated model parameters in the aggregated model to the training module 11 after determining an aggregated model, so that the training module 11 may adopt the aggregated model parameters as the initial values of model parameters in the next iteration training.
[0079] For example, for the case shown in FIG. 3, assuming the aggregated weights in the aggregated model A2 is AW2=a×IWK+M+ (1-a) ×AW1 and the aggregated statistics in the aggregated model A2 is AS2=b×ISK+M+ (1-b) ×AS1, the stabilization module 12 may send AW2 and AS2 to the training module 11. The training module 11 may first update the model weight of the neural network model to AW2 and update the statistics of the neural network model to AS2, and then start the (K+M+1) th iteration training.
[0080] The structure of the model training apparatus 10 above is merely an example, and in other embodiments, the model training apparatus 10 may include more or fewer modules, or may combine or split parts of the modules, which are not limited herein.
[0081] Each module of the model training apparatus 10 may be deployed in one electronic device or in a plurality of electronic devices, and the functions of each module may be implemented by the processor of the electronic device in which each module is deployed by executing instructions.
[0082] In some embodiments, one module of the model training apparatus 10 may also be deployed in a plurality of electronic devices, which is not limited herein. For example, the training module 11 may be deployed in a plurality of electronic devices, and the plurality of electronic devices perform distributed training on the neural network model to obtain intermediate models corresponding to the neural network model. The stabilization module 12 may be deployed in one or more electronic devices for obtaining intermediate models from the electronic devices in which the training module 11 is deployed, and determining an aggregated model based on the obtained intermediate models and / or determining a regularization term based on the intermediate model and the aggregated model, and the like.
[0083] The technical solution of the present disclosure will be further described with reference to FIGS. 4 to 10.
[0084] FIG. 4 shows a flow diagram of a model training method according to some embodiments of the present disclosure; FIG. 5 shows a process diagram of a model training apparatus 10 implementing the model training method shown in FIG. 4, according to some embodiments of the present disclosure.
[0085] As shown in FIG. 4, the flow includes the following steps.
[0086] 401, obtain the kth intermediate model determined by the training module 11.
[0087] Illustratively, the stabilization module 12 may obtain the Kth intermediate model during the Kth (K is a natural number) loop of aggregation training, in which the Kth intermediate model is determined by the training module 11 during iteration training of the neural network model. The Kth intermediate model comprises intermediate model parameters corresponding to the neural network model, such as intermediate weights, intermediate statistics, and the like.
[0088] For example, referring to FIG. 5, the training module 11 may perform iteration training on the neural network model based on the input neural network model and training data. The stabilization module 12 may obtain the intermediate model obtained by any one iteration training from the training module 11 as the Kth intermediate model.
[0089] In some embodiments, the training module 11 may perform at least one iteration training on the neural network model to obtain at least one intermediate model during each loop of aggregation training. The stabilization module 12 may arbitrarily select an intermediate model from the at least one intermediate model as the Kth intermediate model. That is, the Kth intermediate model obtained by the stabilization module 12 may be an intermediate model obtained by the training module 11 during the Kth iteration training, or may be an intermediate model obtained by the training module 11 during the K+M (M≥1) th iteration training, which is not limited herein.
[0090] 402, determine the kth aggregated model based on the kth intermediate model and the (k-1) th aggregated model.
[0091] Illustratively, the stabilization module 12 may determine the Kth aggregated model based on the Kth intermediate model and the Kth aggregated model after obtaining the Kth intermediate model.
[0092] In some embodiments, in the case of K=1 (i.e., in the case where the stabilization module 12 obtains the intermediate model for the first time) , the Kth aggregated model may be the Kth intermediate model.
[0093] In some embodiments, the stabilization module 12 may derive the aggregated weights in the Kth aggregated model by weighted summation of the intermediate weights in the Kth intermediate model with the aggregated weights in the Kth aggregated model. The stabilization module 12 may also obtain the aggregation statistics in the Kth aggregated model by weighted summation of the intermediate statistics in the Kth intermediate model and the aggregation statistics in the Kth aggregated model.
[0094] Illustratively, referring to FIG. 5, the stabilization module 12 may determine the aggregation weight in the Kth aggregated model by adding the product of intermediate weight in the Kth intermediate model and a to the product of the aggregation weight in the (K-1) th aggregated model and 1-a. The stabilization module 12 may also determine the aggregation statistics in the Kth aggregated model by adding the product of the intermediate statistics in the Kth intermediate model and b to the product of the aggregation statistics in the Kth intermediate model and 1-b. For example, assuming that the intermediate weights in the Kth intermediate model is IWK+M, the intermediate statistics in the Kth intermediate model is ISK+M, the aggregation weight in the (K-1) th aggregated model is AW1, and the aggregation statistics in the (K-1) th aggregated model is AS1. The aggregation weight in the Kth aggregated model is AW2=a×IWK+M+ (1-a) ×AW1, and the aggregation statistics in the Kth aggregated model is AS2=b×ISK+M+ (1-b) ×AS1.
[0095] In some embodiments, the values of a and b may be set empirically, or may be set according to verifying the aggregated model with a verification dataset, which is not limited herein.
[0096] For example, assuming that when the Kth intermediate model and the (K-1) th aggregated model are verified by a certain verification dataset, the correct rate of the result obtained by the Kth intermediate model based on inferring the features in the verification dataset is c, and the correct rate of the result obtained by the (K-1) th aggregated model based on inferring the features in the verification dataset is d. Then a or b may be c / (c+d) .
[0097] In some embodiments, the values of a and b may be the same or different, which are not limited herein.
[0098] In some embodiments, the values of a and b may also be determined by other means, which are not limited herein.
[0099] 403, determine whether the iteration training is completed.
[0100] The stabilization module 12 determines whether the iteration training is completed. If the iteration training is completed, then proceed to step 404, otherwise, proceed to step 405.
[0101] In some embodiments, the stabilization module 12 may determine the iteration training completed when the condition for termination of the training is satisfied, and proceed to step 404.
[0102] In some embodiments, the condition of terminating training may include at least one of the following conditions:
[0103] The number of iteration training times reaches a preset number;
[0104] The loss functions is converged after iteration training.
[0105] 404, determine the kth aggregated model as the training results.
[0106] The stabilization module 12 adopts the Kth aggregated model as the training result while the iteration training is completed.
[0107] In some embodiments, the stabilization module 12 may send the Kth aggregated model to the training module 11, so that the training module 11 feeds the Kth aggregated model back to the user as a result of the training.
[0108] 405, update the model parameters in the training module 11 to the aggregated model parameters in the kth aggregated model.
[0109] The stabilization module 12 may update the aggregated model parameters in the Kth aggregated model into the training module 11. Hence the training module 11 may perform the next iteration training with the aggregated model parameters as the initial values of the model parameters, which benefiting the converging speed of the training.
[0110] In some embodiments, the stabilization module 12 may also not update the model parameters in the training module 11 to the aggregated model parameters in the Kth aggregated model, which means step 405 may not be conducted.
[0111] 406, proceed to the k+1 loop.
[0112] In some embodiments, the model training apparatus 10 may repeat the foregoing steps 401 to 405 to perform the (K+1) th loop of the aggregation training after updating the model parameters in the training module 11 to the aggregated model parameters in the Kth aggregated model.
[0113] In some embodiments, the training module 11 may perform at least one iteration training on the neural network model in the (K+1) th loop of the aggregation training. In the (K+1) th loop of the aggregation training, the training module 11 may train the neural network model by adopting the aggregated model parameter of the Kth aggregated model as the initial value of the model parameters of the neural network model. In this way, it is advantageous to improve the converging speed of the neural network model and the training efficiency.
[0114] Based on the above method, since the values of the model parameters in the aggregated model are obtained by weighted summation the values of the model parameters in the multiple intermediate models, even if each intermediate model is a sub-optimal result, the aggregated model can combine the performance of different intermediate models, which is beneficial to improving the generalization performance of the trained neural network model.
[0115] Further, in some embodiments, the model training apparatus 10 may also determine a regularization term for the subsequent training process based on the aggregated model and the intermediate model in order to avoid over-fitting during iteration training of the neural network model by the training module 11.
[0116] FIG. 6 shows a process diagram of a model training apparatus 10 determining regularization terms based on aggregated model and intermediate model according to some embodiments of the present disclosure.
[0117] As shown in FIG. 6, after obtaining an aggregated model, the stabilization module 12 may determine the regularization term used for subsequent iteration training by:
[0118] First, the stabilization module 12 may input the regularization data into the aggregated model to obtain the gradient of each weights in the aggregated model.
[0119] It should be understood that the regularization data may include at least part of the training data for iteration training of the neural network model by the training module 11, or may be training data different from the training data for iteration training of the neural network model by the training module 11, which is not limited herein.
[0120] In some embodiments, the stabilization module 12 may utilize backpropagation algorithm to derive the gradient of each weights in the aggregated model, such as static backpropagation algorithm, recurrent backpropagation algorithm, or the like.
[0121] In some embodiments, the gradient of a weights may indicate the contribution of the model weights to the loss function of the neural network model. The greater the gradient, the greater the change in the loss function while the weights changes.
[0122] Then, the stabilization module 12 may determine the norm of the gradient of the weights in each layer of the aggregated model (for ease of description, the norm of the model weights in ith layer is denoted as Gi) and the norm of the gradients of all the weights in the aggregated model (denoted as Gall) .
[0123] In some embodiments, the norm of the gradient of the weights in each layer (Gi) and the norm of the gradient of all of the weights in the aggregated model (Gall) may be any type of norm, which including but not limited to L0 norm, Ll norm, L2 norm, L infinite norm, Frobenius norm, spectral norm (also referred to as induction norm) , infinite norm, and the like.
[0124] In some embodiments, the norm of the gradient of the weights in each layer (Gi) and the norm of the gradient of all of the weights in the aggregated model (Gall) may be the same type of norm. For example, both Gi and Gall may be L2 norm.
[0125] Next, the stabilization module 12 may determine the contribution of each layer to the loss function corresponding to neural network model based on the norm of the gradient of the weights in each layer (Gi) and the norm of the gradient of all of the weights in the aggregated model (Gall) . For ease of description, the contribution of ith layer to the loss function corresponding to the neural network model is denoted as αi.
[0126] In some embodiments, αi may be expressed as Gi / Gall. The greater the value of αi, the greater the change in the loss function while the weights in the ith layer change.
[0127] In some embodiments, the contribution of each layer to the loss function corresponding to neural network model may be determined by other means, which is not limited herein.
[0128] Finally, the stabilization module 12 may determine the regularization term R in the loss function during the next loop of aggregation training based on the intermediate weights, aggregation weights, and αi.
[0129] In some embodiments, R may be determined by ∑αi×Δi, wherein Δi is the difference between the aggregation weights in the ith layer of the aggregated model and the intermediate weights in the -th layer of the intermediate model.
[0130] Illustratively, assuming that the matrix corresponding to the aggregated weights in the ith layer of the aggregated model is Wi1 and the matrix corresponding to the intermediate weights in the ith layer of the intermediate model is Wi2, Δi may be denoted as ∑| (Wi1 (m) -Wi2 (m) ) | or sqrt (∑ (Wi1 (m) -Wi2 (m) ) 2) . Wherein Wi1 (m) denotes the mth element of the matrix Wi1, Wi2 (m) denotes the mth element of the matrix Wi2, sqrt () denotes a square root, and || denotes an absolute value.
[0131] In some embodiments, the determination of the difference Δi above is merely an example, and Δi may be determined by other means in other embodiments, which is not limited herein.
[0132] In some embodiments, the stabilization module 12 may update the determined regularization term R to the loss function of the training module 11 so that the training module 11 may train the neural network model based on the updated loss function in the subsequent iteration training.
[0133] Illustratively, assuming that the loss function currently employed by the training module is L1=F+R0, the updated loss function L2 may be expressed as λ1×F+λ2×R. Wherein R0 is the regularization term in the loss function L1, λ1 and λ2 are any values that are not 0.
[0134] Based on the process shown in FIG. 6, some embodiments of the present disclosure further provide a model training method.
[0135] FIG. 7 shows a flow diagram of a model training method according to some embodiments of the present disclosure.
[0136] As shown in FIG. 7, the flow includes the following steps.
[0137] 701, obtain the kth intermediate model determined by the training module 11.
[0138] Illustratively, the stabilization module 12 may obtain the Kth intermediate model during the Kth (K is a natural number) loop of aggregation training, in which the Kth intermediate model is determined by the training module 11 during iteration training of the neural network model. The Kth intermediate model comprises intermediate model parameters corresponding to the neural network model, such as intermediate weights, intermediate statistics, and the like.
[0139] In some embodiments, the way in which the stabilization module 12 obtains the Kth intermediate model may refer to the foregoing step 401, and details are not described herein.
[0140] 702, determine the kth aggregated model based on the kth intermediate model and the (k-1) th aggregated model.
[0141] Illustratively, the stabilization module 12 may determine the Kth aggregated model based on the Kth intermediate model and the (K-1) th aggregated model.
[0142] In some embodiments, the way in which the stabilization module 12 determines the Kth aggregated model may refer to the foregoing step 402, and details are not described herein.
[0143] 703, determine whether the iteration training is completed.
[0144] The stabilization module 12 determines whether the iteration training is completed. If the iteration training is completed, then proceed step 704, otherwise proceed to step 705.
[0145] In some embodiments, the way in which the stabilization module 12 determines whether the iteration training is completed may refer to the foregoing step 403, and details are not described herein.
[0146] 704, determine the kth aggregated model as the training result.
[0147] The stabilization module 12 may adopt the Kth aggregated model as the training result of the neural network model while the iteration training is completed.
[0148] 705, determine the regularization term R.
[0149] The stabilization module 12 may determine the regularization term based on the Kth aggregated model and the Kth intermediate model while the iteration training is not completed.
[0150] In some embodiments, based on the embodiment shown in FIG. 6, the stabilization module 12 may determine the regularization term R by:
[0151] First, the stabilization module 12 may input the regularization data to the Kth aggregated model to obtain the gradient of each weights in the Kth aggregated model.
[0152] Then, the stabilization module 12 may determine the norm corresponding to the gradients of weights in the ith layer of the Kth aggregated model (denoted as Gi) and the norm corresponding to the gradients of all the weights of the Kth aggregated model (denoted as Gi) .
[0153] Next, the stabilization module 12 may determine the contribution of ith layer to the loss function corresponding to the Kth aggregated model (denoted as αi) . For example, αi may be calculated by Gi / Gall.
[0154] Finally, the stabilization module 12 may determine the regularization term R in the loss function during the next loop of aggregation training based on the intermediate weights, aggregated weights, and αi.
[0155] For example, R may be calculated by ∑αi×Δi, wherein Δi is the difference between the aggregated weights in the ith layer of the Kth aggregated model and the intermediate weights in ith layer of the Kth intermediate model.
[0156] 706, update the model parameters and the regularization term in the training module 11.
[0157] The stabilization module 12 may update the aggregated model parameters in the Kth aggregated model to the training module 11, and update the regularization term R to the loss function of the training module 11.
[0158] Illustratively, assuming that the loss function currently employed by the training module is L1=F+R0, the updated loss function L2 may be expressed as λ1×F+λ2×R. Wherein R0 is the regularization term in the loss function L1, λ1 and λ2 are any values that are not 0.
[0159] 707, proceed to the k+1 loop.
[0160] In some embodiments, the stabilization module 12 may repeat the foregoing steps 701 to 706 to perform the (K+1) th loop of aggregation training after updating the model parameters and the regularization term in the training module 11.
[0161] In some embodiments, the training module 11 may perform at least one iteration training on the neural network model based on the updated loss function. In the at least one iteration training process, the training module 11 may perform iteration training on the neural network model by adopting the aggregated model parameter of the Kth aggregated model as the initial value of the model parameter of the neural network model, which is advantageous to improve the converging speed of the neural network model and the training efficiency.
[0162] Based on the method above, since the values of the model parameters in the aggregated model are obtained by weighted summation based on the values of the model parameters in the multiple intermediate models, even if each intermediate model is a sub-optimal result, the aggregated model can combine the performance of different intermediate models, which is beneficial to improving the generalization performance of the trained neural network model. In addition, in the training process, the regularization term can be dynamically updated based on the aggregated model and the intermediate model, which is beneficial to improving the converging speed of the training of the neural network model and the accuracy of the training result.
[0163] In some embodiments, the model training apparatus 10 may not aggregate the intermediate model during the training of the neural network model, but dynamically update the regularization term to avoid over-fitting.
[0164] For example, FIG. 8 shows a process diagram of a model training apparatus 10 dynamically updating regularization terms based on an intermediate model according to some embodiments of the present disclosure.
[0165] As shown in FIG. 8, the stabilization module 12 may store the intermediate model determined by the training module 11(hereinafter referred to as the latest saved model) . After the training module 11 obtains a new intermediate model (hereinafter referred to as the latest intermediate model) , the stabilization module 12 may determine the regularization term adopted for the subsequent iteration training by:
[0166] First, the stabilization module 12 may input the regularization data to the latest saved model to obtain the gradient of each weights in the latest saved model.
[0167] In some embodiments, the stabilization module 12 may utilize backpropagation algorithm to derive the gradient of each weights in the latest saved model.
[0168] Then, the stabilization module 12 may determine the norm corresponding to the gradients of weights in the ith layer of the latest saved model (denoted as Gi) and the norm corresponding to the gradients of all the weights of the latest saved model (denoted as Gi) .
[0169] Next, the stabilization module 12 may determine the contribution of ith layer to the loss function corresponding to the latest saved model (denoted as αi) . For example, αi may be calculated by Gi / Gall.
[0170] Finally, the stabilization module 12 may determine the regularization term R in the loss function during the next loop of training based on the intermediate weights in the latest saved model, the intermediate weights in the latest intermediate model and αi.
[0171] In some embodiments, R may be calculated by ∑αi×Δi, wherein Δi is the difference between the intermediate weights in the ith layer of the latest intermediate model and the intermediate weights in the ith layer of the latest saved model.
[0172] Illustratively, assuming that the matrix corresponding to the intermediate weights in the ith layer of the latest saved model is Wi3 and the matrix corresponding to the intermediate weights in the ith layer of the latest intermediate model is Wi4, Δi may be denoted as ∑| (Wi3 (m) -Wi4 (m) ) | or sqrt (∑ (Wi3 (m) -Wi4 (m) ) 2) . Wherein Wi3 (m) denotes the mth element of the matrix Wi3, Wi4 (m) denotes the mth element of the matrix Wi4, sqrt () denotes a square root, and || denotes an absolute value.
[0173] After determining the regularization term R, the stabilization module 12 may update the determined regularization term R to the loss function of the training module 11 so that the training module 11 may train the neural network model based on the updated loss function in the subsequent iteration training. Illustratively, assuming that the loss function currently employed by the training module is L1=F+R0, the updated loss function L2 may be expressed as λ1×F+λ2×R. Wherein R0 is the regularization term in the loss function L1, λ1 and λ2 are any values that are not 0.
[0174] Based on the process shown in FIG. 8, some embodiments of the present disclosure further provide a model training method.
[0175] FIG. 9 shows a flow diagram of another model training method according to some embodiments of the present disclosure.
[0176] As shown in FIG. 9, the flow includes the following steps.
[0177] 901, obtain the Kth intermediate model determined by the training module 11.
[0178] Illustratively, the stabilization module 12 may obtain the Kth intermediate model during the Kth (K is a natural number) loop of aggregation training, in which the Kth intermediate model is determined by the training module 11 during iteration training of the neural network model. The Kth intermediate model comprises intermediate model parameters corresponding to the neural network model, such as intermediate weights, intermediate statistics, and the like.
[0179] In some embodiments, the way in which the stabilization module 12 obtains the Kth intermediate model may refer to the foregoing step 401, and details are not described herein.
[0180] 902, determine whether the iteration training is completed.
[0181] The stabilization module 12 determines whether the iteration training is completed. If the iteration training is completed, then proceed to step 903, otherwise, proceed step 904.
[0182] In some embodiments, the way in which the stabilization module 12 determines whether the iteration training is completed may refer to the foregoing step 403, and details are not described herein.
[0183] 903, determine the Kth intermediate model as the training result.
[0184] The stabilization module 12 may adopt the Kth intermediate model as the training result of the neural network model while the iteration training is completed.
[0185] 904, determining the regularization term R.
[0186] The stabilization module 12 may determine the regularization term R based on the Kth intermediate model and the (K-1) th intermediate model while the iteration training is not completed.
[0187] In some embodiments, based on the embodiment shown in FIG. 8, the stabilization module 12 may determine the regularization term R by:
[0188] First, the stabilization module 12 may input the regularization data to the (K-1) th intermediate model to obtain the gradient of each weights in the (K-1) th intermediate model.
[0189] Then, the stabilization module 12 may determine the norm corresponding to the gradients of weights in the ith layer of the (K-1) th intermediate model (denoted as Gi) and the norm corresponding to the gradients of all the weights the (K-1) th intermediate model (denoted as Gi) .
[0190] Next, the stabilization module 12 may determine the contribution of ith layer to the loss function corresponding to the (K-1) th intermediate model (denoted as αi) . For example, αi may be calculated by Gi / Gall.
[0191] Finally, the stabilization module 12 may determine the regularization term R in the loss function during the next loop of training based on the intermediate weights in the (K-1) th intermediate model, the intermediate weights in the Kth intermediate model and αi.
[0192] In some embodiments, R may be calculated by ∑αi×Δi, wherein Δi is the difference between the intermediate weights in the ith layer of the (K-1) th intermediate model and the intermediate weights in the ith layer of the (K-1) th intermediate model.
[0193] Illustratively, assuming that the matrix corresponding to the intermediate weights in the ith layer of the (K-1) th intermediate model is Wi3 and the matrix corresponding to the intermediate weights in the ith layer of the Kth intermediate model is Wi4, Δi may be denoted as ∑| (Wi3 (m) -Wi4 (m) ) | or sqrt (∑ (Wi3 (m) -Wi4 (m) ) 2) . Wherein Wi3 (m) denotes the mth element of the matrix Wi3, Wi4 (m) denotes the mth element of the matrix Wi4, sqrt () denotes a square root, and || denotes an absolute value.
[0194] 905, update the regularization term in the training module 11.
[0195] After determining the regularization term R, the stabilization module 12 may update the regularization term R into the training module 11.
[0196] Illustratively, assuming that the loss function currently employed by the training module is L1=F+R0, the updated loss function L2 may be expressed as λ1×F+λ2×R. Wherein R0 is the regularization term in the loss function L1, λ1 and λ2 are any values that are not 0.
[0197] In some embodiments, the stabilization module 12 may also update the regularization term R into the loss function of the training module 11 in other ways, without limitation.
[0198] 906, proceed to the k+1 loop.
[0199] In some embodiments, after updating the regularization term in the training module 11, the stabilization module 12 may repeat the foregoing steps 901 to 905 to perform the (K+1) th loop of training based on the updated regularization term.
[0200] Based on the above method, the model training apparatus 10 can dynamically update the regularization term during the training process, thereby improving the converging speed of the neural network model training and the accuracy of the training result, and avoiding over-fitting.
[0201] Further, embodiments of the present disclosure further provide an electronic device 100 that can be used to deploy at least part of the modules of the foregoing model training apparatus 10. For example, the electronic device 100 may be used to deploy the training module 11 and / or the stabilization module 12.
[0202] FIG. 10 shows a schematic structural diagram of an electronic device 100 according to some embodiments of the present disclosure.
[0203] As shown in FIG. 10, an electronic device 100 includes one or more processors 101, a memory 102, a communication interface 103, and a bus 104.
[0204] The processor 101 may include one or more processing units, for example, the processor 101 may include CPU (central processing unit) , AP (application processor) , GPU (graphics processing unit) , ISP (image signal processor) , DSP (digital signal processor) , NPU (neural-network processing unit) , ASIC (application-specific integrated circuit) , and the like. The different processing units may be separate devices or may be integrated in one or more processors.
[0205] In some embodiments, the processor 101 may be configured to execute instructions to implement the model training methods provided by various embodiments of the present disclosure or implement the functions of the model training apparatus 10.
[0206] For example, the processor 101 may be configured to execute instructions to: perform iteration training of the neural network model, obtain intermediate models determined by the iteration training, determine aggregated model based on the intermediate models, determine regularization terms based on the aggregated model and the intermediate model, update model parameters and / or loss functions in the training module 11, and the like.
[0207] Memory 102 may include volatile memory and non-volatile memory for storing data and instructions.
[0208] The volatile memory may include RAM (random-access memory) , DDR SDRAM (double data rate synchronous dynamic random access memory) , and the like. The volatile memory is employed to temporarily store data and / or instructions. For example, in some embodiments, the volatile memory may be employed to temporarily store neural network models, training data, intermediate models, aggregated models, regularization terms, etc., or may be used to temporarily store instructions for execution by processor 101.
[0209] The non-volatile memory may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. In some embodiments, the nonvolatile memory may include any suitable nonvolatile memory, such as flash memory, and / or any suitable nonvolatile storage device, such as HDD (hard disk drive) , CD (compact disc) , DVD (digital versatile disc) , SSD (solid-state drive ) , and the like.
[0210] In some embodiments, the non-volatile memory may also be a removable storage medium.
[0211] In some embodiments, the non-volatile memory may be employed to permanently store neural network models, training data, intermediate models, aggregated models, regularization terms, etc., or may be employed to permanently store instructions for execution by the processor 101.
[0212] In particular, the volatile memory and the non-volatile memory in the memory 102 may include a temporary copy and a permanent copy of the instruction 105, respectively. The instructions 105 may include causing the electronic device 100, when executed by at least one of the processors 101, to perform the model training method provided in the foregoing embodiments, or to perform at least some of the functions of the model training apparatus 10.
[0213] In some embodiments, the instructions 105 may include instructions for performing iteration training the neural network model, instructions for obtaining intermediate models in the iteration training of the neural network model, instructions for determining aggregated model based on the intermediate models, instructions for determining regularization terms based on the aggregated model and the intermediate model, instructions for updating model parameters / loss functions in the training module 11, and the like.
[0214] The communication interface 103 is configured to communicate between electronic devices 100 and other devices.
[0215] In some embodiments, communication interface 103 may include a transceiver for providing a wired or wireless communication interface for electronic device 100, such as an interface of an Ethernet, WAN (wireless access network ) , WLAN (wireless local area networks ) , or the like.
[0216] In some embodiments, the electronic device 100 may establish a communication connection with other electronic devices through a communication interface 103, obtaining data from or transmit data to other electronic devices. For example, when the electronic device 100 is a device in which the training module 11 is deployed, the electronic device 100 may transmit intermediate models to other devices through the communication interface 103, and receive aggregated model, regularization term, and the like from the other devices. For another example, when the electronic device 100 is a device in which the stabilization module 12 is deployed, the electronic device 100 may receive intermediate models from another devices through the communication interface 103, and transmit aggregated model, regularization term, and the like to the other device.
[0217] The bus 104 is used to connect the processor 101, the memory 102, and the communication interface 103 to enable communication between the processor 101, the memory 102, and the communication interface 103.
[0218] In other embodiments, the electronic device 100 may also include input / output devices, such as a keyboard, mouse, display screen, and the like.
[0219] It will be appreciated that the electronic device 100 may be any electronic device capable of executing instructions, including, but not limited to, a laptop computer, a desktop computer, a tablet computer, a mobile phone, a server, and the like, and is not limited herein.
[0220] It will be appreciated that the structure of the electronic device 100 shown in the embodiments of the present disclosure does not constitute a specific limitation on the electronic device 100. In other embodiments, electronic device 100 may include more or fewer components than shown, or may combine certain components, or may split certain components, or may have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0221] The components of the illustrative devices and methods employed in accordance with the illustrated embodiments can be implemented, at least in part, in digital electronic circuitry, analog electronic circuitry, or in computer hardware, firmware, software, or in combinations of them. These components can be implemented, for example, as a computer program product such as a computer program, program code or computer instructions tangibly embodied in an information carrier, or in a machine-readable storage device, for execution by, or to control the operation of, data processing apparatus such as a programmable processor, a computer, or multiple computers.
[0222] A computer program can be written in any form of programming language, including compiled or interpreted languages, and it can be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other units suitable for use in a computing environment. A computer program can be deployed to be executed on one computer or on multiple computers at one site or distributed across multiple sites and interconnected by a communication network. Also, functional programs, codes, and code segments for accomplishing the techniques described herein can be easily construed as within the scope of the claims by programmers skilled in the art to which the techniques described herein pertain. Method steps associated with the illustrative embodiments can be performed by one or more programmable processors executing a computer program, code or instructions to perform functions (e.g., by operating on input data and / or generating an output) . Method steps can also be performed by, and apparatus for performing the methods can be implemented as, special purpose logic circuitry.
[0223] Processors suitable for the execution of a computer program include, by way of example, both general and special purpose microprocessors, and any one or more processors of any kind of digital computer. Generally, a processor will receive instructions and data from a read-only memory (ROM) or a random-access memory or both. The required elements of a computer are a processor for executing instructions and one or more memory devices for storing instructions and data. Generally, a computer will also include, or be operatively coupled to receive data from or transfer data to, or both, one or more mass storage devices for storing data, e.g., magnetic, magneto-optical disks, or optical disks. Information carriers suitable for embodying computer program instructions and data include all forms of non-volatile memory, including by way of example, semiconductor memory devices, e.g., electrically programmable ROM (EPROM) , electrically erasable programmable ROM (EEPROM) , flash memory devices, or data storage disks. The processor and the memory can be supplemented by or incorporated in special purpose logic circuitry.
[0224] As used herein, “readable storage medium” (or “machine-readable medium” , “computer-readable medium” , “readable medium” ) comprises a device able to store instructions and data temporarily or permanently and may include, but is not limited to, random-access memory, read-only memory, buffer memory, flash memory, optical media, magnetic media, cache memory, other types of storage, and / or any suitable combination thereof. The term “readable storage medium” should be taken to include a single medium or multiple media (e.g., a centralized or distributed database, or associated caches and servers) able to store processor instructions. The term “readable storage medium” shall also be taken to include any medium or a combination of multiple media, which is capable of storing instructions for execution by one or more processors 101, wherein the instructions executed by one or more processors 101, cause the electronic device 100 to perform any one or more of the methodologies described herein.
[0225] Although the present disclosure has been described with reference to specific features and embodiments thereof, it is evident that various modifications and combinations can be made thereto without departing from the scope of the disclosure. For example, other components may be added to, or removed from, the described systems. The specification and drawings are, accordingly, to be regarded simply as an illustration of the disclosure as defined by the appended claims, and are contemplated to cover any and all modifications, variations, combinations or equivalents that fall within the scope of the present disclosure. Other aspects may be within the scope of the following claims.
Claims
1.An apparatus comprising:a memory for storing instructions;one or more processors for executing the instructions to cause the apparatus to:perform N iteration training on the first model, wherein N is an integer greater than 1;obtain M intermediate models in the N iteration training processes, and aggregate the M intermediate models to a second model, wherein M is an integer greater than 1;wherein aggregate the M intermediate models to obtain a second model comprising:aggregate the M intermediate models based on M model weights and M statistics corresponding to the M intermediate models.2.The apparatus of claim 1, wherein:perform N iteration training on the first model comprising:aggregate the preceding K intermediate models of the M intermediate models to obtain a Kth aggregated model;update the model weights and the statistics of the Kth aggregated model to the first model;determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model.3.The apparatus of claim 2, wherein:aggregate the preceding K intermediate models of the M intermediate models to obtain a Kth aggregated model comprising:obtain a (K-1) th aggregated model determined by aggregation of the Kth intermediate model and the preceding (K-1) intermediate models;determine a third value corresponding to the model weight in the Kth aggregated model based on performing weighted summation on a first value of the model weight in the Kth intermediate model and a second value of the model weight in the Kth aggregated model, anddetermine a sixth value corresponding to the statistics in the Kth aggregated model based on performing weighted summation on a fourth value of the statistics in the Kth intermediate model and a fifth value of the statistics in the Kth aggregated model.4.The apparatus of claim 3, wherein:determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model comprising:determine a regularization term based on the Kth intermediate model and the Kth aggregated model;update the loss function corresponding to the first model based on the regularization term;determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model based on the updated loss function.5.The apparatus of claim 4, wherein the first model comprises P layers, the model weight comprises a plurality of weights, and P is natural number; anddetermine a regularization term based on the Kth intermediate model and the Kth aggregated model comprising:determine gradient of each weights by inputting first data to the Kth aggregated model;determine the contribution of each layer to the loss function corresponding to the first model based on the gradient of each of the weights in each layer;determine the regularization term based on the contribution to the loss function corresponding to the first model of each layer, the first value of the model weight, and the third value of the model weight.6.The apparatus of claim 5, wherein:determine the contribution of each layer to the loss function corresponding to the first model based on the gradient of each of the weights in each layer comprising:determine first norm corresponding to the gradient of weights in the Qth layer, and second norm corresponding to the gradient of all weights in the first model, wherein Q is a natural number less than or equal to P;determine the quotient of the first norm divided by the second norm as the contribution to the loss function corresponding to the first model of the Qth layer.7.The apparatus according to claim 5, wherein:determine the regularization term based on the contribution to the loss function corresponding to the first model of each layer, the first value of the model weight, and the third value of the model weight comprising:determine the regularization term according to the formula: R=∑αQ×ΔQ;wherein R is the regularization term, αQ is the contribution to the loss function corresponding to the first model of Qth layer, ΔQ is the difference between the data corresponding to the Qth layer network in the first value and the data corresponding to the Qth layer network in the third value.8.The apparatus of claim 1, wherein:aggregate the M intermediate models based on M model weights and M statistics corresponding to the M intermediate models comprising:determine the first intermediate model of the M intermediate models as the initial model of the second model;aggregate the second intermediate model to the Mth intermediate model of the M intermediate models to the second model one by one;wherein the Pth intermediate model of the M intermediate models is aggregated to the second model by:obtaining the Pth intermediate model, wherein the Pth intermediate model comprises a seventh value of the model weight and an eighth value of the statistics, 1<P≤M;updating the model weight in the second model to a ninth value, and updating the statistics in the second model to a tenth value, wherein the ninth value is the weighted sum of the seventh value and the current value of the model weight in the second model, the tenth value is the weighted sum of the eighth value and the current value of the statistics in the second model.9.A method comprising:perform N iteration training on the first model, wherein N is an integer greater than 1;obtain M intermediate models in the N iteration training processes, and aggregate the M intermediate models to a second model, wherein M is an integer greater than 1;wherein aggregate the M intermediate models to obtain a second model comprising:aggregate the M intermediate models based on M model weights and M statistics corresponding to the M intermediate models.10.The method of claim 9, wherein:perform N iteration training on the first model comprising:aggregate the preceding K intermediate models of the M intermediate models to obtain a Kth aggregated model;update the model weights and the statistics of the Kth aggregated model to the first model;determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model.11.The method of claim 10, wherein:aggregate the preceding K intermediate models of the M intermediate models to obtain a Kth aggregated model comprising:obtain a (K-1) th aggregated model determined by aggregation of the Kth intermediate model and the preceding (K-1) intermediate models;determine a third value corresponding to the model weight in the Kth aggregated model based on performing weighted summation on a first value of the model weight in the Kth intermediate model and a second value of the model weight in the Kth aggregated model, anddetermine a sixth value corresponding to the statistics in the Kth aggregated model based on performing weighted summation on a fourth value of the statistics in the Kth intermediate model and a fifth value of the statistics in the Kth aggregated model.12.The method of claim 11, wherein:determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model comprising:determine a regularization term based on the Kth intermediate model and the Kth aggregated model;update the loss function corresponding to the first model based on the regularization term;determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model based on the updated loss function.13.The method of claim 12, wherein the first model comprises P layers, the model weight comprises a plurality of weights, and P is natural number; anddetermine a regularization term based on the Kth intermediate model and the Kth aggregated model comprising:determine gradient of each weights by inputting first data to the Kth aggregated model;determine the contribution of each layer to the loss function corresponding to the first model based on the gradient of each of the weights in each layer;determine the regularization term based on the contribution to the loss function corresponding to the first model of each layer, the first value of the model weight, and the third value of the model weight.14.The method of claim 13, wherein:determine the contribution of each layer to the loss function corresponding to the first model based on the gradient of each of the weights in each layer comprising:determining first norm corresponding to the gradient of weights in the Qth layer, and second norm corresponding to the gradient of all weights in the first model, wherein Q is a natural number less than or equal to P;determining the quotient of the first norm divided by the second norm as the contribution to the loss function corresponding to the first model of the Qth layer;wherein the regularization term is determined according to the formula: R=∑αQ×ΔQ, wherein R is the regularization term, αQ is the contribution to the loss function corresponding to the first model of Qth layer, ΔQ is the difference between the data corresponding to the Qth layer network in the first value and the data corresponding to the Qth layer network in the third value.15.The method of claim 13, wherein:determine the regularization term based on the contribution to the loss function corresponding to the first model of each layer, the first value of the model weight, and the third value of the model weight comprising:determine the regularization term according to the formula: R=∑αQ×ΔQ;wherein R is the regularization term, αQ is the contribution to the loss function corresponding to the first model of Qth layer, ΔQ is the difference between the data corresponding to the Qth layer network in the first value and the data corresponding to the Qth layer network in the third value.16.The method of claim 9, wherein:aggregate the M intermediate models based on M model weights and M statistics corresponding to the M intermediate models comprising:determine the first intermediate model of the M intermediate models as the initial model of the second model;aggregate the second intermediate model to the Mth intermediate model of the M intermediate models to the second model one by one;wherein the Pth intermediate model of the M intermediate models is aggregated to the second model by:obtaining the Pth intermediate model, wherein the Pth intermediate model comprises a seventh value of the model weight and an eighth value of the statistics, 1<P≤M;updating the model weight in the second model to a ninth value, and updating the statistics in the second model to a tenth value, wherein the ninth value is the weighted sum of the seventh value and the current value of the model weight in the second model, the tenth value is the weighted sum of the eighth value and the current value of the statistics in the second model.17.A machine-readable storage medium storing instructions, wherein the instructions when executed by one or more processors of a machine, cause the machine to:perform N iteration training on the first model, wherein N is an integer greater than 1;obtain M intermediate models in the N iteration training processes, and aggregate the M intermediate models to a second model, wherein M is an integer greater than 1;wherein aggregate the M intermediate models to obtain a second model comprising:aggregate the M intermediate models based on M model weights and M statistics corresponding to the M intermediate models.18.The machine-readable storage medium of claim 17, wherein:perform N iteration training on the first model comprising:aggregate the preceding K intermediate models of the M intermediate models to obtain a Kth aggregated model;update the model weights and the statistics of the Kth aggregated model to the first model;determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model.19.The machine-readable storage medium of claim 18, wherein:aggregate the preceding K intermediate models of the M intermediate models to obtain a Kth aggregated model comprising:obtain a (K-1) th aggregated model determined by aggregation of the Kth intermediate model and the preceding (K-1) intermediate models;determine a third value corresponding to the model weight in the Kth aggregated model based on performing weighted summation on a first value of the model weight in the Kth intermediate model and a second value of the model weight in the Kth aggregated model, anddetermine a sixth value corresponding to the statistics in the Kth aggregated model based on performing weighted summation on a fourth value of the statistics in the Kth intermediate model and a fifth value of the statistics in the Kth aggregated model.20.The machine-readable storage medium of claim19, wherein:determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model comprising:determine a regularization term based on the Kth intermediate model and the Kth aggregated model;update the loss function corresponding to the first model based on the regularization term;determine the (K+1) th intermediate model of the M intermediate models by performing at least one iteration training on the updated first model based on the updated loss function.21.The machine-readable storage medium of claim 20, wherein the first model comprises P layers, the model weight comprises a plurality of weights, and P is natural number; anddetermine a regularization term based on the Kth intermediate model and the Kth aggregated model comprising:determine gradient of each weights by inputting first data to the Kth aggregated model;determine the contribution of each layer to the loss function corresponding to the first model based on the gradient of each of the weights in each layer;determine the regularization term based on the contribution to the loss function corresponding to the first model of each layer, the first value of the model weight, and the third value of the model weight.22.The machine-readable storage medium of claim 21, wherein:determine the contribution of each layer to the loss function corresponding to the first model based on the gradient of each of the weights in each layer comprising:determine first norm corresponding to the gradient of weights in the Qth layer, and second norm corresponding to the gradient of all weights in the first model, wherein Q is a natural number less than or equal to P;determine the quotient of the first norm divided by the second norm as the contribution to the loss function corresponding to the first model of the Qth layer.23.The machine-readable storage medium of claim 21, wherein:determine the regularization term based on the contribution to the loss function corresponding to the first model of each layer, the first value of the model weight, and the third value of the model weight comprising:determine the regularization term according to the formula: R=∑αQ×ΔQ;wherein R is the regularization term, αQ is the contribution to the loss function corresponding to the first model of Qth layer, ΔQ is the difference between the data corresponding to the Qth layer network in the first value and the data corresponding to the Qth layer network in the third value.24.The machine-readable storage medium of claim 17, wherein:aggregate the M intermediate models based on M model weights and M statistics corresponding to the M intermediate models comprising:determine the first intermediate model of the M intermediate models as the initial model of the second model;aggregate the second intermediate model to the Mth intermediate model of the M intermediate models to the second model one by one;wherein the Pth intermediate model of the M intermediate models is aggregated to the second model by:obtaining the Pth intermediate model, wherein the Pth intermediate model comprises a seventh value of the model weight and an eighth value of the statistics, 1<P≤M;updating the model weight in the second model to a ninth value, and updating the statistics in the second model to a tenth value, wherein the ninth value is the weighted sum of the seventh value and the current value of the model weight in the second model, the tenth value is the weighted sum of the eighth value and the current value of the statistics in the second model.
Citation Information
Patent Citations
Risk model training method and device
CN110991905A
Federal learning method and device
CN115249073A
Industrial internet cloud edge model aggregation method based on federated learning
CN116204793A
Federated Learning with Adaptive Optimization
US20210073639A1