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

CN115205576BActive Publication Date: 2026-08-07ALIBABA (CHINA) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ALIBABA (CHINA) CO LTD
Filing Date
2022-05-13
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

[0004]但是,这种训练方式未考虑负样本中的有效信息,从而不利于进一步提升模型的分类性能

Benefits of technology

[0010] This application also provides a computer-readable storage medium storing a computer program, which, when executed, can implement the steps in the method provided in this application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115205576B_ABST
    Figure CN115205576B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide an image classification method, a data classification method, a model training method, a device and a storage medium. In the data classification method, a classification model used for performing a classification operation on data is trained according to positive classification labels of positive sample data and negative classification labels of negative sample data. Thus, 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 improve the recognition and differentiation ability of the feature distribution of the positive classification labels 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 filter out data matching the negative classification labels to reduce the probability of the data being identified as a category to which the positive classification labels belong based on the principle of exclusion, and can filter out data not matching the negative classification labels to improve the probability of the data being identified as the category to which the positive classification labels belong, thereby greatly improving the classification accuracy of the classification model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of machine learning technology, and in particular to an image classification, data classification, image classification model training method, device and storage medium. Background Technology

[0002] Classification is one of the tasks in the field of machine learning. The goal of classification is to select labels that match the data to be classified from a pre-defined set of labels based on the given data to be classified.

[0003] The classification model learns the feature distribution of data corresponding to different labels through training data. During the training process of the classification model, data augmentation methods can be used to add some negative sample data to the training samples, thereby increasing the coverage of the training data and enhancing the model's generalization ability.

[0004] However, this training method does not consider the effective information in negative samples, which is detrimental to further improving the model's classification performance. Therefore, a new solution is needed. Summary of the Invention

[0005] This application provides an image classification, data classification, model training method, device, and storage medium in several aspects to improve the classification performance of a classification model.

[0006] This application provides an image classification method, comprising: acquiring an image to be classified; using the classification model to determine a predicted label corresponding to the image from a preset label set; the preset label set includes positive classification labels and negative classification labels; determining the category to which the image belongs based on the predicted label; wherein the classification model is trained based on a classification error, and the classification error is determined based on the error between the positive classification label and the predicted label of a positive sample image, and the error between the negative classification label and the predicted label of a negative sample image.

[0007] This application provides a data classification method, including: acquiring data to be classified; using the classification model to determine the predicted label corresponding to the data from a preset label set; the preset label set includes positive classification labels and negative classification labels; determining the category to which the data belongs based on the predicted label; wherein the classification model is trained based on classification error, and the classification error is determined based on the error between the positive classification label and the predicted label of positive sample data, and the error between the negative classification label and the predicted label of negative sample data.

[0008] This application embodiment also provides a method for training a classification model, comprising: acquiring a sample dataset, the sample dataset including a positive sample dataset and a negative sample dataset; inputting the positive sample dataset and the negative sample dataset into a machine learning model to obtain the predicted labels of the positive sample data in the positive sample dataset and the predicted labels of the negative sample data in the negative sample dataset; determining the classification error of the machine learning model based on the error between the positive classification labels and the predicted labels of the positive sample data in the positive sample dataset and the error between the negative classification labels and the predicted labels of the negative sample data in the negative sample dataset; and adjusting the parameters in the machine learning model based on the classification error until the classification error meets the convergence condition to obtain a classification model.

[0009] This application also provides an electronic device, including: a memory and a processor; the memory is used to store one or more computer instructions; the processor is used to execute the one or more computer instructions to perform the steps in the method provided in this application.

[0010] This application also provides a computer-readable storage medium storing a computer program, which, when executed, can implement the steps in the method provided in this application.

[0011] In the data classification method provided in this application, the classification model used to perform classification operations on data is trained based on the positive classification labels of positive sample data and the negative classification labels of negative sample data. Thus, the model can learn the feature distributions of both positive and negative classification labels during the training phase, and improve its ability to identify and distinguish the feature distributions of positive and negative classification labels based on the relationship between them. During the prediction phase, the model can filter out data that matches the negative classification labels to reduce the probability of this data being identified as belonging to the category of the positive classification label based on the principle of elimination, and can also filter out data that does not match the negative classification labels to increase the probability of this data being identified as belonging to the category of the positive classification label, thereby greatly improving the classification accuracy of the classification model. Attached Figure Description

[0012] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 A flowchart illustrating a data classification method provided in an exemplary embodiment of this application; Figure 2 A schematic diagram illustrating the classification model training process provided in an exemplary embodiment of this application; Figure 3 The query representation intent of negative classification labels provided for an exemplary embodiment of this application; Figure 4 A schematic flowchart of an image classification method provided for an exemplary embodiment of this application; Figure 5 A schematic diagram of the structure of an electronic device provided for an exemplary embodiment of this application. Detailed Implementation

