Model training method and device, equipment, storage medium and program product

By determining the error degree and adjusting the parameter weight during the model training process, the problem of low model training efficiency under limited hardware resources is solved, efficient and accurate model training is achieved, and model performance is improved.

CN120409741AActive Publication Date: 2025-08-01INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510896704.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-30
Publication Date
2025-08-01
Estimated Expiration
2045-06-30

AI Technical Summary

Technical Problem

With limited hardware resources, the model training efficiency cannot be effectively improved, and there are fluctuations in the direction and amplitude of parameter updates during model training, resulting in increased training time and decreased model performance.

Method used

By determining the error degree of model parameters at the end of the training iteration, adjusting the parameter weight according to the error degree, and updating the model parameters based on the weight, ensuring the correctness of the parameter update direction and amplitude, reducing fluctuations during the training process.

Benefits of technology

In the case of limited hardware resources, the model training efficiency is improved, the model prediction accuracy and generalization ability are improved, the training time is shortened and the model performance is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120409741A_ABST
    Figure CN120409741A_ABST
Patent Text Reader

Abstract

The invention discloses a model training method and device, equipment, a storage medium and a program product, and relates to the technical field of artificial intelligence, in the method, when current training iteration is finished, the error degree of a first model parameter can be determined based on the first model parameter obtained by the current training iteration. Furthermore, when the error degree is relatively large, a relatively small parameter weight can be given to the first model parameter, and when the error degree is relatively small, a relatively large parameter weight can be given to the first model parameter. Therefore, when the parameter updating direction or the updating amplitude of the current training iteration is incorrect, the influence of the current training iteration on the whole model training process can be reduced, so that in the model training process, the model parameters can be updated according to the correct parameter updating direction or updating amplitude all the time, and the training efficiency is improved. The problem that the model training time is prolonged due to fluctuation in the model training process is avoided, and therefore the model training efficiency can be greatly improved even under the condition that hardware resources are limited.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular, to a model training method, apparatus, device, storage medium, and program product. Background Art

[0002] Currently, before applying some models (such as neural network models) to specific business fields, the models are usually trained based on data in the corresponding business fields. Generally, the training efficiency of a model is closely related to the amount of hardware resources used in the model training process. For example, using multiple Graphics Processing Units (GPUs) to perform parallel training on a model can greatly improve the model training efficiency. However, in the case of limited hardware resources, the training efficiency of the model cannot be effectively improved. Summary of the Invention

[0003] The present application provides a model training method, a model training apparatus, an electronic device, a computer non-volatile readable storage medium, and a computer program product to at least solve the problem in the related art that the training efficiency of a model cannot be effectively improved in the case of limited hardware resources.

[0004] The present application provides a model training method, including: obtaining model training information, where the model training information includes first model parameters of a trained model obtained at the end of the current training iteration; determining an error degree of the first model parameters, where the error degree characterizes the fluctuation degree and deviation degree of the first model parameters; determining a parameter weight of the first model parameters based on the error degree, where the parameter weight characterizes the importance degree of the first model parameters in the model training process, and where the larger the error degree, the smaller the parameter weight; updating the first model parameters according to the parameter weight to obtain second model parameters, and using the second model parameters as initial model parameters for the next training iteration.

[0005] The present application further provides a model training apparatus, including: an information acquisition module, configured to obtain model training information, where the model training information includes first model parameters of a trained model obtained at the end of the current training iteration; a parameter evaluation module, configured to determine an error degree of the first model parameters, where the error degree characterizes the fluctuation degree and deviation degree of the first model parameters; a weight determination module, configured to determine a parameter weight of the first model parameters based on the error degree, where the parameter weight characterizes the importance degree of the first model parameters in the model training process; A parameter update module, configured to update the first model parameters according to the parameter weights to obtain second model parameters, and use the second model parameters as the initial model parameters for the next training iteration.

[0006] This application also provides an electronic device, including: a memory for storing a computer program; a processor for implementing the steps of the above model training method when executing the computer program.

[0007] This application also provides a computer non-volatile readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of the above model training method are implemented.

[0008] This application also provides a computer program product, including a computer program. When the computer program is executed by a processor, the steps of the above model training method are implemented.

[0009] In the technical solutions of some embodiments of this application, at the end of the current training iteration, based on the first model parameters obtained from the current training iteration, the error degree of the first model parameters can be determined. Furthermore, when the error degree is large, a smaller parameter weight can be given to the first model parameters, and when the error degree is small, a larger parameter weight can be given to the first model parameters. In this way, after updating the first model parameters based on the parameter weights and using the updated second model parameters as the initial model parameters for the next training iteration, when the parameter update direction or update amplitude in the current training iteration is incorrect, the impact of the current training iteration on the entire model training process can be reduced. Furthermore, during the model training process, the model parameters can always be updated in the correct parameter update direction or update amplitude, avoiding the problem of increased model training time caused by fluctuations in the model training process. Therefore, even in the case of limited hardware resources, the model training efficiency can be greatly improved, thereby solving the problem in some technologies that the training efficiency of the model cannot be effectively improved in the case of limited hardware resources. Description of the Drawings

[0010] To more clearly illustrate the embodiments of this application, the following will briefly introduce the drawings required in the embodiments. Obviously, the drawings in the following description are only some embodiments of this application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0011] Figure 1 It is a schematic diagram of hardware resource interaction during some model training processes; Figure 2 It is a schematic diagram of parallel training of a model in some scenarios; Figure 3 Schematic diagram for parallel training of a model in some other scenarios; Figure 4 Flow schematic diagram of the model training method provided by some embodiments of the present application; Figure 5 Module schematic diagram of the model training device provided by some embodiments of the present application; Figure 6 Module schematic diagram of the electronic device provided by some embodiments of the present application. Detailed implementation manners

[0012] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the protection scope of the present application.

[0013] It should be noted that in the description of the present application, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in the present application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0014] In order to enable those skilled in the art of the present technology to better understand the solution of the present application, the present application will be further described in detail below in conjunction with the accompanying drawings and specific implementation manners.

[0015] Model training refers to the process of inputting training data into a model, and the model automatically adjusts the model parameters based on the difference between the output result and the true result. Model training may specifically include the following steps: 1) Based on the function that the model needs to achieve, construct the training data set of the model. The training data set may include multiple (for example, tens of thousands of) pieces of training data. The training data may be images, texts, etc.

[0016] 2) Use the training data in the training dataset to train the model for multiple iterations. In this application, a complete traversal of the training data in the training dataset is called an iteration. In other words, using all the training data in the training dataset to perform one round of training on the model is called an iteration. For example, assume that the training dataset includes training data 1, 2, ……, 10001. After using training data 1, 2, ……, 10001 to perform one round of training on the model, it is called the first iteration. After using training data 1, 2, ……, 10001 to perform one round of training on the model again, it is called the second iteration. And so on. During the training process of each iteration, the model will automatically adjust the model parameters based on the difference between the output result and the true result to minimize the difference between the output result and the true result. In this way, during the training process of multiple iterations, the model parameters can gradually become accurate, and during the training process of different iterations, the accuracy of the output result of the model may not be exactly the same. For example, in the first iteration, when using the above-mentioned training data 1, 2, ……, 10001 to train the model, the correct rate of the output result of the model is only 20%, but in the second iteration, when using the above-mentioned training data 1, 2, ……, 10001 to train the model again, the correct rate of the output result of the model can reach 25%. After multiple iterations of training, when the difference between the output result and the true result is less than the threshold, it indicates that the model training is completed.

