CN114120273A - Model training method and device - Google Patents

Model training method and device Download PDF

Info

Publication number
CN114120273A
CN114120273A CN202111334977.3A CN202111334977A CN114120273A CN 114120273 A CN114120273 A CN 114120273A CN 202111334977 A CN202111334977 A CN 202111334977A CN 114120273 A CN114120273 A CN 114120273A
Authority
CN
China
Prior art keywords
training sample
training
weight
prediction model
current round
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
CN202111334977.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.)
Beijing Sankuai Online Technology Co Ltd
Original Assignee
Beijing Sankuai Online Technology Co 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 Beijing Sankuai Online Technology Co Ltd filed Critical Beijing Sankuai Online Technology Co Ltd
Priority to CN202111334977.3A priority Critical patent/CN114120273A/en
Publication of CN114120273A publication Critical patent/CN114120273A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting

Landscapes

  • Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Artificial Intelligence (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The specification discloses a method and a device for model training, which relate to the field of unmanned driving, a sample set is obtained, a training sample is input into a prediction model to be trained aiming at each training sample in the sample set to obtain a prediction result aiming at the training sample, the weight of the training sample aiming at the prediction model is determined according to the prediction result of the training sample and the actual result of the training sample, the weight is used as the weight corresponding to the training sample, the loss value of the training sample aiming at the prediction model is determined according to the weight corresponding to the training sample, the parameter adjusting gradient of the training sample aiming at the prediction model is determined according to the loss value, the parameters contained in the prediction model are adjusted according to the parameter adjusting gradient to complete the training of the prediction model, wherein if the weight corresponding to the training sample is larger, the parameter adjusting gradient corresponding to the training sample is larger, thereby improving the prediction effect of the trained prediction model.

Description

Model training method and device
Technical Field
The specification relates to the field of unmanned driving, in particular to a model training method and device.
Background
In the unmanned technology, the unmanned device usually needs to predict the track of the surrounding obstacle in the next period of time according to the track of the surrounding obstacle in the next period of time, so as to select the subsequent driving strategy based on the predicted future track of the surrounding obstacle.
In the prior art, a trained prediction model is usually required to be used for predicting the travel track of a surrounding obstacle, so that a large number of training samples are required for training the prediction model, and training samples with low value on the prediction model often exist in the large number of training samples, for example, a sample with high obstacle track noise exists in the training samples, and a large number of samples with redundant data (for example, the trend of the obstacle track is repeated) may cause certain inaccuracy on the trained prediction model.
Therefore, how to make the trained prediction model capable of predicting the trajectory more accurately is an urgent problem to be solved.
Disclosure of Invention
The present specification provides a method and apparatus for model training to partially solve the above problems in the prior art.
The technical scheme adopted by the specification is as follows:
the present specification provides a method of model training, comprising:
obtaining a sample set;
inputting the training sample into a prediction model to be trained aiming at each training sample in the sample set to obtain a prediction result aiming at the training sample;
determining the weight of the training sample aiming at the prediction model according to the prediction result of the training sample and the actual result of the training sample, and taking the weight as the weight corresponding to the training sample;
determining a loss value of the training sample aiming at the prediction model according to the weight corresponding to the training sample, and determining a parameter adjusting gradient of the training sample aiming at the prediction model according to the loss value, wherein if the weight corresponding to the training sample is larger, the parameter adjusting gradient is larger;
and adjusting parameters contained in the prediction model according to the parameter adjusting gradient so as to finish the training of the prediction model.
Optionally, determining, according to the prediction result of the training sample and the actual result of the training sample, a weight of the training sample for the prediction model as a weight corresponding to the training sample specifically includes:
determining a deviation between the predicted result of the training sample and the actual result of the training sample;
determining the weight corresponding to the training sample according to the deviation, the preset maximum deviation and the preset minimum deviation, wherein the relation between the deviation and the weight satisfies the following conditions: between the maximum deviation and the minimum deviation, there is a maximum value of the weight, at which the weight takes a minimum value.
Optionally, obtaining a sample set specifically includes:
obtaining a sample set required by the training of the current round;
for each training sample in the sample set, inputting the training sample into a prediction model to be trained to obtain a prediction result for the training sample, specifically including:
for each training sample in the sample set, inputting the training sample into the prediction model to be trained in the current round to obtain a prediction result for the training sample;
determining the weight of the training sample for the prediction model according to the prediction result of the training sample and the actual result of the training sample, as the weight corresponding to the training sample, specifically including:
determining the weight of the training sample for the prediction model in the training of the current round according to the prediction result of the training sample and the actual result of the training sample, and taking the weight as the weight corresponding to the training sample in the current round;
determining a loss value of the training sample for the prediction model according to the weight of the training sample corresponding to the current round, and determining a parameter adjusting gradient of the training sample for the prediction model according to the loss value, specifically comprising:
determining a loss value of the training sample for the prediction model in the training of the current round according to the weight of the training sample corresponding to the current round, and determining a parameter adjusting gradient of the training sample for the prediction model in the training of the current round according to the loss value;
adjusting parameters included in the prediction model according to the parameter adjusting gradient, specifically comprising:
and adjusting parameters contained in the prediction model in the current turn according to the parameter adjusting gradient to obtain an adjusted prediction model.
Optionally, the method further comprises:
taking the adjusted prediction model as a prediction model needing to be trained in the next round;
and screening out training samples used in the next round of training from the sample set according to the weight of each training sample contained in the sample set corresponding to the current round, and constructing a sample set used for training the prediction model to be trained in the next round of training according to the screened training samples.
Optionally, determining, according to the prediction result of the training sample and the actual result of the training sample, a weight of the training sample for the prediction model in the training of the current round as a weight corresponding to the training sample in the current round specifically includes:
determining a deviation between the predicted result of the training sample and the actual result of the training sample;
determining the weight of the training sample corresponding to the current round according to the deviation, the determined maximum deviation corresponding to the current round and the determined minimum deviation corresponding to the current round, wherein the relation between the deviation and the weight satisfies the following conditions: the maximum value of the weight exists between the maximum deviation corresponding to the current round and the minimum deviation corresponding to the current round, and the weight is the minimum value at the maximum deviation corresponding to the current round and the minimum deviation corresponding to the current round;
optionally, determining the maximum deviation corresponding to the current round and the minimum deviation corresponding to the current round specifically includes:
determining the maximum deviation corresponding to the current round according to the number of rounds corresponding to the current round and the maximum deviation corresponding to the previous round, and determining the minimum deviation corresponding to the current round according to the number of rounds corresponding to the current round and the minimum deviation corresponding to the previous round, wherein the minimum deviation corresponding to the current round is determined according to the number of rounds corresponding to the current round and the minimum deviation corresponding to the previous round, and the minimum deviation corresponding to the current round is determined according to the number of rounds corresponding to the current round and the minimum deviation corresponding to the previous round
And the minimum deviation corresponding to the previous round is smaller than the minimum deviation corresponding to the current round, and the maximum deviation corresponding to the previous round is larger than the maximum deviation corresponding to the current round.
Optionally, the prediction model is used for predicting a track of a target object around the unmanned device, the training sample includes a historical track of the target object around the unmanned device, and the prediction result is a predicted travel track of the target object in a future period of time based on the historical track of the target object.
The present specification provides an apparatus for model training, comprising:
the acquisition module is used for acquiring a sample set;
the prediction module is used for inputting the training sample into a prediction model to be trained aiming at each training sample in the sample set to obtain a prediction result aiming at the training sample;
the weight determining module is used for determining the weight of the training sample aiming at the prediction model according to the prediction result of the training sample and the actual result of the training sample, and the weight is used as the weight corresponding to the training sample;
the loss determining module is used for determining a loss value of the training sample for the prediction model according to the weight corresponding to the training sample, and determining a parameter adjusting gradient of the training sample for the prediction model according to the loss value, wherein if the weight corresponding to the training sample is larger, the parameter adjusting gradient is larger;
and the training module is used for adjusting parameters contained in the prediction model according to the parameter adjusting gradient so as to finish the training of the prediction model.
The present specification provides a computer-readable storage medium, which stores a computer program that, when executed by a processor, implements the above-described method of model training.
The present specification provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the above-described method of model training when executing the program.
The technical scheme adopted by the specification can achieve the following beneficial effects:
it can be seen from the above method that a sample set is obtained, and for each training sample in the sample set, the training sample is input into a prediction model to be trained, a prediction result for the training sample is obtained, and according to the prediction result of the training sample and an actual result of the training sample, a weight of the training sample for the prediction model is determined, as a weight corresponding to the training sample, a loss value of the training sample for the prediction model is determined according to the weight corresponding to the training sample, a parameter adjusting gradient of the training sample for the prediction model is determined according to the loss value, and according to the parameter adjusting gradient, a parameter included in the prediction model is adjusted to complete training of the prediction model, wherein if the weight corresponding to the training sample is larger, the parameter adjusting gradient corresponding to the training sample is larger.
It can be seen from the above that, according to the prediction result of the training sample and the actual result of the training sample, the method can determine the weight of the training sample on the training of the prediction model, and according to the weight, determine the loss value for the prediction model, and determine the parameter adjusting gradient, the larger the parameter adjusting gradient is, the larger the weight of the training sample is, so that, if the weight of the training sample is higher, the larger the influence on the model is, the lower the weight of the training sample is, the smaller the influence on the model is, and by determining the weight of the training sample, the training sample with a smaller training value on the model can be made to have a smaller weight, so that the influence on the prediction model is smaller, and the prediction effect of the trained prediction model is improved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the specification and are incorporated in and constitute a part of this specification, illustrate embodiments of the specification and together with the description serve to explain the specification and not to limit the specification in a non-limiting sense. In the drawings:
FIG. 1 is a schematic flow chart of a method of model training in the present specification;
FIG. 2 is a diagram illustrating a complete process for training a prediction model according to the present disclosure;
FIG. 3 is a schematic diagram of a model training apparatus provided herein;
fig. 4 is a schematic diagram of an electronic device corresponding to fig. 1 provided in the present specification.
Detailed Description
In order to make the objects, technical solutions and advantages of the present disclosure more clear, the technical solutions of the present disclosure will be clearly and completely described below with reference to the specific embodiments of the present disclosure and the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present disclosure, and not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present specification without any creative effort belong to the protection scope of the present specification.
The technical solutions provided by the embodiments of the present description are described in detail below with reference to the accompanying drawings.
Fig. 1 is a schematic flow chart of a model training method in this specification, which specifically includes the following steps:
s101: a sample set is obtained.
S102: and inputting the training sample into a prediction model to be trained aiming at each training sample in the sample set to obtain a prediction result aiming at the training sample.
In practical applications, this task of prediction can be applied in a variety of scenarios. For example, the unmanned device can predict the track of the surrounding target object so as to perform the next driving strategy, and the unmanned device can be ensured to a certain extent by accurately predicting the driving track of the surrounding target object. As another example, in a recommendation scenario, a click rate may be predicted.
In any of these prediction tasks, it is usually necessary to predict the target object by using a prediction model, and therefore it is very important to train the prediction model appropriately so that the prediction model can accurately predict the target object.
Based on this, the server may obtain a sample set, input the training sample into the prediction model to be trained for each training sample in the sample set to obtain a prediction result for the training sample, and determine the weight of the training sample for the prediction model according to the prediction result of the training sample and the actual result of the training sample, as the weight corresponding to the training sample.
There are various ways to determine the weights of the training samples to the predictive model. For example, a deviation between the predicted result and the actual result of the training sample may be determined, and the weight corresponding to the training sample may be determined according to the deviation, a preset maximum deviation and a preset minimum deviation, where the relationship between the deviation and the weight between the predicted result and the actual result of the training sample mentioned herein satisfies: the maximum value of the weight exists between the preset maximum deviation and the preset minimum deviation, and the weight takes the minimum value at the preset maximum deviation and the preset minimum deviation.
That is, a maximum deviation and a minimum deviation may be preset, a maximum value of the weight exists in a deviation range between the maximum deviation and the minimum deviation, if a deviation between a prediction result and an actual result of a training sample (hereinafter referred to as a deviation corresponding to the training sample) is closer to the maximum deviation or closer to the minimum deviation within the maximum deviation and the minimum deviation, the weight corresponding to the training sample is smaller, and when the deviation corresponding to the training sample is at the maximum deviation and the minimum deviation, or the deviation corresponding to the training sample is larger than the maximum deviation or smaller than the minimum deviation, the weight corresponding to the training sample may be a minimum value.
In this specification, the weight corresponding to the training sample determined by the above method may be obtained by optimizing a preset objective function in a model training stage, that is:
Figure BDA0003350238350000071
v in the above objective functioniFor the weight corresponding to the ith training sample, fw(xi) Prediction result output for the prediction model for the ith training sample, yiThe actual result (i.e., label) corresponding to the ith training sample, and therefore, in the above-mentioned objective function (f)w(xi)-yi) For deviations between predicted and actual results, λ1For the minimum deviation, λ, mentioned above2For the maximum deviation mentioned above, the deviation is,
Figure BDA0003350238350000072
for the added step item, the weight of the training sample is determined through the step item, firstly, the model parameters are fixed to determine the weight:
Figure BDA0003350238350000073
the target function is simplified to obtain:
Figure BDA0003350238350000074
wherein l is fw(xi)-yiThe derivation of the above formula can be obtained:
h′(v)=λ1λ2v+λ1λ2+l2-(λ12)l
by deriving the above equation to 0, v, λ can be determined1、λ2And the relationship between l, namely:
Figure BDA0003350238350000075
since the weight should not be negative, when the offset is at λ1And λ2When the weight is within the range of (A), the relationship between the weight and the deviation satisfies the above expression, and when the deviation is located at λ1And λ2Out of range, the weight may be set to 0, i.e.:
Figure BDA0003350238350000081
the above equation can represent the relationship between the weights and the training samples, i.e. when the deviation is located at λ1And λ2Within a range of weight of
Figure BDA0003350238350000082
When the deviation is located at λ1And λ2Is 0, the weight is zero.
S104: determining a loss value of the training sample for the prediction model according to the weight corresponding to the training sample, and determining a parameter adjusting gradient of the training sample for the prediction model according to the loss value, wherein if the weight corresponding to the training sample is larger, the parameter adjusting gradient is larger.
S105: and adjusting parameters contained in the prediction model according to the parameter adjusting gradient so as to finish the training of the prediction model.
After the weight of the training sample is determined, a loss value of the training sample for the prediction model may be determined according to the weight corresponding to the training sample, and a parameter adjusting gradient of the training sample for the prediction model may be determined according to the loss value, so that parameters included in the prediction model are adjusted according to the parameter adjusting gradient to complete the training of the prediction model, wherein if the weight corresponding to the training sample is larger, the parameter adjusting gradient is larger.
That is, if the weight of a training sample is larger, the parameter-adjusting gradient calculated by the training sample is larger and the amplitude of parameter adjustment for the prediction model is larger when the prediction model is adjusted by the training sample, and the weight of the training sample is smaller, the parameter-adjusting gradient calculated by the training sample is smaller and the amplitude of parameter adjustment for the prediction model is smaller when the prediction model is adjusted by the training sample, and the effect of the training sample in the training of the prediction model is smaller.
That is, the weight corresponding to a training sample determines the influence of the training sample on the training of the prediction model, and when the weight corresponding to the training sample is large, the influence of the training sample on the training of the prediction model is also large, and when the weight corresponding to the training sample is small, the influence of the training sample on the training of the prediction model is also small.
The objective function when the prediction model is trained may be as follows:
Figure BDA0003350238350000091
by performing a gradient descent, one can obtain:
w←w-αΔw
Figure BDA0003350238350000092
it can be seen that the tuning parameter gradient in the above formula is in a positive correlation with the weight corresponding to the training sample.
As mentioned above, the deviation between the predicted result and the actual result corresponding to the training sample and the weight of the training sample may satisfy: for the maximum deviation and the minimum deviation, when the deviation is within the range of the maximum deviation and the minimum deviation, the more the deviation is in the central position, the more the weight of the training sample is increased, and the deviation is closer to the maximum deviation, or the closer to the minimum deviation, the less the weight of the training sample is, and if the deviation is in the maximum deviation, or exceeds the maximum deviation, or the deviation is in the minimum deviation, or exceeds the minimum deviation, the weight of the training sample may be 0.
This is because, if the deviation (deviation between the prediction result and the actual result) corresponding to the training sample is small, the prediction model has been learned to have a good effect by such a training sample. The value of the training sample to the prediction model is not large, and if the deviation of the training sample is large, it may be that the noise included in the training sample itself (e.g., the noise existing in the historical track included in the training sample) is large, and the value of such training sample to the prediction model is also not large.
However, there is a problem in simply excluding the training samples with extremely large or extremely small deviations, in the scenario of trajectory prediction, there may be a certain amount of noise in the history trajectory in the training samples with a high probability, and the existing noise is not necessarily extremely large, nor is it completely absent, and for a plurality of training samples, the noise contained in the history trajectory may be different in each training sample, and the noise may be from very small to very large, and therefore, the training value of each training sample to the prediction model may be different, and therefore, in this specification, there is a maximum value of the weight within the range of the maximum deviation and the minimum deviation, and when the deviation corresponding to one training sample is within the range of the maximum deviation and the minimum deviation, the closer the deviation is to the maximum deviation or the smaller the deviation is, the lower the weight of the training sample is.
In this specification, the prediction model may be iteratively trained, and therefore, the prediction model may be trained in multiple rounds, and therefore, in the nth round, a sample set required for the training of the current round may be obtained, and for each training sample in the sample set, the training sample is input into the prediction model that needs to be trained in the current round, so as to obtain a prediction result for the training sample, and according to the prediction result of the training sample and an actual result of the training sample, a weight of the training sample for the prediction model in the training of the current round is determined, and is used as a weight corresponding to the training sample in the current round.
And then, according to the weight corresponding to the training sample in the current round, determining a loss value of the training sample in the current round aiming at the prediction model, according to the loss value, determining a parameter adjusting gradient of the training sample in the current round aiming at the prediction model, and further according to the parameter adjusting gradient, adjusting parameters contained in the prediction model in the current round to obtain the adjusted prediction model.
That is, in each round, the weight corresponding to the training sample may be calculated, and then the prediction model is trained by the weight of the training sample to obtain the adjusted prediction model of the round, and after the round of training is completed, the next round of training is required, so that the weight of the training sample needs to be determined in the next round of training, and the adjusted prediction model needs to be trained by the determined weight.
That is, the adjusted prediction model of the current round may be used as the prediction model to be trained in the next round, and the training samples used in the next round of training may be selected from the sample set according to the weight of each training sample included in the sample set corresponding to the current round, and the sample set used in the next round of training to train the prediction model to be trained in the next round may be constructed according to the selected training samples.
That is, as the number of training samples in the sample set for training the prediction model increases, the number of training samples in the sample set for training the prediction model may gradually decrease, that is, samples with higher weights in the sample set may be selected, and the selected samples may be added to the sample set for training in the next round.
It should be noted that, when determining the weight of a training sample corresponding to the current round, it is necessary to determine a deviation between a prediction result of the training sample and an actual result of the training sample, and determine the weight of the training sample corresponding to the current round according to the deviation, the determined maximum deviation corresponding to the current round, and the determined minimum deviation corresponding to the current round, where a relationship between the deviation and the weight satisfies: the maximum value of the weight exists between the maximum deviation corresponding to the current round and the minimum deviation corresponding to the current round, and the weight is the minimum value at the maximum deviation corresponding to the current round and the minimum deviation corresponding to the current round.
That is, in each round of training, since the prediction model is trained once in the previous round, and the corresponding maximum deviation and minimum deviation in each round can be determined again, the calculation of the weight needs to be performed again in each round of training.
In each round, determining the weight of the current round, determining the maximum deviation corresponding to the current round according to the number of rounds corresponding to the current round and the maximum deviation corresponding to the previous round, and determining the minimum deviation corresponding to the current round according to the number of rounds corresponding to the current round and the minimum deviation corresponding to the previous round, wherein the minimum deviation corresponding to the previous round is smaller than the minimum deviation corresponding to the current round, and the maximum deviation corresponding to the previous round is larger than the maximum deviation corresponding to the current round.
That is, as training rounds increase, adjustments may be made with a maximum deviation and a minimum deviation, the maximum deviation may become smaller and the minimum deviation may become larger.
Of course, a certain training may be performed on the prediction model initially to serve as the initialized prediction model, and then the determination of the weight of the training sample is performed in each round of training, specifically, the training process of the prediction model may be fully described by the following diagram.
Fig. 2 is a schematic diagram of a complete process of training a prediction model in this specification.
As can be seen from fig. 2, the prediction model may be initialized, that is, the above-mentioned prediction model is trained to have a certain prediction capability, then the prediction model is iteratively trained, in each iteration, the maximum deviation and the minimum deviation of the current round are determined, then the weight corresponding to each training sample is determined according to the maximum deviation and the minimum deviation corresponding to the current round, and the prediction model is trained based on the weight corresponding to each training sample, if the weight of a training sample is 0 (or the weight is the minimum), the training sample will not function in the model training, the larger the weight of a training sample is, the greater the function of the model training will be, and then the training sample that needs to be used in the next round can be determined according to the weight corresponding to the training sample, and then the next round of training is performed, in the next round of training, the weights of the training samples also need to be determined, and the parameters of the prediction model are adjusted according to the weights of the training samples until preset training conditions are met, so that the training of the prediction model can be terminated.
The above-mentioned preset training conditions may be various, for example, the training of the prediction model may be terminated when the number of training rounds has reached a large number; as another example, the training of the predictive model may be terminated when the optimization for the objective function reaches a certain level.
The unmanned equipment mentioned above may refer to equipment capable of realizing automatic driving, such as unmanned vehicles, unmanned aerial vehicles, automatic distribution equipment, and the like. Based on this, the method for model training provided by the specification can be used for training a track prediction model for predicting the driving track of a target object around the unmanned device, and the unmanned device can be particularly applied to the field of distribution through the unmanned device, such as business scenes of distribution such as express delivery, logistics and takeout through the unmanned device.
It can be seen from the above method that, the weight of the training sample on the training of the prediction model can be determined according to the prediction result of the training sample and the actual result of the training sample, and the loss value for the prediction model can be determined according to the weight, and the parameter adjusting gradient is determined, the larger the parameter adjusting gradient is, the larger the weight of the training sample is, so that, if the weight of the training sample is higher, the larger the influence on the model is, the lower the weight of the training sample is, and the smaller the influence on the model is, and by determining the weight of the training sample, the training sample with smaller training value on the model can be made to have smaller weight, so that the influence on the prediction model is smaller, and the effect of the trained prediction model is improved.
The weight may be determined by a maximum deviation, a minimum deviation, and a deviation corresponding to the training sample, such that if the deviation corresponding to the training sample approaches the maximum deviation or the minimum deviation within a range of the maximum deviation and the minimum deviation (noise included in the training sample is large, or an actual result corresponding to the training sample is already well predicted by the prediction model), the weight of the training sample is low, and if the deviation corresponding to the training sample is within the range of the maximum deviation and the minimum deviation, the weight of the training sample is high, away from the maximum deviation or the minimum deviation (noise included in the training sample is not so large, and the actual result corresponding to the training sample is not well predicted by the prediction model).
Based on the same idea, the present specification further provides a corresponding model training apparatus, as shown in fig. 3.
Fig. 3 is a schematic diagram of a model training apparatus provided in this specification, which specifically includes:
an obtaining module 301, configured to obtain a sample set;
a prediction module 302, configured to, for each training sample in the sample set, input the training sample into a prediction model to be trained, so as to obtain a prediction result for the training sample;
a weight determining module 303, configured to determine, according to the prediction result of the training sample and the actual result of the training sample, a weight of the training sample with respect to the prediction model as a weight corresponding to the training sample;
a loss determining module 304, configured to determine a loss value of the training sample for the prediction model according to a weight corresponding to the training sample, and determine a parameter adjusting gradient of the training sample for the prediction model according to the loss value, where if the weight corresponding to the training sample is larger, the parameter adjusting gradient is larger;
a training module 305, configured to adjust parameters included in the prediction model according to the parameter tuning gradient, so as to complete training of the prediction model.
Optionally, the weight determining module 303 is specifically configured to determine a deviation between a predicted result of the training sample and an actual result of the training sample; determining the weight corresponding to the training sample according to the deviation, the preset maximum deviation and the preset minimum deviation, wherein the relation between the deviation and the weight satisfies the following conditions: between the maximum deviation and the minimum deviation, there is a maximum value of the weight, at which the weight takes a minimum value.
Optionally, the obtaining module 301 is specifically configured to obtain a sample set required by a training of a current round;
the prediction module 302 is specifically configured to, for each training sample in the sample set, input the training sample into the prediction model that needs to be trained in the current round, so as to obtain a prediction result for the training sample;
the weight determining module 303 is specifically configured to determine, according to the prediction result of the training sample and the actual result of the training sample, a weight of the training sample for the prediction model in the training of the current round, as a weight corresponding to the training sample in the current round;
the loss determining module 304 is specifically configured to determine, according to the weight corresponding to the training sample in the current round, a loss value of the training sample for the prediction model in the training of the current round, and determine, according to the loss value, a parameter tuning gradient of the training sample for the prediction model in the training of the current round;
the training module 305 is specifically configured to adjust parameters included in the prediction model in the current round according to the parameter adjustment gradient, so as to obtain an adjusted prediction model.
Optionally, the apparatus further comprises:
a screening module 306, configured to use the adjusted prediction model as a prediction model to be trained in the next round; and screening out training samples used in the next round of training from the sample set according to the weight of each training sample contained in the sample set corresponding to the current round, and constructing a sample set used for training the prediction model to be trained in the next round of training according to the screened training samples.
Optionally, the weight determining module 303 is specifically configured to determine a deviation between a predicted result of the training sample and an actual result of the training sample; determining the weight of the training sample corresponding to the current round according to the deviation, the determined maximum deviation corresponding to the current round and the determined minimum deviation corresponding to the current round, wherein the relation between the deviation and the weight satisfies the following conditions: and the maximum value of the weight exists between the maximum deviation corresponding to the current round and the minimum deviation corresponding to the current round, and the weight is the minimum value at the maximum deviation corresponding to the current round and the minimum deviation corresponding to the current round.
Optionally, the weight determining module 303 is specifically configured to determine a maximum deviation corresponding to the current round according to the number of rounds corresponding to the current round and a maximum deviation corresponding to a previous round, and determine a minimum deviation corresponding to the current round according to the number of rounds corresponding to the current round and a minimum deviation corresponding to the previous round, where the minimum deviation corresponding to the previous round is smaller than the minimum deviation corresponding to the current round, and the maximum deviation corresponding to the previous round is larger than the maximum deviation corresponding to the current round.
Optionally, the prediction model is used for predicting a track of a target object around the unmanned device, the training sample includes a historical track of the target object around the unmanned device, and the prediction result is a predicted travel track of the target object in a future period of time based on the historical track of the target object.
The present specification also provides a computer readable storage medium having stored thereon a computer program operable to perform the method of model training provided in fig. 1 above.
This specification also provides a schematic block diagram of the electronic device shown in fig. 4. As shown in fig. 4, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include hardware required for other services. The processor reads a corresponding computer program from the non-volatile memory into the memory and then runs the computer program to implement the model training method described in fig. 1. Of course, besides the software implementation, the present specification does not exclude other implementations, such as logic devices or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, and may be hardware or logic devices.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Hardware Description Language), traffic, pl (core universal Programming Language), HDCal (jhdware Description Language), lang, Lola, HDL, laspam, hardward Description Language (vhr Description Language), vhal (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functions of the various elements may be implemented in the same one or more software and/or hardware implementations of the present description.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention 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, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. 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 flow or flows and/or block diagram 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 flow or flows and/or block diagram 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 flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the description 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, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
This description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present specification, and is not intended to limit the present specification. Various modifications and alterations to this description will become apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification should be included in the scope of the claims of the present specification.

Claims (10)

1. A method of model training, comprising:
obtaining a sample set;
inputting the training sample into a prediction model to be trained aiming at each training sample in the sample set to obtain a prediction result aiming at the training sample;
determining the weight of the training sample aiming at the prediction model according to the prediction result of the training sample and the actual result of the training sample, and taking the weight as the weight corresponding to the training sample;
determining a loss value of the training sample aiming at the prediction model according to the weight corresponding to the training sample, and determining a parameter adjusting gradient of the training sample aiming at the prediction model according to the loss value, wherein if the weight corresponding to the training sample is larger, the parameter adjusting gradient is larger;
and adjusting parameters contained in the prediction model according to the parameter adjusting gradient so as to finish the training of the prediction model.
2. The method of claim 1, wherein determining the weight of the training sample with respect to the prediction model according to the predicted result of the training sample and the actual result of the training sample as the weight corresponding to the training sample specifically comprises:
determining a deviation between the predicted result of the training sample and the actual result of the training sample;
determining the weight corresponding to the training sample according to the deviation, the preset maximum deviation and the preset minimum deviation, wherein the relation between the deviation and the weight satisfies the following conditions: between the maximum deviation and the minimum deviation, there is a maximum value of the weight, at which the weight takes a minimum value.
3. The method of claim 1, wherein obtaining a sample set specifically comprises:
obtaining a sample set required by the training of the current round;
for each training sample in the sample set, inputting the training sample into a prediction model to be trained to obtain a prediction result for the training sample, specifically including:
for each training sample in the sample set, inputting the training sample into the prediction model to be trained in the current round to obtain a prediction result for the training sample;
determining the weight of the training sample for the prediction model according to the prediction result of the training sample and the actual result of the training sample, as the weight corresponding to the training sample, specifically including:
determining the weight of the training sample for the prediction model in the training of the current round according to the prediction result of the training sample and the actual result of the training sample, and taking the weight as the weight corresponding to the training sample in the current round;
determining a loss value of the training sample for the prediction model according to the weight of the training sample corresponding to the current round, and determining a parameter adjusting gradient of the training sample for the prediction model according to the loss value, specifically comprising:
determining a loss value of the training sample for the prediction model in the training of the current round according to the weight of the training sample corresponding to the current round, and determining a parameter adjusting gradient of the training sample for the prediction model in the training of the current round according to the loss value;
adjusting parameters included in the prediction model according to the parameter adjusting gradient, specifically comprising:
and adjusting parameters contained in the prediction model in the current turn according to the parameter adjusting gradient to obtain an adjusted prediction model.
4. The method of claim 3, wherein the method further comprises:
taking the adjusted prediction model as a prediction model needing to be trained in the next round;
and screening out training samples used in the next round of training from the sample set according to the weight of each training sample contained in the sample set corresponding to the current round, and constructing a sample set used for training the prediction model to be trained in the next round of training according to the screened training samples.
5. The method according to claim 3, wherein determining the weight of the training sample for the prediction model in the training of the current round according to the prediction result of the training sample and the actual result of the training sample, as the weight corresponding to the training sample in the current round, specifically comprises:
determining a deviation between the predicted result of the training sample and the actual result of the training sample;
determining the weight of the training sample corresponding to the current round according to the deviation, the determined maximum deviation corresponding to the current round and the determined minimum deviation corresponding to the current round, wherein the relation between the deviation and the weight satisfies the following conditions: and the maximum value of the weight exists between the maximum deviation corresponding to the current round and the minimum deviation corresponding to the current round, and the weight is the minimum value at the maximum deviation corresponding to the current round and the minimum deviation corresponding to the current round.
6. The method according to claim 5, wherein determining the maximum deviation corresponding to the current round and the minimum deviation corresponding to the current round specifically comprises:
determining the maximum deviation corresponding to the current round according to the number of rounds corresponding to the current round and the maximum deviation corresponding to the previous round, and determining the minimum deviation corresponding to the current round according to the number of rounds corresponding to the current round and the minimum deviation corresponding to the previous round, wherein the minimum deviation corresponding to the current round is determined according to the number of rounds corresponding to the current round and the minimum deviation corresponding to the previous round, and the minimum deviation corresponding to the current round is determined according to the number of rounds corresponding to the current round and the minimum deviation corresponding to the previous round
And the minimum deviation corresponding to the previous round is smaller than the minimum deviation corresponding to the current round, and the maximum deviation corresponding to the previous round is larger than the maximum deviation corresponding to the current round.
7. The method according to any one of claims 1 to 6, wherein the prediction model is used for predicting the track of the target object around the unmanned device, the training sample comprises the historical track of the target object around the unmanned device, and the prediction result is the predicted travel track of the target object in a future period of time based on the historical track of the target object.
8. An apparatus for model training, comprising:
the acquisition module is used for acquiring a sample set;
the prediction module is used for inputting the training sample into a prediction model to be trained aiming at each training sample in the sample set to obtain a prediction result aiming at the training sample;
the weight determining module is used for determining the weight of the training sample aiming at the prediction model according to the prediction result of the training sample and the actual result of the training sample, and the weight is used as the weight corresponding to the training sample;
the loss determining module is used for determining a loss value of the training sample for the prediction model according to the weight corresponding to the training sample, and determining a parameter adjusting gradient of the training sample for the prediction model according to the loss value, wherein if the weight corresponding to the training sample is larger, the parameter adjusting gradient is larger;
and the training module is used for adjusting parameters contained in the prediction model according to the parameter adjusting gradient so as to finish the training of the prediction model.
9. A computer-readable storage medium, characterized in that the storage medium stores a computer program which, when executed by a processor, implements the method of any of the preceding claims 1 to 7.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any of claims 1 to 7 when executing the program.
CN202111334977.3A 2021-11-11 2021-11-11 Model training method and device Pending CN114120273A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111334977.3A CN114120273A (en) 2021-11-11 2021-11-11 Model training method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111334977.3A CN114120273A (en) 2021-11-11 2021-11-11 Model training method and device

Publications (1)

Publication Number Publication Date
CN114120273A true CN114120273A (en) 2022-03-01

Family

ID=80378552

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111334977.3A Pending CN114120273A (en) 2021-11-11 2021-11-11 Model training method and device

Country Status (1)

Country Link
CN (1) CN114120273A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024060852A1 (en) * 2022-09-20 2024-03-28 支付宝(杭州)信息技术有限公司 Model ownership verification method and apparatus, storage medium and electronic device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024060852A1 (en) * 2022-09-20 2024-03-28 支付宝(杭州)信息技术有限公司 Model ownership verification method and apparatus, storage medium and electronic device

Similar Documents

Publication Publication Date Title
CN112766468B (en) Trajectory prediction method and device, storage medium and electronic equipment
CN112990375B (en) Model training method and device, storage medium and electronic equipment
CN113011483B (en) Method and device for model training and business processing
CN110852503B (en) Payment channel selection method and device and payment channel route
CN110008991B (en) Risk event identification method, risk identification model generation method, risk event identification device, risk identification equipment and risk identification medium
CN112966186A (en) Model training and information recommendation method and device
CN116304720B (en) Cost model training method and device, storage medium and electronic equipment
CN113325855B (en) Model training method for predicting obstacle trajectory based on migration scene
CN114997472A (en) Model training method, business wind control method and business wind control device
CN115618964A (en) Model training method and device, storage medium and electronic equipment
CN114120273A (en) Model training method and device
CN116308738B (en) Model training method, business wind control method and device
CN116402108A (en) Model training and graph data processing method, device, medium and equipment
CN115618748B (en) Model optimization method, device, equipment and storage medium
CN112925331B (en) Unmanned equipment control method and device, storage medium and electronic equipment
CN113010562B (en) Information recommendation method and device
CN114860967A (en) Model training method, information recommendation method and device
CN113298445A (en) Method and device for model training and unmanned equipment scheduling
CN113205377A (en) Information recommendation method and device
CN112417275A (en) Information providing method, device storage medium and electronic equipment
CN113010564B (en) Model training and information recommendation method and device
CN116434787B (en) Voice emotion recognition method and device, storage medium and electronic equipment
CN117786061B (en) Large language model prediction method and device based on space-time attention mechanism
CN117933707A (en) Wind control model interpretation method and device, storage medium and electronic equipment
CN117520850A (en) Model training method and device, storage medium and electronic equipment

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