Classification model training method and device, electronic equipment, medium and program

Through the progressive training method, the target model is trained at a multi-level label level, solving the problem of classification characteristics being ignored in the multi-level classification task, and achieving higher classification accuracy and adaptability.

CN119919931APending Publication Date: 2025-05-02SUZHOU KEDA TECH
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411995378.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

The existing classification methods ignore different levels of classification characteristics in multi-level classification tasks, resulting in poor classification results. A classification model training method that can improve the accuracy of multi-level classification tasks is needed.

Method used

By obtaining the training set composed of training data with multi-level labels of the target model, the target model is progressively trained based on the training data of different label levels in the training set, and the training of the target model is completed based on the loss function value and the loss threshold.

Benefits of technology

This method can ensure that the model learns the correlation between levels, improves the accuracy of multi-level classification of the target model, and improves the adaptability of the model to multi-level classification tasks without changing the model structure, and improves the accuracy of model classification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919931A_ABST
    Figure CN119919931A_ABST
Patent Text Reader

Abstract

The invention discloses a classification model training method and device, electronic equipment, a medium and a program, and the method comprises the steps: obtaining a training set of a target model, and enabling training data of the training set to have multi-level labels, and enabling the multi-level labels to have at least two label levels; carrying out progressive training on the target model based on the training data of each label hierarchy in the training set; and completing training of the target model according to the loss function value and the loss threshold value of the target model. According to the embodiment of the invention, progressive training is carried out on the target model through the training data of different label hierarchies, so that the model can be guaranteed to learn the incidence relation between the hierarchies, the accuracy of multi-level classification of the target model can be improved, the adaptability of the model to a multi-level classification task can be improved on the basis of not changing the model structure, and the classification efficiency is improved. The accuracy of model classification can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer application technology, and in particular to a classification model training method, device, electronic equipment, medium and program. Background Art

[0002] In the field of deep learning, classification tasks are already relatively mature, and their accuracy can reach 90%. Currently, it is no longer possible to continue to improve the accuracy by optimizing the model. In the classification task, there is a multi-level classification task. Taking image recognition as an example, food images need to be classified into vegetables, meat, staple foods, etc., and under the major categories of vegetables, meat, staple foods, etc., some series of subcategories can also be included. Vegetables can be subdivided into green vegetables and fruits, and green vegetables can be subdivided into specific categories such as lettuce and Shanghai green. The main feature of this multi-level classification is that there are a large number of overall categories, which leads to the classification model based on the existing classification method often treating the above multi-level classification task as a classification task. There is no difference in the classification process at different levels, resulting in the classification features at different levels being ignored, resulting in poor classification results. At present, there is an urgent need for a classification model training method that makes the training process fit the multi-level features of the multi-level classification task, thereby improving the accuracy of the execution of the multi-level classification task. Summary of the invention

[0003] The present invention provides a classification model training method, device, electronic device, medium and program to solve the problem of poor multi-level model training effect, which can improve the classification accuracy of the model and assist in the accurate processing of multi-level classification tasks.

[0004] According to one aspect of the present invention, a classification model training method is provided, wherein the method comprises:

[0005] Obtaining a training set of a target model, wherein the training data of the training set has multi-level labels, and the label levels of the multi-level labels are at least two layers;

[0006] Performing progressive training on the target model based on training data of different label levels in the training set;

[0007] The training of the target model is completed according to the loss function value and the loss threshold of the target model.

[0008] According to another aspect of the present invention, a classification model training device is provided, wherein the device comprises:

[0009] A training set module, used to obtain a training set of a target model, wherein the training data of the training set has multi-level labels, and the label levels of the multi-level labels are at least two layers;

[0010] A progressive training module, used for performing progressive training on the target model based on training data of different label levels in the training set;

[0011] The training completion module is used to complete the training of the target model according to the loss function value and the loss threshold of the target model.

[0012] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0013] at least one processor; and

[0014] a memory communicatively connected to the at least one processor; wherein,

[0015] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the classification model training method described in any embodiment of the present invention.

[0016] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the classification model training method described in any embodiment of the present invention when executed.

[0017] According to another aspect of the present invention, a computer program product is provided, wherein the computer program product includes a computer program, and when the computer program is executed by a processor, the classification model training method described in any embodiment of the present invention is implemented.