[0017] Refer to in combination Figure 1 , which is a schematic diagram of hardware resource interaction during the training process of some models. Figure 1 In, the hardware resources may include a hard disk, a motherboard, and a graphics card. Among them, the motherboard integrates a central processing unit and a memory, and the graphics card integrates a video memory and at least one graphics processing unit. The motherboard and the graphics card can be connected through a PCIe (Peripheral Component Interconnect Express, Peripheral Component Interconnect Express) bus. The hard disk can be used to persistently store the training data of the model.

[0018] When the model training is started, the central processing unit can perform the following operations: 1) Initialize the model and save the initialization parameters of the model to the memory. 2) Load the training data in the hard disk into the memory and preprocess the training data, such as normalization processing, data augmentation, etc. 3) Divide the preprocessed training data into multiple batches (i.e., batches). For example, assume that the central processing unit loads 10,000 pieces of training data of the model from the hard disk, then the training data can be divided into 10 batches, and each batch includes 1,000 pieces of training data. 4) Based on the PCIe bus between the motherboard and the graphics card, save the initialization parameters of the model and at least part of the batches of training data to the video memory.

[0019] Multiple graphics processing units can read initialization parameters and training data from video memory and perform parallel training on the model based on the read initialization parameters and training data. Specifically, the following describes two scenarios of parallel training.

[0020] Scenario 1: Based on the initialization parameters, each graphics processing unit can run an identical model separately (i.e., the models running in different graphics processing units are the same). Different graphics processing units can use different batches of training data to train the running model. It can be understood that since the training data used by different graphics processing units is not exactly the same, even if the models running in different graphics processing units are the same, the gradient data obtained during the training process is not exactly the same. Each graphics processing unit can save the gradient data to the video memory. After aggregating and calculating (such as averaging) the gradient data of each graphics processing unit saved in the video memory, the final gradient data can be obtained. Based on this final gradient data, the model parameters in each graphics processing unit can be updated. In this way, the models running in each graphics processing unit can always be kept consistent. Thus, after multiple iterations of training, the model training can be completed.

[0021] For ease of understanding, refer to Figure 2 for the schematic diagram of parallel training of the model in some scenarios. Figure 2 In, it is assumed that the central processing unit divides the training data into 10 batches, and there are 5 graphics processing units G1, G2, G3, G4, G5 integrated on the graphics card. Then, based on the initialization parameters, the graphics processing units G1, G2, G3, G4, G5 can run the model M separately. Further, the graphics processing unit G1 can train the running model M based on the training data in batches 1 and 6, obtain the corresponding gradient data D1, and save the gradient data D1 to the video memory. The graphics processing unit G2 can train the running model M based on the training data in batches 2 and 7, obtain the corresponding gradient data D2, and save the gradient data D2 to the video memory. And so on, the gradient data D1, D2, D3, D4, D5 as shown in Figure 2 can be obtained. Since the graphics processing units G1, G2, G3, G4, G5 use different batches of training data to train the running model, the obtained gradient data D1, D2, D3, D4, D5 may not be exactly the same. By aggregating and calculating the gradient data D1, D2, D3, D4, D5, the final gradient data D can be obtained. Based on the gradient data D, the model parameters of each model can be updated.

[0022] Scenario 2: When the model is a neural network model, different graphics processing units run different neural network layers of the same model and train the run neural network layers based on training data. For example, with reference to Figure 3 , it is a schematic diagram of parallel training of the model in some other scenarios. Figure 3 In, it is assumed that there are 5 graphics processing units G1, G2, G3, G4, G5 integrated on the graphics card, and the model includes neural network layers L1 to L10. Then, the graphics processing unit G1 can run neural network layers L1 and L2 and train neural network layers L1 and L2 based on training data. The graphics processing unit G2 can run neural network layers L3 and L4 and train neural network layers L3 and L4 based on training data. And so on. Data transmission can be performed between different neural network layers among different graphics processing units. For example, the graphics processing unit G1 can send the output result of the neural network layer L2 to the graphics processing unit G2 as the input of the neural network layer L3. In this way, after multiple iterations of training, the model training can be completed.

[0023] Based on the descriptions of the above two scenarios, it can be understood that through parallel training, the model training efficiency can be greatly improved. However, this parallel training depends on sufficient hardware resources. If the hardware resources are limited, the training efficiency of the model cannot be effectively improved. For example, in Scenarios 1 and 2 above, if there is only one graphics processing unit on the graphics card, then parallel training cannot be performed based on multiple graphics processing units, and thus the model training efficiency cannot be effectively improved.

[0024] In addition, although parallel training can improve the training efficiency, there are also some defects. For example, taking Scenario 1 above as an example. Since the training data used by each graphics processing unit is only part of the training data, it is easily affected by the noise of the training data, resulting in fluctuations in the update direction and update amplitude of the model parameters, and further causing the updated model parameters to be inaccurate. For example, in the third training iteration, the obtained model parameters are already relatively accurate, but in the fourth training iteration, the accuracy of the obtained model parameters may be lower than that of the model parameters in the third training iteration. In this way, there will be large fluctuations in the update direction and update amplitude of the model parameters. On the one hand, there will be instability problems in the model training process, reducing the model training efficiency. On the other hand, it will have a great impact on the model performance, such as the prediction result of the model is not accurate enough, the generalization ability of the model is relatively poor, etc.

[0025] In view of this, the present application provides a model training method, which can improve the model training efficiency under the condition of limited hardware resources. At the same time, it can also improve the model performance, for example, improve the prediction accuracy and generalization ability of the model. The model training method can be applied to electronic devices. The electronic devices can include, but are not limited to, tablet computers, laptop computers, servers, etc. Referring to Figure 4 , which is a schematic flowchart of the model training method provided in some embodiments of the present application. Figure 4 In , the model training method includes the following steps:

[0026] Specifically, the first model parameter refers to the trainable parameters in the trained model, such as weight matrices, bias vectors, scaling / offset factors of normalization layers, etc.

[0027] In this embodiment, at the end of the current training iteration, a snapshot operation can be performed on the trainable parameters of the trained model (that is, the trainable parameters and their related states are completely saved). In this way, the first model parameters of the trained model at the end of the current training iteration can be obtained.

[0028] Step S402, determine the error degree of the first model parameter, where the error degree characterizes the fluctuation degree and deviation degree of the first model parameter.

[0029] Specifically, the fluctuation degree refers to the difference between the first model parameter and the model parameters in adjacent historical training iterations. For example, the first model parameter can be compared with the model parameters in the previous training iteration. If the difference between the two is large, it means that the fluctuation of the first model parameter is large. If the difference between the two is small, it means that the fluctuation of the first model parameter is small. For another example, the first model parameter can also be compared with the average value of the model parameters in the previous few training iterations. If the difference between the two is large, it means that the fluctuation of the first model parameter is large. If the difference between the two is small, it means that the fluctuation of the first model parameter is small. It can be understood that in adjacent training iterations of model training, the change of model parameters should be relatively small. If the first model parameter has a large difference from the model parameters in adjacent historical training iterations, it can indicate that the parameter update in the current training iteration is not accurate enough, that is, the first model parameter is not accurate enough. Generally, the fluctuation degree can represent the parameter stability degree in the model training process. According to the definition of the fluctuation degree, by comparing the first model parameter with the model parameters in adjacent historical training iterations, the fluctuation degree of the first model parameter can be obtained.

