CN111860789A - Model training method, terminal and storage medium - Google Patents

Model training method, terminal and storage medium Download PDF

Info

Publication number
CN111860789A
CN111860789A CN202010760865.3A CN202010760865A CN111860789A CN 111860789 A CN111860789 A CN 111860789A CN 202010760865 A CN202010760865 A CN 202010760865A CN 111860789 A CN111860789 A CN 111860789A
Authority
CN
China
Prior art keywords
ith
error
training
learning rate
model
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010760865.3A
Other languages
Chinese (zh)
Inventor
刘君
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN202010760865.3A priority Critical patent/CN111860789A/en
Publication of CN111860789A publication Critical patent/CN111860789A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • General Engineering & Computer Science (AREA)
  • Biomedical Technology (AREA)
  • Molecular Biology (AREA)
  • General Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Biophysics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Medical Informatics (AREA)
  • Image Analysis (AREA)

Abstract

The embodiment of the application discloses a model training method, a terminal and a storage medium, wherein the model training method comprises the following steps: configuring an ith weight when the prediction model is trained through the training data; the ith weight is used for carrying out ith round of training on the prediction model; i is an integer greater than 0; inputting training data into a prediction model to obtain an ith loss value, and determining an ith learning rate according to the ith loss value and a deviation lower limit threshold; the ith loss value is used for determining the deviation degree between the predicted value and the true value output by the prediction model; configuring an (i +1) th weight according to the ith learning rate, and performing (i +1) th round training on the prediction model according to the (i +1) th weight until a prediction model which is completely trained is obtained; and performing prediction processing on the object to be predicted by using the trained prediction model.

Description