[0018] The technical solution of the embodiment of the present invention obtains a training set consisting of training data with multi-level labels of the target model, performs progressive training on the target model based on the training data of different label levels in the training set, and completes the training of the target model through the loss function value and loss threshold of the objective function. The target model can be trained in sequence based on the training data of different label levels to achieve progressive training of the target model, and the training of the target model is completed according to the loss value and the instantaneous threshold. The embodiment of the present invention performs progressive training on the target model through training data of different label levels, which can ensure that the model learns the correlation between the levels, improve the accuracy of multi-level classification of the target model, and improve the adaptability of the model to multi-level classification tasks without changing the model structure, thereby improving the accuracy of model classification.

[0019] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0021] Figure 1 is a flow chart of a classification model training method provided according to Embodiment 1 of the present invention;

[0022] Figure 2 is a flowchart of another classification model training method provided according to Embodiment 2 of the present invention;

[0023] Figure 3 is a flowchart of another classification model training method provided according to Embodiment 3 of the present invention;

[0024] Figure 4 is an example diagram of another classification model training method provided according to Embodiment 4 of the present invention;

[0025] Figure 5 is an example diagram of another classification model training method provided according to Embodiment 4 of the present invention;

[0026] Figure 6 is a structural schematic diagram of a classification model training device provided according to Embodiment 5 of the present invention;

[0027] Figure 7 It is a structural schematic diagram of an electronic device for implementing the classification model training method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0028] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0030] Embodiment 1

[0031] Figure 1 1 is a flow chart of a classification model training method provided according to the first embodiment of the present invention. This embodiment is applicable to the training of a network model for performing multi-level classification tasks. The method can be performed by a classification model training device. The classification model training device can be implemented in the form of hardware and / or software. The device can be configured in a server or server cluster. Figure 1 As shown, the method includes:

[0032] Step 110: Obtain a training set of the target model, wherein the training data of the training set has multi-level labels, and the label levels of the multi-level labels are at least two layers.

[0033] Among them, the training set can be a data set used to train the target model. The training data in the training set can have multi-level labels, and the multi-level labels can be composed of multiple label levels. The data type of the training data can correspond to the target model. For example, if the target model is an image classification model, the data type of the training data can be image data. If the target type is a text classification model, the data type of the training data can be text data. The multi-level label can be composed of multiple label levels, and each label level can correspond to a classification result of a sub-classification for the label. For example, the hierarchical structure of the label level is vegetables-green vegetables-lettuce. The multi-level label can be represented in a 2-1-3 manner, and the label value of each label level can represent the classification result of the corresponding hierarchical structure. Further, it can be understood that the sub-level label value in the multi-level label of the training data can be vacant or an erroneous value to improve the training effect of the target model.

[0034] In an embodiment of the present invention, the target model may be a machine learning model or a deep learning model to be trained, and the target model may be specifically used for data classification, and the model structure of the target model may include but is not limited to a decision tree, a support vector machine, a convolutional neural network, a recurrent neural network, etc. The output result of the target model may be a multi-level classification result, that is, the output result may include the classification result of each level in the multi-label level of the input data.

[0035] Specifically, when training the target model, a training set of the target model can be obtained, and the training set can be generated by collecting historical data, by performing data enhancement on a small amount of data, or automatically generated by a specific algorithm. The multi-level labels of the training data in the obtained training set can have at least two label levels, and each label level can have one or more sub-level classification results. The multi-level labels of the training data can reflect the sub-level classification results of the training data at different label levels.

[0036] Step 120: Perform progressive training on the target model based on the training data of each label level in the training set.

[0037] Among them, progressive training can be a process of training a target model according to training data of different label levels. During the progressive training process, the target model can be trained using training data in a sequence from high level to low level or from low level to high level.

[0038] In an embodiment of the present invention, a training set can be input into a target model, and the target model can be trained respectively according to different label levels in the multi-level label. Each time the target model is trained using training data of the multi-level label of one level of label, it can be determined that the target model has completed one stage of training. After the target model is trained according to the training data corresponding to all label levels of the multi-level label, it can be determined that the progressive training is completed. It can be understood that the target model is trained for multiple rounds according to the training data of the label level, and the above-mentioned multi-round target model training process of different label levels can also be used as a progressive training process of the target model.

[0039] Step 130: Complete the training of the target model according to the loss function value and the loss threshold of the target model.