[0030] The degree of deviation refers to the uncertainty of the prediction result when using the trained model with the first model parameter. Among them, the uncertainty is the confidence level of the prediction result. Simply put, if the confidence level of the prediction result obtained when using the trained model with the first model parameter is relatively high, it means that the degree of deviation of the first model parameter is relatively small. On the contrary, if the confidence level of the prediction result obtained when using the trained model with the first model parameter is relatively low, it means that the degree of deviation of the first model parameter is relatively small. Usually, the degree of deviation can represent the performance of the trained model, and the performance of the trained model can be evaluated by the loss value, gradient data, etc. of the trained model. For example, assuming that during the training process of the current training iteration, the loss value of the trained model is relatively large, it can indicate that the degree of deviation of the first model parameter is relatively large. On the contrary, if the loss value of the trained model is relatively small, it can indicate that the degree of deviation of the first model parameter is relatively small.

[0031] In this embodiment, one of the degree of fluctuation and the degree of deviation can be used as the error degree, or alternatively, the degree of fluctuation and the degree of deviation can be weighted and calculated to obtain the error degree. This application does not limit this. In subsequent embodiments of this application, various calculation methods of the error degree are given and will not be elaborated here.

[0032] Step S403: Based on the error degree, determine the parameter weight of the first model parameter. The parameter weight represents the importance of the first model parameter during the model training process, where the larger the error degree, the smaller the parameter weight.

[0033] Specifically, when the error degree of the first model parameter is small, it means that in the current training iteration, the update direction and update amplitude of the model parameter are correct. Therefore, the first model parameter can have a relatively large parameter weight. On the contrary, when the error degree of the first model parameter is large, it means that in the current training iteration, the update direction and update amplitude of the model parameter are incorrect. Therefore, the first model parameter can have a relatively small parameter weight. In this embodiment, the calculation relationship between the error degree and the parameter weight can be as shown in expression (1).

[0034]

[0035] Among them, F represents the parameter weight of the first model parameter, represents the error degree of the first model parameter, represents the hyperparameter. The value change trend of is the same as the value change trend of the error degree That is, the value of increases as the error degree increases and decreases as the error degree is in the denominator, so when the error degree increases, the value of increases, and the value of the parameter weight F decreases. Conversely, when the error degree decreases, the value of decreases, and the value of the parameter weight F increases. In this way, the logic that the larger the error degree, the smaller the parameter weight is realized.

[0036] Furthermore, by adjusting the value of the hyperparameter , the influence degree of the error degree on the parameter weight can be controlled. For example, when the value of the hyperparameter is 10, a small change in the error degree can cause a large change in the parameter weight. When the value of the hyperparameter is 0.5, a large change in the error degree may only cause a small change in the parameter weight. Therefore, in practical applications, the value of the hyperparameter can be determined according to actual needs, and this application does not limit this.

[0037] Furthermore, it can be understood that the calculation relationship between the error degree and the parameter weight may not be limited to the relationship shown in Expression (1). For example, the calculation relationship between the error degree and the parameter weight may also be as shown in Expression (2), and this application does not limit this calculation relationship.

[0038] (2) Step S304, update the first model parameter according to the parameter weight to obtain the second model parameter, and use the second model parameter as the initial model parameter for the next training iteration.

[0039] In this embodiment, the parameter weight can be substituted into Expression (3) to obtain the second model parameter.

[0040]

[0041] Among them, represents the first model parameter, represents the second model parameter, that is, the parameter weight.

[0042] It can be understood that during the model training process, after updating the model parameters obtained in each training iteration based on Expression (3) respectively, it is equivalent to implementing the weighted calculation of the model parameters in multiple training iterations. That is, for the training iterations with correct parameter update directions or update amplitudes, the model parameters of these training iterations can have higher weights, and for the training iterations with incorrect parameter update directions or update amplitudes, the model parameters of these training iterations can have lower weights. In this way, during the model training process, the influence of the training iterations with incorrect parameter update directions or update amplitudes on the model training process can be weakened, and the model can be guided to always update the parameters in the correct parameter update direction or update amplitude. For example, assume that the model parameters of the 1st to 4th training iterations all have a low error degree, but compared with the model parameters of the 4th training iteration, the model parameters in the 5th training iteration have a large fluctuation (that is, there is a large difference between the model parameters of the 4th training iteration and the 5th training iteration). In this case, it means that in the 5th training iteration, due to reasons such as the influence of noise in the training data, the parameter update direction or update amplitude is incorrect. At this time, by reducing the parameter weight of the model parameters in the 5th training iteration, it is possible to control the model parameters not to update along the parameter update direction or update amplitude of the 5th training iteration during the model training process. In this way, problems such as fluctuations in the training process caused by incorrect parameter update directions or update amplitudes are avoided. Correspondingly, the problem of increased training time caused by fluctuations in the training process is also saved, thus achieving the purpose of improving the model training efficiency.

[0043] In this embodiment, if the parameter weight of the current training iteration is lower than the weight threshold (that is, the error degree is greater than the error degree threshold), it can indicate that the parameter update direction or update amplitude of the current training iteration has a serious error, which will cause large fluctuations in the model training process and greatly increase the training duration. In this case, the first model parameters obtained in the current training iteration can be discarded, and the updated model parameters obtained in the previous training iteration can be used as the initial model parameters for the next training iteration. In this way, the problem of greatly increased training time caused by incorrect parameter update directions or update amplitudes in the current training iteration can be avoided.

[0044] In summary, in the technical solutions of some embodiments of the present application, at the end of the current training iteration, based on the first model parameters obtained in the current training iteration, the error degree of the first model parameters can be determined. Furthermore, when the error degree is large, a smaller parameter weight can be given to the first model parameters, and when the error degree is small, a larger parameter weight can be given to the first model parameters. In this way, after updating the first model parameters based on the parameter weights and using the updated second model parameters as the initial model parameters for the next training iteration, when the parameter update direction or update amplitude in the current training iteration is incorrect, the impact of the current training iteration on the entire model training process can be reduced. Furthermore, during the model training process, the model parameters can always be updated in the correct parameter update direction or update amplitude, avoiding the problem of increased model training time caused by fluctuations in the model training process. Therefore, even when the hardware resources are limited, the model training efficiency can be greatly improved, thus solving the problem in some technologies that the training efficiency of the model cannot be effectively improved when the hardware resources are limited.

[0045] For ease of understanding, the following is an example for illustration. For example, in some technologies, due to fluctuations in the model training process, it may take 200 iterations to complete the model training. If these 200 iterations are run relying on limited hardware resources, it will take a long time and the model training efficiency will be low. While by using more hardware resources to perform model training in parallel, the model training duration can be shortened, thus greatly improving the model training efficiency. In the solution of the present application, by reducing the fluctuations in the model training process, the parameter update direction of the model training can always be updated along the correct direction. Therefore, the number of iterations for model training can be reduced. For example, only 20 iterations are required to complete the model training. Since the number of iterations for model training is greatly reduced, therefore, when the hardware resources are effective, the model training duration can also be greatly shortened, thus improving the model training efficiency.

[0046] Furthermore, in the model training method of the present application, since the model parameters can always be updated in the correct update direction and update amplitude, the finally obtained model parameters are relatively accurate. Furthermore, the trained model can have good performance, such as relatively high prediction accuracy and good generalization ability. In some technologies, although a large amount of hardware resources are consumed, due to large fluctuations in the update amplitude and range of the parameters, the model parameters at the time of model convergence may not be optimal, that is, the performance of the trained model is not good enough, such as relatively low prediction accuracy and weak generalization ability.

[0047] The following further elaborates on the above step S402.

[0048] In some embodiments, determining the error degree of the first model parameters in step S402 may include: Obtain the reference model parameters of the current training iteration; Determine the first difference magnitude between the reference model parameters and the first model parameters, and determine the error degree according to the first difference magnitude.