[0013] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0014] Classification is a task in the field of machine learning. The goal of classification is to use a classification model to select labels that match the given data from a pre-defined list of labels. The classification model learns the feature distribution of data corresponding to different labels through training data. During the training process, data augmentation techniques can be used to add negative samples to the training data, thereby increasing the coverage of the training data and enhancing the model's generalization ability. However, this training method does not consider the effective information in negative samples, thus hindering further improvement in the model's classification performance.

[0015] To address the aforementioned technical problems, a solution is provided in some embodiments of this application. The technical solutions provided by each embodiment of this application are described in detail below with reference to the accompanying drawings.

[0016] Figure 1 A flowchart illustrating a data classification method provided in an exemplary embodiment of this application is shown below. Figure 1 As shown, the method includes: Step 101: Obtain the data to be classified.

[0017] Step 102: Using a classification model, determine the predicted label corresponding to the data from a preset label set; the preset label set includes positive classification labels and negative classification labels; wherein, the classification model is trained based on the classification error, which is determined based on the error between the positive classification label and the predicted label of the positive sample data, and the error between the negative classification label and the predicted label of the negative sample data.

[0018] Step 103: Determine the category of the data based on the predicted label.

[0019] In this embodiment, the classification model can be applied to various classification scenarios, such as image classification, natural language processing, and behavioral data analysis. The form of the data to be classified differs in different scenarios. For example, in image classification, the data to be classified can be images; in natural language processing, it can be text or audio; and in behavioral data analysis, it can be user behavior data, such as user click data, user webpage browsing time data, etc., to be listed further. When the model is applied to different classification scenarios, the classification model can be trained using sample images corresponding to that scenario. The specific training process will be described in subsequent embodiments.

[0020] The preset label set can include multiple classification labels, including preset positive and negative classification labels. Positive classification labels refer to the preset labels for the categories to be classified, and the sample data corresponding to these labels can be described as positive sample data. For example, when classifying products, positive classification labels can include preset product category labels. For instance, positive classification labels could be product category labels such as mobile phones, tablets, and game consoles. Negative sample labels are not labels for the categories to be classified and can be defined based on negative sample data. Negative sample data is sample data added during the classification model training process to improve the breadth of sample coverage. Labels for the categories to which negative sample data belongs can be defined as negative classification labels. For example, when classifying electronic products, if the negative samples include animal images, the negative classification label can be set as an animal species label.

[0021] In this embodiment, sample data can be used to train the machine learning model to obtain a classification model. The machine learning model may include, but is not limited to, one or more of the following: Convolutional Neural Networks (CNN), Deep Neural Networks (DNN), Graph Convolutional Networks (GCN), Recurrent Neural Networks (RNN), and Long Short-Term Memory (LSTM), or may be derived from variations of one or more of the above neural networks. This embodiment does not impose any limitations.

[0022] In this context, positive samples refer to sample data containing the classification object, while negative samples refer to sample data that does not contain the classification object or has interfering information superimposed on the classification object to make it difficult to identify. For example, in a face recognition scenario, positive samples can be images containing the face region, while negative samples can be images including environmental elements, human limbs, clothing, etc. Adding some negative samples during the training of a machine learning model allows the model to learn to distinguish different features, reducing overfitting and thus improving the model's generalization ability.

[0023] Based on the error between the positive classification label and the predicted label of positive sample data, the machine learning model can learn the feature distribution of 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 predicted label of negative sample data, the machine learning model can learn the feature distribution of negative sample data and learn the ability to distinguish data that conforms to the negative sample feature distribution.

[0024] For machine learning models, once they possess the ability to distinguish data that conforms to the distribution of negative sample features, during the prediction phase, the machine learning model can proactively filter out data that matches the negative classification label, reducing the probability of this data being identified as belonging to the positive label category based on the principle of elimination. Simultaneously, the machine learning model can proactively filter out data that does not match the negative label, increasing the probability of this data being identified as belonging to the positive label category based on the principle of elimination. Based on this approach, the model's classification performance can be enhanced by learning the features of negative samples, greatly improving the classification accuracy of the model.

[0025] In some exemplary embodiments, the classification model can be trained using the following methods: Obtain a sample dataset for training, which includes a positive sample dataset and a negative sample dataset. The positive sample dataset may contain M positive samples, and the negative sample dataset may contain N negative samples, where M and N are positive integers.