[0040] Among them, the loss function value can be a numerical value that measures the difference length between the predicted result of the objective function and the true label. The loss function value can reflect the training degree of the target model. The loss function value can be determined based on the cross entropy loss function, logarithmic loss function, KL divergence loss function, etc. The loss threshold can be the limit of the loss function value that measures the training status of the target model or determines the training process. The loss function threshold can be set in advance.

[0041] In an embodiment of the present invention, each time the target model completes progressive training based on the training data, the prediction result of the target model can be obtained, the prediction result and the multi-level labels of the training data can be used to determine the corresponding loss function value through the loss function, and the loss function value can be compared with the loss threshold of the target model to determine whether the target model has completed training. For example, when the loss function value is greater than the loss threshold, the target model has not completed training, and the weight parameters of the target model can be adjusted, and the target model can be re-progressively trained using the training set.

[0042] The embodiment of the present invention obtains a training set consisting of training data with multi-level labels of the target model, performs progressive training on the target model based on the training data of different label levels in the training set, completes the training of the target model through the loss function value and the loss threshold of the objective function, can train the target model in sequence based on the training data of different label levels, realizes progressive training of the target model, and completes the training of the target model according to the loss value and the instantaneous threshold. The embodiment of the present invention performs progressive training on the target model through training data of different levels, which can ensure that the model learns the correlation between the levels, can improve the accuracy of multi-level classification of the target model, can improve the adaptability of the model to multi-level classification tasks without changing the model structure, and can improve the accuracy of model classification.

[0043] Embodiment 2

[0044] Figure 2 is a flowchart of another classification model training method provided according to the second embodiment of the present invention. The embodiment of the present invention is a specific embodiment based on the above embodiment, and describes the process of progressive training. Figure 2 The method provided in the embodiment of the present invention specifically includes the following steps:

[0045] Step 210: Obtain a training set of the target model, wherein the training data of the training set has multi-level labels, and the label levels of the multi-level labels are at least two layers.

[0046] Step 220: Select the highest level among the label levels in the training set as the current level.

[0047] The highest level may be the highest label level in the label level of the multi-level labels, and the highest level may have one or more layers of sample labels.

[0048] In an embodiment of the present invention, the highest level of each label level in a multi-level label can be recorded as the current level. For example, the first-level label in the multi-level label is meat, the second-level label is beef, and the third-level label is sirloin. The label level of the highest level first-level label can be marked as the current level.

[0049] Step 230: determine the current training data according to the current level and the training set.

[0050] Among them, the current training data can be the data used to train the target model in the current stage, and the current training data can be determined by the current level, for example, the training data with all sub-level labels under the current level, and the sub-level labels can include the sample labels of the current level and all sample labels of the next label level belonging to the current level.

[0051] In an embodiment of the present invention, training data can be selected in the training set according to the current level as the current training data. The selection method can include selecting the training data of all label items corresponding to the current level in the training set as the current training data, or randomly selecting a part of the training data with label items of the current level in the training set as the current training data.

[0052] Step 240: Train the target model according to the current training data.

[0053] Specifically, the current training data may be output to the target model, and the target model processes the current training data to generate corresponding model output results, thereby realizing the training process of the target model.

[0054] Step 250: Take the target level that is located at the next level of the current level in the label level as the new current level, and return to extract the current training data in the training set for the current level until the new current level cannot be obtained.

[0055] The target level may be a tag level that is a level below the current level in the multi-level tags.

[0056] In an embodiment of the present invention, the target level that is located at the next level of the current level in the multi-level labels in the training set can be determined, and the target level can be used as the new current level. Then, the process returns to step 230 to obtain the current training data corresponding to the new current level. If the current level is already the last label level in the multi-level labels, the new current level cannot be obtained, and it can be considered that the current round of progressive training process of the target model is completed.

[0057] Step 260: Complete the training of the target model according to the loss function value and the loss threshold of the target model.

[0058] In an embodiment of the present invention, a training set of a target model is obtained, and the lowest level of the hierarchical labels of the multi-level labels of the training set is used as the current level. Based on the current level, current training data is selected in the training set, and the target model is trained according to the current training data. The next label level of the current level is used as the target level, and the target level is used as the new current level. Then, the acquisition process of the current training data is returned to execute. After the target model is trained with the training data of all label levels, the training of the target model is completed according to the loss function value and the loss threshold of the target model. In an embodiment of the present invention, the target model is progressively trained by selecting training data in sequence according to the label level, so that the target model learns the hierarchical relationship of the label levels in the multi-level labels, which can improve the accuracy of the target model training, realize the multi-level classification of the target model, and improve the adaptability of the model to the multi-level classification task without changing the model structure, thereby improving the accuracy of the model classification.