[0049] Specifically, the initial model parameters of the current training iteration can be used as the reference model parameters. Among them, the initial model parameters of the current training iteration are the model parameters updated according to the parameter weights obtained in the previous training iteration. Since there are usually multiple model parameters, the initial model parameters and the first model parameters can be subtracted point by point, and then the L2 norm square of the subtraction result is taken (that is, the sum of the squares of all difference results). In this way, the result of the L2 norm square can be regarded as the square of the distance between the initial model parameters and the first model parameters, and this square of the distance can be used as the first difference magnitude between the reference model parameters and the first model parameters.

[0050] Furthermore, the so-called point by point means subtracting the corresponding parameters in the reference model parameters and the first model parameters. For the convenience of understanding, the following is illustrated by an example. Suppose the model parameters of the model to be trained include (trq1, trq2, trq3). It can be understood that in different training iterations of the model, the same parameter can have different values. For example, in the first training iteration, after updating based on the parameter weights, the value of parameter trq1 is 0.2, the value of parameter trq2 is 0.4, and the value of parameter trq3 is 0.8. Since the model parameters updated based on the parameter weights in the first training iteration will be used as the initial model parameters in the second training iteration, in the second training iteration, the initial value of parameter trq1 is 0.2, the initial value of parameter trq2 is 0.4, and the initial value of parameter trq3 is 0.8. After training in the second training iteration, the value of parameter trq1 becomes 0.5, the value of parameter trq2 becomes 0.3, and the value of parameter trq3 becomes 0.6. Then, when the second training iteration is the current training iteration, point-by-point subtraction means subtracting the final value 0.5 of parameter trq1 from the initial value 0.2 to get 0.3, subtracting the final value 0.3 of parameter trq2 from the initial value 0.4 to get -0.1, and subtracting the final value 0.6 of parameter trq3 from the initial value 0.8 to get -0.2. After the subtraction is completed, the sum of the squares of each difference result can be calculated, that is . The obtained result can be used as the first difference magnitude. Since in the L2 norm square, the square of the difference is performed, if there is a large difference (that is, there is an abnormal fluctuation), the squared value will also be amplified (that is, the abnormal fluctuation can be amplified). In this way, the model parameters with abnormal fluctuations can be better monitored.

[0051] Under normal circumstances, the larger the first difference magnitude, the greater the fluctuations in the parameter update direction or update amplitude of the current training iteration. Therefore, the error degree can be greater. Conversely, the smaller the first difference magnitude, the smaller the fluctuations in the parameter update direction or update amplitude of the current training iteration. Therefore, the error degree can be smaller.

[0052] In the above embodiments, the error degree is determined based on the difference magnitude between the initial model parameters and the first model parameters of the current training iteration, which can evaluate whether the model parameters are updated in the correct direction or amplitude. Furthermore, when the parameter update direction or amplitude is incorrect, the error degree can be used to control the influence degree of the first model parameters during the entire model training process, thereby reducing the problem of increased training time caused by incorrect parameter update direction or amplitude.

[0053] In some other embodiments, the first difference magnitude can also be determined based on methods other than the square of the L2 norm. For example, among the differences obtained by subtracting the initial model parameters from the first model parameters point by point, if the absolute values of no less than a specified number of differences are greater than the difference threshold, it indicates that the first difference magnitude between the initial model parameters and the first model parameters of the current training iteration is larger, and the error degree can be larger. Conversely, if the absolute values of less than the specified number of differences are greater than the difference threshold, it indicates that the first difference magnitude between the initial model parameters and the first model parameters of the current training iteration is smaller, and the error degree can be smaller. For example, assume that the specified number is 2 and the difference threshold is 0.15. Among the above model parameters (trq1, trq2, trq3), the absolute values of the differences obtained by subtracting the initial model parameters from the first model parameters point by point include 0.3, 0.1, and 0.2. Since there are two absolute values of differences greater than the difference threshold of 0.15, the error degree can be larger.

[0054] In some embodiments, it is also possible to obtain the average model parameters of multiple training iterations based on the current training iteration and the initial model parameters of multiple training iterations before the current training iteration, and use the average model parameters as the reference model parameters. For example, assume that the model parameters of the model to be trained include (trq1, trq2, trq3). After being trained in the current training iteration A, the value of parameter trq1 becomes 0.5, the value of parameter trq2 becomes 0.3, and the value of parameter trq3 becomes 0.6. In the current training iteration A, the initial value of parameter trq1 is 0.4, the initial value of parameter trq2 is 0.2, and the initial value of parameter trq3 is 0.1. In the previous training iteration B of the current training iteration A, the initial value of parameter trq1 is 0.3, the initial value of parameter trq2 is 0.22, and the initial value of parameter trq3 is 0.15. In the previous training iteration C of training iteration B, the initial value of parameter trq1 is 0.1, the initial value of parameter trq2 is 0.26, and the initial value of parameter trq3 is 0.18. Then, the average value of the initial values of parameter trq1 in training iterations A, B, and C can be taken to obtain the average value of parameter trq1 as 0.26, and the average value of the initial values of parameter trq2 in training iterations A, B, and C can be taken to obtain the average value of parameter trq2 as 0.23. Similarly, the average value of the initial values of parameter trq3 in training iterations A, B, and C can be taken to obtain the average value of parameter trq3 as 0.14. Furthermore, the value of parameter trq1 at the end of the current training iteration, 0.5, can be subtracted from the average value of trq1, 0.26, and the value of trq2 at the end of the current training iteration, 0.3, can be subtracted from the average value of trq2, 0.23, and the value of trq3 at the end of the current training iteration, 0.6, can be subtracted from the average value of trq3, 0.14. In this way, a point-to-point subtraction between the reference model parameters and the first model parameters is achieved, obtaining the first difference magnitude.

[0055] In the above embodiments, by performing an average calculation on the current training iteration and the initial model parameters of multiple training iterations before the current training iteration, and using the result of the average calculation as the reference model parameters, the fluctuations of each training iteration can be neutralized, making the reference model parameters more accurate, and thus the first difference magnitude can be made more accurate.

[0056] In some embodiments, the method of the present application may further include: If the first difference magnitude is not greater than the first difference threshold, then use the first difference magnitude as the error degree; If the first difference magnitude is greater than the first difference threshold, then increase the first difference magnitude to obtain the second difference magnitude, and use the second difference magnitude as the error degree.

[0057] Specifically, when the first difference magnitude is not greater than the first difference threshold, it indicates that there is no serious error in the parameter update direction or update amplitude of the current training iteration. In this case, the first difference magnitude can be directly used as the error degree, and then the parameter update direction or update amplitude during the model training process can be controlled according to the parameter weights of the first model parameters. When the first difference magnitude is greater than the first difference threshold, it indicates that there is a serious error in the parameter update direction or update amplitude of the current training iteration. In this case, the second difference magnitude can be increased. In this way, the obtained error degree is larger, and correspondingly, the parameter weights obtained based on the error degree are smaller. In this way, during the model training process, the model can be inhibited from updating parameters in the wrong parameter update direction or with the wrong update amplitude, thereby shortening the model training duration.

[0058] Further, in some embodiments, the difference threshold may include a first difference threshold and a second difference threshold, where the second difference threshold may be greater than the first difference threshold. If the first difference magnitude is not greater than the first difference threshold, the first difference magnitude is used as the error degree. If the first difference magnitude is greater than the first difference threshold but less than the second difference threshold, the first difference magnitude is increased to obtain the second difference magnitude, and the second difference magnitude is used as the error degree. If the first difference magnitude is greater than the second difference threshold, the first model parameters obtained in the current training iteration can be discarded, and the updated model parameters obtained in the previous training iteration are used as the initial model parameters for the next training iteration. In this way, the problem of a significant increase in training time caused by incorrect parameter update direction or update amplitude in the current training iteration can be avoided.