[0026] Optionally, the categories to be classified and the corresponding positive classification labels for each category can be predetermined. After the categories to be classified are determined, sample data corresponding to each category can be collected as positive sample data, and positive classification labels corresponding to the category can be added to the collected sample data. These positive classification labels are used as supervision signals in the supervised training process.

[0027] In some optional embodiments, the negative sample dataset can be generated based on the positive sample data. After obtaining the positive sample dataset, the positive sample data of different categories in the positive sample dataset can be fused to obtain the negative sample data in the negative sample dataset. In the negative sample dataset, any negative sample data is obtained by fusing any number of positive sample data of different categories in the positive sample dataset. Here, fusion refers to combining multiple data into one data. In some embodiments, a data fusion function can be used to calculate multiple positive sample data to obtain a negative sample data. Optionally, the function used to perform the fusion operation can be a linear calculation function or a non-linear calculation function, which is not limited in this embodiment.

[0028] Taking any negative sample data as an example, the process of generating negative sample data can be shown in the following formula 1-1: Formula 1-1 in, This represents newly generated negative sample data. For positive sample data, Let be the function used to fuse sample data. When this function is a linear computation function, the process of generating negative sample data can be shown in the following formula 1-2: Formula 1-2 in, .

[0029] like Figure 2 As shown, positive sample data can be... and positive sample data Merging into negative sample data positive sample data and positive sample data Merging into negative sample data Optionally, during the process of fusing positive sample data from the positive sample dataset to obtain the negative sample dataset, the classification labels of multiple positive sample data used to obtain the negative sample data can be obtained, and a negative classification label for the negative sample data can be generated based on the classification labels of these multiple positive sample data. For example... Figure 2 As shown, positive category labels can be... and positive category tags Merge into negative category labels Positive category tags and positive category tags Merge into negative category labels .

[0030] In some optional embodiments, when generating negative classification labels for negative sample data based on the classification labels of multiple positive sample data, the classification labels of the multiple positive sample data can be concatenated to obtain the classification label corresponding to the negative sample. For example, if the classification label of positive sample image P1 is L1 and the classification label of positive sample image P2 is L2, during the process of fusing positive sample images P1 and P2 to obtain negative sample image N1, the classification labels L1 and L2 are concatenated to obtain new classification labels L1-L2, which is the classification label of negative sample image N1.

[0031] In some alternative embodiments, when generating negative classification labels for negative sample data based on the classification labels of multiple positive sample data, the classification labels of the multiple positive sample data can be calculated to obtain the classification label corresponding to the negative sample. This calculation method can be linear or non-linear; this embodiment does not impose any limitations.

[0032] Taking any negative sample data as an example, the process of generating negative classification labels for negative sample data can be shown in the following formula 2: Formula 2 in, Representing negative sample data Category tags, Positive sample data Category tags, Positive sample data Category tags, This is a function for generating category labels.

[0033] In some alternative embodiments, alternative classification labels for negative sample data can be pre-generated, and these alternative classification labels can be stored in a two-dimensional table. In the two-dimensional table, the fields corresponding to rows and columns can represent positive and negative classification labels, respectively, and the value of the field is the new classification label corresponding to that field.

[0034] When generating negative classification labels for negative sample data based on the classification labels of multiple positive sample data, the negative classification labels for the negative sample data can be obtained by querying a two-dimensional table based on the identifiers of the classification labels of the multiple positive sample data. In this implementation, in Formula 2... It can be a mapping function. For example... Figure 3 As shown, determine The new category label can be determined by querying the two-dimensional table. .For example, = a1, When =b2, query the two-dimensional table to determine the new category label. = ab12.

[0035] After determining the positive classification labels of positive sample data and the negative classification labels of negative sample data based on the above implementation methods, the positive classification labels are used as the supervision signal GT (ground truth) to train the machine learning model.

[0036] like Figure 2 As shown, both positive and negative sample datasets can be input into a machine learning model. Within the machine learning model, an encoder network (Encoder Network) can be used to... Figure 2 In a simplified illustration, E) extracts the feature vector of each sample data and uses a classifier. Figure 2 In a simplified illustration, C) the sample data is classified according to the feature vector to obtain the predicted label for each sample data.

[0037] The predicted label is calculated by the machine learning model based on its current parameters. When the machine learning model has learned the feature distributions of both positive and negative samples well, the predicted label output by the model for any given sample will have a high similarity to the classification label of that sample. Conversely, the classification ability of the machine learning model can be improved by optimizing its parameters.

[0038] After obtaining the predicted labels for each positive sample in the positive sample dataset and the predicted labels for each negative sample in the negative sample dataset, the classification error of the machine learning model can be determined based on the error between the positive and predicted labels for the positive sample data, and the error between the negative and predicted labels for the negative sample data. This classification error serves as the training loss for the machine learning model in this round and is used for iterative optimization. During the iterative optimization process, the parameters in the machine learning model can be adjusted based on this classification error until the classification error meets the convergence condition, thus obtaining the classification model.