[0059] Further, based on the above-mentioned embodiments of the invention, current training data is determined according to the current level and the training set, including:

[0060] Searching for a current label item of a current level in the multi-level labels, and determining the sub-level label items of the current label item; using the training data having the sub-level label items and the current label item in the multi-level labels as the current training data.

[0061] Among them, the current label item can be a sample label of the current level, and the sub-level label item can be a label item constituting a multi-level label, each sub-level label item can be a label item of the next level or multiple levels of the current label, and the sub-level label item can include sample labels of all label levels under the current level. Exemplarily, the first-level labels are meat and vegetables, and the second-level labels of the next level of meat include chicken and beef, wherein the next-level label of chicken includes chicken breast and chicken thigh, and the next-level label of beef includes sirloin. When the current level is the first-level label, meat and vegetables can be used as current labels respectively, and chicken, beef, chicken breast, chicken thigh, and sirloin under meat can all be used as sub-level label items of meat.

[0062] In an embodiment of the present invention, a multi-level label of a training data set can be extracted, and a label hierarchical structure of the multi-level label can be determined. The current label item of the corresponding label level can be determined in the multi-level label according to the current level, and the corresponding sub-level label items can be found for each current label item. The training data having each current label item in the multi-level label or the sub-level label items corresponding to each current label item can be used as the current training data. It can be understood that the current label item may not have a sub-level label item, and only the training data having the current label item can be used as the current training data.

[0063] In some embodiments of the invention, training data that does not have the current label item and does not have the child label item of the current label item can also be used as negative sample data, and the negative sample data can also be used as current training data.

[0064] Further, based on the above-mentioned embodiments of the invention, the lower the label level of the current level in the training set, the smaller the number of training data with corresponding sub-level label items.

[0065] In an embodiment of the present invention, when acquiring the current training data, the lower the label level, the less training data with sub-level label items, so that the training difficulty of the target model increases as the label level decreases, thereby improving the multi-level classification ability of the target model. For example, the proportion of training data with first-level labels in the training set is A, the proportion of training data with second-level labels is B, and the proportion of training data with third-level labels is C, the value of C is less than the value of B, and the value of B is less than the value of A.

[0066] In some embodiments of the invention, taking the training data of the sub-level label items and the current label item in the training set as the current training data includes:

[0067] For each training data in the training set, a sequence label is constructed, where each sequence position in the sequence label corresponds to a label item of the multi-level label in the training set;

[0068] If the target label item of the multi-level label of the training data is the same as the current label item or the sub-level label item of the current label item, the sequence positions of all sub-level label items of the target label item are set to 1, and the other sequence positions in the sequence label are set to 0.

[0069] Among them, the sequence label can be a sequence of elements, and each element in the sequence label can correspond to a label item of the multi-level label in the training set. Take the first-level labels of the multi-level label as meat and vegetables, and the second-level labels of the next level of meat include chicken and beef, among which the next-level labels of chicken include chicken breast and chicken thigh, and the next-level labels of beef include sirloin. For example, the sequence label can include the sequence positions of 7 labels such as meat, vegetables, chicken, beef, chicken breast, chicken thigh, and sirloin. That is, the sequence label can include 7 sequence positions, and each sequence position can correspond to one of the 7 labels such as meat, vegetables, chicken, beef, chicken breast, chicken thigh, and sirloin.

[0070] In an embodiment of the present invention, each training data in the training set can be extracted, and a sequence label can be constructed for the training data according to the type of label item of the multi-level label in the training set, so that each sequence position in the sequence label corresponds to a label item of the multi-level label in the training set. For each training data, if the multi-level label of the training data includes a target label item that is the same as the current label item or the sub-level label item of the current label item, then the sequence position corresponding to the target label item and the sequence position of the sub-level label item of the target label item are determined in the sequence label of the training data, the above sequence position is set to 1, and the other sequence positions in the sequence label are set to 0.

[0071] Further, it can be understood that when the multi-level labels of the training data do not include the target label item, all sequence positions of the sequence labels of the training data can be set to 0.

[0072] Embodiment 3

[0073] Figure 3 is a flowchart of another classification model training method provided according to the third embodiment of the present invention. The embodiment of the present invention describes the process of determining the loss function value based on the above embodiment. Figure 3 The method provided in the embodiment of the present invention specifically includes the following steps:

[0074] Step 310: Obtain a training set of the target model, wherein the training data of the training set has multi-level labels, and the label levels of the multi-level labels are at least two layers.

[0075] Step 320: Perform progressive training on the target model based on the training data of each label level in the training set.

[0076] Step 330: Obtain the model output result generated by the progressive training, wherein the model output result at least includes the classification result of the target model for the sample labels of the label level within the multi-level label.

[0077] Among them, the sample label can be the label item of all multi-level labels in the data set. The model output result can have a corresponding classification result for each sample label. The classification result can include the probability or result indication that the training data belongs to the corresponding sample label. The model output result can include the classification results of all sample labels. The model output result of the target model can include multiple binary classification processing results.

[0078] In an embodiment of the present invention, the model output result generated by the target model in the progressive training process can be obtained. The model output result can include the classification result generated by processing the training data of different label levels in the target model. It can be understood that the target model can classify the training data, and can determine the distribution probability of the training data belonging to each sample label in the multi-level label. The distribution probability can be used as the classification result, and the classification result corresponding to each of the above sample labels can be used as the model output result of the training data. In the progressive training process of the target model, each stage uses training data of different label levels for training, and each training stage of the progressive training can have its own model output result. The loss function value can be calculated by the model output result for each progressive stage, or the loss function value can be calculated based on the model output results of all stages.

[0079] Step 340: Substitute the model output result and the multi-level labels of the training data into a preset loss function to obtain a loss function value.

[0080] Specifically, the model output results of each training stage in the progressive training and the multi-level labels of the training data can be input into the preset loss function respectively, or the model output results of all training stages and the multi-level labels of the training data can be input into the preset loss function together. The preset loss function is used to determine the gap between the model output results and the actual classification results of the multi-level labels. The above gap can be used as the loss function value. It can be understood that the preset loss function can include one or more of the cross entropy loss function, the logarithmic loss function, and the KL divergence loss function.

[0081] Step 350: When the loss function value is less than or equal to the loss threshold, it is determined that the target model has completed training.

[0082] Specifically, when the loss function value is less than or equal to the loss threshold, the gap between the model output result of the target model and the true classification result of the multi-level label does not exceed the loss threshold, then it can be considered that the classification performance of the target model meets the training end condition, and it can be determined that the target model has completed training.

[0083] Step 360: When the loss function value is greater than the loss threshold, the model parameters of the target model are adjusted according to the loss function value, and the target model is re-progressively trained.

[0084] Among them, the model parameters can be used to determine the model structure information of the target model. When the type of the target model is different, the model parameters may include different parameter types. When the target model includes a neural network model, the model parameters may include weight values ​​and biases, or, when the target model includes a decision tree model, the model parameters may include node classification rules, tree depth, etc., or, when the target model includes a support vector machine model, the model parameters may include kernel function parameters, penalty parameters, etc.

[0085] In an embodiment of the present invention, when the loss function value is greater than the loss threshold, the gap value between the model output result of the target model and the actual classification result of the multi-level label exceeds the loss threshold, and the target model has not yet reached the end condition for completing the training. The model parameters of the target model can be adjusted according to the value of the loss function, and then return to step 320 to re-train the target model progressively.

[0086] On the basis of the above-mentioned embodiments of the invention, the process of adjusting the model parameters of the target model according to the loss function value can be implemented by the gradient descent method, the rate of change of the loss function values ​​of different rounds with the model parameters of the target model can be calculated, the gradient of the loss function for each model parameter of the target model can be determined with the help of the back propagation algorithm, the adjustment direction and adjustment step size of the model parameters can be determined by the above-mentioned gradient, and the parameter values ​​in the model parameters can be adjusted according to the adjustment direction and adjustment step size.

[0087] The embodiment of the present invention obtains a training set of the target model, performs progressive training on the target model based on training data of different label levels in the training set, obtains the model output result of the progressive training, calculates the corresponding loss function value of the model output result and the multi-level labels of the training data through a preset loss function, and completes the training of the target model when the loss function value is less than the loss threshold, otherwise, adjusts the model parameters of the target model according to the loss function value, and retrains the target model. The embodiment of the present invention performs progressive training on the target model through training data of different levels, which can ensure that the model learns the correlation between the levels, improve the accuracy of the multi-level classification of the target model, improve the adaptability of the model to the multi-level classification task without changing the model structure, and improve the accuracy of the model classification.