Model training method, terminal and storage medium
Technical Field
The invention relates to the technical field of neural networks, in particular to a model training method, a terminal and a storage medium.
Background
When the model training is performed by using the gradient descent method, the update of the weight can be realized by adjusting the learning rate. The convergence rate of the model is accelerated by an appropriate learning rate, and the loss value of the objective function can be increased sharply by an undesirable learning rate, so that the training of the model cannot be completed. Therefore, selecting an appropriate learning rate will be crucial for the training of the model.
At present, common methods for adjusting the learning rate mainly include discrete reduction, exponential slowing, score slowing, and the like, and specifically, the methods for adjusting the learning rate are all adjustment methods in which the learning rate is decreased according to a certain rule as the number of training rounds increases, and the method for adjusting the learning rate depending on the number of training rounds cannot obtain the most appropriate learning rate, so that the convergence rate of the model is reduced.
Disclosure of Invention
The embodiment of the application provides a model training method, a terminal and a storage medium, when model training is carried out, the learning rate can be updated in time, the most appropriate learning rate is obtained, and therefore the convergence rate of the model is improved.
The technical scheme of the embodiment of the application is realized as follows:
in a first aspect, an embodiment of the present application provides a model training method, where the method includes:
configuring an ith weight when the prediction model is trained through the training data; wherein the ith weight is used for carrying out an ith round of training on the prediction model; i is an integer greater than 0;
inputting the training data into the prediction model to obtain an ith loss value, and determining an ith learning rate according to the ith loss value and a deviation lower limit threshold; the ith loss value is used for determining the deviation degree between the predicted value and the true value output by the prediction model;
configuring an (i +1) th weight according to the ith learning rate, and performing (i +1) th round training on the prediction model according to the (i +1) th weight until a prediction model which is completely trained is obtained;
and performing prediction processing on the object to be predicted by using the trained prediction model.
In a second aspect, an embodiment of the present application provides a terminal, where the terminal includes: a configuration unit, an acquisition unit, a determination unit, a training unit, a prediction unit,
the configuration unit is used for configuring the ith weight when the prediction model is trained through the training data; wherein the ith weight is used for carrying out an ith round of training on the prediction model; i is an integer greater than 0;
the acquisition unit is used for inputting the training data into the prediction model to obtain an ith loss value;
the determining unit is used for determining an ith learning rate according to the ith loss value and a deviation lower limit threshold;
the configuration unit is further used for configuring an (i +1) th weight according to the ith learning rate;
the training unit is used for carrying out (i +1) th round training on the prediction model according to the (i +1) th weight until a prediction model which is completely trained is obtained;
and the prediction unit is used for performing prediction processing on the object to be predicted by using the trained prediction model.
In a third aspect, an embodiment of the present application provides a terminal, where the terminal includes a processor and a memory storing instructions executable by the processor, and when the instructions are executed by the processor, the method for training a model as described above is implemented.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a program is stored, and the program is applied to a terminal, and when executed by a processor, implements the model training method as described above.
The embodiment of the application provides a model training method, a terminal and a storage medium, wherein the terminal configures the ith weight when training a prediction model through training data; the ith weight is used for carrying out ith round of training on the prediction model; i is an integer greater than 0; inputting training data into a prediction model to obtain an ith loss value, and determining an ith learning rate according to the ith loss value and a deviation lower limit threshold; the ith loss value is used for determining the deviation degree between the predicted value and the true value output by the prediction model; configuring an (i +1) th weight according to the ith learning rate, and performing (i +1) th round training on the prediction model according to the (i +1) th weight until a prediction model which is completely trained is obtained; and performing prediction processing on the object to be predicted by using the trained prediction model. That is to say, in the embodiment of the application, in the process of training the prediction model, the terminal feeds back the error between the output loss value and the deviation lower limit threshold value to the process of adjusting the learning rate in time, so that a more appropriate learning rate can be obtained by using error calculation, then the weight is updated according to the adjusted learning rate, and the next round of training is performed on the prediction model by using the new weight, so that the convergence of the prediction model can be accelerated. Therefore, when the terminal conducts model training, the learning rate can be updated in time, the most appropriate learning rate is obtained, and therefore the convergence rate of the model is improved.
Drawings
FIG. 1 is a first schematic flow chart of the implementation of the model training method;
FIG. 2 is a video frame prediction method based on a predetermined training strategy;
FIG. 3 is a diagram of an image defogging method based on a preset training strategy;
FIG. 4 is a three-dimensional human body modeling and texture reconstruction method based on a preset training strategy;
FIG. 5 is a schematic diagram of a second implementation flow of the model training method;
FIG. 6 is a third schematic flow chart of the implementation of the model training method;
FIG. 7 is a schematic diagram of a fourth implementation flow of the model training method;
FIG. 8 is a schematic diagram of an implementation flow of the model training method
FIG. 9 is a schematic illustration of learning rate adjustment;
FIG. 10 is a fifth flowchart illustrating an implementation of the model training method;
FIG. 11 is a sixth schematic flow chart of an implementation of the model training method;
FIG. 12 is a first schematic diagram of the structure of the terminal;
fig. 13 is a schematic diagram of a terminal structure.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. It is to be understood that the specific embodiments described herein are illustrative of the relevant application and are not limiting of the application. It should be noted that, for the convenience of description, only the parts related to the related applications are shown in the drawings.
The Gradient Descent (GD) method is a commonly used method for solving an unconstrained optimization problem, and is widely applied to the fields of optimization, statistics, machine learning and the like. In particular, gradient descent is one of the iterative methods that can be used to solve a least squares problem (both linear and non-linear). Gradient descent is one of the most commonly used methods when solving model parameters of machine learning algorithms, i.e. unconstrained optimization problems, and the other commonly used method is the least squares method. When the minimum value of the loss function is solved, iterative solution can be carried out step by step through a gradient descent method, and the minimized loss function and the model parameter value are obtained. Conversely, if we need to solve the maximum of the loss function, then we need to iterate through the gradient ascent method. In machine learning, two gradient descent methods, namely a random gradient descent method and a batch gradient descent method, are developed based on a basic gradient descent method.
In the training of the neural network, if the gradient descent algorithm is adopted to update the weight of the network structure, the old weight W is used as the basisoldThe updated weight W can be generally obtained by formula (1)new
Figure BDA0002613039950000021
Wherein η is the learning rate and L is the loss function.
The Learning rate (Learning rate) is an important super-parameter in supervised Learning and deep Learning, and determines whether and when the objective function can converge to a local minimum. An appropriate learning rate enables the objective function to converge to a local minimum in an appropriate time. Specifically, when the learning rate setting is too small, the convergence process will become very slow; when the learning rate is set too large, the gradient may oscillate around the minimum value and may even fail to converge.
The loss function (loss function) is a function that maps the value of a random event or its related random variables to non-negative real numbers to represent the "risk" or "loss" of the random event. In application, the loss function is usually associated with the optimization problem as a learning criterion, i.e. the model is solved and evaluated by minimizing the loss function. For example, it is used for parameter estimation of models in statistics and machine learning, for risk management and decision making in macro-economics, and for optimal control theory in control theory.
The convergence rate of the model is accelerated by an appropriate learning rate, and the loss value of the objective function can be increased sharply by an undesirable learning rate, so that the training of the model cannot be completed. And when the model begins to train, a larger learning rate needs to be selected to enable the model to reach a convergence position as soon as possible, and when the model approaches to convergence, a smaller learning rate needs to be selected to prevent the model from shaking during training. Therefore, selecting an appropriate learning rate will be crucial for the training of the model.
At present, common methods for adjusting the learning rate mainly include discrete descent (discrete stationary case), exponential slow down (exponential slow) and fractional slow down (1/t slow), wherein:
1. discrete descent is the reduction of the number of rounds, for example, for deep learning, the learning rate is halved every t rounds of training; for supervised learning, a larger learning rate is initially set, and then the learning rate is decreased as the number of iterations increases.
2. The learning rate decreases exponentially, i.e. the learning rate decreases exponentially according to the increase of the number of training rounds, for example, for deep learning, the learning rate decreases exponentially according to the increase of the number of training rounds by the difference value.
3. The score is slowed down, and the learning rate eta is decreased progressively according to a formula (2), wherein k is a hyperparameter, and t is the number of training rounds:
Figure BDA0002613039950000031
as can be seen, the conventional learning rate adjustment method is only related to the number of training rounds of model training, and the value of the learning rate is not related to the model output (loss function), i.e., the learning rate adjustment method is a completely open-loop method. That is, when the learning rate is adjusted, the magnitude of the learning rate cannot be updated in time according to the output, and the convergence rate of the model is reduced.
In order to solve the above problem, in the embodiment of the application, in the process of training the prediction model, the terminal feeds back the error between the output loss value and the deviation lower limit threshold value to the process of adjusting the learning rate in time, so that a more appropriate learning rate can be obtained by using error calculation, then the weight is updated according to the adjusted learning rate, and the next round of training is performed on the prediction model by using a new weight, so that the convergence of the prediction model can be accelerated. Therefore, when the terminal conducts model training, the learning rate can be updated in time, the most appropriate learning rate is obtained, and therefore the convergence rate of the model is improved.
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
An embodiment of the present application provides a model training method, fig. 1 is a schematic diagram of an implementation flow of the model training method, as shown in fig. 1, in an embodiment of the present application, a method for a terminal to perform model training may include the following steps:
101, configuring ith weight when training a prediction model through training data; the ith weight is used for carrying out ith round of training on the prediction model; i is an integer greater than 0.
In the embodiment of the application, when the terminal trains the prediction model through the training data, an ith weight used for an ith round of training of the prediction model may be configured first.
Specifically, in the present application, when i is an integer greater than 0, for example, i is 2, the terminal is configured with a second weight for performing a second round of training on the prediction model.
It is understood that in the embodiment of the present application, the prediction model is the neural network to be trained. The Neural Networks (NN) is an algorithmic mathematical model which simulates animal Neural network behavior characteristics and performs distributed parallel information processing. The network achieves the aim of processing information by adjusting the mutual connection relationship among a large number of nodes in the network depending on the complexity of the system.
Further, in embodiments of the present application, a prediction model may be used to perform the image prediction process. For example, a frame of image is input into a prediction model, image prediction processing can be completed by the prediction model, and a new frame of image is output.
It should be noted that, in the present application, the training of the prediction model by the terminal may be understood as a process in which the neural network updates the weights by propagating forward and backward. Where the Weights (Weights) are constant inputs to each node of the neural network.
For example, in the embodiments of the present application, the terminal may be any terminal device with a storage function, for example: a tablet Computer, a mobile phone, an electronic reader, a remote controller, a Personal Computer (PC), a notebook Computer, a vehicle-mounted device, a network tv, a wearable device, a Personal Digital Assistant (PDA), a Portable Media Player (PMP), a navigation device, and other terminal devices.
Step 102, inputting training data into a prediction model to obtain an ith loss value, and determining an ith learning rate according to the ith loss value and a deviation lower limit threshold; and the ith loss value is used for determining the deviation degree between the predicted value and the true value output by the prediction model.
In the embodiment of the application, after configuring the ith weight, the terminal may start an ith round of training on the prediction model, specifically, the terminal may input training data to the prediction model and then obtain an ith loss value, and then the terminal may determine an ith learning rate according to the ith loss value and the deviation lower limit threshold.
Further, in the embodiment of the present application, the ith loss value may be a loss function obtained by the terminal after the ith round of training on the prediction model. Specifically, the ith loss value may be used to determine the degree of deviation between the predicted value and the true value, which are output by the prediction model after the ith round of training.
The loss function is a function for calculating a difference between a predicted value and a true value of the network model with respect to a single sample, that is, the loss function is defined on the single sample and refers to an error of one sample. Commonly used loss functions include 0-1 loss functions, square loss functions, absolute loss functions, logarithmic loss functions, and the like.
The loss function is generally denoted as L (y, f (x)) and measures the degree of inconsistency between the true value y and the predicted value f (x), with smaller values generally being better. To facilitate the comparison of different loss functions, they are often expressed as univariate functions, where this variable is y-f (x) in the regression problem and yf (x) in the classification problem.
That is, in the embodiment of the present application, after the terminal performs training on the prediction model, the terminal may compare the output real value with the expected predicted value, so that the loss function, i.e., the loss value, determined after the training of the round may be determined according to the comparison result.
It should be noted that, in the embodiment of the present application, the terminal may train the prediction model by using a gradient descent method. Among them, the gradient descent method is simply a method for finding the minimization of the objective function. Specifically, the method is a method for iteratively searching for a local minimum value of a current point on a function corresponding to a distance point with a specified step size in the opposite direction of a gradient (or an approximate gradient).
It is understood that, in the embodiment of the present application, the terminal performs the first round of training on the prediction model, and the first weight used by the terminal is preset by the terminal.
Further, in the embodiment of the present application, when determining the ith learning rate according to the ith loss value and the deviation lower limit threshold, the terminal may first determine the ith error according to the ith loss value and the deviation lower limit threshold; and if the ith error does not meet the preset error requirement, the terminal can determine the ith learning rate according to the ith error.
That is, in the present application, after the terminal performs the ith round of training on the prediction model according to the ith weight and obtains the ith loss value, the ith error may be determined according to the ith loss value and the deviation lower limit threshold.
It is understood that, in the embodiment of the present application, after the terminal completes the ith round of training on the prediction model, the terminal may compare the output ith loss value with the deviation lower limit threshold, so that the ith error may be determined according to the difference between the output ith loss value and the deviation lower limit threshold.
It should be noted that, in the embodiment of the present application, the terminal may preset a desired loss value, that is, determine the lower limit threshold of the deviation. The lower deviation threshold may be understood as the minimum error between the predicted value and the actual value of the prediction model output, which is allowed by the terminal.
Further, in the embodiment of the present application, the terminal may determine the ith error by using the following formula:
e(i)=L(i)- (3)
wherein, is the deviation lower limit threshold, e (i) is the ith error, and L (i) is the ith loss value.
Further, in the embodiment of the present application, after determining the ith error according to the ith loss value and the deviation lower limit threshold, the terminal may first determine whether the ith error meets a preset error requirement, and if it is determined that the ith error does not meet the preset error requirement, the terminal may further determine the ith learning rate according to the ith error.
It should be noted that, in the present application, in the process of training the prediction model by using the gradient descent method, the weights of the prediction model may be updated by using error back propagation, which is simply referred to as back propagation. The amount of weight update is referred to herein as the step size or learning rate. In particular, the learning rate is a configurable hyper-parameter used in neural network training, which has a small positive value, typically in the range between 0 and 1.
The learning rate can be understood as an update coefficient of the network weight, and can control the rate or speed of model learning. In particular, the learning rate may control the number of allocation errors, and the weights of the model are updated each time they are updated. In general, a larger learning rate allows the model to learn faster at the expense of reaching a suboptimal final weight set. A smaller learning rate may allow the model to learn a more optimal or even globally optimal set of weights, but may take longer to train.
In extreme cases, an excessive learning rate will result in too large a weight update, and the performance of the model (e.g., its loss on the training data set) will oscillate over the training period. The wobble performance is said to be caused by the weight of divergence (divergence). Too small a learning rate may never converge or may fall into a sub-optimal solution.
It should be noted that, in the embodiment of the present application, the preset error requirement may be used to measure the magnitude of the ith error, that is, the preset error requirement can determine whether to complete the training of the prediction model.
It can be understood that, in the embodiment of the present application, if the terminal determines that the ith error does not meet the preset error requirement, it may be considered that the prediction model needs to be trained further, and before performing the next round of training, the terminal may determine the ith learning rate according to the ith error.
That is, in the present application, if the ith error does not satisfy the preset error requirement, the terminal may set the ith learning rate before performing the next round of training on the prediction model. Specifically, when setting the ith learning rate, the terminal may introduce the ith error determined after the ith round of training, i.e., determine the ith learning rate based on the ith error.
It is to be understood that, in the embodiment of the present application, the ith learning rate is used to adjust and update the weights of the prediction model so as to obtain the weights used in the next round of training.
As can be seen from the above, in the present application, in the process of training the prediction model by using the gradient descent method, the learning rate is not fixed, nor is it changed according to the number of training rounds, but is adjusted according to the loss value output after each training round, that is, the learning rate can be updated by using the error corresponding to each training round.
Further, in the embodiment of the present application, when determining the ith learning rate according to the ith error, the terminal may update and adjust the learning rate by adjusting the parameter and the ith error. The adjusting parameters may include a proportional adjusting coefficient, an integral adjusting coefficient and a differential adjusting coefficient, and accordingly, the adjusting parameters update the learning rate through at least one of the proportional adjusting, the integral adjusting and the differential adjusting.
It should be noted that, in the embodiment of the present application, when the terminal updates and adjusts the learning rate through the adjustment parameter and the ith error, the ith learning rate may be obtained by directly calculating the adjustment parameter and the ith error, or the adjustment parameter may be adjusted through the ith error, and then the ith learning rate is obtained by calculating the adjusted adjustment parameter and the ith error.
Further, in the embodiment of the present application, the terminal may determine an error range in advance, that is, a preset error range, where the preset error range may be an acceptable minimum error interval. Then, after obtaining the ith error, the ith error may be compared with the preset error range, and then whether the ith error meets the preset error requirement may be determined according to the comparison result.
It can be understood that, in the embodiment of the present application, after comparing the ith error with the preset error range, if the ith error belongs to the preset error range, the terminal may consider that the training of the prediction model is completed, and therefore may determine that the ith error meets the preset error requirement; if the ith error exceeds the preset error range, the prediction model is considered to be required to be trained, and therefore the ith error can be judged not to meet the preset error requirement.
For example, in the present application, the terminal may set the preset error range to (-0.01, 0.01), and if the ith error is 0.1, that is, the ith error exceeds the preset error range, the terminal may determine that the ith error does not satisfy the preset error requirement, and may need to continue training the prediction model.
Further, in the embodiment of the application, after obtaining the ith error, the terminal may directly compare the ith error with 0, and if the ith error is equal to 0, it may be considered that training of the prediction model is completed, so that it may be determined that the ith error meets the preset error requirement; if the ith error is not equal to 0, the prediction model is considered to be required to be trained, and therefore the ith error can be judged not to meet the preset error requirement.
For example, in the present application, if the ith error is 0.05, that is, the ith error is not equal to 0, the terminal may determine that the ith error does not meet the preset error requirement, and may need to continue training the prediction model.
And 103, configuring an (i +1) th weight according to the ith learning rate, and performing (i +1) th round training on the prediction model according to the (i +1) th weight until the prediction model which is completely trained is obtained.
In the embodiment of the application, if the ith error does not meet the preset error requirement, after the ith learning rate is determined according to the ith error, the terminal may determine the (i +1) th weight according to the ith learning rate, and perform the (i +1) th round of training on the prediction model according to the (i +1) th weight until the training on the prediction model is completed.
It is to be understood that, in the embodiment of the present application, after determining the ith learning rate according to the ith error, the terminal further determines the weight of the next round of training, i.e., the (i +1) th weight, based on the ith learning rate. Wherein the (i +1) th weight is determined based on the i-th learning rate adjusted by the terminal, and the terminal introduces the i-th error obtained based on the i-th round of training in determining the i-th learning rate, so that the (i +1) th weight is adjusted based on the i-th error as compared with the i-th weight.
That is, in the present application, in the process of training the prediction model using the gradient descent method, since the learning rate is adjusted according to the loss value output after each training round, the (i +1) th weight after the readjustment is also updated based on the loss value corresponding to the training round after the ith training round, and has no relation with the number of training rounds.
For example, in the embodiment of the present application, the terminal may determine the (i +1) th weight W used in the (i +1) th round of training by the following formulai+1
Figure BDA0002613039950000061
Wherein L (i) is the ith weight, η, used in the ith round of trainingiIs the ith learning rate.
Further, in an embodiment of the present application, after performing (i +1) th round training on the prediction model using the (i +1) th weight, the terminal may obtain a corresponding loss function, that is, the (i +1) th loss value, and then may continue to compare the (i +1) th loss value with the deviation lower threshold, so that the (i +1) th error may be determined according to a difference between the two.
Further, in this application, the terminal may first determine whether the (i +1) th error meets a preset error requirement, and if it is determined that the (i +1) th error does not meet the preset error requirement, the terminal may further determine the (i +1) th learning rate according to the (i +1) th error.
It should be noted that, in the embodiment of the present application, after determining the (i +1) th learning rate according to the (i +1) th error, the terminal may continue to perform the next round of training according to the (i +1) th learning rate, specifically, the terminal may determine the (i +2) th weight according to the (i +1) th learning rate, and perform the (i +2) th round of training on the prediction model according to the (i +2) th weight until the obtained error meets the preset error requirement.
Specifically, in the embodiment of the application, after determining whether the (i +1) th error meets the preset error requirement, if it is determined that the (i +1) th error meets the preset error requirement, the terminal may consider that the training of the prediction model is completed, and may end the training process of the model.
It should be noted that, in the embodiment of the present application, when determining whether to complete the training of the prediction model, whether to end the model training may be determined by using the above-mentioned proposed manner of whether to meet the preset error requirement; the number of rounds of model training may be set in advance so that the model training is ended after the predetermined number of rounds is reached; the time of model training can be set in advance, so that the model training is finished after the specified time is reached; and a convergence condition can be set in advance, and when the prediction model after multiple times of training meets the convergence condition, the model training is ended.
It can be understood that, in the embodiment of the present application, when i is greater than 1, for other rounds of training after the first round of training of the prediction model, the terminal may update the learning rate according to the model training method proposed in the above steps 101 to 103, and for the first round of training of the prediction model, the terminal may initialize the first weight value, the adjustment parameter, the first learning rate, and the deviation lower limit threshold before performing the first round of training on the prediction model; wherein the adjustment parameter is used for updating the learning rate. And then training the prediction model according to the first weight, obtaining a first loss value after completing the first round of training on the prediction model, determining a first error according to the first loss value and a deviation lower limit threshold, and if the first error does not meet the preset error requirement, determining a second weight by the terminal directly according to the first learning rate, and further performing a second round of training on the prediction model according to the second weight.
It is understood that, in the embodiment of the present application, for the first round of training of the prediction model, the terminal may also perform updating of the learning rate according to the model training method proposed in the above-mentioned step 101 to step 103. Specifically, the terminal may initialize the first weight value, the adjustment parameter, and the lower threshold of the deviation before performing the first round of training on the prediction model. And then training the prediction model according to the first weight, obtaining a first loss value after completing the first round of training on the prediction model, determining a first error according to the first loss value and a deviation lower limit threshold, if the first error does not meet a preset error requirement, calculating a first learning rate according to the first error by the terminal, then determining a second weight by using the first learning rate, and further performing a second round of training on the prediction model according to the second weight. I.e., i may also be an integer greater than or equal to 1.
And 104, performing prediction processing on the object to be predicted by using the trained prediction model.
In the embodiment of the application, after the terminal obtains the trained prediction model, the trained prediction model can be used to perform prediction processing on the object to be predicted.
It is to be appreciated that in embodiments of the present application, the prediction model may be used to perform an image prediction process or a video prediction process. The object to be predicted is a frame of image or a video frame rate sequence.
For example, in the embodiment of the present application, if the object to be predicted is a video to be predicted, when the terminal predicts the object to be predicted by using the prediction model, an original frame may be extracted from the video to be predicted first; then inputting the original frame into a prediction model to obtain a generated frame corresponding to the original frame; and finally, determining a frame prediction result corresponding to the video to be predicted according to the generated frame.
It can be understood that, in the present application, by the model training method proposed in step 101 to step 103, after each round of training, the terminal may obtain an appropriate learning rate through the output obtained error feedback calculation, so that a strong correlation exists between the learning rate and the error, thereby improving the convergence rate, improving the training effect, and obtaining a prediction model with a higher prediction effect. And the flow of feedback calculation is automatically completed in the whole training process, so that the human intervention is not needed, and the training cost is greatly reduced.
The embodiment of the application provides a model training method, wherein when a prediction model is trained through training data, the ith weight is configured; the ith weight is used for carrying out ith round of training on the prediction model; i is an integer greater than 0; inputting training data into a prediction model to obtain an ith loss value, and determining an ith learning rate according to the ith loss value and a deviation lower limit threshold; the ith loss value is used for determining the deviation degree between the predicted value and the true value output by the prediction model; configuring an (i +1) th weight according to the ith learning rate, and performing (i +1) th round training on the prediction model according to the (i +1) th weight until a prediction model which is completely trained is obtained; and performing prediction processing on the object to be predicted by using the trained prediction model. That is to say, in the embodiment of the application, in the process of training the prediction model, the terminal feeds back the error between the output loss value and the deviation lower limit threshold value to the process of adjusting the learning rate in time, so that a more appropriate learning rate can be obtained by using error calculation, then the weight is updated according to the adjusted learning rate, and the next round of training is performed on the prediction model by using the new weight, so that the convergence of the prediction model can be accelerated. Therefore, when the terminal conducts model training, the learning rate can be updated in time, the most appropriate learning rate is obtained, and therefore the convergence rate of the model is improved.
Based on the foregoing embodiment, in yet another embodiment of the present application, it can be understood that the model training method provided in the embodiment of the present application is not only applicable to training of prediction models, but also applicable to training of various other types of models, for example, a terminal may train any type of models, such as a classification model, a defogging model, a noise reduction model, and a generation model, using the model training method provided in the present application.
Fig. 2 is a video frame prediction method based on a preset training strategy, and as shown in fig. 2, in an embodiment of the present application, a method for a terminal to perform video frame prediction based on the preset training strategy may include the following steps:
step 201, constructing a generation model and a discrimination model based on the generated countermeasure network.
Step 202, establishing a generating network according to the generating model, the distinguishing model and a prestored video data set; wherein, the generation network is used for acquiring new video content.
And step 203, training the generated network according to a preset training strategy.
Step 204, inputting the video to be predicted into a generation network which completes training, and obtaining a frame prediction result corresponding to the video to be predicted; wherein the frame prediction result comprises new video content.
In an embodiment of the present application, a generation network may be used to obtain new video content. Specifically, the generation network is a network model which is obtained by the terminal through learning and training the pre-stored video data set based on the generation countermeasure network and can generate samples which are consistent with the distribution of the pre-stored video data set.
It should be noted that, in the embodiment of the present application, the preset training strategy is used to continuously adjust the learning rate by using the error between the loss value and the deviation lower limit threshold in the training process of generating the network, so that the weight can be updated by using the adjusted learning rate, and a next round of training is performed.
Further, in an embodiment of the present application, the method for training the generated network by the terminal according to the preset training strategy may include the following steps:
step 203a, configuring the ith weight when training a generated network by pre-storing a video data set; the ith weight is used for carrying out ith round of training on the generated network; i is an integer greater than 0.
Step 203b, inputting a pre-stored video data set to a generation network to obtain an ith loss value, and determining an ith learning rate according to the ith loss value and a deviation lower limit threshold; and determining the deviation degree between the predicted value and the true value of the generated network output by the ith loss value.
And step 203c, configuring an (i +1) th weight according to the ith learning rate, and performing (i +1) th round training on the generation network according to the (i +1) th weight until the generation network which is trained is obtained.
Fig. 3 is an image defogging method based on a preset training strategy, and as shown in fig. 3, in the embodiment of the present application, the method for the terminal to perform image defogging based on the preset training strategy may include the following steps:
step 301, after the image to be processed is judged to be the atomization image, determining the size parameter of the image to be processed.
Step 302, determining a preprocessing strategy corresponding to the image to be processed according to the size parameter; wherein the pre-processing strategy is used to limit the image size.
And 303, if the preprocessing strategy is to divide the image to be processed, dividing the image to be processed to obtain the sub-image corresponding to the image to be processed.
And 304, training an image defogging model according to a preset training strategy, and defogging the sub-images according to the image defogging model to obtain the defogged sub-images corresponding to the sub-images.
And 305, training an image splicing model according to a preset training strategy, and splicing the defogged subimages according to the image splicing model to obtain a defogged image corresponding to the image to be processed.
In the embodiment of the application, the terminal can utilize the image defogging model obtained by the deep learning to perform defogging treatment on the image to be processed, and meanwhile, for the image to be processed with a large size, the terminal can also use the image splicing model obtained by the deep learning to perform splicing treatment after the defogging treatment is performed on the subimage divided by the image defogging model on the image to be processed, so that the processing precision is ensured and the processing speed is increased. Further, the image defogging model and the image splicing model are obtained by the terminal through the minimum network design of the CNN, so that the image defogging method can be operated in the terminal in real time. .
It should be noted that, in the embodiment of the present application, the preset training strategy is used to continuously adjust the learning rate by using the error between the loss value and the lower threshold of the deviation in the training process of the image defogging model and the image stitching model, so that the weight can be updated by using the adjusted learning rate, and a next round of training can be performed.
Further, in the embodiment of the application, when the terminal trains the image defogging model according to a preset training strategy, the ith weight may be configured first; the ith weight is used for carrying out ith round of training on the generated model; i is an integer larger than 0, then training data are input into the image defogging model to obtain an ith loss value, and the ith learning rate is determined according to the ith loss value and the deviation lower limit threshold; and finally, the terminal can configure an (i +1) th weight according to the i-th learning rate and perform (i +1) th training on the image defogging model according to the (i +1) th weight until the image defogging model which is trained is obtained.
Correspondingly, in the application, when the terminal trains the image mosaic model according to the preset training strategy, the ith weight can be configured firstly; the ith weight is used for carrying out ith round of training on the generated model; i is an integer larger than 0, then training data are input into the image stitching model to obtain an ith loss value, and the ith learning rate is determined according to the ith loss value and the deviation lower limit threshold; and finally, the terminal can configure an (i +1) th weight according to the i-th learning rate and perform (i +1) th training on the image mosaic model according to the (i +1) th weight until the trained image mosaic model is obtained.
Fig. 4 is a three-dimensional human body modeling and texture reconstructing method based on a preset training strategy, and as shown in fig. 4, in this embodiment, a method for a terminal to perform three-dimensional human body modeling and texture reconstruction based on a preset training strategy may include the following steps:
step 401, acquiring a target image, and performing segmentation processing based on an object to be reconstructed in the target image to obtain a segmented image; the target image is a frame of front image corresponding to the object to be reconstructed.
Step 402, respectively obtaining an initial estimated shape and partial texture information of an object to be reconstructed based on the segmented image.
Step 403, reconstructing an initial three-dimensional model of the object to be reconstructed by using the initial estimation shape; wherein the initial three-dimensional model is a non-textured three-dimensional model.
And step 404, training a texture generation model according to a preset training strategy, and generating the model according to the partial texture information and the texture to obtain complete texture information of the object to be reconstructed.
Step 405, generating a three-dimensional reconstruction model of the object to be reconstructed based on the initial three-dimensional model and the complete texture information; wherein the three-dimensional reconstruction model is a textured three-dimensional model.
In the embodiment of the application, the terminal may use a texture generation model, such as an InferGAN network, to restore invisible other texture information based on visible part of the texture information of the human body, and may finally construct all the texture information of the human body. The texture generation model may be obtained by using Generative Adaptive Networks (GAN) training.
It should be noted that, in the embodiment of the present application, the preset training strategy is used to continuously adjust the learning rate by using the error between the loss value and the lower threshold of the deviation in the training process of the texture generation model, so that the weight can be updated by using the adjusted learning rate, and a next round of training is performed.
Further, in the embodiment of the application, when the terminal trains the texture generation model according to a preset training strategy, the ith weight may be configured first; the ith weight is used for carrying out ith round of training on the texture generation model; i is an integer larger than 0, then the training data set is input into the texture generation model to obtain the ith loss value, and the ith learning rate is determined according to the ith loss value and the deviation lower limit threshold; and finally, configuring an (i +1) th weight according to the i-th learning rate, and performing (i +1) th training on the texture generation model according to the (i +1) th weight until the trained texture generation model is obtained.
It can be understood that, in this application, the preset training strategy provided by the embodiment of the present application can obtain a proper learning rate through the output error feedback calculation after each round of training, so that a strong correlation exists between the learning rate and the error, thereby improving the convergence rate, improving the training effect, and obtaining a model with a better effect. And the flow of feedback calculation is automatically completed in the whole training process, so that the human intervention is not needed, and the training cost is greatly reduced.
That is to say, in the embodiment of the application, in the process of training the model, the terminal feeds back the error between the output loss value and the lower limit deviation threshold value to the process of adjusting the learning rate in time, so that a more appropriate learning rate can be obtained by using error calculation, then the weight is updated according to the adjusted learning rate, and the model is trained by using a new weight in the next round, so that the convergence of the model can be accelerated. Therefore, when the terminal conducts model training, the learning rate can be updated in time, the most appropriate learning rate is obtained, and therefore the convergence rate of the model is improved.
Based on the foregoing embodiment, another embodiment of the present application provides a model training method, fig. 5 is a schematic diagram of an implementation flow of the model training method, as shown in fig. 5, in an embodiment of the present application, a method for a terminal to perform model training may include the following steps:
step 501, obtaining an ith loss value after an ith round of training is performed on the target model according to the ith weight; wherein i is an integer greater than 0.
In the embodiment of the present application, the terminal may obtain the ith loss value after performing the ith round of training on the target model according to the ith weight.
It should be noted that, in the embodiment of the present application, the target model may be any type of model such as a prediction model, a classification model, a defogging model, a noise reduction model, and a generation model.
Specifically, in the present application, when i is an integer greater than 0, for example, i is 2, the terminal may obtain a second loss value after performing a second round of training on the target model according to the second weight.
It is understood that in the embodiment of the present application, the target model is the neural network to be trained.
It should be noted that, in the present application, the training of the target model by the terminal may be understood as a process in which the neural network updates the weights by propagating forward and backward. Wherein the weight is a constant input to each node of the neural network.
Further, in the embodiment of the present application, the ith loss value may be a loss function obtained by the terminal after the ith round of training on the target model.
The loss function is a function for calculating a difference between a predicted value and a true value of the network model with respect to a single sample, that is, the loss function is defined on the single sample and refers to an error of one sample. Commonly used loss functions include 0-1 loss functions, square loss functions, absolute loss functions, logarithmic loss functions, and the like.
That is, in the embodiment of the present application, after the terminal performs training on the target model, the terminal may compare the output real value with the expected predicted value, so that the loss function, i.e., the loss value, determined after the training of the round may be determined according to the comparison result.
It should be noted that, in the embodiment of the present application, the terminal may train the target model by using a gradient descent method. Among them, the gradient descent method is simply a method for finding the minimization of the objective function. Specifically, the method is a method for iteratively searching for a local minimum value of a current point on a function corresponding to a distance point with a specified step size in the opposite direction of a gradient (or an approximate gradient).
It is understood that, in the embodiment of the present application, the terminal performs the first round of training on the target model, and the first weight used by the terminal is preset by the terminal.
And 502, determining an ith error according to the ith loss value and the deviation lower limit threshold.
In the embodiment of the application, after the terminal performs the ith round of training on the target model according to the ith weight and obtains the ith loss value, the ith error can be determined according to the ith loss value and the deviation lower limit threshold.
It is understood that, in the embodiment of the present application, after the terminal completes the ith round of training on the target model, the terminal may compare the output ith loss value with the deviation lower limit threshold, so that the ith error may be determined according to the difference between the output ith loss value and the deviation lower limit threshold.
It should be noted that, in the embodiment of the present application, the terminal may preset a desired loss value, that is, determine the lower limit threshold of the deviation.
Further, in an embodiment of the present application, the terminal may determine the ith error using equation (3) above.
And 503, if the ith error does not meet the preset error requirement, determining the ith learning rate according to the ith error.
In the embodiment of the application, after determining the ith error according to the ith loss value and the deviation lower limit threshold, the terminal may first determine whether the ith error meets a preset error requirement, and if it is determined that the ith error does not meet the preset error requirement, the terminal may further determine the ith learning rate according to the ith error.
It should be noted that, in the present application, in the process of training the target model by using the gradient descent method, the weights of the target model may be updated by using error back propagation, which is referred to as back propagation. The amount of weight update is referred to herein as the step size or learning rate. In particular, the learning rate is a configurable hyper-parameter used in neural network training, which has a small positive value, typically in the range between 0 and 1.
The learning rate can be understood as an update coefficient of the network weight, and can control the rate or speed of model learning. In particular, the learning rate may control the number of allocation errors, and the weights of the model are updated each time they are updated. In general, a larger learning rate allows the model to learn faster at the expense of reaching a suboptimal final weight set. A smaller learning rate may allow the model to learn a more optimal or even globally optimal set of weights, but may take longer to train.
In extreme cases, an excessive learning rate will result in too large a weight update, and the performance of the model (e.g., its loss on the training data set) will oscillate over the training period. The wobble performance is said to be caused by the weight of divergence (divergence). Too small a learning rate may never converge or may fall into a sub-optimal solution.
It should be noted that, in the embodiment of the present application, the preset error requirement may be used to measure the magnitude of the ith error, that is, the preset error requirement can determine whether to complete the training of the target model.
It can be understood that, in the embodiment of the present application, if the terminal determines that the ith error does not meet the preset error requirement, it may be considered that the target model still needs to be trained, and before performing the next round of training, the terminal may determine the ith learning rate according to the ith error.
That is, in the present application, if the ith error does not satisfy the preset error requirement, the terminal may set the ith learning rate before performing the next round of training on the target model. Specifically, when setting the ith learning rate, the terminal may introduce the ith error determined after the ith round of training, i.e., determine the ith learning rate based on the ith error.
It is to be understood that, in the embodiment of the present application, the ith learning rate is used to adjust and update the weights of the target model, so as to obtain the weights used in the next round of training.
As can be seen from the above, in the present application, in the process of training the target model by using the gradient descent method, the learning rate is not fixed, nor is it changed according to the number of training rounds, but is adjusted according to the loss value output after each training round, that is, the learning rate can be updated by using the error corresponding to each training round.
Further, in the embodiment of the present application, when determining the ith learning rate according to the ith error, the terminal may update and adjust the learning rate by adjusting the parameter and the ith error. The adjusting parameters may include a proportional adjusting coefficient, an integral adjusting coefficient and a differential adjusting coefficient, and accordingly, the adjusting parameters update the learning rate through at least one of the proportional adjusting, the integral adjusting and the differential adjusting.
It should be noted that, in the embodiment of the present application, when the terminal updates and adjusts the learning rate through the adjustment parameter and the ith error, the ith learning rate may be obtained by directly calculating the adjustment parameter and the ith error, or the adjustment parameter may be adjusted through the ith error, and then the ith learning rate is obtained by calculating the adjusted adjustment parameter and the ith error.
In an embodiment of the present application, further, fig. 6 is a schematic view of an implementation flow of a model training method, as shown in fig. 6, after the terminal determines the ith error according to the ith loss value and the deviation lower limit threshold, that is, after step 502, the method for the terminal to perform model training may further include the following steps:
and 505, if the ith error does not belong to the preset error range, judging that the ith error does not meet the preset error requirement.
Step 506, if the ith error belongs to the preset error range, determining that the ith error meets the preset error requirement.
In an embodiment of the present application, the terminal may determine an error range in advance, that is, a preset error range, where the preset error range may be an acceptable minimum error interval. Then, after obtaining the ith error, the ith error may be compared with the preset error range, and then whether the ith error meets the preset error requirement may be determined according to the comparison result.
It can be understood that, in the embodiment of the present application, after comparing the ith error with the preset error range, if the ith error belongs to the preset error range, the terminal may consider that the training of the target model is completed, and therefore may determine that the ith error meets the preset error requirement; if the ith error exceeds the preset error range, the target model is considered to be required to be trained continuously, and therefore the ith error can be judged not to meet the preset error requirement.
For example, in the present application, the terminal may set the preset error range to (-0.01, 0.01), and if the ith error is 0.1, that is, the ith error exceeds the preset error range, the terminal may determine that the ith error does not satisfy the preset error requirement, and may need to continue training the target model.
In an embodiment of the present application, further, fig. 7 is a schematic diagram of an implementation flow of a model training method, as shown in fig. 7, after the terminal determines the ith error according to the ith loss value and the deviation lower limit threshold, that is, after step 502, the method for the terminal to perform model training may further include the following steps:
and 507, if the ith error is not equal to 0, judging that the ith error does not meet the preset error requirement.
And step 508, if the ith error is equal to 0, judging that the ith error meets the preset error requirement.
In the embodiment of the application, after obtaining the ith error, the terminal may directly compare the ith error with 0, and if the ith error is equal to 0, the training of the target model may be considered to be completed, so that it may be determined that the ith error meets the preset error requirement; if the ith error is not equal to 0, the target model is considered to be required to be trained, and therefore the ith error can be judged not to meet the preset error requirement.
For example, in the present application, if the ith error is 0.05, that is, the ith error is not equal to 0, the terminal may determine that the ith error does not meet the preset error requirement, and may need to continue training the target model.
And step 504, determining the (i +1) th weight according to the ith learning rate, and performing the (i +1) th round of training on the target model according to the (i +1) th weight.
In an embodiment of the application, if the ith error does not meet the preset error requirement, after determining the ith learning rate according to the ith error, the terminal may determine an (i +1) th weight according to the ith learning rate, and perform an (i +1) th round of training on the target model according to the (i +1) th weight.
It is to be understood that, in the embodiment of the present application, after determining the ith learning rate according to the ith error, the terminal further determines the weight of the next round of training, i.e., the (i +1) th weight, based on the ith learning rate. Wherein the (i +1) th weight is determined based on the i-th learning rate adjusted by the terminal, and the terminal introduces the i-th error obtained based on the i-th round of training in determining the i-th learning rate, so that the (i +1) th weight is adjusted based on the i-th error as compared with the i-th weight.
That is, in the present application, in the process of training the target model using the gradient descent method, since the learning rate is adjusted according to the loss value output after each round of training, the (i +1) th weight after readjustment is also updated based on the loss value corresponding to the i-th round of training, and has no relation with the number of rounds of training.
For example, in the embodiment of the present application, the terminal may determine the (i +1) th weight W used in the (i +1) th round of training by the above formula (4)i+1
In an embodiment of the present application, further, fig. 8 is a schematic diagram illustrating an implementation flow of the model training method in fig. 8, as shown in fig. 8, after the terminal determines the (i +1) th weight according to the ith learning rate and performs the (i +1) th round of training on the target model according to the (i +1) th weight, that is, after step 504, the method for the terminal to perform the model training may further include the following steps:
and 509, obtaining an (i +1) th loss value, and determining an (i +1) th error according to the (i +1) th loss value and the deviation lower limit threshold.
And step 5010, if the (i +1) th error does not meet the preset error requirement, determining the (i +1) th learning rate according to the (i +1) th error.
And step 5011, continuing to perform the next round of training according to the (i +1) th learning rate until the obtained error meets the preset error requirement.
In an embodiment of the present application, after performing (i +1) th round training on the target model using the (i +1) th weight, the terminal may obtain a corresponding loss function, i.e., an (i +1) th loss value, and may then compare the (i +1) th loss value with the deviation lower limit threshold, so that the (i +1) th error may be determined according to a difference between the two.
Further, in this application, the terminal may first determine whether the (i +1) th error meets a preset error requirement, and if it is determined that the (i +1) th error does not meet the preset error requirement, the terminal may further determine the (i +1) th learning rate according to the (i +1) th error.
It should be noted that, in the embodiment of the present application, after determining the (i +1) th learning rate according to the (i +1) th error, the terminal may continue to perform the next training round according to the (i +1) th learning rate, specifically, the terminal may determine the (i +2) th weight according to the (i +1) th learning rate, and perform the (i +2) th training round on the target model according to the (i +2) th weight until the obtained error meets the preset error requirement.
Specifically, in the embodiment of the application, after determining whether the (i +1) th error meets the preset error requirement, if it is determined that the (i +1) th error meets the preset error requirement, the terminal may consider that the training of the target model is completed, and may end the training process of the model.
It is understood that, in the embodiment of the present application, when i is greater than 1, for other rounds of training after the first round of training of the target model, the terminal may update the learning rate according to the model training methods proposed in the above steps 501 to 504, and for the first round of training of the target model, the terminal may initialize the first weight value, the adjustment parameter, the first learning rate, and the deviation lower limit threshold before performing the first round of training on the target model; wherein the adjustment parameter is used for updating the learning rate. And then training the target model according to the first weight, obtaining a first loss value after completing the first round of training on the target model, determining a first error according to the first loss value and a deviation lower limit threshold, and if the first error does not meet a preset error requirement, determining a second weight by the terminal directly according to the first learning rate, and further performing a second round of training on the target model according to the second weight.
It is understood that, in the embodiment of the present application, for the first round of training of the target model, the terminal may also perform the updating of the learning rate according to the model training method proposed in the above steps 501 to 504. Specifically, the terminal may initialize the first weight value, the adjustment parameter, and the lower threshold of the deviation before performing the first round of training on the target model. And then training the target model according to the first weight, obtaining a first loss value after completing the first round of training on the target model, determining a first error according to the first loss value and a deviation lower limit threshold, if the first error does not meet a preset error requirement, calculating a first learning rate by the terminal according to the first error, then determining a second weight by using the first learning rate, and further performing a second round of training on the target model according to the second weight. I.e., i may also be an integer greater than or equal to 1.
In summary, with the model training methods proposed in steps 501 to 5011, after each training, the terminal can obtain an appropriate learning rate through the output obtained error feedback calculation, so that the learning rate and the error have a strong correlation, and thus the convergence rate can be increased. And the flow of feedback calculation is automatically completed in the whole training process, so that the human intervention is not needed, and the training cost is greatly reduced.
The embodiment of the application provides a model training method, wherein a terminal obtains an ith loss value after performing ith round of training on a target model according to ith weight; wherein i is an integer greater than 0; determining an ith error according to the ith loss value and the deviation lower limit threshold; if the ith error does not meet the preset error requirement, determining an ith learning rate according to the ith error; and determining an (i +1) th weight according to the ith learning rate, and performing an (i +1) th round of training on the target model according to the (i +1) th weight. That is to say, in the embodiment of the application, in the process of training the target model, the terminal feeds back the error between the output loss value and the deviation lower limit threshold value to the adjustment process of the learning rate in time, so that a more appropriate learning rate can be obtained by using error calculation, then the weight is updated according to the adjusted learning rate, and the new weight is used to perform the next round of training on the target model, so that the convergence of the target model can be accelerated. Therefore, when the terminal conducts model training, the learning rate can be updated in time, the most appropriate learning rate is obtained, and therefore the convergence rate of the model is improved.
Based on the above embodiment, in another embodiment of the present application, before performing the first round of training on the target model, the terminal may initialize the first weight value, the adjustment parameter, and the deviation lower limit threshold.
That is, in the present application, before starting training of the target model, the terminal needs to initialize the first weight value used in the first round of training, so that the first round of training can be performed on the target model using the first weight value. Meanwhile, the terminal also needs to perform initial setting on the adjustment parameter and the deviation lower limit threshold.
It is understood that in the embodiments of the present application, the tuning parameters may be used to implement the updating and adjusting of the learning rate, i.e., the tuning parameters may be used to perform the updating of the learning rate.
Further, in an embodiment of the present application, the adjustment parameters may include a proportional adjustment coefficient, an integral adjustment coefficient, and a derivative adjustment coefficient. The proportional adjustment parameter can be used for performing proportional adjustment on the learning rate, the integral adjustment coefficient can be used for performing integral adjustment on the learning rate, and the differential adjustment coefficient can be used for performing differential adjustment on the learning rate.
That is, in the present application, the terminal may perform the update of the learning rate by at least one of the proportional adjustment, the integral adjustment, and the derivative adjustment using the adjustment parameter.
Illustratively, in the present application, the terminal may implement the ith learning rate η by the following formulaiDetermination of (1):
Figure BDA0002613039950000131
wherein p is a proportional adjustment coefficient, q is an integral adjustment coefficient, d is a derivative adjustment coefficient, e (i) is an ith error, and e (i-1) is an (i-1) th error.
Based on the above equation (5), fig. 9 is a schematic diagram of learning rate adjustment, and as shown in fig. 9, the terminal may implement adjustment and update of the learning rate through an adjusting module 10, where the adjusting module 10 may include a proportional adjusting unit 11, an integral adjusting unit 12, a derivative adjusting unit 13, an updating unit 14, and a feedback unit 15.
Further, in the embodiment of the present application, the proportion adjustment unit 11 in the adjustment module 10 is configured to implement the proportion adjustment part p × e (i) in the above formula (5); the integral adjustment unit 12 in the adjustment module 10 is used to implement the integral adjustment part in the above equation (5)
Figure BDA0002613039950000132
The differential adjustment unit 13 in the adjustment module 10 is adapted to implement the differential adjustment part d x [ e (i) -e (i-1) in the above equation (5)]。
It is understood that, in the embodiment of the present application, the feedback unit 15 in the adjusting module 10 feeds back the error after one round of training to the adjusting module 10, and then, based on the error, the adjusting module 10 adjusts and updates the learning rate through the updating unit 14 by using at least one of the proportional adjusting unit 11, the integral adjusting unit 12, and the derivative adjusting unit 13, so as to obtain a new learning rate.
It should be noted that, in the embodiment of the present application, the proportional adjustment part × e (i) implemented by the proportional adjustment unit 11 is a timely response to the error fed back by the feedback unit 15, and the proportional adjustment coefficient p reflects the response degree of the proportional adjustment unit 11, and in the early stage of model training, by setting an appropriate proportional adjustment coefficient p, an appropriate learning rate can be calculated.
However, when the model training approaches the end sound, the error of the loss function fed back by the feedback unit 15 may be small, and the output of the proportional adjustment unit 11 is almost 0 and hardly plays a role of adjusting the learning rate, while the integral adjustment part implemented by the integral adjustment unit 12
Figure BDA0002613039950000133
Can play a greater role in adjusting the learning rate, the integral adjustment part
Figure BDA0002613039950000134
The accumulated error from the beginning of training to the current time is multiplied by an integral adjusting coefficient q, and an appropriate learning rate can be obtained by setting an appropriate integral adjusting coefficient q in the later stage of model training.
Further, in the present application, as the model training continues, the target model converges step by step, the accumulation of the integral adjusting unit 12 becomes larger, the learning rate of the network may increase, and a sudden change may occur, and this situation may be avoided by the differential adjusting part d × [ e (i) -e (i-1) ] implemented by the differential adjusting unit 13, where the differential adjusting unit 13 is the difference between the differential adjusting coefficient multiplied by the current error and the previous error, and if the error becomes smaller, the finally obtained value may be a negative value, and by setting an appropriate differential adjusting coefficient d, the problem of a sudden change in the learning rate may be solved.
As can be seen from the above, in the present application, the proportional regulator 11, the integral regulator 12, and the derivative regulator 13 in the regulator module 10 simultaneously act on the update of the learning rate during the model training process, but the three functions are different in different periods of the model training.
It should be noted that, in the embodiment of the present application, the terminal may update the learning rate by implementing at least one of a proportional adjustment, an integral adjustment, and a derivative adjustment by using the setting of the adjustment parameter. For example, in the present application, when initializing the adjustment parameter, if only the value set by the differential adjustment coefficient is set to 0, the terminal may determine to update the learning rate by using two adjustment modes, namely, proportional adjustment and integral adjustment.
Further, in the embodiment of the application, when determining the ith learning rate according to the ith error, the terminal may directly obtain the ith learning rate by using the adjustment parameter and the ith error, or may adjust the adjustment parameter by using the ith error, and then obtain the ith learning rate by using the adjusted adjustment parameter and the ith error.
For example, in the present application, the terminal may calculate the ith learning rate based on the above equation (5) by using the ith error, the (i-1) th error and the adjustment parameter.
For example, in the present application, the terminal may first adjust the tuning parameter according to the ith error to obtain an adjusted tuning parameter, and then calculate the ith learning rate according to the adjusted tuning parameter, the ith error and the (i-1) th error based on the above formula (5).
That is to say, in the embodiment of the present application, after the training setting initializes the adjustment parameters, the adjustment parameters may not be modified, and the learning rate is updated and adjusted based on the error obtained after each training; or after each round of training, adjusting at least one of the proportional adjustment coefficient, the integral adjustment coefficient and the differential adjustment coefficient in the adjustment parameters according to the corresponding error to obtain the adjusted adjustment parameters, and then updating and adjusting the learning rate by using the adjusted adjustment parameters.
For example, in the present application, if the error after training is greater than an error threshold, that is, the error output after training is larger, the terminal may adaptively increase the scaling factor, so as to obtain the adjusted tuning parameter.
For example, in the present application, if the sum of the errors from the training start to the current time is greater than an error threshold, that is, the accumulated error of the training is relatively large, the terminal may adaptively increase the integral adjustment coefficient to obtain the adjusted adjustment parameter.
For example, in the present application, if the error of the current output is larger than the error of the previous training output, that is, the error has a sudden change, the terminal may adaptively increase the differential adjustment coefficient, so as to obtain the adjusted adjustment parameter.
In the embodiment of the application, further, when the terminal determines the learning rate by using the adjustment parameter, the terminal may select to update the learning rate by using at least one of a proportional adjustment manner, an integral adjustment manner, and a differential adjustment manner through setting of a proportional adjustment coefficient, an integral adjustment coefficient, and a differential adjustment coefficient.
That is, in the present application, the proportional adjustment unit 11, the integral adjustment unit 12, and the derivative adjustment unit 13 in fig. 9 may be used simultaneously, or at least one of the rows may be selected for use. The updating and calculation of the learning rate can be completed even with one adjusting unit alone, but a better convergence effect can be obtained with the proportional adjusting unit 11, the integral adjusting unit 12, and the derivative adjusting unit 13 used together. For example, for the training process without error abrupt change, the proportional adjustment unit 11 and the integral adjustment unit 12 can be selected to calculate a suitable learning rate, and the differential adjustment unit 13 can be omitted.
It is understood that, in the embodiment of the present application, a proper learning rate can be calculated by only the combined action of the proportional adjustment unit 11 and the integral adjustment unit 12, but when a sudden change value occurs in an error during training, the calculated learning rate will be large, and when a large negative number is calculated by using the differential adjustment unit 13, the learning rate can be pulled back to a normal value, so that the differential adjustment unit 13 also has the function of preventing overshoot of the system.
For example, in the present application, when initializing the adjustment parameter, the terminal may set a value of the differential adjustment coefficient to 0, and set the proportional adjustment coefficient and the integral adjustment coefficient to be different from 0, so that the learning rate may be adjusted through two adjustment modes, namely, proportional adjustment and integral adjustment.
However, as the training of the target model is iterated, when an error sudden change occurs in the training process, the differential adjustment needs to be added to pull back the excessive learning rate to the normal value, and at this time, the differential adjustment coefficient may be reset, so as to adjust the adjustment parameter, obtain the adjusted adjustment parameter, and continue to determine the new learning rate based on the adjusted adjustment parameter.
That is to say, in the present application, when the terminal determines the ith learning rate according to the ith error, if the ith error meets the preset mutation condition, the value of the differential adjustment coefficient may be adjusted to be greater than 0, so as to obtain an adjusted adjustment parameter; and then calculating the ith learning rate according to the adjusted adjusting parameter and the ith error.
Therefore, according to the model training method provided by the application, when the corresponding error after each round of training is introduced into the learning rate adjusting process, the learning rate can be updated through the error and the initialized adjusting parameter, the adjusting parameter can be adjusted through the error, and then the learning rate is further adjusted by using the adjusted adjusting parameter and the error.
In summary, for the determination of the learning rate, the present application introduces a feedback mechanism, i.e. the feedback unit 15, and also introduces an automatic adjustment mechanism, i.e. the proportional adjustment unit 11, the integral adjustment unit 12, and the derivative adjustment unit 13, to feed back the actual output (e.g. loss function output) to the input, and add the difference between the feedback and the expected output as an error to the calculation of the learning rate. By adding a feedback mechanism and an automatic regulation mechanism, the calculation of the training learning rate of the neural network is completed, so that the network can be quickly converged without manually regulating the learning rate.
The embodiment of the application provides a model training method, wherein a terminal obtains an ith loss value after performing ith round of training on a target model according to ith weight; wherein i is an integer greater than 0; determining an ith error according to the ith loss value and the deviation lower limit threshold; if the ith error does not meet the preset error requirement, determining an ith learning rate according to the ith error; and determining an (i +1) th weight according to the ith learning rate, and performing an (i +1) th round of training on the target model according to the (i +1) th weight. That is to say, in the embodiment of the application, in the process of training the target model, the terminal feeds back the error between the output loss value and the deviation lower limit threshold value to the adjustment process of the learning rate in time, so that a more appropriate learning rate can be obtained by using error calculation, then the weight is updated according to the adjusted learning rate, and the new weight is used to perform the next round of training on the target model, so that the convergence of the target model can be accelerated. Therefore, when the terminal conducts model training, the learning rate can be updated in time, the most appropriate learning rate is obtained, and therefore the convergence rate of the model is improved.
Based on the foregoing embodiment, in another embodiment of the present application, fig. 10 is a schematic diagram illustrating an implementation flow of a model training method in a sixth embodiment, as shown in fig. 10, the method for the terminal to perform model training may include the following steps:
step 601, initializing a first weight, a first learning rate, an adjustment parameter and a deviation lower limit threshold.
In an embodiment of the application, the terminal may initialize the first weight, the first learning rate, the adjustment parameter, and the lower deviation threshold before training the target model.
The adjusting parameters may include a proportional adjusting coefficient, an integral adjusting coefficient and a differential adjusting coefficient, and accordingly, the adjusting parameters update the learning rate through at least one of the proportional adjusting, the integral adjusting and the differential adjusting.
Step 602, perform a first round of training using the first weight, and output a first loss value.
In the embodiment of the present application, the terminal may perform a first round of training on the target model according to the first weight, and output a loss function, i.e., a first loss value.
Step 603, calculating a first error.
In an embodiment of the present application, the terminal may calculate and obtain an error value output by the first round of training, that is, a first error, by using the first loss value and the lower deviation limit threshold.
Step 604, whether the first error is equal to 0, if not, step 605 is executed, otherwise, step 6012 is executed.
In the embodiment of the application, the terminal may first determine whether the first error meets a preset error requirement. Specifically, if the first error is equal to 0, the first error may be considered to satisfy a preset error requirement; if the first error is not equal to 0, the first error may be deemed not to satisfy the preset error requirement.
In step 605, the ith weight (i ═ 2) is determined using the first learning rate.
In an embodiment of the present application, if the first error does not meet the preset error requirement, it may be considered that the target model needs to be trained. In this case, the terminal may calculate the ith weight by directly using the first learning rate, and obtain the weight used for the next training, with i being 2.
And 606, performing the ith round of training by using the ith weight, and outputting an ith loss value.
In the embodiment of the application, after the terminal completes updating of the weight according to the first learning rate and obtains the ith weight, the terminal can continue to perform the ith round of training by using the ith weight and output a loss function, namely, the ith loss value.
Step 607, calculate the ith error.
In the embodiment of the application, the terminal may calculate and obtain an error value output by the ith round of training, that is, an ith error, by using the ith loss value and the deviation lower limit threshold.
Step 608, whether the ith error is equal to 0, if not, step 609 is executed, otherwise, step 6012 is executed.
In the embodiment of the application, the terminal may first determine whether the ith error meets a preset error requirement. Specifically, if the ith error is equal to 0, the ith error can be considered to meet the preset error requirement; if the ith error is not equal to 0, the ith error may be considered not to satisfy the preset error requirement.
And step 609, adjusting the adjusting parameter by using the ith error to obtain the adjusted adjusting parameter.
And 6010, calculating an ith learning rate according to the adjusted adjusting parameter and the ith error.
In the embodiment of the present application, if the ith error does not meet the preset error requirement, it may be considered that the target model needs to be trained. At this time, the terminal may perform the calculation of the learning rate using the ith error and the adjustment parameter.
Specifically, the terminal may first adjust the adjustment parameter by using the ith error to obtain an adjusted adjustment parameter, and then calculate the ith learning rate according to the adjusted adjustment parameter and the ith error to complete the learning rate.
Step 6011, the weight is updated according to the ith learning rate, and training continues after i +1, that is, step 606 is executed.
In the embodiment of the present application, after the terminal completes updating the learning rate based on the ith error, the terminal may perform the calculation of the (i +1) th weight according to the ith learning rate to obtain the weight used in the (i +1) th round of training. And after another i +1, continuing to perform the next round of training until the output error meets the preset error requirement.
And step 6012, finishing the training process.
In the embodiment of the application, if the preset error requirement is met, the training of the target model is considered to be completed, and the terminal may end the training process.
In an embodiment of the present application, further, fig. 11 is a seventh implementation flowchart of the model training method, and as shown in fig. 11, the method for the terminal to perform the model training may include the following steps:
step 701, initializing a first weight, an adjustment parameter and a deviation lower limit threshold.
In an embodiment of the present application, the terminal may initialize the first weight, the adjustment parameter, and the lower threshold of the deviation before training the target model.
The adjusting parameters may include a proportional adjusting coefficient, an integral adjusting coefficient and a differential adjusting coefficient, and accordingly, the adjusting parameters update the learning rate through at least one of the proportional adjusting, the integral adjusting and the differential adjusting.
In step 702, the jth training round is performed by using the first weight, and a jth loss value (j equals 1) is output.
In the embodiment of the present application, let j equal to 1, the terminal may perform a first round of training on the target model according to the first weight, and output a loss function, that is, a jth loss value.
And step 703, calculating a j error.
In the embodiment of the application, the terminal may calculate and obtain an error value output by the jth training round, that is, a jth error, by using the jth loss value and the deviation lower limit threshold.
Step 704, whether the jth error belongs to (-0.1, 0.1), if not, step 705 is executed, otherwise, step 707 is executed.
In the embodiment of the application, the terminal may first determine whether the jth error meets a preset error requirement. Specifically, if the jth error belongs to the preset error range (-0.1, 0.1), the jth error can be considered to meet the preset error requirement; if the jth error does not belong to the preset error range (-0.1, 0.1), the jth error can be considered not to meet the preset error requirement.
Step 705, calculating the jth learning rate by using the adjusting parameter and the jth error.
In the embodiment of the present application, if the jth error does not meet the preset error requirement, it may be considered that the target model needs to be trained. At this time, the terminal may perform the calculation of the learning rate using the jth error and the adjustment parameter.
Step 706, the weight is updated according to the jth learning rate, and training continues after j +1, that is, step 702 is executed.
In the embodiment of the present application, after the terminal completes updating the learning rate based on the jth error, the terminal may perform the calculation of the (j +1) th weight according to the jth learning rate to obtain the weight used in the (j +1) th training round. And after another j +1, continuing to perform the next round of training until the output error meets the preset error requirement.
And step 707, finishing the training process.
In the embodiment of the application, if the preset error requirement is met, the training of the target model is considered to be completed, and the terminal may end the training process.
It should be noted that, in the embodiment of the present application, the terminal may perform at least one type of adjustment of proportional adjustment, integral adjustment, and derivative adjustment on the learning rate based on the adjustment parameter. That is, by assigning the proportional adjustment coefficient, the integral adjustment coefficient, and the derivative adjustment coefficient, the terminal can update the learning rate in at least one of the proportional adjustment, the integral adjustment, and the derivative adjustment.
For example, to achieve better adjustment effect, the terminal may preferably select the above three adjustment modes at the same time.
Illustratively, since the main function of the differential adjustment is to avoid the abnormality of the calculated learning rate when the feedback suddenly changes, the terminal can also remove the differential adjustment (set the differential adjustment coefficient to 0) and calculate the appropriate learning rate by only combining the proportional adjustment and the integral adjustment without the error sudden change.
The embodiment of the application provides a model training method, wherein a terminal obtains an ith loss value after performing ith round of training on a target model according to ith weight; wherein i is an integer greater than 0; determining an ith error according to the ith loss value and the deviation lower limit threshold; if the ith error does not meet the preset error requirement, determining an ith learning rate according to the ith error; and determining an (i +1) th weight according to the ith learning rate, and performing an (i +1) th round of training on the target model according to the (i +1) th weight. That is to say, in the embodiment of the application, in the process of training the target model, the terminal feeds back the error between the output loss value and the deviation lower limit threshold value to the adjustment process of the learning rate in time, so that a more appropriate learning rate can be obtained by using error calculation, then the weight is updated according to the adjusted learning rate, and the new weight is used to perform the next round of training on the target model, so that the convergence of the target model can be accelerated. Therefore, when the terminal conducts model training, the learning rate can be updated in time, the most appropriate learning rate is obtained, and therefore the convergence rate of the model is improved.
Based on the foregoing embodiment, in another embodiment of the present application, fig. 12 is a schematic diagram of a composition structure of a terminal, and as shown in fig. 12, a terminal 20 provided in this embodiment of the present application may include: configuration unit 21, acquisition unit 22, determination unit 23, training unit 24, prediction unit 25, initialization unit 26, and judgment unit 27.
The configuration unit 21 is configured to configure an ith weight when the prediction model is trained by the training data; wherein the ith weight is used for carrying out an ith round of training on the prediction model; i is an integer greater than 0;
the obtaining unit 22 is configured to input the training data to the prediction model to obtain an ith loss value;
the determining unit 23 is configured to determine an ith learning rate according to the ith loss value and a deviation lower limit threshold;
the configuration unit 21 is further configured to configure an (i +1) th weight according to the i-th learning rate;
the training unit 24 is configured to perform an (i +1) th round of training on the prediction model according to the (i +1) th weight until a trained prediction model is obtained;
the prediction unit 25 is configured to perform prediction processing on the object to be predicted by using the trained prediction model.
Further, in the embodiment of the present application, the determining unit 23 is specifically configured to determine an ith error according to the ith loss value and a deviation lower limit threshold; and if the ith error does not meet the preset error requirement, determining the ith learning rate according to the ith error.
Further, in the embodiment of the present application, the initializing unit 26 is configured to initialize a first weight value, an adjustment parameter, a first learning rate, and the deviation lower limit threshold before performing the first round of training on the prediction model; wherein the adjustment parameter is used for updating the learning rate.
Further, in the embodiment of the present application, the obtaining unit 22 is further configured to obtain a first loss value after performing a first round of training on the prediction model according to the first weight;
the determining unit 23 is further configured to determine a first error according to the first loss value and the deviation lower limit threshold; if the first error does not meet the preset error requirement, determining a second weight according to the first learning rate;
the training unit 24 is further configured to perform a second round of training on the prediction model according to the second weight.
Further, in an embodiment of the present application, the adjustment parameters include a proportional adjustment coefficient, an integral adjustment coefficient, and a differential adjustment coefficient; accordingly, the adjustment parameter is updated by at least one of a proportional adjustment, an integral adjustment, and a derivative adjustment.
The determining unit 23 is specifically configured to calculate the ith learning rate according to the adjustment parameter and the ith error.
The determining unit 23 is further specifically configured to adjust the adjusting parameter according to the ith error, so as to obtain an adjusted adjusting parameter; and calculating the ith learning rate according to the adjusted adjusting parameter and the ith error.
Further, in the embodiment of the present application, the initialization unit 26 is specifically configured to set a value of the differential adjustment coefficient to 0.
Further, in an embodiment of the present application, the determining unit 23 is further specifically configured to, if the ith error meets a preset mutation condition, adjust a value of the differential adjustment coefficient to be greater than 0, and obtain the adjusted adjustment parameter; and calculating the ith learning rate according to the adjusted adjusting parameter and the ith error.
Further, in an embodiment of the present application, the determining unit 27 is configured to determine that, after an ith error is determined according to the ith loss value and a deviation lower limit threshold, if the ith error does not belong to a preset error range, it is determined that the ith error does not meet the preset error requirement; and if the ith error belongs to the preset error range, judging that the ith error meets the preset error requirement.
Further, in an embodiment of the present application, the determining unit 27 is further configured to determine that, after an ith error is determined according to the ith loss value and a deviation lower limit threshold, if the ith error is not equal to 0, it is determined that the ith error does not meet the preset error requirement; and if the ith error is equal to 0, judging that the ith error meets the preset error requirement.
Further, in the embodiment of the present application, the prediction unit 25 is further configured to input the object to be predicted into the prediction model, and output a prediction result.
In an embodiment of the present application, further, fig. 13 is a schematic diagram of a composition structure of a terminal, as shown in fig. 13, the terminal 20 provided in the embodiment of the present application may further include a processor 28, a memory 29 storing executable instructions of the processor 28, and further, the terminal 20 may further include a communication interface 210, and a bus 211 for connecting the processor 28, the memory 29, and the communication interface 210.
In an embodiment of the present application, the Processor 28 may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a ProgRAMmable Logic Device (PLD), a Field ProgRAMmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understood that the electronic devices for implementing the above processor functions may be other devices, and the embodiments of the present application are not limited in particular. The terminal 20 may further comprise a memory 29, which memory 29 may be connected to the processor 28, wherein the memory 29 is adapted to store executable program code comprising computer operating instructions, and wherein the memory 29 may comprise a high speed RAM memory and may further comprise a non-volatile memory, such as at least two disk memories.
In the embodiment of the present application, the bus 211 is used to connect the communication interface 210, the processor 28, and the memory 29 and the intercommunication among these devices.
In the embodiment of the present application, the memory 29 is used for storing instructions and data.
Further, in an embodiment of the present application, the processor 28 is configured to configure an ith weight when the prediction model is trained by the training data; wherein the ith weight is used for carrying out an ith round of training on the prediction model; i is an integer greater than 0; inputting the training data into the prediction model to obtain an ith loss value, and determining an ith learning rate according to the ith loss value and a deviation lower limit threshold; the ith loss value is used for determining the deviation degree between the predicted value and the true value output by the prediction model; configuring an (i +1) th weight according to the ith learning rate, and performing (i +1) th round training on the prediction model according to the (i +1) th weight until a prediction model which is completely trained is obtained; and performing prediction processing on the object to be predicted by using the trained prediction model.
In practical applications, the Memory 29 may be a volatile Memory (volatile Memory), such as a Random-Access Memory (RAM); or a non-volatile Memory (non-volatile Memory), such as a Read-Only Memory (ROM), a flash Memory (flash Memory), a Hard disk (Hard disk Drive, HDD) or a Solid-State Drive (SSD); or a combination of the above types of memories and provides instructions and data to processor 28.
In addition, each functional module in this embodiment may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware or a form of a software functional module.
Based on the understanding that the technical solution of the present embodiment essentially or a part contributing to the prior art, or all or part of the technical solution, may be embodied in the form of a software product stored in a storage medium, and include several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) to execute all or part of the steps of the method of the present embodiment. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The embodiment of the application provides a terminal, wherein the terminal configures the ith weight when training a prediction model through training data; the ith weight is used for carrying out ith round of training on the prediction model; i is an integer greater than 0; inputting training data into a prediction model to obtain an ith loss value, and determining an ith learning rate according to the ith loss value and a deviation lower limit threshold; the ith loss value is used for determining the deviation degree between the predicted value and the true value output by the prediction model; configuring an (i +1) th weight according to the ith learning rate, and performing (i +1) th round training on the prediction model according to the (i +1) th weight until a prediction model which is completely trained is obtained; and performing prediction processing on the object to be predicted by using the trained prediction model. That is to say, in the embodiment of the application, in the process of training the prediction model, the terminal feeds back the error between the output loss value and the deviation lower limit threshold value to the process of adjusting the learning rate in time, so that a more appropriate learning rate can be obtained by using error calculation, then the weight is updated according to the adjusted learning rate, and the next round of training is performed on the prediction model by using the new weight, so that the convergence of the prediction model can be accelerated. Therefore, when the terminal conducts model training, the learning rate can be updated in time, the most appropriate learning rate is obtained, and therefore the convergence rate of the model is improved.
An embodiment of the present application provides a computer-readable storage medium, on which a program is stored, which when executed by a processor implements the model training method as described above.
Specifically, the program instructions corresponding to a model training method in the present embodiment may be stored on a storage medium such as an optical disc, a hard disc, a usb disk, or the like, and when the program instructions corresponding to a model training method in the storage medium are read or executed by an electronic device, the method includes the following steps:
configuring an ith weight when the prediction model is trained through the training data; wherein the ith weight is used for carrying out an ith round of training on the prediction model; i is an integer greater than 0;
inputting the training data into the prediction model to obtain an ith loss value, and determining an ith learning rate according to the ith loss value and a deviation lower limit threshold; the ith loss value is used for determining the deviation degree between the predicted value and the true value output by the prediction model;
configuring an (i +1) th weight according to the ith learning rate, and performing (i +1) th round training on the prediction model according to the (i +1) th weight until a prediction model which is completely trained is obtained;
and performing prediction processing on the object to be predicted by using the trained prediction model.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of a hardware embodiment, a software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of implementations of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart block or blocks and/or flowchart block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks in the flowchart and/or block diagram block or blocks.
The above description is only a preferred embodiment of the present application, and is not intended to limit the scope of the present application.