[0039] Optionally, the classification error of the machine learning model can be calculated using a loss function, which may include, but is not limited to, at least one of the following: cross-entropy loss, binomial loss, Kullback-Leibler Divergence Loss, contrastive loss, and negative maximum likeness loss.

[0040] In some optional embodiments, a negative log-likelihood loss function can be constructed based on the error between the positive classification label and the predicted label of positive sample data, and the error between the negative classification label and the predicted label of negative sample data, as the classification error of the machine learning model. This negative log-likelihood loss function can better characterize the probability distribution, and in the classification training process of multi-class tasks, it helps the machine learning model to find the parameter values ​​most likely to cause such a distribution using the known sample feature distribution.

[0041] Optionally, in this embodiment, when constructing the negative log-likelihood loss function, for any sample data in the positive and negative sample datasets, the similarity between the feature vector of the sample data and the feature vector of the classification label of the sample data can be obtained as the first similarity of the sample data; and the similarity between the feature vector of the sample data and the feature vector of the predicted label of the sample data can be obtained as the second similarity of the sample data. The use of "first" and "second" to describe similarity is only for the convenience of partitioning the same descriptive objects and does not impose other limitations.

[0042] For ease of description, the sample dataset consisting of the positive sample dataset and the negative sample dataset is labeled as sample dataset L. Let the first sample dataset L contain the first sample sample dataset L. i Taking a sample of data as an example, the formula for calculating the first similarity can be shown in Formula 3-1 below: Formula 3-1 in, Indicates the first The first similarity of the sample data Indicates the first The feature vector of the classification label of each sample data. For the first The transpose matrix of the feature vectors of the classification labels of each sample data set. The positive sample dataset contains... The negative sample dataset contains 1 classification label. Category tags, .

[0043] No. The formula for calculating the second similarity of individual sample data is shown in Formula 3-2 below: Formula 3-2 in, Indicates the first The second similarity of the sample data Indicates the first The feature vector of the predicted label for each sample data. For the firsti The transpose of the feature vectors of the predicted labels for each sample data.

[0044] Continuing with the example of any given sample data, after calculating the second similarity of each sample data based on the above implementation method, the cumulative similarity value of the second similarity of each of the multiple sample data in the sample dataset is determined, and the ratio of the first similarity of the sample data to the cumulative similarity value of the sample dataset is obtained as the similarity error of the sample data. The negative logarithm of the similarity error of the sample data is obtained, which can be used as the negative log-likelihood loss of the sample data. By summing the negative log-likelihood losses of each of the multiple sample data in the sample dataset, the negative log-likelihood loss function of the machine learning model can be obtained.

[0045] The first and second similarities can be calculated using formulas 3-1 and 3-2, respectively. Alternatively, functions can be used to further calculate the results of formulas 3-1 and 3-2 to capture subtle errors. For example, an exponential function can be used to optimize the first and second similarities to improve the machine learning model's sensitivity to errors. For instance, the first similarity can be: The second similarity can be: .

[0046] The negative logarithmic loss function constructed in the above implementation method can be described with reference to the following formula 4: Formula 4 Based on the loss function mentioned above, the machine learning model can learn the feature distribution of positive samples and the feature distribution of negative samples during iterative training, thereby learning the ability to distinguish between positive and negative samples and thus improving classification performance.

[0047] The data classification method provided in this application can be applied to various classification scenarios, such as image classification, natural language processing, and behavioral data analysis. Different classification labels can be defined in different scenarios. For example, in behavioral data analysis, sentiment classification labels can be defined to determine user preferences for products. In natural language processing, language classification labels can be defined to identify the language corresponding to the speech. For example, in image classification, different product classification labels can be defined to identify products of different categories.

[0048] The following will provide an example illustration using a typical image classification scenario.

[0049] Figure 4 A flowchart illustrating an exemplary embodiment of the image classification method provided in this application is shown below. Figure 4 As shown, this image classification method includes: Step 401: Obtain the image to be classified.

[0050] Step 402: Using a classification model, determine the predicted label corresponding to the image from a preset label set; the preset label set includes positive classification labels and negative classification labels; wherein, the classification model is trained based on the classification error, which is determined based on the error between the positive classification label and the predicted label of the positive sample image, and the error between the negative classification label and the predicted label of the negative sample image.

[0051] Step 403: Determine the category to which the image belongs based on the predicted label.