[0088] Based on the above-mentioned embodiments of the invention, the model output results and the multi-level labels are substituted into the preset loss function to obtain the loss function value, including:

[0089] Obtain the result sequence of each training data in the model output result, wherein each sequence position in the result sequence corresponds to the classification result of a label item in the training set; obtain the multi-level label of each training data; map each result sequence to a classification probability value according to a preset function, wherein the classification probability value ranges from 0 to 1; input the classification probability value of each training data and the multi-level label into the cross entropy loss value function to obtain the loss function value.

[0090] Among them, the result sequence can be a sequence composed of the classification results of the training data for each type of label in the multi-level label. The corresponding classification result can be set at each sequence position in the result sequence. The classification result can exist in the form of probability or indicator parameter. Exemplarily, the result sequence can be a binary sequence, and each element in the sequence corresponds to a type of label in the multi-level label. When the element is 1, the training data is classified into this type of label. When the element is 0, the training data is not classified into this type of label.

[0091] Specifically, the preset function may include a sigma function, which may be specifically:

[0092]

[0093] The sigma function can be called a logistic function or an S-type function, which can map the input value to the interval between 0 and 1, x i It can represent the input parameter of the i-th input. The cross entropy loss function can be a loss function that measures the gap between the true label and the predicted result. The cross entropy loss function can be expressed as follows:

[0094] Loss = -[ylog(x)+(1-y)log(1-x)], where x represents the model output and y represents the true label.

[0095] In an embodiment of the present invention, a model output result can be obtained, and the model output result can be the output result generated in each progressive training stage. A result sequence for each training data can be extracted from the model output result, and the result sequence includes the classification result for each label item determined by the target model for the training data. The result sequence of all training data can be processed into a classification probability value ranging from 0 to 1 through a sigma function, and the classifiable probability values ​​of all training data and multi-level labels can be calculated through a cross entropy loss value function to obtain a loss function value.

[0096] Further, based on the above-mentioned embodiments of the invention, the preset loss function includes:

[0097]

[0098] in,

[0099]

[0100] N is the total number of training data in the training set, n is the total number of labels, x ij represents the classification result of the training data i in the training set for the jth sample label in the target model, y ij Represents the true value of the jth sample label in the multi-level label of training data i in the training set.

[0101] In the embodiment of the present invention, σ(x i ) The classification results of the training data for different sample labels in the target model are processed into classification probability values. The gap values ​​between the classification results of different training data for different sample labels and the true labels can be accumulated, and the above gap values ​​are averaged based on the total number of training data. The target loss value is converted into a positive number by taking the inverse of the average of the above gap values ​​so as to be compared with the loss threshold of the target model.

[0102] Embodiment 4

[0103] Figure 4 is an example diagram of another classification model training method provided according to Embodiment 4 of the present invention. In the embodiment of the present invention, a progressive model training method is provided to improve the classification accuracy of the model in a multi-level classification scenario. Figure 4 , the training set can include multiple levels of training data. The training process may include: first use the training data of the first-level label to classify the model. When the first-level label training converges, use the second-level label to classify the model. After the second-level label converges, the model is trained with the third-level label, so as to achieve classification training from easy to difficult for the model. However, the cross entropy loss is currently used in classification tasks to measure the training of the model. The cross entropy loss can be calculated as follows:

[0104]

[0105] Where N is the total number of training data input in each stage of progressive training, n is the total number of label types in the corresponding progressive training stage, and x i represents the classification result of the training data i in the target model for the jth label output after cross entropy calculation, y ij Represents the true value of the jth label in the multi-level label of training data i.

[0106] However, in the above formula, n is a fixed value. However, during the progressive training process, the number of label types will change dynamically with different stages. Therefore, when adjusting the level of training labels during training, the value of n needs to be changed.

[0107] However, the above training process is rather cumbersome and requires adjustment of the number of classification categories during the training process.

