Movatterモバイル変換


[0]ホーム

URL:


CN115205576A - Image classification method, data classification device, model training method, image classification device, model training device and storage medium - Google Patents

Image classification method, data classification device, model training method, image classification device, model training device and storage medium
Download PDF

Info

Publication number
CN115205576A
CN115205576ACN202210523942.2ACN202210523942ACN115205576ACN 115205576 ACN115205576 ACN 115205576ACN 202210523942 ACN202210523942 ACN 202210523942ACN 115205576 ACN115205576 ACN 115205576A
Authority
CN
China
Prior art keywords
sample data
classification
negative
label
positive
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210523942.2A
Other languages
Chinese (zh)
Inventor
许璐
邴立东
黄非
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba China Co Ltd
Original Assignee
Alibaba China Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba China Co LtdfiledCriticalAlibaba China Co Ltd
Priority to CN202210523942.2ApriorityCriticalpatent/CN115205576A/en
Publication of CN115205576ApublicationCriticalpatent/CN115205576A/en
Pendinglegal-statusCriticalCurrent

Links

Images

Classifications

Landscapes

Abstract

The embodiment of the application provides an image classification method, a data classification method, a model training method, equipment and a storage medium. In the data classification method, a classification model for performing classification operation on data is obtained by training a positive classification label of positive sample data and a negative classification label of negative sample data. Therefore, the model can learn the feature distribution of the positive classification labels and the feature distribution of the negative classification labels in a training stage, and the identification and distinguishing capability of the feature distribution of the positive classification labels is improved based on the relationship between the feature distribution of the positive classification labels and the feature distribution of the negative classification labels. In the prediction stage, the model can screen out the data matched with the negative classification label, so that the probability that the part of data is identified as the class to which the positive classification label belongs is reduced based on the principle of elimination, and the data unmatched with the negative classification label can be screened out, so that the probability that the part of data is identified as the class to which the positive classification label belongs is improved, and the classification accuracy of the classification model can be greatly improved.

Description