[0052] The image can be a product image, a face image, a road image, an animal image, etc. Taking a product image as an example, in some scenarios, when providing product search services to users, an image of the product to be identified can be obtained from the user and input into a classification model. The classification model can calculate the product category corresponding to the product image based on pre-learned parameters and output a predicted product category label. Based on this product category label, products matching the product image can be identified, and accurate product search results can be returned to the user.

[0053] When training a classification model, a set of sample images can be obtained, which includes a set of positive sample images and a set of negative sample images. Optionally, the set of negative sample images is generated from the set of positive sample images. Positive sample images of different categories in the set of positive sample images can be fused to obtain negative sample images in the set of negative sample images; any negative sample image in the set of negative sample images is obtained by fusing any number of positive sample images in the set of positive sample images.

[0054] For example, in a product classification scenario, images of multiple product categories can be acquired as positive sample images. Fusing these multiple product images yields negative sample images for the product classification scenario. In a face recognition scenario, facial images of different users can be acquired as positive sample images. Fusing these facial images of multiple users yields negative sample images for the face recognition scenario. In an animal recognition scenario, images of different animals can be acquired as positive sample images. Fusing these animal images yields negative sample images for the animal classification scenario. Optional implementation methods for fusing multiple images can be found in the foregoing embodiments and will not be repeated here.

[0055] Optionally, in the process of fusing positive sample images of different categories in the positive sample image set to obtain a negative sample image set, the classification labels of each of the multiple positive sample images used to fuse the negative sample image can be obtained, and the negative classification label of the negative sample image can be generated based on the classification labels of the multiple positive sample images.

[0056] For example, in an animal classification scenario, the labels for multiple animal categories could be: "cat," "dog," and "fox." When generating a negative sample image, an animal image labeled "cat" can be merged with an animal image labeled "dog" to obtain a single negative sample image. The label for this negative sample image can be generated based on the labels "cat" and "dog."

[0057] Next, the positive and negative image sets are input into the machine learning model to obtain the predicted labels for each positive image in the positive image set and each negative image in the negative image set. Based on the errors between the positive and predicted labels of the positive images in the positive image set and the errors between the negative and predicted labels of the negative images in the negative image set, the classification error of the machine learning model is determined. Based on this classification error, the parameters in the machine learning model are adjusted until the classification error meets the convergence condition, thus obtaining the classification model.

[0058] Optionally, the classification error can be constructed based on the negative log-likelihood loss function. In constructing the negative log-likelihood loss function, for any sample image in the sample image set, the similarity between the feature vector of the sample image and the feature vector of the classification label of the sample image is obtained as the first similarity of the sample image; and the similarity between the feature vector of the sample image and the feature vector of the predicted label of the sample image is obtained as the second similarity of the sample image. The cumulative similarity value of the second similarity of each of the multiple sample images included in the sample image set is determined, and the ratio of the first similarity of the sample image to the cumulative similarity value is obtained as the similarity error of the sample image. The negative logarithm of the similarity error of the sample image is obtained as the negative log-likelihood loss of the sample image, and the negative log-likelihood losses of each of the multiple sample images are accumulated to obtain the negative log-likelihood loss function. For details, please refer to the description in the foregoing embodiments, which will not be repeated here.

[0059] In the image classification method provided in this embodiment, the classification model used to perform image classification operations is trained based on the positive classification labels of positive sample images and the negative classification labels of negative sample images. Thus, the model can learn the feature distributions of both positive and negative classification labels during the training phase, and improve its ability to identify and distinguish the feature distributions of positive classification labels based on the relationship between them. During the prediction phase, the model can filter out images that match the negative classification labels to reduce the probability of these images being identified as belonging to the positive classification label category based on the principle of elimination, and can also filter out images that do not match the negative classification labels to increase the probability of these images being identified as belonging to the positive classification label category, thereby greatly improving the classification accuracy of the classification model.

[0060] In some scenarios, the data classification methods, image classification methods, or classification model training methods provided in the foregoing embodiments can be encapsulated into software tools that can be used by third parties, such as SaaS (Software-as-a-Service) tools. These SaaS tools can be implemented as plugins or applications. These plugins or applications can be deployed on a server and can expose specified interfaces to third-party users such as clients. For ease of description, in this embodiment, the specified interface is described as a first interface. Furthermore, third-party users such as clients can conveniently access and use the methods provided by the server-side device by calling this first interface. The server can be a conventional server or a cloud server; this embodiment does not impose any limitations.

[0061] Taking a SaaS tool corresponding to a data classification method as an example, the server can respond to the client's call request to the first interface and obtain the data to be classified contained in the interface parameters. The server can then input this data into the trained classification model, obtain the predicted label corresponding to the data, and return the predicted label to the client.