[0108] Figure 5 is an example diagram of another classification model training method provided according to the fourth embodiment of the present invention. In the embodiment of the present invention, each label can be regarded as an independent binary type model. When the label of the sample is a true label, its label value is 1, otherwise it is 0. Figure 5 , when training the first level label, all sub-labels with level 1 can be set to 1, and other labels can be set to 0. When training the second level label, all sub-labels with level 2 can be set to 1, and other labels can be set to 0, and so on, until the model training is completed. During the training process, as the label level goes deeper, the number of labels with level 1 continues to decrease until it becomes the only one in the end, thereby avoiding the need to manually change the number of categories when dynamically changing the label level of progressive training. It is only necessary to automatically link with the label level of training when inputting the label of the data, so as to achieve progressive training of the model. In the embodiment of the present invention, during the training process, as the label level increases, the number of labels set to 1 gradually decreases. During the training process, the total length of the vector finally output by the network remains unchanged at n. This allows the label level training to be automatically carried out during the training process. During the training process of the model, after the training of each label level is completed, the loss value calculation of a single classification can be determined for the classification result of a single label level. In the embodiment of the present invention, the single classification loss function of the model can be defined as:

[0109]

[0110] in,

[0111]

[0112] N is the total number of training data in the training set, n is the total number of labels, x ij represents the classification result of the training data i in the training set for the jth sample label in the target model, y ij Represents the true value of the jth sample label in the multi-level label of training data i in the training set.

[0113] The embodiment of the present invention can compare the training results of the target model by the above automatic classification training and directly training the third-level labels at one time. The model performance of the target model under the above two training methods can be shown in the following table:

[0114] Model classification performance table

[0115] method Accuracy Recall Directly train one-time according to the three-level label 86.2% 89.46% Level-by-level progressive training 89.73% 94.31%

[0116] From the above table, we can see that the hierarchical progressive training method has significantly improved the accuracy and recall rate in the three-level label classification task.

[0117] Embodiment 5

[0118] Figure 6 Schematic diagram of a classification model training device provided according to Embodiment 5 of the present invention. Figure 6 As shown, the device comprises:

[0119] The training set module 410 is used to obtain a training set of a target model, wherein the training data of the training set has multi-level labels, and the label levels of the multi-level labels are at least two layers.

[0120] The progressive training module 420 is used to perform progressive training on the target model based on the training data of different label levels in the training set.

[0121] The training completion module 430 is used to complete the training of the target model according to the loss function value and the loss threshold of the target model.

[0122] In an embodiment of the present invention, a training set consisting of training data with multi-level labels of a target model is obtained through a training set module. The progressive training module performs progressive training on the target model based on the training data of different label levels in the training set. The training completion module completes the training of the target model through the loss function value and the loss threshold of the objective function. The target model can be trained in sequence based on the training data of different label levels to achieve progressive training of the target model. The training of the target model is completed according to the loss value and the instantaneous threshold. In an embodiment of the present invention, the target model is progressively trained through training data of different levels, which can ensure that the model learns the correlation between levels, improve the accuracy of multi-level classification of the target model, improve the adaptability of the model to multi-level classification tasks without changing the model structure, and improve the accuracy of model classification.

[0123] Based on the above-mentioned embodiment of the invention, the progressive training module 420 includes:

[0124] An initialization unit is used to select the highest level among the label levels in the training set as the current level.

[0125] A data extraction unit is used to determine current training data according to the current level and the training set.

[0126] A stage training unit is used to train the target model according to the current training data.

[0127] The training end unit is used to take the target level located at the next level of the current level in the label level as the new current level, and return to extracting the current training data in the training set for the current level until the new current level cannot be obtained.

[0128] Furthermore, based on the above-mentioned embodiments of the invention, the data extraction unit is specifically used to: search for the current label item of the current level in the multi-level label, and determine the sub-level label items of the current label item; and use the training data having the sub-level label items and the current label item in the multi-level label as the current training data.

[0129] Based on the above-mentioned embodiment of the invention, the data extraction unit uses the training data having the sub-level label items and the current label items in the multi-level label as the current training data, including:

[0130] For each of the training data in the training set, construct a sequence label, wherein each sequence position in the sequence label corresponds to a label item of the multi-level label in the training set;

[0131] If the target label item of the multi-level label of the training data is the same as the current label item or a sub-level label item of the current label item, the sequence positions of all sub-level label items of the target label item are set to 1, and the other sequence positions in the sequence label are set to 0.

[0132] In some inventive embodiments, the training completion module 430 includes:

[0133] A result acquisition unit is used to acquire the model output result generated by the progressive training, wherein the model output result at least includes the classification result of the target model for the sample label of the label level in the multi-level label.

[0134] The loss value unit is used to substitute the model output result and the multi-level labels of the training data into a preset loss function to obtain the loss function value.

[0135] A training end unit is used to determine that the target model has completed training when the loss function value is less than or equal to the loss threshold.