Image classification method, data classification device, model training method, image classification device, model training device and storage medium
Technical Field
The present application relates to the field of machine learning technologies, and in particular, to a method, an apparatus, and a storage medium for image classification, data classification, and model training.
Background
The classification task is one of the tasks in the field of machine learning, and the targets of the classification task are: and screening out labels matched with the data to be classified from preset labels through a classification model based on the given data to be classified.
The classification model can learn the characteristic distribution conditions of the data corresponding to different labels through training data. In the training process of the classification model, partial negative sample data can be added into the training samples by a data enhancement method, so that the coverage of the training data is increased, and the generalization capability of the model is enhanced.
However, this training method does not consider valid information in the negative sample, and is not favorable for further improving the classification performance of the model. Therefore, a new solution is yet to be proposed.
Disclosure of Invention
Aspects of the present application provide a method, device, and storage medium for image classification, data classification, and model training to improve classification performance of a classification model.
The embodiment of the application provides an image classification method, which comprises the following steps: acquiring an image to be classified; determining a prediction label corresponding to the image from a preset label set by using the classification model; the preset label set comprises a positive classification label and a negative classification label; determining the category of the image according to the prediction label; the classification model is obtained by training according to classification errors, and the classification errors are determined according to errors between a positive classification label and a prediction label of a positive sample image and errors between a negative classification label and the prediction label of a negative sample image.
The embodiment of the application provides a data classification method, which comprises the following steps: acquiring data to be classified; determining a prediction label corresponding to the data from a preset label set by using the classification model; the preset label set comprises a positive classification label and a negative classification label; determining the category of the data according to the prediction label; the classification model is obtained according to classification error training, and the classification error is determined according to the error between the positive classification label and the prediction label of the positive sample data and the error between the negative classification label and the prediction label of the negative sample data.
The embodiment of the present application further provides a training method for classification models, including: obtaining a sample data set, wherein the sample data set comprises: a positive sample data set and a negative sample data set; inputting the positive sample data set and the negative sample data set into a machine learning model to obtain respective prediction labels of positive sample data in the positive sample data set and respective prediction labels of negative sample data in the negative sample data set; determining a classification error of the machine learning model according to an error between a positive classification label and a prediction label of positive sample data in the positive sample data set and an error between a negative classification label and a prediction label of negative sample data in the negative sample data set; and adjusting parameters in the machine learning model according to the classification errors until the classification errors meet a convergence condition to obtain a classification model.
An embodiment of the present application further provides an electronic device, including: a memory and a processor; the memory is to store one or more computer instructions; the processor is to execute the one or more computer instructions to: the steps in the method provided by the embodiments of the present application are performed.
Embodiments of the present application further provide a computer-readable storage medium storing a computer program, where the computer program can implement the steps in the method provided in the embodiments of the present application when executed.
In the data classification method provided by the embodiment of the application, the classification model for performing classification operation on data is obtained by training the positive classification label of positive sample data by the negative classification label of negative sample data. Therefore, the model can learn the feature distribution of the positive classification labels and the feature distribution of the negative classification labels in the training stage, and the identification and distinguishing capability of the feature distribution of the positive classification labels is improved based on the relationship between the feature distribution of the positive classification labels and the feature distribution of the negative classification labels. In the prediction stage, the model can screen out the data matched with the negative classification label, so that the probability that the part of data is identified as the class to which the positive classification label belongs is reduced based on the principle of elimination, and the data unmatched with the negative classification label can be screened out, so that the probability that the part of data is identified as the class to which the positive classification label belongs is improved, and the classification accuracy of the classification model can be greatly improved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
FIG. 1 is a schematic flow chart diagram illustrating a data classification method according to an exemplary embodiment of the present application;
FIG. 2 is a diagram illustrating a classification model training process provided in an exemplary embodiment of the present application;
FIG. 3 is a query representation intent for negative category labels provided in an exemplary embodiment of the present application;
FIG. 4 is a flowchart illustrating an image classification method according to an exemplary embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only a few embodiments of the present application, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The classification task is one of the tasks in the field of machine learning, and the targets of the classification task are: and screening out labels matched with the data to be classified from preset labels through a classification model based on the given data to be classified. The classification model can learn the characteristic distribution conditions of the data corresponding to different labels through training data. In the training process of the classification model, partial negative sample data can be added into the training samples by a data enhancement method, so that the coverage of the training data is increased, and the generalization capability of the model is enhanced. However, this training method does not consider valid information in the negative sample, and is not favorable for further improving the classification performance of the model.
In view of the above technical problems, in some embodiments of the present application, a solution is provided, and the technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Fig. 1 is a schematic flowchart of a data classification method according to an exemplary embodiment of the present application, and as shown in fig. 1, the method includes:
step 101, data to be classified are obtained.
102, determining a prediction label corresponding to the data from a preset label set by using a classification model; the preset label set comprises a positive classification label and a negative classification label; the classification model is obtained by training according to a classification error, and the classification error is determined according to an error between a positive classification label and a prediction label of positive sample data and an error between a negative classification label and a prediction label of negative sample data.
Step 103, determining the data type according to the prediction label.
In the present embodiment, the classification model can be applied to various classification scenarios, such as an image classification scenario, a natural language processing scenario, a behavior data analysis scenario, and the like. In different scenes, the data to be classified are realized in different forms. For example, in an image classification scenario, the data to be classified may be an image; in a natural language processing scenario, the data to be classified may be text or audio; in the behavior data analysis scenario, the data to be classified may be user behavior data, such as click rate data of a user, web browsing duration data of the user, and so on, which are not listed one by one. When the model is applied to different classification scenes, the sample image corresponding to the classification scene can be used to train the classification model, and the specific training process will be described in the following embodiments.
The preset label set may include a plurality of classification labels, where the classification labels include preset positive classification labels and preset negative classification labels. The positive classification label refers to a preset label of a category to be classified, and sample data corresponding to the positive classification label can be described as positive sample data. For example, when classifying an item, the positive classification label may include a preset item category label. For example, the positive category label may be a product category label for a cell phone, tablet, game console, and the like. The negative sample label is not a label of the category to be classified, and can be defined according to the negative sample data. The negative sample data is sample data added for improving the coverage of the sample in the training process of the classification model, and a label of a category to which the negative sample data belongs can be defined as a negative classification label. For example, when classifying electronic products, if the negative example includes an animal image, the negative classification tag may be set as an animal species tag.
In this embodiment, the machine learning model may be trained by using sample data to obtain a classification model. Among other things, machine learning models may include, but are not limited to: one or more of Convolutional Neural Networks (CNN), deep Neural Networks (DNN), graph Convolutional Neural Networks (GCN), recurrent Neural Networks (RNN), and Long-Short Term Memory Neural Networks (LSTM), or may be obtained by deforming one or more of the above Neural Networks, which is not limited in this embodiment.
Here, positive sample data (positive samples) refers to sample data that includes a classification target, and negative sample data (negative samples) refers to sample data that does not include a classification target or that includes interference information superimposed on a classification target so that the classification target is difficult to recognize. For example, in a face recognition scene, positive sample data may be an image containing a face region, and negative sample data may be an image including information of environmental elements, limbs of a human body, clothes, and the like. In the process of training the machine learning model, partial negative sample data is added, so that the machine learning model can learn and distinguish different characteristics, the overfitting phenomenon of the machine learning model is reduced, and the generalization capability of the model is improved.
Based on the error between the positive classification label and the prediction label of the positive sample data, the machine learning model can learn the feature distribution of the positive sample data and learn the ability to distinguish data that conforms to the positive sample feature distribution. Based on the error between the negative classification label and the prediction label of the negative sample data, the machine learning model can learn the feature distribution of the negative sample data and learn the ability to distinguish data conforming to the feature distribution of the negative sample.
For a machine learning model, after the machine learning model has the capability of distinguishing data conforming to the characteristic distribution of a negative sample, in a prediction stage, the machine learning model can actively screen out data matched with a negative classification label so as to reduce the probability that the part of data is identified as a category to which a positive label belongs based on an exclusion principle; meanwhile, the machine learning model can actively screen out data which are not matched with the negative label, so that the probability that the part of data are identified as the category to which the positive label belongs is improved based on the principle of elimination. Based on the mode, the classification performance of the model can be strengthened by learning the characteristics of the negative samples, and the classification accuracy of the classification model is greatly improved.
In some exemplary embodiments, the classification model may be trained using the following implementation:
obtaining a sample data set for training, the sample data set comprising: a positive sample data set and a negative sample data set. The positive sample data set may include M positive sample data, the negative sample data set may include N negative sample data, and M and N are positive integers.
Alternatively, the categories to be classified and the positive classification labels corresponding to each category may be predetermined. After the classes to be classified are determined, sample data corresponding to each class can be collected to serve as positive sample data, positive classification labels corresponding to the classes can be added to the collected sample data, and the positive classification labels are used as supervision signals in the supervised training process.
In some optional embodiments, the set of negative sample data may be generated from positive sample data. After the positive sample data set is obtained, different types of positive sample data in the positive sample data set can be fused to obtain negative sample data in the negative sample data set. In the negative sample data set, any negative sample data is obtained by fusing any multiple different types of positive sample data in the positive sample data set. The fusion means that a plurality of data are fused into one data. In some embodiments, a plurality of positive sample data may be calculated through a data fusion function to obtain one negative sample data. Optionally, the function for performing the fusion operation may be a linear calculation function or a nonlinear calculation function, and the embodiment is not limited.
Taking any negative sample data as an example, the generation process of the negative sample data can be shown as the following formula 1-1:
Figure BDA0003643230790000061
wherein,
Figure BDA0003643230790000062
representing newly generated negative sample data, xa ,xb As positive sample data, qx Is a function used to fuse sample data. When the function is a linear calculation function, the generation process of the negative sample data can be as shown in the following equations 1-2:
Figure BDA0003643230790000063
wherein k ∈ (0, 1).
As shown in FIG. 2, positive sample data x may be sampled1 And positive sample data x2 Fusion to negative sample data
Figure BDA0003643230790000067
Positive sample data x2 And positive sample data x3 Fusion to negative sample data
Figure BDA0003643230790000064
Optionally, in the process of fusing positive sample data in the positive sample data set to obtain the negative sample data set, the respective classification tags of the multiple positive sample data used for fusing the negative sample data obtained may be obtained, and the negative classification tag of the negative sample data may be generated according to the respective classification tags of the multiple positive sample data. As shown in FIG. 2, positive category labels y may be labeled1 And positive class label y2 Fusion as negative classification label
Figure BDA0003643230790000065
Positive classification label y2 And positive class label y3 Fusion as negative classification label
Figure BDA0003643230790000066
In some optional embodiments, when the negative classification label of the negative sample data is generated according to the respective classification labels of the plurality of positive sample data, the respective classification labels of the plurality of positive sample data may be spliced to obtain the classification label corresponding to the negative sample. For example, the classification label of the positive sample image P1 is L1, the classification label of the positive sample image P2 is L2, and the classification label L1 and the classification label L2 are spliced in the process of obtaining the negative sample image N1 by fusing the positive sample image P1 and the positive sample image P2 to obtain new classification labels L1-L2 and the classification label of the negative sample image N1.
In other optional embodiments, when the negative classification label of the negative sample data is generated according to the classification labels of the multiple positive sample data, the classification labels of the multiple positive sample data may be calculated to obtain the classification label corresponding to the negative sample. The calculation method may be linear calculation or non-linear calculation, and this embodiment is not limited.
Taking any negative sample data as an example, the generation process of the negative classification label of the negative sample data can be shown as the following formula 2:
Figure BDA0003643230790000071
wherein,
Figure BDA0003643230790000072
representing negative sample data
Figure BDA0003643230790000073
Class label of ya Is positive sample data xa Classification label of (a), yb Is positive sample data xb Class label of qy Is a generating function of the classification label.
In still other alternative embodiments, alternate class labels for negative sample data may be pre-generated and stored using a two-dimensional table. In the two-dimensional table, the fields corresponding to the rows and columns can respectively represent the positive classification labels and the negative classification labels, and the value of the field is the new classification label corresponding to the field.
When a negative classification label of the negative sample data is generated according to the classification labels of the positive sample data, the two-dimensional table can be inquired according to the identifications of the classification labels of the positive sample data, and the negative classification label corresponding to the negative sample data is obtained. In this embodiment, q in equation 2y May be a mapping function. As shown in fig. 3, y is determineda ,yb Then, based on qy By looking up the two-dimensional table, new class labels can be determined
Figure BDA0003643230790000074
E.g. ya =a1,yb If = b2, look up the two-dimensional table, the new classification label can be determined
Figure BDA0003643230790000075
After determining the positive classification label of the positive sample data and the negative classification label of the negative sample data based on the above embodiments, the machine learning model is trained using the positive classification label as the supervision signal GT (ground route).
As shown in fig. 2, a positive sample data set as well as a negative sample data set may be input into the machine learning model. In the machine learning model, a feature vector of each sample data may be extracted through an encoding Network (illustrated simply as E in fig. 2), and the sample data is classified according to the feature vector by using a classifier (illustrated simply as C in fig. 2), so as to obtain a prediction tag of each sample data.
The prediction label is obtained by the machine learning model through calculation based on the current model parameters, and after the machine learning model well learns the feature distribution of positive sample data and the feature distribution of negative sample data, the prediction label output by the machine learning model aiming at any sample data has higher similarity with the classification label of the sample data. Otherwise, the classification capability of the machine learning model can be improved by optimizing the model parameters of the machine learning.
After the prediction labels of the positive sample data in the positive sample data set and the prediction labels of the negative sample data in the negative sample data set are obtained, the classification error of the machine learning model can be determined according to the error between the positive classification label and the prediction label of the positive sample data and the error between the negative classification label and the prediction label of the negative sample data. The classification error is the training loss of the machine learning model in the current round and is used for carrying out iterative optimization on the machine learning model. In the iterative optimization process, parameters in the machine learning model can be adjusted according to the classification error until the classification error meets the convergence condition, and the classification model is obtained.
Alternatively, the classification error of the machine learning model may be calculated by a Loss function, which may include, but is not limited to, at least one of a Cross Entropy Loss function (Cross Entropy Loss), a binomial Loss function, a KL Divergence Loss function (Kullback-Leibler Divergence Loss), a contrast Loss function (constructive Loss), and a negative log likelihood Loss function (negative Maximum likelihood Loss).
In some optional embodiments, a negative log likelihood Loss function (negative Maximum Likehood Loss) may be constructed as the classification error of the machine learning model according to the error between the positive classification label and the prediction label of the positive sample data and the error between the negative classification label and the prediction label of the negative sample data. The negative log-likelihood loss function can well represent probability distribution, and is beneficial to enabling a machine learning model to find parameter values which most possibly cause the distribution by utilizing known sample characteristic distribution in the classification training process of a multi-classification task.
Optionally, in this embodiment, when constructing the negative log likelihood loss function, for any sample data in the positive sample data set and the negative sample data set, a similarity between a feature vector of the sample data and a feature vector of a classification label of the sample data may be obtained as a first similarity of the sample data; and obtaining the similarity between the feature vector of the sample data and the feature vector of the prediction tag of the sample data as a second similarity of the sample data. The similarity between the first and second descriptions is only used to partition the same description object conveniently, and is not limited otherwise.
For convenience of description, a sample data set consisting of a positive sample data set and a negative sample data set is labeled as sample data set L. Taking the ith sample data in the sample data set L as an example, the calculation formula of the first similarity may be as shown in the following formula 3-1:
Figure BDA0003643230790000091
wherein,
Figure BDA0003643230790000092
denotes a first similarity, W, of the ith sample datag Feature vector, W, representing class label of ith sample datagT A transposed matrix of the eigenvectors of the classification labels for the ith sample data. Wherein, the positive sample data set comprises c classification labelsThe negative sample dataset contains z-c classification tags, i ∈ [1, M +N]。
The calculation formula of the second similarity of the ith sample data may be as shown in the following formula 3-2:
Figure BDA0003643230790000093
wherein,
Figure BDA0003643230790000094
represents a second similarity, W, of the ith sample datal A feature vector, W, representing a prediction tag of the ith sample datalT A transposed matrix of eigenvectors of the prediction labels for the ith sample data.
Taking any sample data as an example, after the second similarity of each sample data is obtained by calculation based on the above embodiment, a similarity integrated value of the second similarity of each of the plurality of sample data in the sample data set is determined, and a ratio of the first similarity of the sample data to the similarity integrated value of the sample data set is obtained as a similarity error of the sample data. And obtaining the negative logarithm of the similarity error of the sample data, and taking the negative logarithm of the similarity error as the negative logarithm likelihood loss of the sample data. And accumulating the negative log likelihood loss of each of a plurality of sample data in the sample data set to obtain a negative log likelihood loss function of the machine learning model.
The first similarity and the second similarity may be calculated by using the above formulas 3-1 and 3-2, or may be further calculated by using a function to capture a fine error. For example, the first similarity and the second similarity may be optimized by using an exponential function to improve the sensitivity of the machine learning model to errors. For example, the first similarity may be:
Figure BDA0003643230790000101
the second similarity may be:
Figure BDA0003643230790000102
the negative logarithmic loss function constructed in the above embodiment can be described by referring to the following equation 4:
Figure BDA0003643230790000103
based on the loss function, the machine learning model can learn the feature distribution of the positive sample and the feature distribution of the negative sample in the iterative training process, so that the resolving power of the positive sample and the resolving power of the negative sample are learned, and the classification performance is improved.
The data classification method provided by the embodiment of the application can be applied to various classification scenes, such as an image classification scene, a natural language processing scene, a behavior data analysis scene and the like. In different scenarios, different category labels may be defined. For example, in a behavior data analysis scenario, sentiment classification tags may be defined to determine user preferences for products. In a natural language processing scenario, language class tags may be defined to identify the language corresponding to speech. For example, in an image classification scenario, different product classification tags may be defined to identify different classes of products.
The following is an exemplary description in connection with a typical image classification scenario.
Fig. 4 is a schematic flowchart of an image classification method according to an exemplary embodiment of the present application, and as shown in fig. 4, the image classification method includes:
step 401, obtaining an image to be classified.
Step 402, determining a prediction label corresponding to the image from a preset label set by using a classification model; the preset label set comprises a positive classification label and a negative classification label; the classification model is obtained according to classification error training, and the classification error is determined according to the error between the positive classification label and the prediction label of the positive sample image and the error between the negative classification label and the prediction label of the negative sample image.
Step 403, determining the category to which the image belongs according to the prediction label.
The image may be a commodity image, a face image, a road image, an animal image, and the like. Taking a commodity image as an example, in some scenes, when a commodity search service is provided for a user, a commodity image to be identified provided by the user can be acquired, and the commodity image is input into a classification model. The classification model may calculate a commodity category corresponding to the commodity image based on a parameter learned in advance, and output a predicted commodity category label. Based on the item category label, an item matching the item image may be determined and an accurate item search result returned to the user.
In training the classification model, a sample image set may be obtained, the sample image set comprising: a positive sample image set and a negative sample image set. Optionally, the negative sample image set is generated from the positive sample image set. Different types of positive sample images in the positive sample image set can be fused to obtain a negative sample image in the negative sample image set; in the negative sample image set, any negative sample image is obtained by fusing any plurality of positive sample images in the positive sample image set.
For example, in a merchandise classification scenario, a plurality of different categories of merchandise images may be acquired as positive sample images. And fusing the plurality of commodity images to obtain a negative sample image in the commodity classification scene. In a scene of face recognition, face images of different users can be acquired as positive sample images. And fusing the face images of a plurality of users to obtain a negative sample image in the face recognition scene. In an animal identification scenario, images of different animals may be acquired as positive sample images. And fusing the plurality of animal images to obtain a negative sample image in the animal classification scene. For an optional implementation of fusing multiple images, reference may be made to the description of the foregoing embodiments, which are not described herein again.
Optionally, in the process of fusing different types of positive sample images in the positive sample image set to obtain the negative sample image set, the respective classification labels of the plurality of positive sample images used for fusing to obtain the negative sample image may be obtained, and the negative classification label of the negative sample image may be generated according to the respective classification labels of the plurality of positive sample images.
For example, in an animal classification scenario, the labels corresponding to multiple animal categories may be: "cat", "dog" and "fox". When a negative sample image is generated, an animal image labeled "cat" and an animal image labeled "dog" can be fused to obtain a negative sample image. The label for the negative swatch image can be generated from the label "cat" and the label "dog".
Next, the positive sample image set and the negative sample image set may be input into a machine learning model, and a prediction label of each positive sample image in the positive sample image set and a prediction label of each negative sample image in the negative sample image set are obtained. And determining the classification error of the machine learning model according to the error between the positive classification label and the prediction label of the positive sample image in the positive sample image set and the error between the negative classification label and the prediction label of the negative sample image in the negative sample image set. And adjusting parameters in the machine learning model according to the classification error until the classification error meets a convergence condition to obtain the classification model.
Alternatively, the classification error may be constructed based on a negative log-likelihood loss function. In the process of constructing a negative log-likelihood loss function, for any sample image in the sample image set, obtaining the similarity between the feature vector of the sample image and the feature vector of the classification label of the sample image, and taking the similarity as the first similarity of the sample image; and acquiring the similarity between the feature vector of the sample image and the feature vector of the prediction label of the sample image as a second similarity of the sample image. Determining a similarity cumulative value of second similarities of a plurality of sample images contained in the sample image set, obtaining a ratio of a first similarity of the sample images to the similarity cumulative value, obtaining a negative logarithm of the similarity error of the sample images as a similarity error of the sample images, obtaining a negative logarithm of the similarity error of the sample images as a negative logarithm likelihood loss of the sample images, and accumulating the negative logarithm likelihood losses of the sample images to obtain the negative logarithm likelihood loss function. Reference may be made to the description of the foregoing embodiments, which are not repeated herein.
In the image classification method provided in this embodiment, the classification model for performing the classification operation on the image is obtained by training the positive classification label of the positive sample image with the negative classification label of the negative sample image. Therefore, the model can learn the feature distribution of the positive classification labels and the feature distribution of the negative classification labels in a training stage, and the identification and distinguishing capability of the feature distribution of the positive classification labels is improved based on the relationship between the feature distribution of the positive classification labels and the feature distribution of the negative classification labels. In the prediction stage, the model can screen out the images matched with the negative classification labels, so that the probability that the partial images are identified as the classes to which the positive classification labels belong is reduced based on the principle of elimination, and the images unmatched with the negative classification labels can be screened out, so that the probability that the partial images are identified as the classes to which the positive classification labels belong is improved, and the classification accuracy of the classification model can be greatly improved.
In some scenarios, the data classification method, the image classification method, or the classification model training method provided by the foregoing embodiments may be packaged as a Software tool, such as a SaaS (Software-as-a-Service) tool, available to a third party. Wherein the SaaS tool may be implemented as a plug-in or an application. The plug-in or application may be deployed on a server and may open a specified interface to a third party user, such as a client. For convenience of description, in the present embodiment, the specified interface is described as the first interface. Furthermore, a third-party user such as a client conveniently accesses and uses the method provided by the server device by calling the first interface. The server may be a conventional server or a cloud server, and this embodiment is not limited.
Taking the SaaS tool corresponding to the data classification method as an example, the server may respond to a call request of the client to the first interface, and obtain data to be classified included in the interface parameters. The server can input the data into the trained classification model to obtain a prediction label corresponding to the data, and returns the prediction label to the client.
Taking the SaaS tool corresponding to the image classification method as an example, the server may respond to a call request of the client to the first interface, and obtain an image to be classified included in the interface parameter. The server can input the image into the trained classification model to obtain a prediction label corresponding to the image, and returns the prediction label to the client.
Taking the SaaS tool corresponding to the classification model training method as an example, the server may respond to a call request of the client to the first interface, and obtain positive sample data and classification labels of the positive sample number included in the interface parameters. The server can generate negative sample data and classification labels corresponding to the negative sample data according to the positive sample data and the classification labels of the positive sample number. After the positive sample data and the negative sample data are input into the machine learning model, respective prediction labels of the positive sample data and the negative sample data can be obtained. And constructing a loss function according to the respective prediction labels of the positive sample data and the negative sample data, and performing iterative training on the machine learning model according to the loss function. And after the loss function is converged, the server can return the trained result model to the client.
In such an embodiment, the server may provide a data classification service, an image classification service, or a classification model training service to the client based on the SaaS tool running thereon, which reduces the computational stress and computational cost of the client.
It should be noted that the execution subjects of the steps of the methods provided in the above embodiments may be the same device, or different devices may be used as the execution subjects of the methods. For example, the execution subject ofsteps 101 to 103 may be device a; for another example, the execution subject ofsteps 101 and 102 may be device a, and the execution subject ofstep 103 may be device B; and so on.
In addition, in some of the flows described in the above embodiments and the drawings, a plurality of operations occurring in a specific order are included, but it should be clearly understood that these operations may be executed out of order or in parallel as they appear herein, and the sequence numbers of the operations, such as 101, 102, etc., are used merely to distinguish various operations, and the sequence numbers themselves do not represent any execution order. Additionally, the flows may include more or fewer operations, and the operations may be performed sequentially or in parallel. It should be noted that, the descriptions of "first", "second", etc. in this document are used for distinguishing different messages, devices, modules, etc., and do not represent a sequential order, nor limit the types of "first" and "second" to be different.
Fig. 5 is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present application, and as shown in fig. 5, the electronic device includes: amemory 501 and aprocessor 502.
Thememory 501 is used for storing computer programs and may be configured to store other various data to support operations on the electronic device. Examples of such data include instructions, messages, pictures, videos, etc. for any application or method operating on the electronic device.
Thememory 501 may be implemented by any type or combination of volatile or non-volatile memory devices, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
In some embodiments, the server shown in FIG. 5 may be used to perform the data classification method. Aprocessor 502 coupled to thememory 501 for executing the computer program in thememory 501 for: acquiring data to be classified; determining a prediction label corresponding to the data from a preset label set by using a classification model; the preset label set comprises a positive classification label and a negative classification label; determining the category of the data according to the prediction label; the classification model is obtained by training according to a classification error, and the classification error is determined according to an error between a positive classification label and a prediction label of positive sample data and an error between a negative classification label and a prediction label of negative sample data.
Optionally, theprocessor 502 is further configured to: obtaining a sample data set, the sample data set comprising: a positive sample data set and a negative sample data set; inputting the positive sample data set and the negative sample data set into a machine learning model to obtain respective prediction labels of positive sample data in the positive sample data set and respective prediction labels of negative sample data in the negative sample data set; determining a classification error of the machine learning model according to an error between a positive classification label and a prediction label of positive sample data in the positive sample data set and an error between a negative classification label and a prediction label of negative sample data in the negative sample data set; and adjusting parameters in the machine learning model according to the classification error until the classification error meets a convergence condition to obtain the classification model.
Optionally, when theprocessor 502 acquires the positive sample data set and the negative sample data set, it is specifically configured to: acquiring the positive sample data set; fusing different types of positive sample data in the positive sample data set to obtain negative sample data in the negative sample data set; in the negative sample data set, any negative sample data is obtained by fusing any multiple different types of positive sample data in the positive sample data set.
Optionally, theprocessor 502 is further configured to: acquiring respective classification labels of a plurality of positive sample data for fusing to obtain the negative sample data in the process of fusing different types of positive sample data in the positive sample data set to obtain the negative sample data set; and generating a negative classification label of the negative sample data according to the classification labels of the plurality of positive sample data.
Optionally, theprocessor 502 is specifically configured to, when determining the classification error of the machine learning model according to the error between the positive classification label and the prediction label of the positive sample data in the positive sample data set and the error between the negative classification label and the prediction label of the negative sample data in the negative sample data set: and constructing a negative log-likelihood loss function as the classification error according to the error between the positive classification label and the prediction label of the positive sample data in the positive sample data set and the error between the negative classification label and the prediction label of the negative sample data in the negative sample data set.
Optionally, theprocessor 502 is specifically configured to, when constructing a negative log-likelihood loss function according to an error between the positive classification label and the prediction label of the positive sample data in the positive sample data set and an error between the negative classification label and the prediction label of the negative sample data in the negative sample data set, as the classification error: for any sample data in the sample data set, acquiring the similarity between the feature vector of the sample data and the feature vector of the classification label of the sample data, and taking the similarity as a first similarity of the sample data; acquiring the similarity between the feature vector of the sample data and the feature vector of the prediction tag of the sample data as a second similarity of the sample data; determining a similarity cumulative value of respective second similarities of a plurality of sample data contained in the sample data set, and acquiring a ratio of the first similarity of the sample data to the similarity cumulative value as a similarity error of the sample data; obtaining the negative logarithm of the similarity error of the sample data as the negative logarithm likelihood loss of the sample data; and accumulating the negative log-likelihood losses of the plurality of sample data to obtain the negative log-likelihood loss function.
Further, as shown in fig. 5, the electronic device further includes:communication component 503,display component 504,power component 505,audio component 506, and the like. Only some of the components are schematically shown in fig. 5, and it is not meant that the electronic device comprises only the components shown in fig. 5.
Wherein thecommunication component 503 is configured to facilitate communication between the device in which the communication component is located and other devices in a wired or wireless manner. The device in which the communication component is located may access a wireless network based on a communication standard, such as WiFi,2G, 3G, 4G, or 5G, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component may be implemented based on Near Field Communication (NFC) technology, radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
Thedisplay assembly 504 includes a screen, which may include a liquid crystal display assembly (LCD) and a Touch Panel (TP), among others. If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide action.
Thepower supply unit 505 provides power to various components of the device in which the power supply unit is located. The power components may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device in which the power component is located.
In this embodiment, the classification model for performing the classification operation on the data is obtained by training the positive classification label of the positive sample data with the negative classification label of the negative sample data. Therefore, the model can learn the feature distribution of the positive classification labels and the feature distribution of the negative classification labels in a training stage, and the identification and distinguishing capability of the feature distribution of the positive classification labels is improved based on the relationship between the feature distribution of the positive classification labels and the feature distribution of the negative classification labels. In the prediction stage, the model can screen out the data matched with the negative classification label, so that the probability that the part of data is identified as the class to which the positive classification label belongs is reduced based on the principle of elimination, and the data unmatched with the negative classification label can be screened out, so that the probability that the part of data is identified as the class to which the positive classification label belongs is improved, and the classification accuracy of the classification model can be greatly improved.
The electronic device shown in fig. 5 may further perform a training method of the classification model as follows: theprocessor 502 obtains a sample data set comprising: a positive sample data set and a negative sample data set; inputting the positive sample data set and the negative sample data set into a machine learning model to obtain respective prediction labels of positive sample data in the positive sample data set and respective prediction labels of negative sample data in the negative sample data set; determining a classification error of the machine learning model according to an error between a positive classification label and a prediction label of positive sample data in the positive sample data set and an error between a negative classification label and a prediction label of negative sample data in the negative sample data set; and adjusting parameters in the machine learning model according to the classification error until the classification error meets a convergence condition to obtain a classification model.
The electronic device shown in fig. 5 may also perform the following image classification method: theprocessor 502 acquires an image to be classified; determining a prediction label corresponding to the image from a preset label set by using a classification model; the preset label set comprises a positive classification label and a negative classification label; determining the category of the image according to the prediction label; the classification model is obtained according to classification error training, and the classification error is determined according to the error between the positive classification label and the prediction label of the positive sample image and the error between the negative classification label and the prediction label of the negative sample image.
Accordingly, the present application further provides a computer-readable storage medium storing a computer program, where the computer program is capable of implementing the steps that can be executed by the electronic device in the foregoing method embodiments when executed.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable depth metric learning based model optimization apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable depth metric learning based model optimization apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable depth metric learning-based model optimization apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable depth metric learning-based model optimization device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer implemented process such that the instructions which execute on the computer or other programmable device provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising a," "8230," "8230," or "comprising" does not exclude the presence of other like elements in a process, method, article, or apparatus comprising the element.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. An image classification method, comprising:
acquiring an image to be classified;
determining a prediction label corresponding to the image from a preset label set by using the classification model; the preset label set comprises a positive classification label and a negative classification label;
determining the category of the image according to the prediction label;
the classification model is obtained according to classification error training, and the classification error is determined according to an error between a positive classification label and a prediction label of a positive sample image and an error between a negative classification label and a prediction label of a negative sample image.
2. A method of data classification, comprising:
acquiring data to be classified;
determining a prediction label corresponding to the data from a preset label set by using the classification model; the preset label set comprises positive classification labels and negative classification labels;
determining the category of the data according to the prediction label;
the classification model is obtained according to classification error training, and the classification error is determined according to the error between the positive classification label and the prediction label of the positive sample data and the error between the negative classification label and the prediction label of the negative sample data.
3. The method of claim 2, further comprising:
obtaining a sample data set, wherein the sample data set comprises: a positive sample data set and a negative sample data set;
inputting the positive sample data set and the negative sample data set into a machine learning model to obtain respective prediction labels of positive sample data in the positive sample data set and respective prediction labels of negative sample data in the negative sample data set;
determining a classification error of the machine learning model according to an error between a positive classification label and a prediction label of positive sample data in the positive sample data set and an error between a negative classification label and a prediction label of negative sample data in the negative sample data set;
and adjusting parameters in the machine learning model according to the classification errors until the classification errors meet convergence conditions to obtain the classification model.
4. The method of claim 3, wherein obtaining a positive sample data set and a negative sample data set comprises:
acquiring the positive sample data set;
fusing different types of positive sample data in the positive sample data set to obtain negative sample data in the negative sample data set; in the negative sample data set, any negative sample data is obtained by fusing any multiple different types of positive sample data in the positive sample data set.
5. The method of claim 4, further comprising:
acquiring respective classification labels of a plurality of positive sample data used for fusing to obtain negative sample data in the process of fusing different types of positive sample data in the positive sample data set to obtain the negative sample data set;
and generating a negative classification label of the negative sample data according to the respective classification labels of the plurality of positive sample data.
6. The method of claim 3, wherein determining a classification error of the machine learning model from an error between a positive classification label and a prediction label for positive sample data in the positive sample data set and an error between a negative classification label and a prediction label for negative sample data in the negative sample data set comprises:
and constructing a negative log-likelihood loss function according to the error between the positive classification label and the prediction label of the positive sample data in the positive sample data set and the error between the negative classification label and the prediction label of the negative sample data in the negative sample data set, wherein the negative log-likelihood loss function is used as the classification error.
7. The method of claim 6, wherein constructing a negative log-likelihood loss function from an error between a positive class label and a prediction label for positive sample data in the positive sample data set and an error between a negative class label and a prediction label for negative sample data in the negative sample data set as the class error comprises:
for any sample data in the sample data set, obtaining the similarity between the feature vector of the sample data and the feature vector of the classification label of the sample data, and taking the similarity as a first similarity of the sample data; acquiring the similarity between the feature vector of the sample data and the feature vector of the prediction tag of the sample data, and taking the similarity as a second similarity of the sample data;
determining a similarity cumulative value of respective second similarities of a plurality of sample data contained in the sample data set, and acquiring a ratio of a first similarity of the sample data to the similarity cumulative value as a similarity error of the sample data;
obtaining a negative logarithm of the similarity error of the sample data, and taking the negative logarithm of the similarity error as the negative logarithm likelihood loss of the sample data;
and accumulating the negative log-likelihood losses of the plurality of sample data to obtain the negative log-likelihood loss function.
8. A training method of a classification model is characterized by comprising the following steps:
obtaining a sample data set, wherein the sample data set comprises: a positive sample data set and a negative sample data set;
inputting the positive sample data set and the negative sample data set into a machine learning model to obtain respective prediction labels of positive sample data in the positive sample data set and respective prediction labels of negative sample data in the negative sample data set;
determining a classification error of the machine learning model according to an error between a positive classification label and a prediction label of positive sample data in the positive sample data set and an error between a negative classification label and a prediction label of negative sample data in the negative sample data set;
and adjusting parameters in the machine learning model according to the classification errors until the classification errors meet convergence conditions to obtain a classification model.
9. An electronic device, comprising: a memory and a processor;
the memory is to store one or more computer instructions;
the processor is to execute the one or more computer instructions to: performing the steps of the method of any one of claims 1 to 8.
10. A computer-readable storage medium storing a computer program, wherein the computer program is capable of performing the steps of the method of any one of claims 1 to 8 when executed.
CN202210523942.2A2022-05-132022-05-13Image classification method, data classification device, model training method, image classification device, model training device and storage mediumPendingCN115205576A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202210523942.2ACN115205576A (en)2022-05-132022-05-13Image classification method, data classification device, model training method, image classification device, model training device and storage medium

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202210523942.2ACN115205576A (en)2022-05-132022-05-13Image classification method, data classification device, model training method, image classification device, model training device and storage medium