[0062] Taking a SaaS tool corresponding to an image classification method as an example, the server can respond to the client's call request to the first interface and obtain the image to be classified, which is included in the interface parameters. The server can then input the image into the trained classification model to obtain the predicted label corresponding to the image and return the predicted label to the client.

[0063] Taking a SaaS tool corresponding to a classification model training method as an example, the server can respond to the client's call request to the first interface, obtaining the positive sample data and the classification labels of the positive sample count contained in the interface parameters. Based on the positive sample data and the classification labels of the positive sample count, the server can generate negative sample data and their corresponding classification labels. After inputting the positive and negative sample data into the machine learning model, the predicted labels for each positive and negative sample data can be obtained. Based on the predicted labels of the positive and negative sample data, a loss function can be constructed, and the machine learning model can be iteratively trained using this loss function. When the loss function converges, the server can return the trained model to the client.

[0064] In this implementation, the server can provide data classification services, image classification services, or classification model training services to the client based on the SaaS tools running on it, thereby reducing the computational pressure and cost on the client.

[0065] It should be noted that the execution subject of each step of the method provided in the above embodiments can be the same device, or the method can be executed by different devices. For example, the execution subject of steps 101 to 103 can be device A; or the execution subject of steps 101 and 102 can be device A, and the execution subject of step 103 can be device B; and so on.

[0066] Furthermore, some processes described in the above embodiments and accompanying drawings include multiple operations appearing in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or they may be executed in parallel. The operation numbers, such as 101, 102, etc., are merely used to distinguish different operations and do not represent any execution order. Additionally, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first" and "second" in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.

[0067] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an exemplary embodiment of this application, as shown below. Figure 5 As shown, the electronic device includes a memory 501 and a processor 502.

[0068] Memory 501 is used to store computer programs and can be configured to store various other data to support operation on the electronic device. Examples of this data include instructions, messages, pictures, videos, etc., for any application or method used to operate on the electronic device.

[0069] The memory 501 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, 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 storage, flash memory, magnetic disk or optical disk.

[0070] In some embodiments, Figure 5The server shown can be used to execute a data classification method. A processor 502, coupled to a memory 501, is used to execute a computer program in the memory 501 for: acquiring data to be classified; using a classification model to determine a predicted label corresponding to the data from a preset label set; the preset label set includes positive and negative classification labels; and determining the category to which the data belongs based on the predicted label; wherein the classification model is trained based on a classification error, which is determined based on the error between the positive classification label and the predicted label of positive sample data, and the error between the negative classification label and the predicted label of negative sample data.

[0071] Optionally, the processor 502 is further configured to: acquire a sample dataset, which includes a positive sample dataset and a negative sample dataset; input the positive sample dataset and the negative sample dataset into a machine learning model to obtain the predicted labels for each positive sample data in the positive sample dataset and the predicted labels for each negative sample data in the negative sample dataset; determine the classification error of the machine learning model based on the error between the positive classification labels and the predicted labels for the positive sample data in the positive sample dataset and the error between the negative classification labels and the predicted labels for the negative sample data in the negative sample dataset; and adjust the parameters in the machine learning model based on the classification error until the classification error meets the convergence condition to obtain the classification model.

[0072] Optionally, when the processor 502 acquires the positive sample dataset and the negative sample dataset, it is specifically used to: acquire the positive sample dataset; fuse the positive sample data of different categories in the positive sample dataset to obtain the negative sample data in the negative sample dataset; and in the negative sample dataset, any negative sample data is obtained by fusing any number of positive sample data of different categories in the positive sample dataset.

[0073] Optionally, the processor 502 is further configured to: in the process of fusing positive sample data of different categories in the positive sample dataset to obtain a negative sample dataset, obtain the classification labels of each of the multiple positive sample data used to obtain the negative sample data; and generate a negative classification label for the negative sample data based on the classification labels of the multiple positive sample data.

[0074] Optionally, when determining the classification error of the machine learning model based on the error between the positive classification label and the predicted label of the positive sample data in the positive sample dataset, and the error between the negative classification label and the predicted label of the negative sample data in the negative sample dataset, the processor 502 specifically constructs a negative log-likelihood loss function as the classification error based on the error between the positive classification label and the predicted label of the positive sample data in the positive sample dataset, and the error between the negative classification label and the predicted label of the negative sample data in the negative sample dataset.

