Training method and training device for classification model

By training the classification model separately and adding noise to the generative model, the problem that the generative adversarial network is solved that the unstable and false data is not helpful to training during the training process, achieving a more stable and efficient training effect.

CN111950579BActive Publication Date: 2025-03-21BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201910414262.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-05-17
Publication Date
2025-03-21
Estimated Expiration
2039-05-17

AI Technical Summary

Technical Problem

The existing semi-supervised classification method based on generative adversarial networks is unstable during the training process, and the addition of false categories increases training complexity. The overly real false data generated by the generated model is not helpful for training.

Method used

A method of training classification models separately is proposed, by setting a loss function to suppress activation of all output categories and adding noise to the feature layer to avoid generating too real fake data.

Benefits of technology

It improves the stability of the classification model, reduces the training complexity, and improves the effectiveness and training effect of the training data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111950579B_ABST
    Figure CN111950579B_ABST
Patent Text Reader

Abstract

The present disclosure proposes a classification model training method and training device, which relate to the field of machine learning. The present disclosure trains the classification model separately, which has better model stability than training two related models at the same time; and sets a loss function for suppressing the activation of all output categories based on generated sample data, which does not require additional false categories on the basis of real categories, and is conducive to reducing the complexity of training.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of machine learning, and in particular to a training method and a training device for a classification model. Background Art

[0002] Semi-supervised classification method based on Generative Adversarial Networks (GAN): During the training phase, the generative model and classification model of the generative adversarial network are trained simultaneously. Generally speaking, the number of iterations required to train the classification model is less than the number of iterations required to train the generative model, which makes the generative adversarial network less stable. When training the classification model, an additional false category needs to be added, which is specifically used to identify the "false data" generated by the generative model, but this false category will not be used in the testing phase, which increases the complexity of training to a certain extent. In addition, the generative model sometimes generates "false data" that is real enough, and such training data is not helpful for training. Summary of the invention

[0003] The present disclosure can train the classification model separately, which has better stability than training two related models at the same time; and the loss function for suppressing the activation of all output categories is set based on the generated sample data, and there is no need to add additional false categories on the basis of the real categories, which is conducive to reducing the complexity of training. In addition, by adding noise to the feature layer, the generation model is prevented from generating "false data" that is too real to a certain extent, which is conducive to improving the effectiveness of training data and improving training effects.

[0004] According to one aspect of the present disclosure, a classification model training method is proposed, comprising:

[0005] Inputting real sample data and label data of the real sample data into a classification model to be trained, obtaining a first set of output values ​​output by the classification model, calculating a first loss based on a preset first loss function and the first set of output values, and calculating first gradient information of the first loss function under current parameters of the classification model;

[0006] Inputting the generated sample data into the classification model to obtain a second set of output values ​​output by the classification model, calculating a second loss based on a preset second loss function for suppressing activation of all output categories and the second set of output values, and calculating second gradient information of the second loss function under the current parameters of the classification model;

[0007] Whether the classification model converges is determined based on the first loss and the second loss. If the classification model has not converged, the parameters of the classification model are updated according to the gradient superposition information of the first gradient information and the second gradient information according to the gradient descent method, and the classification model continues to be trained.

[0008] In some embodiments, the second loss function is determined based on difference information between an output value of each output category in the second set of output values ​​and a preset value with a small value.

[0009] In some embodiments, the formula of the second loss function is expressed as:

[0010]

[0011] Among them, c represents the number of input and output categories, i represents one of the output categories, represents the output value of the classification model on the output category i, T represents a small preset value, max represents the operation of taking the maximum value, L ss,m Indicates the second loss.

[0012] In some embodiments, T is less than or equal to log 0.0001.

[0013] In some embodiments, the generated sample data is generated by a generative model, wherein a feature layer of the generative model is configured to add noise.

[0014] In some embodiments, the method further includes: classifying the input image data using the converged classification model.

[0015] In some embodiments, the classification model is an image classification model; the real sample data is image data of real objects, the label data of the real sample data is the types of annotated real objects, and the first set of output values ​​are the probabilities of the image data of real objects in each type; the generated sample data is image data of false objects obtained by adding noise to the image data of real objects, and the second set of output values ​​are the probabilities of the image data of false objects in each type.

[0016] According to another aspect of the present disclosure, a training device for a classification model is provided, comprising:

[0017] A first training unit is configured to input real sample data and label data of the real sample data into a classification model to be trained, obtain a first set of output values ​​output by the classification model, calculate a first loss based on a preset first loss function and the first set of output values, and calculate first gradient information of the first loss function under current parameters of the classification model;

[0018] A second training unit is configured to input the generated sample data into the classification model to obtain a second set of output values ​​output by the classification model, calculate a second loss based on a preset second loss function for suppressing activation of all output categories and the second set of output values, and calculate second gradient information of the second loss function under current parameters of the classification model;