Publications (1)

Publication NumberPublication Date
CN115205576Atrue CN115205576A (en)2022-10-18

Family

ID=83574379

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202210523942.2APendingCN115205576A (en)2022-05-132022-05-13Image classification method, data classification device, model training method, image classification device, model training device and storage medium

Country Status (1)

CountryLink
CN (1)CN115205576A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN116129122A (en)*2023-02-242023-05-16北京百度网讯科技有限公司 Image segmentation sample generation method, device and equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN116129122A (en)*2023-02-242023-05-16北京百度网讯科技有限公司 Image segmentation sample generation method, device and equipment

Similar Documents

PublicationPublication DateTitle
CN111966914B (en)Content recommendation method and device based on artificial intelligence and computer equipment
US11487941B2 (en)Techniques for determining categorized text
CN112348117B (en)Scene recognition method, device, computer equipment and storage medium
CN110458107B (en)Method and device for image recognition
CN114861836B (en)Model deployment method based on artificial intelligence platform and related equipment
CN111523621A (en)Image recognition method and device, computer equipment and storage medium
CN113807399A (en)Neural network training method, neural network detection method and neural network detection device
CN113657087B (en)Information matching method and device
CN110348580A (en) Method and device for constructing GBDT model and prediction method and device
CN112364204B (en)Video searching method, device, computer equipment and storage medium
CN112287994A (en)Pseudo label processing method, device, equipment and computer readable storage medium
CN114118259B (en) Target detection method and device
CN113837257A (en)Target detection method and device
CN113723462B (en)Dangerous goods detection method, dangerous goods detection device, computer equipment and storage medium
CN111105786B (en)Multi-sampling-rate voice recognition method, device, system and storage medium
CN115187772A (en) Target detection network training and target detection method, device and equipment
CN113779380B (en)Cross-domain recommendation and content recommendation methods, devices and equipment
CN110598084A (en)Object sorting method, commodity sorting device and electronic equipment
CN110059743B (en)Method, apparatus and storage medium for determining a predicted reliability metric
CN112925939B (en) Image search method, description information generation method, device and storage medium
CN117058498B (en)Training method of segmentation map evaluation model, and segmentation map evaluation method and device
CN116701587A (en)Question and answer method and device based on machine learning
US20240161483A1 (en)In-situ model adaptation for privacy-compliant image processing
CN113516141B (en)Optimization method, equipment and storage medium of depth measurement model
CN115205576A (en)Image classification method, data classification device, model training method, image classification device, model training device and storage medium

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination

[8]ページ先頭

©2009-2025 Movatter.jp