[0059] In some embodiments, the method of the present application may further include: If the first difference magnitude is greater than the second difference threshold, a third difference threshold is obtained, where the third difference threshold represents the maximum allowable difference magnitude between the second model parameters and the initial model parameters of the current training iteration; If the difference magnitude between the second model parameters and the initial model parameters of the current training iteration is greater than the difference amplitude, the second model parameters are clipped so that the difference magnitude between the second model parameters and the initial model parameters of the current training iteration is within the third difference threshold.

[0060] Among them, the third difference threshold is used to limit the parameter update amplitude of the current training iteration. If the first difference magnitude is greater than the second difference threshold, it indicates that there are large fluctuations in the parameter update of the current training iteration. To avoid the parameters of the current training iteration having too much impact on the model training process, the parameter update amplitude of the current training iteration can be forcibly limited by the third difference threshold.

[0061] Specifically, in the solution of this application, after parameter update is performed in the current training iteration and the first model parameters are obtained, the first model parameters are updated based on the parameter weights, and the updated second model parameters are used as the initial model parameters for the next iteration. Therefore, the second model parameters can be regarded as the final model parameters obtained in the current training iteration. Based on this, to prevent the parameter update amplitude in the current training iteration from being too large, after the second model parameters are obtained, the second model parameters can be subtracted from the initial model parameters of the current training iteration point by point to obtain the difference magnitude between the second model parameters and the initial model parameters of the current training iteration. If the difference magnitude is greater than the second difference threshold, it indicates that the parameter update amplitude in the current training iteration is too large. Therefore, the second model parameters can be clipped so that the difference magnitude between the second model parameters and the initial model parameters of the current training iteration is within the third difference threshold. In this way, the influence of the parameter update in the current training iteration on the next training iteration can be effectively reduced, thereby avoiding errors in the parameter update direction or parameter update amplitude.

[0062] In some embodiments, determining the error degree of the first model parameters in step S402 includes: Obtain the first loss curve of the current training iteration, where the first loss curve represents the loss values obtained when training the model to be trained using different batches of training data in the current training iteration; Determine the first dispersion degree of the loss values based on the first loss curve; Determine the error degree based on the first dispersion degree.

[0063] Specifically, in the current training iteration, the training data can be divided into N batches. When using these N batches of training data for model training, N loss values can be obtained. It can be understood that if there are no large fluctuations in the parameter update of the model to be trained in the current training iteration, the N loss values obtained should be relatively concentrated. On the contrary, if there are large fluctuations in the parameter update of the model to be trained in the current training iteration, the N loss values obtained should be relatively discrete. Therefore, through the first dispersion degree of the loss values, it can be reflected whether the model parameter update in the current training iteration is correct. Simply put, the larger the first dispersion degree, the larger the error degree can be.

[0064] In the above embodiments, the error degree of the first model parameters is evaluated based on the dispersion degree of the loss values, and it can also be evaluated whether there are serious errors in the parameter update direction or update amplitude in the current training iteration, thereby shortening the training duration of the model.

[0065] In some embodiments, determining the error degree of the first model parameters in step S402 includes: Obtain the second loss curve of the current training iteration. The second loss curve represents the loss values obtained when validating the trained model using different batches of validation data at the end of the current training iteration; Determine the second dispersion degree of the loss value based on the second loss curve; Determine the error degree based on the second dispersion degree.