[0019] a judging unit, configured to judge whether the classification model converges according to the first loss and the second loss;

[0020] The model parameter updating unit is configured to update the parameters of the classification model according to the gradient descent method based on the gradient superposition information of the first gradient information and the second gradient information when the classification model has not converged, so as to continue to execute the first training unit, the second training unit, the judgment unit and the model parameter updating unit to continue training the classification model.

[0021] According to another aspect of the present disclosure, a training device for a classification model is provided, comprising:

[0022] Memory; and

[0023] A processor coupled to the memory, wherein the processor is configured to execute the classification model training method of any one of the aforementioned embodiments based on instructions stored in the memory.

[0024] According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the steps of the training method of the classification model of any of the aforementioned embodiments are implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The following is a brief introduction to the drawings required for use in the embodiments or related technical descriptions. The present disclosure can be more clearly understood according to the following detailed description with reference to the drawings.

[0026] Obviously, the drawings described below are only some embodiments of the present disclosure, and a person skilled in the art can obtain other drawings based on these drawings without creative work.

[0027] Figure 1 The present invention is a flowchart of some embodiments of the training method of the classification model disclosed herein.

[0028] Figure 2 Schematic diagram showing the information flow during the classification model training process.

[0029] Figure 3 Schematic diagram of the structure of some embodiments of the training device of the classification model disclosed in the present invention.

[0030] Figure 4 Schematic diagram of the structure of some embodiments of the training device of the classification model disclosed in the present invention. DETAILED DESCRIPTION

[0031] The technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure.

[0032] The descriptions of "first" and "second" in the present disclosure are used to distinguish different objects and are not used to indicate the meaning of size or time sequence. For example, the first loss function and the second loss function represent two loss functions.

[0033] The classification model, generation model, etc. in the present disclosure are all machine learning models. The present disclosure uses the classification model for training, and does not limit the specific model of the classification model. The real sample data and its label data used for training are labeled data, and the generated sample data used for training are unlabeled data. Therefore, the present disclosure relates to a semi-supervised classification scheme.

[0034] Figure 1 The present invention is a flowchart of some embodiments of the training method of the classification model disclosed herein.

[0035] like Figure 1 As shown, the training method of this embodiment includes:

[0036] Step 11, input the real sample data and the label data of the real sample data into the classification model to be trained, obtain the first set of output values ​​output by the classification model, calculate the first loss based on the preset first loss function and the first set of output values, and calculate the first gradient information of the first loss function under the current parameters of the classification model.

[0037] Among them, the first loss function is set for real training data, such as a cross entropy loss function, an exponential loss function, a hinge loss function, etc.

[0038] In addition, when the loss function and model parameters are defined, the specific calculation of loss and gradient information can refer to the existing technology.

[0039] Step 12: input the generated sample data into the classification model to obtain a second set of output values ​​output by the classification model, calculate the second loss based on a preset second loss function for suppressing the activation of all output categories and the second set of output values, and calculate the second gradient information of the second loss function under the current parameters of the classification model.

[0040] It is understandable that steps 11 and 12 may be performed in any order.

[0041] The generated sample data is also referred to as "false sample data" relative to the real sample data. In some embodiments, the generated sample data for training can be generated by a generative model, wherein the feature layer of the generative model is configured to add noise so that the generative model generates "false sample data" that is close to the real sample data but not too real to be distinguished by the model, which is conducive to improving the validity of the training data and improving the training effect.

[0042] The second loss function is determined based on the difference information between the output value of each output category in the second group of output values ​​and a preset value with a small value.

[0043] In some embodiments, the formula of the second loss function is, for example,:

[0044]

[0045] Among them, c represents the number of input and output categories, i represents one of the output categories, represents the output value of the classification model on the output category i, T represents a small preset value, for example, T is less than or equal to log0.0001, max represents the operation of taking the maximum value, L ss,m Represents the second loss under multi-classification m.

[0046] If the output value of the classification model on the output category i is very large, indicating that the classification model will recognize the input sample as output category i, that is, the output category i is activated. However, through the second loss function, Once it exceeds T, it will be punished, thereby achieving the purpose of suppressing the activation of each output category i for the generated sample data.

[0047] Then, the second loss L under the binary classification b ss,b It can be expressed as:

[0048]

[0049] Step 13: Determine whether the classification model converges according to the first loss and the second loss.

[0050] For example, the first loss and the second loss are added together to obtain the total loss, and if the change in the total loss is small enough, the classification model is determined to have converged. The change in the total loss is determined based on the difference between the total losses of two adjacent trainings in the iterative training.