Claims (15)

1. A method of model training, the method comprising:
configuring an ith weight when the prediction model is trained through the training data; wherein the ith weight is used for carrying out an ith round of training on the prediction model; i is an integer greater than 0;
inputting the training data into the prediction model to obtain an ith loss value, and determining an ith learning rate according to the ith loss value and a deviation lower limit threshold; the ith loss value is used for determining the deviation degree between the predicted value and the true value output by the prediction model;
configuring an (i +1) th weight according to the ith learning rate, and performing (i +1) th round training on the prediction model according to the (i +1) th weight until a prediction model which is completely trained is obtained;
and performing prediction processing on the object to be predicted by using the trained prediction model.
2. The method of claim 1, wherein determining the ith learning rate from the ith loss value and a lower deviation threshold comprises:
determining an ith error according to the ith loss value and a deviation lower limit threshold;
and if the ith error does not meet the preset error requirement, determining the ith learning rate according to the ith error.
3. The method of claim 2,
initializing a first weight value, an adjustment parameter, a first learning rate, and the deviation lower limit threshold before performing a first round of training on the prediction model; wherein the adjustment parameter is used for updating the learning rate.
4. The method of claim 3,
obtaining a first loss value after a first round of training of the predictive model according to the first weight;
determining a first error according to the first loss value and the deviation lower limit threshold;
and if the first error does not meet the preset error requirement, determining a second weight according to the first learning rate, and performing a second round of training on the prediction model according to the second weight.
5. The method of claim 3 or 4, wherein the adjustment parameters include a proportional adjustment coefficient, an integral adjustment coefficient, and a derivative adjustment coefficient;
accordingly, the adjustment parameter is updated by at least one of a proportional adjustment, an integral adjustment, and a derivative adjustment.
6. The method of claim 5, wherein determining an ith learning rate from the ith error comprises:
and calculating the ith learning rate according to the adjusting parameter and the ith error.
7. The method of claim 5, wherein determining the ith learning rate from the ith error comprises:
adjusting the adjusting parameter according to the ith error to obtain an adjusted adjusting parameter;
and calculating the ith learning rate according to the adjusted adjusting parameter and the ith error.
8. The method of claim 5, wherein the initializing the tuning parameters comprises:
and setting the value of the differential adjustment coefficient to be 0.
9. The method of claim 8, wherein determining the ith learning rate from the ith error comprises:
if the ith error meets a preset mutation condition, adjusting the value of the differential adjustment coefficient to be greater than 0 to obtain the adjusted adjustment parameter;
and calculating the ith learning rate according to the adjusted adjusting parameter and the ith error.
10. The method of claim 2, wherein after determining the ith error based on the ith loss value and a lower deviation threshold, the method further comprises:
if the ith error does not belong to a preset error range, judging that the ith error does not meet the preset error requirement;
and if the ith error belongs to the preset error range, judging that the ith error meets the preset error requirement.
11. The method of claim 2, wherein after determining the ith error based on the ith loss value and a lower deviation threshold, the method further comprises:
if the ith error is not equal to 0, judging that the ith error does not meet the preset error requirement;
and if the ith error is equal to 0, judging that the ith error meets the preset error requirement.
12. The method of claim 1, wherein the performing prediction processing on the object to be predicted by using the trained prediction model comprises:
and inputting the object to be predicted into the prediction model, and outputting a prediction result.
13. A terminal, characterized in that the terminal comprises: a configuration unit, an acquisition unit, a determination unit, a training unit, a prediction unit,
the configuration unit is used for configuring the ith weight when the prediction model is trained through the training data; wherein the ith weight is used for carrying out an ith round of training on the prediction model; i is an integer greater than 0;
the acquisition unit is used for inputting the training data into the prediction model to obtain an ith loss value;
the determining unit is used for determining an ith learning rate according to the ith loss value and a deviation lower limit threshold;
the configuration unit is further used for configuring an (i +1) th weight according to the ith learning rate;
the training unit is used for carrying out (i +1) th round training on the prediction model according to the (i +1) th weight until a prediction model which is completely trained is obtained;
and the prediction unit is used for performing prediction processing on the object to be predicted by using the trained prediction model.
14. A terminal, characterized in that the terminal comprises a processor, a memory storing instructions executable by the processor, which instructions, when executed by the processor, implement the method according to any of claims 1-12.
15. A computer-readable storage medium, on which a program is stored, for use in a terminal, characterized in that the program, when executed by a processor, implements the method according to any one of claims 1-12.
CN202010760865.3A 2020-07-31 2020-07-31 Model training method, terminal and storage medium Pending CN111860789A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010760865.3A CN111860789A (en) 2020-07-31 2020-07-31 Model training method, terminal and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010760865.3A CN111860789A (en) 2020-07-31 2020-07-31 Model training method, terminal and storage medium