[0066] The principles of the first dispersion degree and the second dispersion degree are basically similar. The main difference is that the second dispersion degree is obtained based on the validation data after the current training iteration is completed. Since the second dispersion degree is obtained based on the validation data, the deviation degree of the first model parameters obtained in the current training iteration (i.e., the confidence level of the model's prediction results) can be evaluated. Specifically, the larger the second dispersion degree, the greater the deviation degree of the first model parameters, and the greater the error degree can be.

[0067] In some embodiments, determining the error degree of the first model parameters includes: Obtain the gradient curve of the current training iteration. The gradient curve represents the gradient values obtained when training the trained model using different batches of training data in the current training iteration; Determine the third dispersion degree of the gradient values based on the gradient curve; Determine the error degree based on the third dispersion degree.

[0068] Similar to the loss value, if there is no large fluctuation in the parameter update of the trained model in the current training iteration, the obtained gradient data should be relatively concentrated. On the contrary, if there is a large fluctuation in the parameter update of the trained model in the current training iteration, the obtained gradient data should be relatively discrete. Therefore, the third dispersion degree of the gradient values can also reflect whether the model parameter update in the current training iteration is correct. Simply put, the larger the third dispersion degree, the greater the error degree can be.

[0069] In some embodiments, the first model parameters include multiple sub-parameters; determining the error degree of the first model parameters may include: Obtain the sum of the change amounts of the multiple sub-parameters in the current training iteration; Determine the error degree based on the sum of the change amounts.

[0070] For example, taking the above model parameters (trq1, trq2, trq3) as an example. After subtracting the model parameter values of the second training iteration from the updated model parameter values of the first training iteration (i.e., the initial model parameters of the second training iteration), the change amount of the model parameter trq1 is 0.3, the change amount of the model parameter trq2 is 0.1, and the change amount of the model parameter trq3 is 0.2. Therefore, the sum of the change amounts of the multiple sub-parameters of the first model parameter in the current training iteration is 0.3 + 0.2 + 0.1. The larger the sum of the change amounts, the greater the error degree can be.

[0071] In the above embodiments, the sum of the change amounts can directly reflect the overall change degree of the model parameters, which has an intuitive meaning for understanding the stability of the model parameters. At the same time, based on the sum of the change amounts, determining the error degree can simplify the calculation logic, thereby improving the calculation efficiency.

[0072] In some embodiments, determining the error degree of the first model parameter in step S402 may include: Obtaining the weighted average value and the weighted squared average value of the first model parameter, where the weighted average value is used to track the change trend of the first model parameter, and the weighted squared average value is used to track the change trend of the squared value of the first model parameter; Based on the weighted average value and the weighted squared average value of the first model parameter, determining the error degree.

[0073] Among them, the weighted average value and the weighted squared average value are index value statistics obtained by exponential moving average (EMA). Based on the principle of exponential moving average, higher weights are given to the data closer to the current time point in the time series. At the same time, for the data farther from the current time point in the time series, the weights decay according to an exponential law. In this way, a smooth estimation of the time series can be performed, and the change trend of the time series can be tracked.

[0074] Applying exponential moving average to the solution of the present application can track the change trend of the model parameters. Specifically, referring to expressions (4) and (5) in combination, they are the calculation formulas for the average weight formula and the average squared weight in exponential moving average.

[0075]

[0076]

[0077] In expressions (4) and (5), is the weighted average value of the current training iteration, which is used to track the first-order moment index of the model parameter (i.e., the mean trend of the model parameter), is the model parameter of the current training iteration, is the weighted average of the previous training iteration, is the decay rate of historical data, is the weighted squared average of the current training iteration, used to track the second-order moment index of the model parameters (i.e., the squared trend of the model parameters), is the weighted squared average of the previous training iteration, represents element-wise multiplication, i.e., element-wise squaring operation.

[0078] Furthermore, based on expression (6), per-parameter variance estimation can be performed to obtain the variance estimation value .

[0079] (6) Then, for all elements of take the average or weighted sum, and the resulting value can be used to evaluate the error degree. Specifically, the larger the resulting value, the larger the error degree can be.

[0080] In some embodiments, determining the error degree of the first model parameter in step S402 may include: Obtain the second-order moment index of the gradient in the current training iteration, and the second-order moment index of the gradient is used to characterize the gradient noise in the current training iteration; Based on the second-order moment index of the gradient, determine the error degree.

[0081] This embodiment is similar to the above-mentioned scheme for determining the error degree based on the weighted average and weighted squared average of the first model parameter. The main difference is that this embodiment tracks the second-order moment index of the gradient for each model training iteration based on expression (7) , and uses the second-order moment index of the gradient as the gradient variance of the current training iteration. If the gradient variance of the current training iteration is relatively large, it indicates that the reliability of the model parameters in the current training iteration is low, and the error degree can be relatively large.

[0082] (7) In expression (7), represents the second-order moment index of the gradient of the previous training iteration, represents the element-wise square of the gradient of the current training iteration, represents the decay rate of historical gradient data.

[0083] Thus, the related description of error degree calculation is completed.

[0084] Based on the obtained error degree, it is also possible to determine whether the learning rate setting in the model training process is reasonable. Specifically, when the error degree is large (for example, in the initial stage of model training), it indicates that the update of model parameters is unstable and the gradient noise is large. In this case, on the basis of the current learning rate, the learning rate of model training can be appropriately reduced. In this way, the robust convergence of model training can be ensured. On the contrary, when the error degree is small (for example, in the later stage of model training), it indicates that the update of model parameters is stable and has approached convergence or fallen into a local optimum. In this case, on the basis of the current learning rate, the learning rate of model training can be appropriately increased to jump out of the local optimum and continue to explore the optimal solution.

[0085] Based on the above description, in some embodiments, the model training method of the present application may further include: If the error degree is greater than the first robustness threshold, then based on the first learning rate of the current training iteration, a second learning rate is obtained, and the second learning rate is used as the learning rate for the next training iteration, where the second learning rate is less than the first learning rate; If the error degree is less than the second robustness threshold, then based on the first learning rate of the current training iteration, a third learning rate is obtained, and the third learning rate is used as the learning rate for the next training iteration, where the third learning rate is greater than the first learning rate.

[0086] Specifically, the first robustness threshold may be greater than the second robustness threshold. When the error degree is greater than the first robustness threshold, it indicates that the fluctuation of model parameters is large. Therefore, the learning rate can be reduced to ensure the robust convergence of the model. If the error degree is less than the second robustness threshold, it indicates that the update of model parameters may have entered a local optimum. At this time, by increasing the learning rate, the model training can jump out of the local optimum.

[0087] In the above embodiments, by increasing the learning rate, the update of model parameters can have less fluctuation, and thus the model training can converge as soon as possible, shortening the training duration, thereby improving the model training efficiency. By reducing the learning rate, the local optimum can be jumped out during the model training process and the optimal solution can be continuously explored, so that the obtained model parameters have higher accuracy, thereby improving the model performance. In addition, dynamically adjusting the learning rate based on the error degree can ensure that the learning rate of model training matches different model training stages, avoiding problems such as increased model training time or poor model performance caused by unreasonable learning rate settings.

[0088] Further, in some embodiments, the trained model includes multiple neural network layers, and the parameters of different neural network layers may have their respective corresponding parameter change characteristics. For example, in the later stage of model training, for the convolutional layer close to the input layer, the parameter change is usually small and very stable, but for the fully connected classification layer, the parameter fluctuations may be relatively large. In this case, if all neural network layers share the error degree and learning rate, it may be impossible to distinguish the parameter characteristic differences of different neural network layers, and further, due to problems such as unreasonable learning rate setting, the model training duration may be increased and the model training efficiency may be reduced.

[0089] In view of this, determining the parameter weight of the first model parameter based on the error degree may include: For one target neural network layer among the multiple neural network layers, based on the error degree of the target neural network layer, determine the layer parameter weight of the target neural network layer, where the layer parameter weight represents the importance of the parameters of the target neural network layer obtained in the current training iteration during the model training process.

[0090] Correspondingly, updating the first model parameter according to the parameter weight may include: For one target neural network layer among the multiple neural network layers, based on the layer parameter weight of the target neural network layer, update the first model parameter of the target neural network layer to obtain the second model parameter of the target neural network layer, and use the second model parameter of the target neural network layer as the initial layer parameter of the target neural network layer in the next training iteration.

[0091] In this way, different neural network layers can have their respective corresponding layer parameter weights. Based on the layer parameter weights, the parameter characteristic differences of different neural network layers can be distinguished, so that the neural network layers with relatively stable parameter changes can have higher weights, and the neural network layers with larger parameter fluctuations can have lower weights. In this way, the parameter update during the model training process can be precisely controlled, the correct information can be effectively retained, and the wrong information can be eliminated, thereby accelerating the convergence of the model training and improving the model training efficiency.

[0092] In some embodiments, updating the first model parameter according to the parameter weight to obtain the second model parameter includes: Obtain the first parameter change trend of the current training iteration, where the first parameter change trend represents the parameter change amount and change direction of the model in the current training iteration; Update the first parameter change trend according to the parameter weight to obtain the second parameter change trend; Obtain the second model parameter based on the initial model parameter of the current training iteration and the second parameter change trend.

[0093] Specifically, according to expression (8), the first model parameter can be updated to obtain the second model parameter.

[0094] (8) Among them, represents the second model parameter, represents the error degree, represents the parameter weight, represents the change trend of the first parameter, represents the adjustment coefficient (the value can be selected according to actual needs ), represents the change trend of the second parameter obtained after updating the change trend of the first parameter, represents the initial model parameter of the current training iteration.

[0095] It can be understood that since the change trend of the first parameter reflects the change amount and direction of the model parameter in the current training iteration, therefore, based on the parameter weight, updating the change trend of the first parameter is equivalent to updating the change amount and direction of the model parameter. Furthermore, on the basis of the initial model parameter of the current training iteration, adding the change trend of the second parameter obtained after updating the change trend of the first parameter is equivalent to adjusting the first model parameter based on the parameter weight.

[0096] Expression (7) and expression (3) can be regarded as two parallel schemes for updating the first model parameter. In practical applications, one of the ways can be selected according to actual needs to update the first model parameter.

[0097] Furthermore, in some embodiments, obtaining the change trend of the first parameter in the current training iteration may include: Obtaining the change trend of the third parameter in the previous training iteration, where the change trend of the third parameter represents the change amount and direction of the model parameter in the previous training iteration; Determining the first difference magnitude between the initial model parameter of the current training iteration and the first model parameter, and obtaining the change trend of the first parameter based on the change trend of the third parameter and the first difference magnitude.

[0098] Specifically, the relationship between the change trend of the first parameter and the change trend of the third parameter can be shown as expression (9).

[0099] (9) In expression (9), is the change trend of the third parameter in the previous training iteration, represents the first difference magnitude between the initial model parameter of the current training iteration and the first model parameter. is the weight of the change trend of the third parameter. The larger the value of, the greater the influence of the change trend of the third parameter in the previous training iteration on the change trend of the first parameter in the current training iteration. Based on Expression (9), the trends of different training iterations can be accumulated. Thus, in the flat region during the model training process, the progress can be accelerated, and in the oscillating region during the model training process, the oscillation can be smoothed. In this way, the robustness of model training can be improved.

[0100] Up to this point, the entire description of the method of this application is completed. In the method of this application, at the end of the current training iteration, based on the first model parameters obtained in the current training iteration, the error degree of the first model parameters can be determined. Furthermore, when the error degree is large, a smaller parameter weight can be given to the first model parameters, and when the error degree is small, a larger parameter weight can be given to the first model parameters. In this way, after updating the first model parameters based on the parameter weights and using the updated second model parameters as the initial model parameters for the next training iteration, when the parameter update direction or update amplitude in the current training iteration is incorrect, the influence of the current training iteration on the entire model training process can be reduced. Thus, during the model training process, the model parameters can always be updated in accordance with the correct parameter update direction or update amplitude, avoiding the problem of increased model training time caused by fluctuations in the model training process. Therefore, even in the case of limited hardware resources, the model training efficiency can be greatly improved, thereby solving the problem in some technologies that the training efficiency of the model cannot be effectively improved in the case of limited hardware resources.

[0101] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases, the former is a better implementation method.

[0102] Refer to Figure 5 , which is a schematic diagram of the modules of the model training device provided by some embodiments of this application. Figure 5 In, the model training device includes: An information acquisition module 501, configured to acquire model training information, where the model training information includes the first model parameters of the trained model obtained at the end of the current training iteration; A parameter evaluation module 502, configured to determine the error degree of the first model parameters, where the error degree characterizes the fluctuation degree and deviation degree of the first model parameters; A weight determination module 503, configured to determine the parameter weights of the first model parameters based on the error degree, where the parameter weights characterize the importance of the first model parameters during the model training process; A parameter update module 504 is configured to update the first model parameters according to parameter weights to obtain second model parameters, and use the second model parameters as the initial model parameters for the next training iteration.

[0103] In some embodiments, the parameter evaluation module 502 is specifically configured to: Obtain the reference model parameters of the current training iteration; Determine the first difference magnitude between the reference model parameters and the first model parameters, and determine the error degree according to the first difference magnitude.

[0104] In some embodiments, the parameter evaluation module 502 is specifically configured to: Use the initial model parameters of the current training iteration as the reference model parameters, or obtain the average model parameters of multiple training iterations based on the current training iteration and the initial model parameters of multiple training iterations before the current training iteration, and use the average model parameters as the reference model parameters.

[0105] In some embodiments, the parameter evaluation module 502 is specifically configured to: If the first difference magnitude is not greater than the first difference threshold, use the first difference magnitude as the error degree; If the first difference magnitude is greater than the first difference threshold, increase the first difference magnitude to obtain a second difference magnitude, and use the second difference magnitude as the error degree.

[0106] In some embodiments, the parameter evaluation module 502 is specifically configured to: If the first difference magnitude is greater than the second difference threshold, obtain a third difference threshold, where the third difference threshold represents the maximum allowable difference magnitude between the second model parameters and the initial model parameters of the current training iteration; If the difference magnitude between the second model parameters and the initial model parameters of the current training iteration is greater than the difference amplitude, clip the second model parameters so that the difference magnitude between the second model parameters and the initial model parameters of the current training iteration is within the third difference threshold.

[0107] In some embodiments, the parameter evaluation module 502 is specifically configured to: Obtain the first loss curve of the current training iteration, where the first loss curve represents the loss values obtained when training the model to be trained using different batches of training data in the current training iteration; Determine the first dispersion degree of the loss values according to the first loss curve; Determine the error degree according to the first dispersion degree.

[0108] In some embodiments, the parameter evaluation module 502 is specifically configured to: Obtain the second loss curve of the current training iteration, where the second loss curve represents the loss values obtained when validating the trained model using different batches of validation data at the end of the current training iteration; Determine the second dispersion degree of the loss value based on the second loss curve; Determine the error degree based on the second dispersion degree.

[0109] In some embodiments, the parameter evaluation module 502 is specifically configured to: Obtain the gradient curve of the current training iteration, where the gradient curve represents the gradient values obtained when training the trained model using different batches of training data during the current training iteration; Determine the third dispersion degree of the gradient value based on the gradient curve; Determine the error degree based on the third dispersion degree.

[0110] In some embodiments, the first model parameter includes multiple sub-parameters; the parameter evaluation module 502 is specifically configured to: Obtain the sum of the change amounts of the multiple sub-parameters in the current training iteration; Determine the error degree based on the sum of the change amounts.

[0111] In some embodiments, the parameter evaluation module 502 is specifically configured to: Obtain the weighted average value and the weighted square average value of the first model parameter, where the weighted average value is used to track the change trend of the first model parameter, and the weighted square average value is used to track the change trend of the square value of the first model parameter; Determine the error degree based on the weighted average value and the weighted square average value of the first model parameter.

[0112] In some embodiments, the parameter evaluation module 502 is specifically configured to: Obtain the gradient second moment index in the current training iteration, where the gradient second moment index is used to characterize the gradient noise in the current training iteration; Determine the error degree based on the gradient second moment index.

[0113] In some embodiments, the parameter update module 504 is further configured to: If the error degree is greater than the robustness threshold, obtain a second learning rate based on the first learning rate of the current training iteration, and use the second learning rate as the learning rate for the next training iteration, where the second learning rate is less than the first learning rate; If the error degree is not greater than the robustness threshold, obtain a third learning rate based on the first learning rate of the current training iteration, and use the third learning rate as the learning rate for the next training iteration, where the third learning rate is greater than the first learning rate.

[0114] In some embodiments, the trained model includes multiple neural network layers; the weight determination module 503 is specifically configured to: For one target neural network layer among the multiple neural network layers, based on the error degree of the target neural network layer, determine the layer parameter weight of the target neural network layer, where the layer parameter weight characterizes the importance of the parameters of the target neural network layer obtained in the current training iteration during the model training process.

[0115] In some embodiments, the parameter update module 504 is specifically configured to: For one target neural network layer among the multiple neural network layers, based on the layer parameter weight of the target neural network layer, update the first model parameters of the target neural network layer to obtain the second model parameters of the target neural network layer, and use the second model parameters of the target neural network layer as the initial layer parameters of the target neural network layer in the next training iteration.

[0116] In some embodiments, the parameter update module 504 is specifically configured to: Obtain the first parameter change trend of the current training iteration, where the first parameter change trend characterizes the change amount and change direction of the model parameters in the current training iteration; Update the first parameter change trend according to the parameter weight to obtain the second parameter change trend; Obtain the second model parameters based on the initial model parameters of the current training iteration and the second parameter change trend.

[0117] In some embodiments, the parameter update module 504 is specifically configured to: Obtain the third parameter change trend of the previous training iteration, where the third parameter change trend characterizes the change amount and change direction of the model parameters in the previous training iteration; Determine the first difference magnitude between the initial model parameters of the current training iteration and the first model parameters, and obtain the first parameter change trend based on the third parameter change trend and the first difference magnitude.

[0118] With reference to Figure 6 , an embodiment of the present application further provides an electronic device, including a memory 10 and a processor 20. The memory 10 stores a computer program, and the processor 20 is configured to run the computer program to execute the steps in any of the above model training method embodiments.

[0119] An embodiment of the present application further provides a computer non-volatile readable storage medium, which stores a computer program. The computer program is configured to execute the steps in any of the above model training method embodiments when running.

[0120] In an exemplary embodiment, the above-mentioned computer non-volatile readable storage medium may include, but is not limited to: various media such as USB flash drives, read-only memory (ROM for short), random access memory (RAM for short), external hard drives, magnetic disks or optical discs, etc., which can store computer programs.

[0121] The embodiments of the present application also provide a computer program product. The above-mentioned computer program product includes a computer program, and when the computer program is executed by a processor, it implements the steps in any of the above-mentioned model training method embodiments.

[0122] The embodiments of the present application also provide another computer program product, including a non-volatile computer non-volatile readable storage medium. The non-volatile computer non-volatile readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the steps in any of the above-mentioned model training method embodiments.

[0123] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.

[0124] The above has introduced in detail a model training method, device, equipment, storage medium and program product provided by the present application. Specific examples are used herein to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application. It should be noted that for those of ordinary skill in the art in the technical field, without departing from the principle of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the protection scope of the claims of the present application.

Claims

1. A model training method, characterized in that, The method includes: Obtaining model training information, where the model training information includes first model parameters of the trained model obtained at the end of the current training iteration; Determining the error degree of the first model parameters, where the error degree characterizes the fluctuation degree and deviation degree of the first model parameters; Based on the error degree, determining the parameter weight of the first model parameters, where the parameter weight characterizes the importance degree of the first model parameters in the model training process, and where the larger the error degree, the smaller the parameter weight; Updating the first model parameters according to the parameter weight to obtain second model parameters, and using the second model parameters as the initial model parameters for the next training iteration.

2. The method according to claim 1, wherein The determining the error degree of the first model parameters includes: Obtaining reference model parameters of the current training iteration; Determining the first difference magnitude between the reference model parameters and the first model parameters, and determining the error degree according to the first difference magnitude.

3. The method according to claim 2, wherein The obtaining reference model parameters of the current training iteration includes: Using the initial model parameters of the current training iteration as the reference model parameters, or obtaining average model parameters of multiple training iterations based on the current training iteration and the initial model parameters of multiple training iterations before the current training iteration, and using the average model parameters as the reference model parameters.

4. The method according to claim 2, wherein The determining the error degree according to the first difference magnitude includes: If the first difference magnitude is not greater than the first difference threshold, using the first difference magnitude as the error degree; If the first difference magnitude is greater than the first difference threshold, increasing the first difference magnitude to obtain a second difference magnitude, and using the second difference magnitude as the error degree.

5. The method according to claim 2, wherein The method further includes: If the first difference magnitude is greater than a second difference threshold, obtaining a third difference threshold, where the third difference threshold characterizes the maximum allowable difference magnitude between the second model parameters and the initial model parameters of the current training iteration; If the difference magnitude between the second model parameters and the initial model parameters of the current training iteration is greater than the third difference threshold, trimming the second model parameters so that the difference magnitude between the second model parameters and the initial model parameters of the current training iteration is within the third difference threshold.

6. The method according to claim 1, wherein The determining the error degree of the first model parameters includes: Obtaining a first loss curve of the current training iteration, where the first loss curve characterizes the loss values obtained when training the trained model using different batches of training data in the current training iteration; Determining a first dispersion degree of the loss values according to the first loss curve; Determining the error degree according to the first dispersion degree.

7. The method according to claim 1, characterized in that, The determining the error degree of the first model parameters includes: Obtaining a second loss curve of the current training iteration, where the second loss curve characterizes the loss values obtained when validating the trained model using different batches of validation data at the end of the current training iteration; Determining a second dispersion degree of the loss values according to the second loss curve; Determine the error degree according to the second dispersion degree.

8. The method according to claim 1, wherein The determining the error degree of the first model parameter includes: Obtain the gradient curve of the current training iteration, where the gradient curve represents the gradient values obtained when training the model to be trained using different batches of training data in the current training iteration; Determine the third dispersion degree of the gradient values according to the gradient curve; Determine the error degree according to the third dispersion degree.

9. The method according to claim 1, characterized in that The first model parameter includes multiple sub-parameters; the determining the error degree of the first model parameter includes: Obtain the sum of the changes of the multiple sub-parameters in the current training iteration; Determine the error degree according to the sum of the changes.

10. The method according to claim 1, wherein The determining the error degree of the first model parameter includes: Obtain the weighted average value and the weighted square average value of the first model parameter, where the weighted average value is used to track the change trend of the first model parameter, and the weighted square average value is used to track the change trend of the square value of the first model parameter; Determine the error degree based on the weighted average value and the weighted square average value of the first model parameter.

11. The method according to claim 1, wherein The determining the error degree of the first model parameter includes: Obtain the gradient second moment index in the current training iteration, where the gradient second moment index is used to characterize the gradient noise in the current training iteration; Determine the error degree based on the gradient second moment index.

12. The method according to any one of claims 1 to 11, characterized in that, The method further includes: If the error degree is greater than the first robustness threshold, obtain a second learning rate based on the first learning rate of the current training iteration, and use the second learning rate as the learning rate for the next training iteration, where the second learning rate is less than the first learning rate; If the error degree is less than the second robustness threshold, obtain a third learning rate based on the first learning rate of the current training iteration, and use the third learning rate as the learning rate for the next training iteration, where the third learning rate is greater than the first learning rate.

13. The method according to any one of claims 1 to 11, characterized in that The model to be trained includes multiple neural network layers; The determining the parameter weight of the first model parameter based on the error degree includes: For one target neural network layer among the multiple neural network layers, determine the layer parameter weight of the target neural network layer based on the error degree of the target neural network layer, where the layer parameter weight represents the importance degree of the parameters of the target neural network layer obtained in the current training iteration in the model training process.

14. The method according to claim 13, wherein The updating the first model parameter according to the parameter weight includes: For one target neural network layer among the multiple neural network layers, update the first model parameter of the target neural network layer based on the layer parameter weight of the target neural network layer to obtain the second model parameter of the target neural network layer, and use the second model parameter of the target neural network layer as the initial layer parameter of the target neural network layer in the next training iteration.

15. The method according to claim 1, wherein The updating the first model parameter according to the parameter weight to obtain the second model parameter includes: Obtain a first parameter change trend of the current training iteration, where the first parameter change trend characterizes the change amount and change direction of the model parameters in the current training iteration; Update the first parameter change trend according to the parameter weight to obtain a second parameter change trend; Obtain the second model parameter according to the initial model parameter of the current training iteration and the second parameter change trend.

16. The method according to claim 15, characterized in that, The obtaining of the first parameter change trend of the current training iteration includes: Obtain a third parameter change trend of the previous training iteration, where the third parameter change trend characterizes the change amount and change direction of the model parameters in the previous training iteration; Determine a first difference magnitude between the initial model parameter of the current training iteration and the first model parameter, and obtain the first parameter change trend based on the third parameter change trend and the first difference magnitude.

17. A model training device, characterized in that, The device includes: An information acquisition module, configured to acquire model training information, where the model training information includes a first model parameter of the trained model obtained at the end of the current training iteration; A parameter evaluation module, configured to determine an error degree of the first model parameter, where the error degree characterizes the fluctuation degree and deviation degree of the first model parameter; A weight determination module, configured to determine a parameter weight of the first model parameter based on the error degree, where the parameter weight characterizes the importance degree of the first model parameter in the model training process; A parameter update module, configured to update the first model parameter according to the parameter weight to obtain a second model parameter, and use the second model parameter as the initial model parameter of the next training iteration.

18. An electronic device, characterized in that, including: A memory, configured to store a computer program; A processor, configured to implement the model training method according to any one of claims 1 to 16 when executing the computer program.

19. A computer non-volatile readable storage medium, characterized in that, A computer program is stored in the computer non-volatile readable storage medium, where the computer program implements the model training method according to any one of claims 1 to 16 when executed by a processor.

20. A computer program product, comprising a computer program, characterized in that, The computer program implements the model training method according to any one of claims 1 to 16 when executed by a processor.

Citation Information

Patent Citations

  • Iterative training method, equipment, system and medium

    CN110084380A

  • Large language model training method and device, computer equipment and storage medium

    CN117993461A

  • Multi-stage adaptive model training method for high-quality service of pension community

    CN118798324A

  • Model training method and device, equipment and medium

    CN119227836A

  • Stochastic gradient boosting for deep neural networks

    US10510003B1