[0136] A model adjustment unit is used to adjust the model parameters of the target model according to the loss function value when the loss function value is greater than the loss threshold, and to re-perform the progressive training on the target model.

[0137] On the basis of the above-mentioned embodiment of the invention, the loss value unit is specifically used to: obtain a result sequence of each training data in the output result of the model, wherein each sequence position in the result sequence corresponds to a classification result of a label item in the training set; obtain the multi-level label of each training data; map each result sequence into a classification probability value according to a preset function, wherein the classification probability value ranges from 0 to 1; input the classification probability value of each training data and the multi-level label into the cross entropy loss value function to obtain the loss function value.

[0138] The classification model training device provided in the embodiment of the present invention can execute the classification model training method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0139] Embodiment 6

[0140] Figure 7 It is a structural diagram of an electronic device that implements the classification model training method of an embodiment of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are only examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0141] like Figure 7 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0142] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0143] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as a classification model training method.

[0144] In some embodiments, the classification model training method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the classification model training method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the classification model training method in any other appropriate manner (e.g., by means of firmware).

[0145] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0146] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0147] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0148] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0149] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0150] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0151] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0152] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A classification model training method, characterized in that: The method comprises: Obtaining a training set of a target model, wherein the training data of the training set has multi-level labels, and the label levels of the multi-level labels are at least two layers; Performing progressive training on the target model based on the training data of each label level in the training set; The training of the target model is completed according to the loss function value and the loss threshold of the target model.

2. The method according to claim 1, characterized in that: The progressive training of the target model based on the training data of each label level in the training set includes: Selecting the highest level among the label levels in the training set as the current level; Determining current training data according to the current level and the training set; Training the target model according to the current training data; The target level in the label level that is located at the next level of the current level is taken as the new current level, and the current training data extracted in the training set for the current level is returned until the new current level cannot be obtained.

3. The method according to claim 2, characterized in that: The determining the current training data according to the current level and the training set includes: Searching for a current label item of the current level in the multi-level labels, and determining a sub-level label item of the current label item; The training data having the sub-level label items and the current label item in the multi-level label is used as the current training data.

4. The method according to claim 3, characterized in that: The taking the training data having the sub-level label items and the current label item in the multi-level label as the current training data includes: For each of the training data in the training set, construct a sequence label, wherein each sequence position in the sequence label corresponds to a label item of the multi-level label in the training set; If the target label item of the multi-level label of the training data is the same as the current label item or a sub-level label item of the current label item, the sequence positions of all sub-level label items of the target label item are set to 1, and the other sequence positions in the sequence label are set to 0.

5. The method according to claim 1, characterized in that: The training of the target model is completed according to the loss function value and the loss threshold of the target model, including: Obtaining a model output result generated by the progressive training, wherein the model output result at least includes a classification result of the target model for the sample labels of the label level in the multi-level label; Substituting the model output result and the multi-level labels into a preset loss function to obtain the loss function value; When the loss function value is less than or equal to the loss threshold, determining that the target model has completed training; When the loss function value is greater than the loss threshold, the model parameters of the target model are adjusted according to the loss function value, and the target model is re-progressively trained.

6. The method according to claim 4 or 5, characterized in that: Substituting the model output result and the multi-level label into a preset loss function to obtain the loss function value includes: Obtain a result sequence of each training data in the model output result, wherein each sequence position in the result sequence corresponds to a classification result of a label item in the training set; Obtain the multi-level label of each of the training data; Mapping each of the result sequences into a classification probability value according to a preset function, wherein the classification probability value ranges from 0 to 1; The classification probability value of each of the training data and the multi-level labels are input into a cross entropy loss value function to obtain the loss function value.

7. A classification model training device, characterized in that: The device comprises: A training set module, used to obtain a training set of a target model, wherein the training data of the training set has multi-level labels, and the label levels of the multi-level labels are at least two layers; A progressive training module, used for performing progressive training on the target model based on training data of different label levels in the training set; The training completion module is used to complete the training of the target model according to the loss function value and loss threshold of the target model.

8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the classification model training method described in any one of claims 1-6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the classification model training method described in any one of claims 1 to 6 when executed.

10. A computer program product, characterized in that The computer program product comprises a computer program which, when executed by a processor, implements the classification model training method according to any one of claims 1 to 6.

Citation Information

Cited By

  • Multi-modal large model training method, food material detection method and computer program product

    CN121147672A

  • Method and system for intelligently analyzing and processing device logs

    CN121167366A