Publications (1)

Publication Number Publication Date
CN111860789A true CN111860789A (en) 2020-10-30

Family

ID=72953964

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010760865.3A Pending CN111860789A (en) 2020-07-31 2020-07-31 Model training method, terminal and storage medium

Country Status (1)

Country Link
CN (1) CN111860789A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112529328A (en) * 2020-12-23 2021-03-19 长春理工大学 Product performance prediction method and system
CN113094637A (en) * 2021-04-08 2021-07-09 云岚空间(北京)科技有限公司 Weather forecasting method and device, electronic device and storage medium
CN113535492A (en) * 2021-07-20 2021-10-22 深圳市博辰智控有限公司 Device development method, device and storage medium
CN113642740A (en) * 2021-08-12 2021-11-12 百度在线网络技术(北京)有限公司 Model training method and device, electronic device and medium
CN114612732A (en) * 2022-05-11 2022-06-10 成都数之联科技股份有限公司 Sample data enhancement method, system and device, medium and target classification method

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112529328A (en) * 2020-12-23 2021-03-19 长春理工大学 Product performance prediction method and system
CN112529328B (en) * 2020-12-23 2023-08-22 长春理工大学 Product performance prediction method and system
CN113094637A (en) * 2021-04-08 2021-07-09 云岚空间(北京)科技有限公司 Weather forecasting method and device, electronic device and storage medium
CN113094637B (en) * 2021-04-08 2024-03-19 云岚空间(北京)科技有限公司 Weather forecast method and device, electronic equipment and storage medium
CN113535492A (en) * 2021-07-20 2021-10-22 深圳市博辰智控有限公司 Device development method, device and storage medium
CN113642740A (en) * 2021-08-12 2021-11-12 百度在线网络技术(北京)有限公司 Model training method and device, electronic device and medium
CN114612732A (en) * 2022-05-11 2022-06-10 成都数之联科技股份有限公司 Sample data enhancement method, system and device, medium and target classification method