[0051] Step 14a, when the classification model has not converged, based on the gradient superposition information of the first gradient information and the second gradient information, update the parameters of the classification model according to the gradient descent method, and continue to train the classification model, that is, continue to execute this method from step 11.

[0052] The first gradient information and the second gradient information are superimposed to obtain gradient superposition information.

[0053] Among them, the parameters of the classification model are updated according to the gradient descent method, for example: the parameters of the classification model before updating are subtracted from the product of the learning rate and the gradient superposition information to obtain the parameters of the classification model after updating.

[0054] Step 14b: When the classification model converges, the training of the classification model is completed.

[0055] Furthermore, in some applications, the converged classification model can be used to classify the input image data.

[0056] In the above embodiment, the classification model is trained separately, which has better stability than training two related models at the same time; and the loss function for suppressing the activation of all output categories is set based on the generated sample data, and there is no need to add additional false categories on the basis of the real categories, which is conducive to reducing the complexity of training. In addition, by adding noise to the feature layer, the generation model is prevented from generating "false data" that is too real to a certain extent, which is conducive to improving the effectiveness of training data and improving training effects.

[0057] With respect to the training method described in the above embodiment, Figure 2 A schematic diagram showing the information flow during the classification model training process, wherein the direction of the arrow indicates the direction of information flow.

[0058] In some embodiments, the classification model is an image classification model; the real sample data is image data of real things, the label data of the real sample data is the type of the marked real things, and the first set of output values ​​are the probabilities of the image data of the real things in each type; the generated sample data is image data of false things obtained by adding noise to the image data of the real things, and the second set of output values ​​are the probabilities of the image data of the false things in each type.

[0059] The following takes the classification of clothing images as an example to specifically illustrate the solution of the present disclosure.

[0060] Model training phase:

[0061] Input the categories of the real clothing images and the annotated clothing images into the image classification model to be trained, output the probability of the real clothing images in each category (i.e., the first set of output values), calculate the first loss based on the cross entropy loss function and the probability of the real clothing images in each category, and calculate the first gradient information of the cross entropy loss function under the current parameters of the image classification model;

[0062] Add noise to the real clothing image to obtain a "false" clothing image, input the "false" clothing image into the image classification model, output the probability of the "false" clothing image in each category (i.e., the second set of output values), based on the aforementioned second loss function L for suppressing the activation of all output categories ss,m Calculate the second loss with the second set of output values ​​and calculate the second loss function L ss,m Second gradient information under the current parameters of the image classification model;

[0063] It is judged whether the change of the total loss of the superposition of the first loss and the second loss is small enough to determine whether the image classification model has converged. If the image classification model has not converged, the parameters of the image classification model are updated according to the gradient descent method based on the gradient superposition information of the first gradient information and the second gradient information, and the image classification model is continuously trained until the image classification model converges. Thus, an image classification model capable of classifying clothing images is obtained.

[0064] The image classification model is obtained by training separately. Compared with training the related generation model and classification model at the same time, the image classification model has better stability. In addition, during the training process, only real image types are involved, and no additional false image types are added, which is conducive to reducing the complexity of training.

[0065] Model usage phase:

[0066] The clothing image to be classified is input into the converged classification model obtained by the above training, and the probability of the clothing image to be classified in each category is output, wherein the category with the largest probability is determined as the category of the clothing image.

[0067] Figure 3 Schematic diagram of the structure of some embodiments of the training device of the classification model disclosed in the present invention.

[0068] like Figure 3 As shown, the training device 30 of this embodiment includes:

[0069] The first training unit 31 is configured to input the real sample data and the label data of the real sample data into the classification model to be trained, obtain a first set of output values ​​output by the classification model, calculate a first loss based on a preset first loss function and the first set of output values, and calculate first gradient information of the first loss function under current parameters of the classification model;

[0070] The second training unit 32 is configured to input the generated sample data into the classification model to obtain a second set of output values ​​output by the classification model, calculate a second loss based on a preset second loss function for suppressing activation of all output categories and the second set of output values, and calculate second gradient information of the second loss function under the current parameters of the classification model;

[0071] A judging unit 33 is configured to judge whether the classification model converges according to the first loss and the second loss;

[0072] The model parameter updating unit 34 is configured to update the parameters of the classification model according to the gradient descent method based on the gradient superposition information of the first gradient information and the second gradient information when the classification model has not converged, so as to continue to execute the first training unit, the second training unit, the judgment unit and the model parameter updating unit to continue training the classification model.

[0073] The second loss function involved in the second training unit 32 is determined according to the difference information between the output value of each output category in the second group of output values ​​and the preset value with a small value. For example, the formula of the second loss function is expressed as:

[0074]

[0075] Among them, c represents the number of input and output categories, i represents one of the output categories, represents the output value of the classification model on the output category i, T represents a small preset value, max represents the operation of taking the maximum value, L ss,m Indicates the second loss.