[0075] Optionally, when the processor 502 constructs a negative log-likelihood loss function as the classification error based on the error between the positive classification label and the predicted label of the positive sample data in the positive sample dataset, and the error between the negative classification label and the predicted label of the negative sample data in the negative sample dataset, the specific steps are as follows: for any sample data in the sample dataset, obtain the similarity between the feature vector of the sample data and the feature vector of the classification label of the sample data, as the first similarity of the sample data; and obtain the similarity between the feature vector of the sample data and the feature vector of the predicted label of the sample data, as the second similarity of the sample data; determine the cumulative similarity value of the second similarity of each of the multiple sample data contained in the sample dataset, and obtain the ratio of the first similarity of the sample data to the cumulative similarity value, as the similarity error of the sample data; obtain the negative logarithm of the similarity error of the sample data, as the negative log-likelihood loss of the sample data; and sum the negative log-likelihood losses of each of the multiple sample data to obtain the negative log-likelihood loss function.

[0076] Furthermore, such as Figure 5 As shown, the electronic device also includes other components such as a communication component 503, a display component 504, a power supply component 505, and an audio component 506. Figure 5 The diagram only shows some components and does not mean that the electronic device includes only these components. Figure 5 The components shown.

[0077] The communication component 503 is configured to facilitate wired or wireless communication between the device containing the communication component and other devices. The device containing the communication component can access wireless networks based on communication standards, such as WiFi, 2G, 3G, 4G, or 5G, or combinations thereof. In one exemplary embodiment, the communication component receives broadcast signals 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), Radio Frequency Identification (RFID), Infrared Data Association (IrDA), Ultra Wideband (UWB), Bluetooth (BT), and other technologies.

[0078] The display component 504 includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touchscreen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation.

[0079] The power supply component 505 provides power to various components of the device in which it resides. The power supply component may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which it resides.

[0080] In this embodiment, the classification model used to perform classification operations on the data is trained based on the positive classification labels of positive sample data and the negative classification labels of negative sample data. Thus, during the training phase, the model learns the feature distributions of both positive and negative classification labels, and based on the relationship between these distributions, improves its ability to identify and distinguish the feature distributions of positive classification labels. During the prediction phase, the model can filter out data that matches the negative classification labels, reducing the probability of this data being identified as belonging to the positive classification category based on the principle of elimination, and can also filter out data that does not match the negative classification labels, increasing the probability of this data being identified as belonging to the positive classification category. This significantly improves the classification accuracy of the model.

[0081] Figure 5 The electronic device shown can also perform the following method for training a classification model: the processor 502 acquires a sample dataset, which includes a positive sample dataset and a negative sample dataset; the positive sample dataset and the negative sample dataset are input into a machine learning model to obtain the predicted labels for the positive sample data in the positive sample dataset and the predicted labels for the negative sample data in the negative sample dataset; the classification error of the machine learning model is determined based on the error between the positive classification labels and the predicted labels for the positive sample data in the positive sample dataset, and the error between the negative classification labels and the predicted labels for the negative sample data in the negative sample dataset; the parameters in the machine learning model are adjusted based on the classification error until the classification error meets the convergence condition, thus obtaining a classification model.

[0082] Figure 5 The electronic device shown can also perform the following image classification method: processor 502 acquires an image to be classified; using a classification model, determines the predicted label corresponding to the image from a preset label set; the preset label set includes positive classification labels and negative classification labels; based on the predicted label, the category to which the image belongs is determined; wherein, the classification model is trained based on a classification error, which is determined based on the error between the positive classification label and the predicted label of a positive sample image, and the error between the negative classification label and the predicted label of a negative sample image.

[0083] Accordingly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed, can implement the steps that can be performed by an electronic device in the above method embodiments.

[0084] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can 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, etc.) containing computer-usable program code.

[0085] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable deep metric learning-based model optimization device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable deep metric learning-based model optimization device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0086] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable deep metric learning-based model optimization device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in the process. Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0087] These computer program instructions can also be loaded onto a computer or other programmable deep metric learning-based model optimization device, causing a series of operational steps to be executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable device for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0088] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0089] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0090] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, 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 technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0091] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0092] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. An image classification method, characterized in that, include: Obtain the image to be classified; Using a classification model, the predicted label corresponding to the image is determined from a preset label set; The preset label set includes multiple positive classification labels and multiple negative classification labels, wherein each positive classification label and each negative classification label serve as the direct prediction target of the classification model. Based on the predicted label, determine the category to which the image belongs; The classification model is trained based on the classification error, which is determined based on the error between the positive classification label and the predicted label of the positive sample image in the positive sample image set, and the error between the negative classification label and the predicted label of the negative sample image in the negative sample image set. Any negative sample image is obtained by fusing multiple positive sample images of different categories in the positive sample image set.