Similar Documents

Publication Publication Date Title
CN111860789A (en) Model training method, terminal and storage medium
US11861502B2 (en) Control sequence generation system and methods
JP7016407B2 (en) Energy optimization of the cooling unit through smart supply air temperature setpoint control
US20190108621A1 (en) System and method for estimating optimal parameters
CN107330902B (en) Chaotic genetic BP neural network image segmentation method based on Arnold transformation
CN111788585B (en) Training method and system for deep learning model
EP3779891A1 (en) Method and device for training neural network model, and method and device for generating time-lapse photography video
JP2011034177A (en) Information processor, information processing method, and program
JP2023523029A (en) Image recognition model generation method, apparatus, computer equipment and storage medium
CN110991621A (en) Method for searching convolutional neural network based on channel number
CN111667016A (en) Incremental information classification method based on prototype
CN107643684B (en) Valve flow function optimization method and device
JP2020204909A (en) Machine learning device
Shao et al. Rethinking controllable variational autoencoders
CN112766492A (en) Model processing method and device, electronic equipment and storage medium
JP7073171B2 (en) Learning equipment, learning methods and programs
US6687554B1 (en) Method and device for controlling optimization of a control subject
CN115903901A (en) Output synchronization optimization control method for unmanned cluster system with unknown internal state
CN111754589A (en) Color matching method and device, computer equipment and storage medium
CN113554169A (en) Model optimization method and device, electronic equipment and readable storage medium
CN111522240B (en) MTMLP-ARX model of four-rotor aircraft, identification method, system and storage medium
Chen et al. C 2: Co-design of Robots via Concurrent-Network Coupling Online and Offline Reinforcement Learning
CN117063187A (en) Machine learning device, inference device, machine learning method, and machine learning program
JP7181585B2 (en) LEARNING SYSTEMS, LEARNING METHODS AND PROGRAMS
CN113721655A (en) Control period self-adaptive reinforcement learning unmanned aerial vehicle stable flight control method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination