A regression model training method, device, equipment and storage medium
By introducing a constraint adjustment term into the objective function and updating the model parameters based on the true and predicted labels, the problem of deviation between the model's predicted label distribution and the true label distribution is solved, realizing automatic adjustment and adaptability of the model and improving the prediction performance.
Patent Information
- Application Number
- CN202011072844.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-09
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2041-01-11
AI Technical Summary
In existing technologies, the predicted label distribution of the model deviates from the actual label distribution, the adjustment capability is limited, the degree of automation is low, and the transferability is poor, making it difficult to apply to different data sample sets.
By obtaining the constraint adjustment term in the objective function, determining the value of the constraint adjustment term based on the true label and the predicted label, and updating the model parameters, the prediction effect is matched with the constraint conditions, which is applicable to different data sample sets.
It achieves a match between the model's prediction performance and the constraints, improves the model's versatility and automation, is applicable to diverse data sample sets, reduces human intervention, and enhances prediction accuracy.
Smart Images

Figure CN114417945B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of machine learning technology, and in particular to a regression model training method, apparatus, device, and storage medium. Background Technology
[0002] When using a pre-trained model to predict labels on sample data, there is often a discrepancy between the predicted label distribution obtained by the trained model and the true label distribution of the sample data. Common methods in the existing technology are to use pre-processing or post-processing to make the model's predicted label distribution match the true label distribution. Specifically, the pre-processing method requires scaling the true labels, and the post-processing method requires fine-tuning the predicted labels. That is, both the pre-processing and post-processing methods need to process the corresponding labels based on specific adjustment strategies to make the predicted label distribution close to the true label distribution.
[0003] The aforementioned preprocessing or postprocessing methods have limited adjustment capabilities and may overcorrect; they also have low automation levels, requiring significant manual intervention to achieve better results; furthermore, they have poor transferability, meaning that processing methods applicable to the current sample dataset are not suitable for other sample datasets; therefore, there is an urgent need for a processing method that can make the predicted label distribution close to the true label distribution. Summary of the Invention
[0004] The technical problem to be solved by this application is to provide a regression model training method, apparatus, device and storage medium that can automatically adjust the model parameters according to the constraints so that the prediction effect of the trained model matches the constraints, and can be applied to scenarios using different data sample sets for model training, and has universality.
[0005] To address the aforementioned technical problems, this application provides a regression model training method, which may include:
[0006] Obtain an objective function for training a preset model, wherein the objective function includes a constraint adjustment term generated based on the objective constraint conditions;
[0007] Obtain a target sample set, the target sample set including at least one target sample and the real label of the at least one target sample;
[0008] The at least one target sample is labeled using the preset model to obtain the predicted label of the at least one target sample;
[0009] The value of the constraint adjustment term is determined based on the true label of at least one target sample in the target sample set and the predicted label of the at least one target sample;
[0010] Based on the value of the constraint adjustment term, determine the function value of the objective function;
[0011] The model parameters of the preset model are updated based on the function value of the objective function.
[0012] On the other hand, this application provides a regression model training apparatus, which may include:
[0013] The objective function acquisition module is used to acquire the objective function for training the preset model, wherein the objective function includes a constraint adjustment term generated based on the objective constraint conditions;
[0014] A target sample set acquisition module is used to acquire a target sample set, wherein the target sample set includes at least one target sample and the real label of the at least one target sample;
[0015] The label prediction module is used to predict the labels of the at least one target sample using the preset model, so as to obtain the predicted labels of the at least one target sample.
[0016] The constraint adjustment term value determination module is used to determine the value of the constraint adjustment term based on the true label of at least one target sample in the target sample set and the predicted label of the at least one target sample;
[0017] The function value determination module is used to determine the function value of the objective function based on the value of the constraint adjustment term;
[0018] The model parameter update module is used to update the model parameters of the preset model based on the function value of the objective function.
[0019] On the other hand, this application provides an apparatus comprising a processor and a memory, wherein the memory stores at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the regression model training method as described above.
[0020] On the other hand, this application provides a computer storage medium storing at least one instruction or at least one program, wherein the at least one instruction or the at least one program is loaded by a processor and executed as described above for the regression model training method.
[0021] Implementing the embodiments of this application has the following beneficial effects:
[0022] This application first determines the objective function used to train a pre-defined model, which includes constraint adjustment terms generated based on objective constraints. The pre-defined model then predicts the labels of target samples to obtain predicted labels. Based on the true and predicted labels of the target samples, the values of the constraint adjustment terms are determined, thereby determining the function value of the objective function. Finally, the model parameters of the pre-defined model are updated based on the function value of the objective function. In other words, at the end of each training round, the function value of the objective function containing the constraint adjustment terms is determined based on the predicted and true labels of the input samples obtained by the model in that round. The model parameters are then adjusted in reverse based on the function value of the objective function. This allows for automatic adjustment of model parameters according to constraints, ensuring that the predicted performance of the trained model matches the constraints. Furthermore, it is applicable to scenarios using different data sample sets for model training, demonstrating versatility. Attached Figure Description
[0023] To more clearly illustrate the technical solutions and advantages in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 This is a schematic diagram of the implementation environment provided in the embodiments of this application;
[0025] Figure 2 This is a flowchart of a regression model training method provided in an embodiment of this application;
[0026] Figure 3 This is a flowchart of a method for determining the value of a variance constraint adjustment term provided in an embodiment of this application;
[0027] Figure 4 This is a flowchart of a method for determining the value of a variance constraint adjustment sub-item, provided in an embodiment of this application.
[0028] Figure 5 This is a flowchart illustrating the method for calculating the variance constraint adjustment term value provided in the embodiments of this application;
[0029] Figure 6 This is a flowchart of a method for determining the value of a mean constraint adjustment term provided in an embodiment of this application;
[0030] Figure 7 This is a flowchart illustrating the method for calculating the value of the mean constraint adjustment term provided in an embodiment of this application;
[0031] Figure 8 This is a flowchart of the method for generating the objective function provided in the embodiments of this application;
[0032] Figure 9 This is a flowchart of the method for calculating the function value of the target function provided in the embodiments of this application;
[0033] Figure 10 This is a flowchart of the model parameter update method for the preset model provided in the embodiments of this application;
[0034] Figure 11 This is a schematic diagram of a regression model training device provided in an embodiment of this application;
[0035] Figure 12 This is a schematic diagram of a device structure provided in an embodiment of this application. Detailed Implementation
[0036] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0037] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.
[0038] Please see Figure 1 The illustration shows an implementation environment provided in the embodiments of this application. The implementation environment may include at least one first terminal 110 and a second terminal 120, which can communicate with each other via a network.
[0039] Specifically, the first terminal 110 sends a model training request to the second terminal 120. This request may include an objective function containing constraint adjustment terms and a target sample set. The second terminal 120 trains a preset model based on the objective function and the target sample set, generating a model that meets the constraints and returning it to the first terminal 110. Specifically, the model training request sent by the first terminal 110 to the second terminal 120 may include training constraints and a target sample set. Upon receiving the model training request, the second terminal 120 first generates corresponding constraint adjustment terms based on the training constraints, and then generates an objective function for training. It then trains the preset model based on the objective function and the target sample set, generating a model that meets the constraints and returning it to the first terminal 110.
[0040] The first terminal 110 can communicate with the second terminal 120 based on a browser / server (B / S) or client / server (C / S) model. The first terminal 110 may include physical devices such as smartphones, tablets, laptops, digital assistants, smart wearable devices, in-vehicle terminals, and servers, and may also include software running on the physical device, such as applications. The operating system running on the first terminal 110 in this embodiment may include, but is not limited to, Android, iOS, Linux, and Windows.
[0041] The second terminal 120 and the first terminal 110 can establish a communication connection via wired or wireless means. Specifically, the second terminal 120 can be a server. The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0042] Specifically, cloud computing can be used to calculate parameters during model training. Cloud computing is a computing model that distributes computing tasks across a resource pool composed of a large number of computers, enabling various application systems to obtain computing power, storage space, and information services as needed. The network providing these resources is called the "cloud." From the user's perspective, the resources in the "cloud" are infinitely scalable and can be accessed, used on demand, and expanded at any time.
[0043] Existing technologies employing correlation processing methods to ensure that the model's predicted label distribution for sample data closely approximates the true label distribution suffer from limitations in adjustment capability, low automation, and poor transferability. Therefore, this application provides a regression model training method, the execution entity of which can be the aforementioned... Figure 1 For details, please refer to the second terminal in the text. Figure 2 The method may include:
[0044] S210. Obtain an objective function for training a preset model, wherein the objective function includes a constraint adjustment term generated based on the objective constraint conditions.
[0045] As can be seen from the above description of the embodiments of this application, the objective function can be generated by the second terminal first generating constraint adjustment terms based on the objective constraints, and then generating the objective function based on the constraint adjustment terms; alternatively, the second terminal can directly obtain the objective function from other terminals, such as the first terminal. This application embodiment does not impose specific limitations and can be determined according to the specific implementation situation. For example, considering the low processing performance of the first terminal, in order to reduce the performance resource consumption of the first terminal, the second terminal can generate the corresponding objective function based on the objective constraints; furthermore, in order to improve the processing efficiency of the second terminal and reduce its workload, the second terminal can directly obtain the already generated objective function.
[0046] S220. Obtain a target sample set, wherein the target sample set includes at least one target sample and the real label of the at least one target sample.
[0047] S230. The at least one target sample is labeled using the preset model to obtain the predicted label of the at least one target sample.
[0048] The preset model here can refer to an initial, untrained model or a model that has already been trained.
[0049] S240. Determine the value of the constraint adjustment term based on the true label of at least one target sample in the target sample set and the predicted label of the at least one target sample.
[0050] In the embodiments of this application, the target constraint can be a condition used to constrain the relationship between the predicted label and the true label of the model. For example, in order to make the data distribution characteristics of the predicted label and the true label of the trained model similar, the commonly used descriptions of data distribution characteristics include variance and mean, and constraint adjustment terms related to variance and constraint adjustment terms related to mean can be generated.
[0051] Specifically, when the target constraints include variance constraints, corresponding variance constraint adjustment terms can be generated based on the variance constraints; please refer to [link to relevant documentation]. Figure 3 It illustrates a method for determining the numerical value of the variance constraint adjustment term, which may include:
[0052] S310. Based on the true labels of each target sample in the target sample set, calculate the mean of the true labels of each target sample.
[0053] Here, the true label of each target sample can be the specific data corresponding to each target sample, so the mean of the true labels of each target sample can be calculated.
[0054] S320. For each target sample, based on the true label of the target sample, the predicted label of the target sample, and the mean of the true labels of each target sample, determine the value of the variance constraint adjustment sub-item corresponding to the target sample.
[0055] The value of the variance constraint adjustment term can be determined by the values of multiple variance constraint adjustment sub-items; please refer to [link / reference] for details. Figure 4 It illustrates a method for determining the numerical value of variance constraint adjustment sub-items, which may include:
[0056] S410. For each target sample, the difference between the true label of the target sample and the predicted label of the target sample is determined as a first difference, and the difference between the true label of the target sample and the mean of the true labels of all target samples is determined as a second difference.
[0057] S420. The product of the first difference and the second difference is determined as the value of the variance constraint adjustment sub-item corresponding to the target sample.
[0058] Specifically, for any sample s in a sample set S with N samples... i The corresponding variance constraint adjustment item is valued at
[0059]
[0060] Among them, y i Indicates sample s i The real label, y′ i Indicates sample s i Predicted labels, This represents the mean of the true labels of N samples.
[0061] S330. Determine the value of the variance constraint adjustment term based on the value of the variance constraint adjustment term corresponding to each target sample.
[0062] For details on how to calculate the variance constraint adjustment term, please refer to [link / reference needed]. Figure 5 The method may include:
[0063] S510. Sum the values of the variance constraint adjustment sub-items corresponding to each target sample to obtain the first value.
[0064] S520. Calculate the value of the variance constraint adjustment term based on the value obtained by taking the absolute value of the first value.
[0065] The value of the variance constraint adjustment term can be calculated using the following formula:
[0066]
[0067] Among them, y i Indicates sample s i The real label, y′ i Indicates sample s i Predicted labels, This represents the mean of the true labels of N samples.
[0068] Therefore, according to the above equation (2), the value of the variance constraint adjustment term corresponding to the target sample set S can be obtained.
[0069] In the above Figure 3 Based on the method for determining the variance constraint adjustment term shown, the value of the variance constraint adjustment term can be further determined by combining the mean of the predicted labels of each target sample. Therefore, another way to calculate the variance constraint adjustment term is to directly use the difference between the true label variance and the predicted label variance of the target sample, which can be achieved through the following formula:
[0070]
[0071] Among them, y i Indicates sample s i The real label, y′ i Indicates sample s i Predicted labels, Let represent the mean of the true labels of N samples. This represents the mean of the predicted labels for N samples.
[0072] L rota Its main function is to adjust the variance of the model prediction so that the variance predicted by the model is as close as possible to the actual variance; thus, the value of the variance constraint adjustment term can be calculated based on the above equations (2) and (3), and the specific method to be selected can be determined according to the specific implementation situation. For example, when the sample s is known i Real Labels i Samples s i Predicted label y′ i and the mean of the true labels of N samples When the variance constraint adjustment term is known, equation (2) can be used to calculate the value; when the sample s is known... i Real Labels i Samples s i Predicted label y′ i The mean of the true labels of N samples and the mean of the predicted labels of N samples Equation (3) can be used to calculate the value of the variance constraint adjustment term.
[0073] Specifically, when the target constraint includes a mean constraint, a corresponding mean constraint adjustment term can be generated based on the constraint; please refer to [link to relevant documentation]. Figure 6 It illustrates a method for determining the value of the mean constraint adjustment term, which may include:
[0074] S610. For each target sample, based on the true label of the target sample and the predicted label of the target sample, determine the value of the mean constraint adjustment sub-item corresponding to the target sample.
[0075] Specifically, the difference between the indicator label and the predicted label of the target sample can be determined as the value of the mean constraint adjustment term corresponding to the target sample. For any sample s in a sample set S with N samples... i The corresponding mean constraint adjustment item is valued at
[0076] L2 = y i -y′ i (4)
[0077] Among them, y i Indicates sample s i The real label, y′ i Indicates sample s i Predicted labels.
[0078] S620. Determine the value of the mean constraint adjustment term based on the value of the mean constraint adjustment sub-item corresponding to each target sample.
[0079] For details on how to calculate the value of the mean constraint adjustment term, please refer to [link / reference needed]. Figure 6 The method may include:
[0080] S710. Sum the values of the mean constraint adjustment sub-items corresponding to each target sample to obtain the second value.
[0081] S720. Calculate the value of the mean constraint adjustment term based on the value obtained by taking the absolute value of the second value.
[0082] The value of the mean constraint adjustment term can be calculated using the following formula:
[0083]
[0084] Among them, y i Indicates sample s i The real label, y′ i Indicates sample s i Predicted labels.
[0085] L mean The function is to adjust the mean of the model so that the mean predicted by the model is as close as possible to the true mean; thus, according to the above formula (5), the value of the mean constraint adjustment term corresponding to the target sample set S can be obtained.
[0086] In the specific implementation process, when the target constraint is that the data distribution characteristics of the predicted labels of the trained model are similar to those of the true labels, the corresponding constraint adjustment terms can be variance constraint adjustment terms, mean constraint adjustment terms, or a combination of variance constraint adjustment terms and mean constraint adjustment terms, etc.
[0087] S250. Based on the value of the constraint adjustment term, determine the function value of the objective function.
[0088] In addition to the variance constraint adjustment term and mean constraint adjustment term described in this embodiment, the objective function may also include a preset benchmark term; furthermore, for the specific method of generating the objective function, please refer to [link to relevant documentation]. Figure 8 ,include:
[0089] S810. Assign a benchmark coefficient to the preset benchmark item and an adjustment coefficient to the constraint adjustment item.
[0090] S820. Generate the objective function based on the product of the benchmark coefficient and the preset benchmark term, and the product of the adjustment coefficient and the constraint adjustment term.
[0091] For the preset benchmark term in the objective function, it can be the mean square error (MSE) or the mean absolute error (MAE) corresponding to the target sample set. That is, the preset benchmark term can be:
[0092]
[0093] Alternatively, the preset benchmark item can be:
[0094]
[0095] Among them, y i Indicates sample s i The real label, y′ i Indicates sample s i Predicted labels.
[0096] L mse or L mae Its function is to make the predicted label of a single sample as close as possible to the true label, but it has a very weak ability to control the overall distribution of the model's predictions. Only when there is a lot of data and sufficient training can the model's predicted distribution be the same as the true distribution.
[0097] The resulting objective function can be specifically:
[0098] L=αL mse +βL rota +γL mean (8)
[0099] or,
[0100] L=αL mae +βL rota +γL mean (9)
[0101] In this context, α is typically set to 1, while β and γ are adjustable parameters. The corresponding constraint adjustment terms can be one or two. When the constraint adjustment term is a variance constraint adjustment term, β can be a floating-point number greater than 0, and γ is 0. When the constraint adjustment term is a mean constraint adjustment term, β is 0, and γ can be a floating-point number greater than 0. When the constraint adjustment term is both a variance constraint adjustment term and a mean constraint adjustment term, both β and γ can be floating-point numbers greater than 0.
[0102] For details on how to calculate the value of the objective function, please refer to [link to relevant documentation]. Figure 9 The method may include:
[0103] S910. Determine the value of the preset benchmark item based on the true label of at least one target sample in the target sample set and the predicted label of the at least one target sample.
[0104] S920. Substitute the value of the preset benchmark term and the value of the constraint adjustment term into the objective function to obtain the function value of the objective function.
[0105] After calculating the values of the preset baseline term, variance constraint adjustment term, and mean constraint adjustment term, they can be directly substituted into the objective function to obtain the function value of the objective function.
[0106] S260. Update the model parameters of the preset model based on the function value of the objective function.
[0107] The preset model can be a three-layer structure model including an input layer, a hidden layer, and an output layer. Each of the input layer, hidden layer, and output layer includes a number of neurons. Each neuron in the input layer has a corresponding weight in its connection with each neuron in the hidden layer, and each neuron in the hidden layer has a corresponding weight in its connection with each neuron in the output layer. These weights are initialized during model initialization and adjusted during model training. These weights are the model parameters in this embodiment. For example, the input layer includes two neurons i1 and i2, the hidden layer includes two neurons h1 and h2, and the output layer includes two neurons o1 and o2. The weight of the connection between neuron i1 and neuron h1 is w1, and the weight of the connection between neuron h1 and neuron o1 is w2, etc.
[0108] For details on how to update the model parameters of the preset model, please refer to [link / reference]. Figure 10 The method may include:
[0109] S1010. Calculate the adjustment gradient of each model parameter in the preset model based on the function value of the objective function.
[0110] S1020. Adjust the corresponding model parameters according to the adjustment gradient of each model parameter to obtain the adjusted model parameters.
[0111] S1030. Update the model parameters of the preset model based on the adjusted model parameters.
[0112] After calculating the function value of the objective function, the model parameters of the preset model can be updated in reverse based on the function value of the objective function obtained when the current training round is completed. Specifically, the model parameters can be updated using the backpropagation method in the existing technology, which will not be elaborated here.
[0113] The training objective of the preset model is to minimize the objective function. The termination condition for model training can be a threshold. Training can stop when the objective function value is less than the threshold, or when the objective function value tends to converge. Furthermore, the target sample set used in the training process can be a reused sample set or a newly acquired sample set.
[0114] The specific implementation process of this application embodiment is illustrated using a trainable regression model based on gradient descent as an example. For this regression model, a true label y is received. i Samples s i And predict its label as y′ i Based on the above, it is known that the objective function needs to be minimized, such that the objective function includes the preset benchmark term L. mseVariance constraint adjustment term L rota And mean constraint adjustment term L mean For example, based on the real label y i With predicted label y′ i The preset benchmark term L was obtained respectively. mse Variance constraint adjustment term L rota And mean constraint adjustment term L mean The value of the objective function is obtained by backpropagation, and the model parameters of the regression model are updated based on the value of the objective function.
[0115] When data is insufficient, a variance constraint adjustment term L is introduced. rota And mean constraint adjustment term L mean It can overcome the deficiency of insufficient data. Variance constraint adjustment term L rota The working mechanism is as follows: when the predicted variance σ′ is significantly smaller than the true variance σ, for a single sample, y′ i and Both greater than or less than y i The possibility is very high, therefore L rota The value will be relatively large, resulting in a significant penalty when minimizing the training objective. This is because L... rota The value of is relatively large, resulting in a large objective function value. Therefore, when adjusting model parameters through backpropagation based on the objective function value, the adjustment range of the model parameters is also large. After multiple backpropagation adjustments, the objective function value gradually decreases, thereby increasing σ' to approximately σ'. During this adjustment process, if the learning rate is too large, the predicted variance σ' may be significantly greater than the true variance σ. For a single sample, y′ i and Located at y i The possibilities on both sides are high, due to the effect of absolute value, L rota The value will still be relatively large, and when minimizing the training objective, it will also incur a relatively large penalty, thereby reducing σ' to make σ'≈σ. Through this mechanism, σ' will oscillate around σ until it converges. mean As a mean constraint, its main purpose is to prevent the predicted labels from being biased towards the mean. Mean of the true label A significant deviation has occurred. This is addressed by adjusting the variance constraint term L. rota And mean constraint adjustment term L mean This allows for a better fit between the predicted and actual distributions.
[0116] The constraint-based model training method provided in this application can adjust model parameters inversely based on the function value of the objective function. In this application, the model parameters are the weights between neurons in each layer. Specifically, adjusting the model parameters inversely based on the function value of the objective function can include: taking weight w1 as an example, the partial derivative of the objective function with respect to weight w1 can be calculated, and the corresponding values can be substituted into the formula after calculating the partial derivative to determine the adjustment gradient for weight w1. This achieves the inverse adjustment of model weights based on the function value of the objective function. This allows for automatic adjustment of model parameters according to constraints so that the predicted performance of the trained model matches the constraints. The constraints include variance constraint adjustment terms and / or mean constraint adjustment terms. The goal of model training is to make the model parameters match the predicted performance of the trained model. The objective function should have the smallest possible value, which means minimizing the values of the variance and / or mean constraint adjustment terms within the objective function. Minimizing these values also means minimizing the difference between the predicted variance and / or the predicted mean and the true mean, thus achieving a match between the model's prediction performance and the constraints. When the constraint is to make the predicted label distribution of the preset model similar to the true label distribution, constraint adjustment terms including variance and mean can be set. This constrains the variance and mean of the predicted labels of the preset model, making them similar to the variance and mean of the true labels, thereby ensuring that the predicted label distribution of the preset model is close to the true label distribution.
[0117] When training data is insufficient, the trained model obtained by directly training the model without adding constraint adjustment terms to the objective function struggles to predict labels near the edge of the value range, and the variance of the predicted labels is significantly smaller than the variance of the true labels. In other words, the predicted labels tend to converge towards the mean of the true labels, and there is a lack of explicit constraint between the mean of the predicted labels and the mean of the true labels. In contrast, the trained model obtained by the constraint-based model training method provided in this embodiment yields a predicted label distribution that closely approximates the true label distribution. This demonstrates that the model trained using this method has accurate prediction performance, and the predicted label distribution closely resembles the true distribution of the sample labels, thereby improving the accuracy of model prediction. Specifically, it can automatically adjust the predicted label distribution... The variance of the predicted labels is measured to be close to that of the true labels, and the labels of samples whose true labels are located on the label boundaries are predicted. Explicit constraints are added to the mean of the predicted labels and the mean of the true labels, which can prevent the model's predicted labels from converging with the mean of the true labels. Especially when data is insufficient, the training method provided in this application is combined with an early termination training method. Here, early termination can refer to situations where model training needs to be completed as soon as possible. At this time, the model may have been trained with only a small amount of training data. In order to avoid the problem of poor model prediction performance due to insufficient training data, the above-mentioned model training method based on conditional constraints can obtain a relatively good-performing model, avoid underfitting and overfitting, realize model training and prediction without human intervention, and ensure that the predicted distribution fits the true distribution. In this application, because an adjustment term for distribution constraints is added to the objective function, the training is purposeful and can generate a model that meets the distribution constraints based on a small amount of training data. This can be applied to training scenarios where training data is difficult to obtain or is scarce, as well as to scenarios where training data is sufficient but training needs to be terminated early. Thus, a model with better prediction performance can be obtained while saving training time.
[0118] This application first determines the objective function used to train a pre-defined model, which includes constraint adjustment terms generated based on objective constraints. The pre-defined model then predicts the labels of target samples to obtain predicted labels. Based on the true and predicted labels of the target samples, the values of the constraint adjustment terms are determined, thereby determining the function value of the objective function. Finally, the model parameters of the pre-defined model are updated based on the function value of the objective function. In other words, at the end of each training round, the function value of the objective function containing the constraint adjustment terms is determined based on the predicted and true labels of the input samples obtained by the model in that round. The model parameters are then adjusted in reverse based on the function value of the objective function. This allows for automatic adjustment of model parameters according to constraints, ensuring that the predicted performance of the trained model matches the constraints. Furthermore, it is applicable to scenarios using different data sample sets for model training, demonstrating versatility.
[0119] Specifically, the effectiveness of the conditional constraint-based model training method provided in this application can be verified through a series of experiments. There are eight datasets available, containing 1783, 1800, 1726, 1772, 1805, 1800, 1569, and 723 articles respectively. Each dataset contains very little data, and using traditional training methods, it is difficult to obtain a sufficiently trained scoring model with this limited data.
[0120] To obtain results with high confidence, a 5-fold method can be used, dividing each dataset into 20% test set, 20% validation set, and 60% training set. Quadratic weighted kappa is used as the metric, and the best results from similar models are selected for comparison. The experimental results are shown in Table 1.
[0121] Table 1
[0122]
[0123] Experiments show that when using the simple mean squared error (MSE) as the objective function, the trained model is about 0.01 points lower than the best performance in the industry. However, when using the objective function with added constraint adjustment terms (MSE + ROTA + mean) as described in this application, the trained model outperforms the best performance by 0.009 points. This demonstrates that the constraint-based model training method provided in this application can achieve relatively good model results even with insufficient data.
[0124] This application can be applied to the training of regression models where data collection is challenging, such as subjective question scoring models in educational application platforms, including essay scoring and language pronunciation assessment. Specifically, a training model based on conditional constraints can be used to score students' essays. The distribution of student essay scores output by the model is close to the distribution of actual essay scores, and the scores have good discriminatory power, reflecting differences in students' writing levels. This can help teachers grade essays or allow students to self-assess their writing levels. In addition, the essay scoring model can be combined with a feedback model to form a scoring and feedback system to help students improve their English writing skills.
[0125] This embodiment also provides a regression model training device; please refer to [link / reference]. Figure 11 The device may include:
[0126] The objective function acquisition module 1110 is used to acquire an objective function for training a preset model, wherein the objective function includes a constraint adjustment term generated based on the objective constraint conditions;
[0127] The target sample set acquisition module 1120 is used to acquire a target sample set, wherein the target sample set includes at least one target sample and the real label of the at least one target sample;
[0128] The label prediction module 1130 is used to predict the labels of the at least one target sample using the preset model, so as to obtain the predicted labels of the at least one target sample.
[0129] The constraint adjustment term value determination module 1140 is used to determine the value of the constraint adjustment term based on the true label of at least one target sample in the target sample set and the predicted label of the at least one target sample;
[0130] The function value determination module 1150 is used to determine the function value of the objective function based on the value of the constraint adjustment term;
[0131] The model parameter update module 1160 is used to update the model parameters of the preset model based on the function value of the objective function.
[0132] Further, the target constraint includes a variance constraint, and the constraint adjustment term includes a variance constraint adjustment term generated based on the variance constraint; correspondingly, the constraint adjustment term value determination module 1140 includes:
[0133] The true label mean calculation module is used to calculate the mean of the true labels of each target sample based on the true labels of each target sample in the target sample set;
[0134] The first determining module is used to determine the value of the variance constraint adjustment sub-item corresponding to the target sample for each target sample, based on the true label of the target sample, the predicted label of the target sample, and the mean of the true labels of each target sample;
[0135] The second determining module is used to determine the value of the variance constraint adjustment term based on the value of the variance constraint adjustment sub-term corresponding to each target sample.
[0136] The first determination module includes:
[0137] The difference determination module is used to determine, for each target sample, the difference between the true label of the target sample and the predicted label of the target sample as a first difference, and the difference between the true label of the target sample and the mean of the true labels of all target samples as a second difference;
[0138] The variance constraint adjustment sub-item value determination module is used to determine the product of the first difference and the second difference as the value of the variance constraint adjustment sub-item corresponding to the target sample.
[0139] The second determining module includes:
[0140] The first summation module is used to sum the values of the variance constraint adjustment sub-items corresponding to each target sample to obtain the first value;
[0141] The variance constraint adjustment term value calculation module is used to calculate the value of the variance constraint adjustment term based on the value obtained by taking the absolute value of the first value.
[0142] Further, the target constraint includes a mean constraint, and the constraint adjustment term includes a mean constraint adjustment term generated based on the mean constraint; correspondingly, the constraint adjustment term value determination module 1140 includes:
[0143] The third determining module is used to determine the value of the mean constraint adjustment sub-item corresponding to the target sample for each target sample, based on the true label of the target sample and the predicted label of the target sample;
[0144] The fourth determining module is used to determine the value of the mean constraint adjustment term based on the value of the mean constraint adjustment sub-item corresponding to each target sample.
[0145] The third determination module includes:
[0146] The mean constraint adjustment sub-item value determination module is used to determine, for each target sample, the difference between the true label of the target sample and the predicted label of the target sample as the value of the mean constraint adjustment sub-item corresponding to the target sample.
[0147] The fourth determination module includes:
[0148] The second summation module is used to sum the values of the mean constraint adjustment sub-items corresponding to each target sample to obtain the second value;
[0149] The mean constraint adjustment term value calculation module is used to calculate the value of the mean constraint adjustment term based on the value obtained by taking the absolute value of the second value.
[0150] The objective function also includes a preset benchmark term; correspondingly, the device may further include an objective function generation module, which includes:
[0151] A coefficient allocation module is used to allocate benchmark coefficients to the preset benchmark item and to allocate adjustment coefficients to the constraint adjustment item.
[0152] The first generation module is used to generate the objective function based on the product of the benchmark coefficient and the preset benchmark term, and the product of the adjustment coefficient and the constraint adjustment term.
[0153] Furthermore, the function value determination module 1150 includes:
[0154] A preset benchmark value determination module is used to determine the value of the preset benchmark based on the true label of at least one target sample in the target sample set and the predicted label of the at least one target sample;
[0155] The calculation module is used to substitute the values of the preset benchmark term and the constraint adjustment term into the objective function to obtain the function value of the objective function.
[0156] Model parameter update module 1160 includes:
[0157] The gradient calculation module is used to calculate the adjustment gradient of each model parameter in the preset model based on the function value of the objective function;
[0158] The parameter adjustment module is used to adjust the corresponding model parameters according to the adjustment gradient of each model parameter to obtain the adjusted model parameters;
[0159] The first update module is used to update the model parameters of the preset model based on the adjusted model parameters.
[0160] The apparatus provided in the above embodiments can execute the methods provided in any embodiment of this application, and has the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in the above embodiments can be found in the methods provided in any embodiment of this application.
[0161] This embodiment also provides a computer-readable storage medium storing at least one instruction or at least one program, which is loaded by a processor and executed as any of the methods described above in this embodiment.
[0162] This embodiment also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the methods described in this embodiment.
[0163] This embodiment also provides a device, the structural diagram of which can be found in the following figure. Figure 12 The device 1200 can vary significantly in configuration or performance, and may include one or more central processing units (CPUs) 1222 (e.g., one or more processors) and memory 1232, and one or more storage media 1230 (e.g., one or more mass storage devices) for storing applications 1242 or data 1244. The memory 1232 and storage media 1230 may be temporary or persistent storage. The program stored in the storage media 1230 may include one or more modules (not shown), each module including a series of instruction operations on the device. Furthermore, the CPU 1222 may be configured to communicate with the storage media 1230 and execute the series of instruction operations in the storage media 1230 on the device 1200. The device 1200 may also include one or more power supplies 1226, one or more wired or wireless network interfaces 1250, one or more input / output interfaces 1258, and / or one or more operating systems 1241, such as Windows Server. TM Mac OS X TM Unix TM Linux TM FreeBSD TM Etc. Any of the methods described above in this embodiment can be based on... Figure 12 The equipment shown is used for implementation.
[0164] This specification provides the operational steps of the methods described in the embodiments or flowcharts, but more or fewer operational steps may be included based on conventional or non-inventive labor. The steps and order listed in the embodiments are merely one possible execution order among many steps and do not represent the only execution order. In actual system or interrupt product execution, the methods shown in the embodiments or drawings can be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment).
[0165] The structure shown in this embodiment is only a partial structure related to the solution of this application and does not constitute a limitation on the device to which the solution of this application is applied. Specific devices may include more or fewer components than shown, or combinations of certain components, or arrangements of different components. It should be understood that the methods, apparatuses, etc., disclosed in this embodiment can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between devices or unit modules through some interfaces.
[0166] Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0167] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this specification can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0168] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A regression model training method characterized by comprising: The regression model is a scoring model for composition scoring or a scoring model for language pronunciation evaluation scoring, and the method comprises: obtaining a target function for training a preset model, wherein the target function comprises a constraint adjustment term generated based on a target constraint condition; the target constraint condition comprises a variance constraint condition, and the constraint adjustment term comprises a variance constraint adjustment term generated based on the variance constraint condition; obtaining a target sample set comprising at least one target sample and a true label of the at least one target sample; performing label prediction on the at least one target sample by using the preset model to obtain a predicted label of the at least one target sample; determining a value of the constraint adjustment term based on the true label of the at least one target sample in the target sample set and the predicted label of the at least one target sample; and the determining of the value of the constraint adjustment term based on the true label of the at least one target sample in the target sample set and the predicted label of the at least one target sample comprises: calculating a mean value of the true labels of the target samples based on the true labels of the target samples in the target sample set; for each target sample, determining a first difference value between the true label of the target sample and the predicted label of the target sample, and determining a second difference value between the true label of the target sample and the mean value of the true labels of the target samples; determining a product of the first difference value and the second difference value as a value of a variance constraint adjustment subterm corresponding to the target sample; summing the values of the variance constraint adjustment subterms corresponding to the target samples to obtain a first numerical value; and calculating the value of the variance constraint adjustment term based on a numerical value obtained by taking an absolute value of the first numerical value; determining a function value of the target function based on the value of the constraint adjustment term; updating a model parameter of the preset model based on the function value of the target function. 2.The method of Claim 1, wherein, The target constraint condition comprises a mean constraint condition, and the constraint adjustment term comprises a mean constraint adjustment term generated based on the mean constraint condition; The determining of the value of the constraint adjustment term based on the true label of the at least one target sample in the target sample set and the predicted label of the at least one target sample comprises: for each target sample, determining a value of a mean constraint adjustment subterm corresponding to the target sample based on the true label of the target sample and the predicted label of the target sample; determining the value of the mean constraint adjustment term based on the values of the mean constraint adjustment subterms corresponding to the target samples. 3.The method of Claim 2, wherein, The determining of the value of the mean constraint adjustment subterm corresponding to the target sample based on the true label of the target sample and the predicted label of the target sample for each target sample comprises: for each target sample, determining a difference value between the true label of the target sample and the predicted label of the target sample as the value of the mean constraint adjustment subterm corresponding to the target sample; The determining of the value of the mean constraint adjustment term based on the values of the mean constraint adjustment subterms corresponding to the target samples comprises: Summing values of the mean constraint adjustment sub-items corresponding to each target sample to obtain a second numerical value; calculating the value of the mean constraint adjustment item based on a numerical value obtained after taking an absolute value of the second numerical value. 4.The method of Claim 1, wherein, The target function further includes a preset reference item; The method further includes: allocating a reference coefficient to the preset reference item and an adjustment coefficient to the constraint adjustment item; generating the target function based on a product of the reference coefficient and the preset reference item and a product of the adjustment coefficient and the constraint adjustment item; The determining of the function value of the target function based on the value of the constraint adjustment item includes: determining the value of the preset reference item based on the true label of the at least one target sample in the target sample set and the predicted label of the at least one target sample; substituting the value of the preset reference item and the value of the constraint adjustment item into the target function to obtain the function value of the target function. 5.The method of Claim 1, wherein The updating of the model parameters of the preset model based on the function value of the target function includes: calculating adjustment gradients of the model parameters in the preset model based on the function value of the target function; adjusting the respective model parameters according to the adjustment gradients of the model parameters to obtain adjusted model parameters; updating the model parameters of the preset model based on the adjusted model parameters.
6. A regression model training apparatus characterized by comprising: The regression model is a scoring model for composition scoring or a scoring model for language pronunciation evaluation scoring, and the device includes: a target function acquisition module configured to acquire a target function used for training a preset model, the target function including a constraint adjustment item generated based on a target constraint condition; the target constraint condition includes a variance constraint condition, and the constraint adjustment item includes a variance constraint adjustment item generated based on the variance constraint condition; a target sample set acquisition module configured to acquire a target sample set, the target sample set including at least one target sample and a true label of the at least one target sample; a label prediction module configured to perform label prediction on the at least one target sample by using the preset model to obtain a predicted label of the at least one target sample; a constraint adjustment item value determination module configured to determine a value of the constraint adjustment item based on the true label of the at least one target sample in the target sample set and the predicted label of the at least one target sample; the determination of the value of the constraint adjustment item based on the true label of the at least one target sample in the target sample set and the predicted label of the at least one target sample includes: The mean value of the real labels of the target samples is calculated based on the real labels of the target samples in the target sample set; for each target sample, a first difference value is determined as a difference between the real label of the target sample and the predicted label of the target sample, and a second difference value is determined as a difference between the real label of the target sample and the mean value of the real labels of the target samples; a product of the first difference value and the second difference value is determined as a value of a variance constraint adjustment subterm corresponding to the target sample; the values of the variance constraint adjustment subterms corresponding to the target samples are summed to obtain a first numerical value; and a value of the variance constraint adjustment term is calculated based on a numerical value obtained by taking an absolute value of the first numerical value. The function value determination module is configured to determine a function value of the target function based on the value of the constraint adjustment term. The model parameter updating module is configured to update model parameters of the preset model based on the function value of the target function.
7. The apparatus of claim 6, wherein, The target constraint condition includes a mean value constraint condition, and the constraint adjustment term includes a mean value constraint adjustment term generated based on the mean value constraint condition. The constraint adjustment term value determination module includes: The third determination module is configured to, for each target sample, determine a value of a mean value constraint adjustment subterm corresponding to the target sample based on the real label of the target sample and the predicted label of the target sample. The fourth determination module is configured to determine a value of the mean value constraint adjustment term based on the values of the mean value constraint adjustment subterms corresponding to the target samples.
8. The apparatus of claim 7, wherein, The third determination module includes: The mean value constraint adjustment subterm value determination module is configured to, for each target sample, determine a value of a mean value constraint adjustment subterm corresponding to the target sample as a difference between the real label of the target sample and the predicted label of the target sample. The fourth determination module includes: The second summation module is configured to sum the values of the mean value constraint adjustment subterms corresponding to the target samples to obtain a second numerical value. The mean value constraint adjustment term value calculation module is configured to calculate the value of the mean value constraint adjustment term based on a numerical value obtained by taking an absolute value of the second numerical value.
9. The apparatus of claim 6, wherein, The target function further includes a preset reference term. The apparatus can further include a target function generation module, and the target function generation module includes: The coefficient assignment module is configured to assign a reference coefficient to the preset reference term and assign an adjustment coefficient to the constraint adjustment term. The first generation module is configured to generate the target function based on a product of the reference coefficient and the preset reference term and a product of the adjustment coefficient and the constraint adjustment term. The function value determination module includes: The preset reference term value determination module is configured to determine a value of the preset reference term based on the real label of the at least one target sample in the target sample set and the predicted label of the at least one target sample. The substitution calculation module is configured to substitute the value of the preset reference term and the value of the constraint adjustment term into the target function to obtain a function value of the target function.
10. The apparatus of claim 6, wherein, The model parameter updating module includes: An adjustment gradient calculation module is configured to calculate an adjustment gradient of each model parameter in the preset model based on a function value of the target function. A parameter adjustment module is configured to adjust a corresponding model parameter according to the adjustment gradient of each model parameter, to obtain an adjusted model parameter. A first updating module is configured to update the model parameter of the preset model based on the adjusted model parameter.
11. An apparatus, comprising: The device comprises a processor and a memory, and the memory stores at least one instruction or at least one program, which is loaded and executed by the processor to implement the regression model training method of any one of claims 1 to 5.
12. A computer storage medium, characterized in that, The storage medium stores at least one instruction or at least one program, which is loaded and executed by the processor to implement the regression model training method of any one of claims 1 to 5.
13. A computer program product, characterised in that, The computer program product comprises computer instructions stored in a computer readable storage medium; the processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to enable the computer device to execute the regression model training method of any one of claims 1 to 5.
Citation Information
Patent Citations
Image classification method based on semi-supervised self-paced learning cross-task deep network
CN108764281A
Cross-age face recognition and model training method and device
CN110197099A