2. A data classification method, characterized in that, include: Obtain the data to be classified, which may be text or audio; Using a classification model, the predicted label corresponding to the data is determined from a preset label set; The preset label set includes multiple positive classification labels and multiple negative classification labels, wherein each positive classification label and each negative classification label serve as the direct prediction target of the classification model. Based on the predicted labels, determine the category to which the data belongs; The classification model is trained based on the classification error, which is determined based on the error between the positive classification label and the predicted label of the positive sample data in the positive sample dataset, and the error between the negative classification label and the predicted label of the negative sample data in the negative sample dataset. Any negative sample data is obtained by fusing multiple positive sample data of different categories in the positive sample dataset.

3. The method according to claim 2, characterized in that, Also includes: Obtain a sample dataset, which includes a positive sample dataset and a negative sample dataset; The positive sample dataset and the negative sample dataset are input into the machine learning model to obtain the predicted labels of the positive sample data in the positive sample dataset and the predicted labels of the negative sample data in the negative sample dataset. The classification error of the machine learning model is determined based on the error between the positive classification label and the predicted label of the positive sample data in the positive sample dataset, and the error between the negative classification label and the predicted label of the negative sample data in the negative sample dataset. Based on the classification error, the parameters in the machine learning model are adjusted until the classification error meets the convergence condition, thus obtaining the classification model.

4. The method according to claim 3, characterized in that, Obtain the positive sample dataset and the negative sample dataset, including: Obtain the positive sample dataset; The positive sample data of different categories in the positive sample dataset are fused to obtain the negative sample data in the negative sample dataset.

5. The method according to claim 4, characterized in that, Also includes: In the process of fusing positive sample data of different categories in the positive sample dataset to obtain a negative sample dataset, the classification labels of each of the multiple positive sample data used to fuse the negative sample data are obtained. Based on the classification labels of the multiple positive sample data, negative classification labels are generated for the negative sample data.

6. The method according to claim 3, characterized in that, The classification error of the machine learning model is determined based on the error between the positive classification label and the predicted label of the positive sample data in the positive sample dataset, and the error between the negative classification label and the predicted label of the negative sample data in the negative sample dataset, including: Based on the error between the positive classification label and the predicted label of the positive sample data in the positive sample dataset, and the error between the negative classification label and the predicted label of the negative sample data in the negative sample dataset, a negative log-likelihood loss function is constructed as the classification error.

7. The method according to claim 6, characterized in that, Based on the error between the positive classification label and the predicted label of the positive sample data in the positive sample dataset, and the error between the negative classification label and the predicted label of the negative sample data in the negative sample dataset, a negative log-likelihood loss function is constructed as the classification error, including: For any sample data in the sample dataset, the similarity between the feature vector of the sample data and the feature vector of the classification label of the sample data is obtained as the first similarity of the sample data; and the similarity between the feature vector of the sample data and the feature vector of the predicted label of the sample data is obtained as the second similarity of the sample data. The cumulative similarity value of the second similarity of each of the multiple sample data contained in the sample dataset is determined, and the ratio of the first similarity of the sample data to the cumulative similarity value is obtained as the similarity error of the sample data. Obtain the negative logarithm of the similarity error of the sample data, and use it as the negative log-likelihood loss of the sample data; The negative log-likelihood loss of each of the multiple sample data is accumulated to obtain the negative log-likelihood loss function.

8. A training method for an image classification model, characterized in that, include: Obtain a sample dataset, which includes a positive sample dataset and a negative sample dataset. Any negative sample data in the negative sample dataset is obtained by fusing multiple positive sample data of different categories in the positive sample dataset. The positive sample dataset is a set of positive sample images including positive sample images, and the negative sample dataset is a set of negative sample images including negative sample images. The positive sample dataset and the negative sample dataset are input into the machine learning model so that the machine learning model determines the predicted labels for each positive sample data in the positive sample dataset and the predicted labels for each negative sample data in the negative sample dataset from a preset label set; the preset label set contains multiple positive classification labels and multiple negative classification labels, wherein each positive classification label and each negative classification label serves as the direct prediction target of the machine learning model. The classification error of the machine learning model is determined based on the error between the positive classification label and the predicted label of the positive sample data in the positive sample dataset, and the error between the negative classification label and the predicted label of the negative sample data in the negative sample dataset. Based on the classification error, the parameters in the machine learning model are adjusted until the classification error meets the convergence condition, thus obtaining the classification model.

9. An electronic device, characterized in that, include: Memory and processor; The memory is used to store one or more computer instructions; The processor is configured to execute one or more computer instructions for performing the steps of the method according to any one of claims 1-8.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed, it can perform the steps of the method described in any one of claims 1-8.

Citation Information

Patent Citations

  • Model training method and device, equipment and storage medium

    CN114091594A