[0076] The generated sample data involved in the second training unit 32 is generated by a generation model, wherein the feature layer of the generation model is configured to add noise.

[0077] Figure 4 Schematic diagram of the structure of some embodiments of the training device of the classification model disclosed in the present invention.

[0078] like Figure 4 As shown, the training device 40 of this embodiment includes:

[0079] A memory 41; and a processor 42 coupled to the memory, wherein the processor 42 is configured to execute the training method of the classification model of any of the aforementioned embodiments based on the instructions stored in the memory.

[0080] The memory 41 may include, for example, a system memory, a fixed non-volatile storage medium, etc. The system memory may store, for example, an operating system, an application program, a boot loader, and other programs.

[0081] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable non-transient storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0082] The above description is only a preferred embodiment of the present disclosure and is not intended to limit the present disclosure. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure should be included in the protection scope of the present disclosure.

Claims

1. A classification model training method, comprising: Inputting real sample data and label data of the real sample data into a classification model to be trained, obtaining a first set of output values ​​output by the classification model, calculating a first loss based on a preset first loss function and the first set of output values, and calculating first gradient information of the first loss function under current parameters of the classification model; Inputting the generated sample data into the classification model to obtain a second set of output values ​​output by the classification model, calculating a second loss based on a preset second loss function for suppressing activation of all output categories and the second set of output values, and calculating second gradient information of the second loss function under the current parameters of the classification model; determining whether the classification model has converged according to the first loss and the second loss, and if the classification model has not converged, updating the parameters of the classification model according to the gradient descent method based on the gradient superposition information of the first gradient information and the second gradient information, and continuing to train the classification model, Wherein, the classification model is an image classification model; The real sample data is image data of real objects, the label data of the real sample data is the types of the marked real objects, and the first group of output values ​​is the probability of the image data of the real objects in each type; The generated sample data is image data of false objects obtained by adding noise to image data of real objects, and the second set of output values ​​are the probabilities of the image data of false objects in various categories; The second loss function is determined based on the difference information between the output value of each output category in the second group of output values ​​and a preset value with a small value.

2. The method of claim 1, wherein: The formula of the second loss function is expressed as: Among them, c represents the number of input and output categories, i represents one of the output categories, represents the output value of the classification model on the output category i, T represents a small preset value, max represents the operation of taking the maximum value, Indicates the second loss.

3. The method of claim 2, wherein: T is less than or equal to log0.0001.

4. The method of claim 1, wherein: The generated sample data is generated by a generative model, wherein a feature layer of the generative model is configured to add noise.

5. The method of claim 1, further comprising: The converged classification model is used to classify the input image data.

6. A training device for a classification model, comprising: A first training unit is configured to input real sample data and label data of the real sample data into a classification model to be trained, obtain a first set of output values ​​output by the classification model, calculate a first loss based on a preset first loss function and the first set of output values, and calculate first gradient information of the first loss function under current parameters of the classification model; A second training unit is configured to input the generated sample data into the classification model to obtain a second set of output values ​​output by the classification model, calculate a second loss based on a preset second loss function for suppressing activation of all output categories and the second set of output values, and calculate second gradient information of the second loss function under current parameters of the classification model; a judging unit, configured to judge whether the classification model converges according to the first loss and the second loss; a model parameter updating unit configured to update the parameters of the classification model according to a gradient descent method based on the gradient superposition information of the first gradient information and the second gradient information when the classification model has not converged, so as to continue to execute the first training unit, the second training unit, the judgment unit and the model parameter updating unit to continue training the classification model; Wherein, the classification model is an image classification model; The real sample data is image data of real objects, the label data of the real sample data is the types of the marked real objects, and the first group of output values ​​is the probability of the image data of the real objects in each type; The generated sample data is image data of false objects obtained by adding noise to image data of real objects, and the second set of output values ​​are the probabilities of the image data of false objects in various categories; The second loss function is determined based on the difference information between the output value of each output category in the second group of output values ​​and a preset value with a small value.

7. The device according to claim 6, wherein: The formula of the second loss function is expressed as: Among them, c represents the number of input and output categories, i represents one of the output categories, represents the output value of the classification model on the output category i, T represents a small preset value, max represents the operation of taking the maximum value, Indicates the second loss.

8. The device of claim 6, wherein: The generated sample data is generated by a generative model, wherein a feature layer of the generative model is configured to add noise.

9. A training device for a classification model, comprising: Memory; as well as A processor coupled to the memory, the processor being configured to execute the training method of the classification model according to any one of claims 1 to 5 based on instructions stored in the memory.

10. A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the classification model training method described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and device for establishing generative adversarial network models of three-model games

    CN107273978A

  • Segmentation loss-based generative adversarial network method

    CN108665058A