Machine learning model training method, device and image classification method and device

By transforming and feature extraction of positive sample data of classified images, calculating loss functions, and training machine learning models, the problem of low image classification accuracy in the prior art is solved, and higher image classification accuracy is achieved.

CN112257738BActive Publication Date: 2025-01-17BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010757205.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-31
Publication Date
2025-01-17
Estimated Expiration
2040-07-31

AI Technical Summary

Technical Problem

In the prior art, machine learning model training can only analyze the relationship between the target and a single positive sample, and cannot fully explore the inherent characteristics of image classification, resulting in low image classification accuracy.

Method used

By transforming the first positive sample data of the to-classified image, a plurality of second positive sample data are generated, and the feature vector is extracted using the machine learning model, the function value of the loss function is calculated, and the model is trained to improve the accuracy of image classification.

Benefits of technology

By leveraging the similarity between multiple positive sample data, the intrinsic features of the image are fully mined, and the training effect of the machine learning model and the accuracy of image classification are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112257738B_ABST
    Figure CN112257738B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a training method and device for a machine learning model and an image classification method and device, and relates to the field of artificial intelligence technology. The training method includes: transforming the first positive sample data of the image to be classified to generate multiple second positive sample data, the first positive sample data and the multiple second positive sample data together constitute the positive sample data of the image to be classified; using the machine learning model, extracting the feature vector of the image to be classified as the target feature vector, and extracting the feature vector of each sample data as each sample feature vector, each sample data includes positive sample data and negative sample data; calculating the function value of the loss function according to the similarity between the target feature vector and each sample feature vector; using the function value, training the machine learning model for classifying the image to be classified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a training method for a machine learning model, a training device for a machine learning model, an image classification method, an image classification device, an electronic device, and a non-volatile computer-readable storage medium. Background Art

[0002] In recent years, machine learning methods such as supervised learning and unsupervised learning have been widely used in many artificial intelligence scenarios. For example, image object detection and image classification can be achieved through machine learning methods.

[0003] In the related art, the similarity between the target and the positive sample of each classification is calculated independently to determine the loss function; and the machine learning model is trained using the loss function. Summary of the invention

[0004] The inventors of the present disclosure discovered that the above-mentioned related technologies have the following problems: each training can only analyze the relationship between the target and a single positive sample, and cannot fully explore the intrinsic characteristics of each classification, resulting in poor training effect of the machine learning model, thereby leading to low image classification accuracy.

[0005] In view of this, the present disclosure proposes a technical solution for training a machine learning model, which can improve the training effect of the machine learning model and thus improve the accuracy of image classification.

[0006] According to some embodiments of the present disclosure, a method for training a machine learning model is provided, comprising: transforming first positive sample data of an image to be classified to generate multiple second positive sample data, wherein the first positive sample data and the multiple second positive sample data together constitute the positive sample data of the image to be classified; using the machine learning model, extracting a feature vector of the image to be classified as a target feature vector, and extracting a feature vector of each sample data as each sample feature vector, wherein each sample data includes the positive sample data and negative sample data; calculating a function value of a loss function according to a degree of similarity between the target feature vector and each sample feature vector; and using the function value to train the machine learning model for classifying the image to be classified.

[0007] In some embodiments, calculating the function value of the loss function according to the similarity between the target feature vector and each sample feature vector includes: calculating the similarity between the target feature vector and each sample feature vector according to the statistical characteristics of the feature vector of each positive sample data.

[0008] In some embodiments, calculating the function value of the loss function based on the degree of similarity between the target feature vector and each sample feature vector includes: when the number of positive sample data tends to positive infinity, using the statistical characteristics of the feature vector of each positive sample data, determining the limit of the loss function for calculating the function value.

[0009] In some embodiments, the use of statistical characteristics of the feature vectors of each positive sample data to determine the limit of the loss function includes: determining a first similarity based on the degree of similarity between the target feature vector and the mean of the feature vectors of each positive sample data; determining a second similarity based on the degree of similarity between the target feature vector and the variance of the feature vectors of each positive sample data; determining a third similarity based on the sum of the similarities between the target feature vector and the feature vectors of each negative sample data; determining the limit of the loss function based on the first similarity, the second similarity, and the third similarity, the limit of the loss function being negatively correlated with the first similarity, and positively correlated with the sum of the second similarity and the third similarity.

[0010] In some embodiments, the use of a machine learning model to extract the feature vector of the image to be classified as a target feature vector, and extracting the feature vector of each sample data as each sample feature vector includes: using a first machine learning model to extract the target feature vector, and using a second machine learning model to extract each sample feature vector; the use of the function value to train the machine learning model includes: using the function value to adjust the parameters of the first machine learning model; and adjusting the parameters of the second machine learning model according to the parameters of the first machine learning model.

[0011] In some embodiments, calculating the function value of the loss function based on the similarity between the target feature vector and the feature vectors of each sample includes: determining a sub-loss function corresponding to the positive sample data based on the similarity between the target feature vector and the feature vector of any positive sample data, the sub-loss function being negatively correlated with the similarity between the target feature vector and the feature vector of the positive sample data, and positively correlated with the sum of the similarities between the target feature vector and the feature vectors of all negative sample data; determining the loss function based on the weighted sum of the sub-loss functions.

[0012] In some embodiments, the transformation process includes at least one of a rotation process, a noise adding process, a flipping process, a scaling process, a cropping process, and a translation process.

[0013] In some embodiments, using the function value to train the machine learning model includes: training the machine learning model based on a weighted average of the function values ​​of each image to be classified in a batch of training data.

[0014] According to other embodiments of the present disclosure, a method for classifying an image is provided, comprising: acquiring an image to be classified; and classifying the image to be classified using a machine learning model, wherein the machine learning model is trained according to the training method in any of the above embodiments.

[0015] According to some other embodiments of the present disclosure, a training device for a machine learning model is provided, including: a generation unit, used to transform first positive sample data of an image to be classified to generate multiple second positive sample data, wherein the first positive sample data and the multiple second positive sample data together constitute the positive sample data of the image to be classified; an extraction unit, used to extract, by using a machine learning model, a feature vector of the image to be classified as a target feature vector, and to extract a feature vector of each sample data as each sample feature vector, wherein each sample data includes the positive sample data and negative sample data; a calculation unit, used to calculate a function value of a loss function according to a degree of similarity between the target feature vector and each sample feature vector; and a training unit, used to train the machine learning model by using the function value, so as to classify the image to be classified.

[0016] In some embodiments, the calculation unit calculates the similarity between the target feature vector and each sample feature vector according to the statistical characteristics of the feature vector of each positive sample data.

[0017] In some embodiments, when the number of the positive sample data approaches positive infinity, the calculation unit uses statistical characteristics of the feature vector of each positive sample data to determine the limit of the loss function for calculating the function value.

[0018] In some embodiments, the calculation unit determines a first similarity based on the similarity between the target feature vector and the mean of the feature vectors of the positive sample data; determines a second similarity based on the similarity between the target feature vector and the variance of the feature vectors of the positive sample data; determines a third similarity based on the sum of the similarities between the target feature vector and the feature vectors of the negative sample data; determines a limit of the loss function based on the first similarity, the second similarity, and the third similarity, the limit of the loss function being negatively correlated with the first similarity and positively correlated with the sum of the second similarity and the third similarity.

[0019] In some embodiments, the extraction unit uses a first machine learning model to extract the target feature vector, and uses a second machine learning model to extract each sample feature vector; the training unit uses the function value to adjust the parameters of the first machine learning model; and adjusts the parameters of the second machine learning model according to the parameters of the first machine learning model.

[0020] In some embodiments, the computing unit determines a sub-loss function corresponding to the positive sample data based on the degree of similarity between the target feature vector and the feature vector of any positive sample data, wherein the sub-loss function is negatively correlated with the degree of similarity between the target feature vector and the feature vector of the positive sample data, and is positively correlated with the sum of the similarities between the target feature vector and the feature vectors of all negative sample data; the loss function is determined based on the weighted sum of the sub-loss functions.

[0021] In some embodiments, the transformation process includes at least one of a rotation process, a noise adding process, a flipping process, a scaling process, a cropping process, and a translation process.

[0022] In some embodiments, the training unit trains the machine learning model based on a weighted average of the function values ​​of each image to be classified in a batch of training data.

[0023] According to some other embodiments of the present disclosure, there is provided an image classification device, comprising: an acquisition unit, for acquiring an image to be classified; and a classification unit, for classifying the image to be classified using a machine learning model, wherein the machine learning model is trained according to the training method in any of the above embodiments.

[0024] According to some further embodiments of the present disclosure, there is provided an electronic device, comprising: a memory; and a processor coupled to the memory, wherein the processor is configured to execute the training method of the machine learning model or the image classification method in any one of the above-mentioned embodiments based on instructions stored in the memory device.

[0025] According to some further embodiments of the present disclosure, a non-volatile computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the training method of the machine learning model or the image classification method in any of the above-mentioned embodiments is implemented.

[0026] In the above embodiment, multiple positive sample data are generated based on one positive sample data, and training is performed according to the similarity between the multiple positive sample data and the image to be classified. In this way, the characteristics of shared similarity between the positive sample data can be utilized to fully explore the inherent characteristics of each classification, so as to improve the training effect of the machine learning model, thereby improving the accuracy of image classification. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] The accompanying drawings, which constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0028] The present disclosure may be more clearly understood from the following detailed description with reference to the accompanying drawings, in which:

[0029] Figure 1 A flowchart illustrating some embodiments of the training method of the machine learning model of the present disclosure;

[0030] Figure 2 Schematic diagrams showing some embodiments of the training method of the machine learning model disclosed in the present invention;

[0031] Figure 3 Schematic diagrams showing other embodiments of the training method of the machine learning model disclosed herein;

[0032] Figure 4 A block diagram illustrating some embodiments of the training of a machine learning model of the present disclosure;

[0033] Figure 5 A block diagram showing some embodiments of the electronic device of the present disclosure;

[0034] Figure 6 A block diagram showing some other embodiments of the electronic device of the present disclosure. DETAILED DESCRIPTION

[0035] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values ​​set forth in these embodiments do not limit the scope of the present disclosure unless otherwise specifically stated.

[0036] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.

[0037] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.

[0038] Technologies, methods, and apparatus known to ordinary technicians in the relevant field may not be discussed in detail, but where appropriate, such technologies, methods, and apparatus should be considered part of the authorization specification.

[0039] In all examples shown and discussed herein, any specific values ​​should be interpreted as merely exemplary and not as limiting. Therefore, other examples of the exemplary embodiments may have different values.

[0040] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.

[0041] In view of the above technical problems, in each training process, the present invention simultaneously analyzes the similarity between the image to be classified and multiple positive sample data of the image classification to which it belongs. In this way, the correlation between multiple positive sample data of the same image classification can be used to impose stricter constraints on the training process to improve the training effect. Thus, the accuracy of image classification by the machine learning model can be improved.

[0042] For example, the technical solution of the present disclosure can be implemented through the following embodiments.

[0043] Figure 1 A flowchart illustrating some embodiments of the training method of the machine learning model of the present disclosure.

[0044] like Figure 1 As shown, the method includes: step 110, generating a plurality of second positive sample data; step 120, extracting feature vectors; step 130, calculating the function value of the loss function; and step 140, training the machine learning model.

[0045] In step 110, the first positive sample data of the image to be classified is transformed to generate a plurality of second positive sample data. The first positive sample data and the plurality of second positive sample data together constitute the positive sample data of the image to be classified.

[0046] In some embodiments, the transformation process may be various data augmentation processes. For example, the transformation output may include at least one of rotation, Gaussian noise, flip, scale, crop, and translation.

[0047] For example, the training data set X i Contains the image to be classified And one positive sample data and multiple negative sample data of the image type to which it belongs. The positive sample data can be expanded into multiple positive sample data in the input space (ambient space) m is an integer greater than or equal to 1 and less than or equal to the integer M. The input space may be a value range of pixel values ​​in the image to be classified.

[0048] For example, you can i In Perform M+1 data enhancement processing, take M of the processing results as positive sample data, and take the remaining 1 processing result as the image to be classified.

[0049] In step 120, a machine learning model is used to extract a feature vector of the image to be classified as a target feature vector, and a feature vector of each sample data is extracted as each sample feature vector. Each sample data includes positive sample data and negative sample data.

[0050] In some embodiments, a first machine learning model is used to extract a target feature vector, and a second machine learning model is used to extract each sample feature vector.

[0051] For example, the first machine learning model is a query encoder f(·), and the second machine learning model is a key-value encoder g(·). f(·) is used to extract X i In The target feature vector q i ; g(·) is used to extract X i Each The positive sample feature vector And the negative sample feature vector of each negative sample data j is an integer greater than or equal to 1 and less than or equal to the integer K.

[0052] In some embodiments, the first machine learning model and the second machine learning model may be different deep learning neural networks. The first machine learning model and the second machine learning model may be trained by comparative learning.

[0053] For example, the function value can be used to adjust the parameters of the first machine learning model; and the parameters of the second machine learning model can be adjusted according to the parameters of the first machine learning model.

[0054] In step 130, the function value of the loss function is calculated according to the similarity between the target feature vector and each sample feature vector.

[0055] In some embodiments, the sub-loss function corresponding to the positive sample data is determined based on the similarity between the target feature vector and the feature vector of any positive sample data. The sub-loss function is negatively correlated with the similarity between the target feature vector and the feature vector of the positive sample data, and positively correlated with the sum of the similarities between the target feature vector and the feature vectors of all negative sample data; the loss function is determined based on the weighted sum of the sub-loss functions. For example, Figure 2 The embodiment in determines each sub-loss function.

[0056] Figure 2 Schematic diagram showing some embodiments of the training method of the machine learning model of the present disclosure.

[0057] like Figure 2 As shown, f(·) and g(·) are used to extract X i In Q i and each of use calculate With each The similarity of calculate The similarity with each negative sample data; then use each Calculate positive sample data The corresponding sub-loss function L i,m For example, each L can be calculated by the following formula i,m :

[0058]

[0059] τ is the temperature hyperparameter set according to actual conditions and requirements. From the above formula, we can see that L i,m Root q i and The similarity is negatively correlated with q i and And all negative sample data The sum of similarities is positively correlated.

[0060] In some embodiments, the loss function is determined based on the weighted sum of each sub-loss function. For example, the weight of each sub-loss function is negatively correlated with the number of positive sample data. For example, the average value of M sub-loss functions can be taken as the loss function. M positive sample data of the image classification, loss function It can be calculated by the following formula:

[0061]

[0062] In the above embodiment, multiple positive sample data are generated based on one positive sample data, and training is performed according to the similarity between the multiple positive sample data and the image to be classified. In this way, the characteristics of shared similarity between the positive sample data can be utilized to fully explore the inherent characteristics of each classification, so as to improve the training effect of the machine learning model, thereby improving the accuracy of image classification.

[0063] In some embodiments, the similarity between the target feature vector and each sample feature vector is calculated based on the statistical characteristics of the feature vector of each positive sample data; and the function value of the loss function is calculated based on the similarity.

[0064] For example, you can use various At least one of the mean and variance of the distribution of represents the comprehensive feature vector of the positive sample data; using the comprehensive feature vector, calculate With all degree of similarity.

[0065] In this way, it is not necessary to calculate the similarity between each positive sample data and the image to be classified. It is only necessary to calculate the similarity between the comprehensive feature vector and the image to be classified to determine the function value of the loss function. Thus, the amount of calculation is reduced, and the correlation information between multiple positive sample data is introduced, which improves the training efficiency and the accuracy of image classification.

[0066] Since for a batch of N images to be classified in training data, it is necessary to calculate (M+1)×N pairs and The similarity between the two values ​​is , therefore, this will result in a large amount of calculation. In order to solve this technical problem, the function value of the loss function can be calculated in the manner in the following embodiment.

[0067] In some embodiments, when the number of positive sample data approaches positive infinity, the limit of the loss function is determined by using the statistical characteristics of the feature vector of each positive sample data to calculate the function value.

[0068] For example, the following limit calculation formula can be used to determine the loss function:

[0069]

[0070] To take all the positive sample data in brackets The mean of . Furthermore, the upper limit of the above formula can be determined as:

[0071]

[0072] In the above embodiment, when the number of positive sample data approaches positive infinity, it is determined A strict upper limit is set to obtain the loss function in the case of infinite positive sample data. In this way, the loss function can be closer to the actual situation, improve the training effect, and thus improve the accuracy of image classification.

[0073] In some embodiments, all positive sample data It obeys Gaussian distribution, that is and They are The mean and variance of the distribution of . and Calculate the above formula and For example, Figure 3 The embodiments in the embodiment implement the above technical solution.

[0074] Figure 3Schematic diagrams showing other embodiments of the training method of the machine learning model of the present disclosure.

[0075] like Figure 3 As shown, the first positive sample data can be subjected to M′ data enhancement processing to obtain M′ second positive sample data, where M′ is a positive integer less than M. Use f(·) and g(·) to extract X i In Q i and each of and get all The distribution of Statistical features in and

[0076] In some embodiments, the first similarity is determined based on the similarity between the target feature vector and the mean of the feature vectors of each positive sample data. For example, the first similarity can be

[0077] The second similarity is determined based on the similarity between the variance of the target feature vector and the feature vector of each positive sample data. For example, the second similarity can be

[0078] The third similarity is determined based on the sum of the similarities between the target feature vector and the feature vectors of each negative sample data. For example, the third similarity can be

[0079] According to the first similarity, the second similarity, and the third similarity, the limit of the loss function is determined. The limit of the loss function is negatively correlated with the first similarity and positively correlated with the sum of the second similarity and the third similarity. For example, the loss function can be determined as:

[0080]

[0081] λ is a hyperparameter set according to actual conditions and requirements.

[0082] In the above embodiment, using Statistical characteristics of and The sum of the sub-loss functions of an infinite number of positive sample data is calculated as the loss function, which improves the training effect and the accuracy of image classification.

[0083] In step 140, the function value is used to train a machine learning model for classifying the image to be classified.

[0084] In some embodiments, the machine learning model is trained based on the weighted average of the function values ​​of each image to be classified in a batch of training data. For example, the average of the loss function of all images to be classified can be taken to calculate the final function value used for training:

[0085]

[0086] In some embodiments, after training the machine learning model using any of the above training methods, the machine learning model can be used to classify the acquired images to be classified.

[0087] Figure 4 A block diagram illustrating some embodiments of the training final of the machine learning model of the present disclosure.

[0088] like Figure 4 As shown, the training device 4 includes a generating unit 41 , an extracting unit 42 , a calculating unit 43 and a training unit 44 .

[0089] The generating unit 41 transforms the first positive sample data of the image to be classified to generate a plurality of second positive sample data. The first positive sample data and the plurality of second positive sample data together constitute the positive sample data of the image to be classified.

[0090] In some embodiments, the transformation process includes at least one of a rotation process, a noise adding process, a flipping process, a scaling process, a cropping process, and a translation process.

[0091] The extraction unit 42 uses a machine learning model to extract a feature vector of the image to be classified as a target feature vector, and extracts a feature vector of each sample data as each sample feature vector. Each sample data includes positive sample data and negative sample data.

[0092] The calculation unit 43 calculates the function value of the loss function according to the similarity between the target feature vector and each sample feature vector.

[0093] In some embodiments, the calculation unit 43 calculates the similarity between the target feature vector and each sample feature vector according to the statistical characteristics of the feature vector of each positive sample data.

[0094] In some embodiments, when the number of positive sample data approaches positive infinity, the calculation unit 43 uses the statistical characteristics of the feature vectors of each positive sample data to determine the limit of the loss function for calculating the function value.

[0095] In some embodiments, the calculation unit 43 determines the first similarity according to the similarity between the target feature vector and the mean of the feature vector of each positive sample data; determines the second similarity according to the similarity between the target feature vector and the variance of the feature vector of each positive sample data; determines the third similarity according to the sum of the similarities between the target feature vector and the feature vector of each negative sample data; determines the limit of the loss function according to the first similarity, the second similarity, and the third similarity. The limit of the loss function is negatively correlated with the first similarity and positively correlated with the sum of the second similarity and the third similarity.

[0096] In some embodiments, the calculation unit 43 determines the sub-loss function corresponding to the positive sample data according to the similarity between the target feature vector and the feature vector of any positive sample data. The sub-loss function is negatively correlated with the similarity between the target feature vector and the feature vector of the positive sample data, and positively correlated with the sum of the similarities between the target feature vector and the feature vectors of all negative sample data; the loss function is determined according to the weighted sum of each sub-loss function.

[0097] The training unit 44 uses the function value to train a machine learning model for classifying the image to be classified.

[0098] In some embodiments, the extraction unit 42 uses the first machine learning model to extract the target feature vector, and uses the second machine learning model to extract each sample feature vector; the training unit 44 uses the function value to adjust the parameters of the first machine learning model; and adjusts the parameters of the second machine learning model according to the parameters of the first machine learning model.

[0099] In some embodiments, the training unit 44 trains the machine learning model according to the weighted average of the function values ​​of each image to be classified in a batch of training data.

[0100] In some embodiments, the image classification device includes: an acquisition unit for acquiring the image to be classified; and a classification unit for classifying the image to be classified using a machine learning model. The machine learning model is trained according to the training method in any of the above embodiments.

[0101] Figure 5 A block diagram showing some embodiments of the electronic device of the present disclosure.

[0102] like Figure 5 As shown, the electronic device 5 of this embodiment includes: a memory 51 and a processor 52 coupled to the memory 51, and the processor 52 is configured to execute the training method of the machine learning model or the image classification method in any embodiment of the present disclosure based on the instructions stored in the memory 51.

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

[0104] Figure 6 A block diagram showing some other embodiments of the electronic device of the present disclosure.

[0105] like Figure 6 As shown, the electronic device 6 of this embodiment includes: a memory 610 and a processor 620 coupled to the memory 610, and the processor 620 is configured to execute the training method of the machine learning model or the image classification method in any one of the aforementioned embodiments based on the instructions stored in the memory 610.

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

[0107] The electronic device 6 may also include an input / output interface 630, a network interface 640, a storage interface 650, etc. These interfaces 630, 640, 650, the memory 610, and the processor 620 may be connected, for example, via a bus 660. The input / output interface 630 provides a connection interface for input / output devices such as a display, a mouse, a keyboard, a touch screen, a microphone, and a speaker. The network interface 640 provides a connection interface for various networked devices. The storage interface 650 provides a connection interface for external storage devices such as an SD card and a USB flash drive.

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

[0109] So far, the training method of the machine learning model, the training device of the machine learning model, the image classification method, the image classification device, the electronic device and the non-volatile computer-readable storage medium according to the present disclosure have been described in detail. In order to avoid obscuring the concept of the present disclosure, some details known in the art are not described. Based on the above description, those skilled in the art can fully understand how to implement the technical solution disclosed here.

[0110] The method and system of the present disclosure may be implemented in many ways. For example, the method and system of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present disclosure are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present disclosure may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present disclosure. Therefore, the present disclosure also covers a recording medium storing a program for executing the method according to the present disclosure.

[0111] Although some specific embodiments of the present disclosure have been described in detail by way of example, it should be understood by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present disclosure. It should be understood by those skilled in the art that the above embodiments may be modified without departing from the scope and spirit of the present disclosure. The scope of the present disclosure is defined by the appended claims.

Claims

1. A method for training a machine learning model, comprising: Performing transformation processing on first positive sample data of the image to be classified to generate a plurality of second positive sample data, wherein the first positive sample data and the plurality of second positive sample data together constitute the positive sample data of the image to be classified; Using a machine learning model, extracting a feature vector of the image to be classified as a target feature vector, and extracting a feature vector of each sample data as each sample feature vector, wherein each sample data includes the positive sample data and the negative sample data; Calculating the function value of the loss function according to the similarity between the target feature vector and each sample feature vector; The function value is used to train the machine learning model for classifying the image to be classified, wherein: The method of using a machine learning model to extract the feature vector of the image to be classified as a target feature vector and extracting the feature vector of each sample data as each sample feature vector includes: Extracting the target feature vector using a first machine learning model, and extracting the feature vectors of each sample using a second machine learning model; The using the function value to train the machine learning model comprises: Using the function value, adjusting parameters of the first machine learning model; Adjust the parameters of the second machine learning model according to the parameters of the first machine learning model.

2. The training method according to claim 1, wherein: The step of calculating the function value of the loss function according to the similarity between the target feature vector and each sample feature vector includes: According to the statistical characteristics of the feature vectors of each positive sample data, the similarity between the target feature vector and each sample feature vector is calculated.

3. The training method according to claim 1, wherein: The step of calculating the function value of the loss function according to the similarity between the target feature vector and each sample feature vector includes: When the number of the positive sample data approaches positive infinity, the limit of the loss function is determined by using the statistical characteristics of the feature vectors of each positive sample data, which is used to calculate the function value.

4. The training method according to claim 3, wherein: Determining the limit of the loss function by using the statistical characteristics of the characteristic vector of each positive sample data includes: Determining a first similarity according to a degree of similarity between the target feature vector and the mean of the feature vectors of each positive sample data; Determining a second similarity according to a degree of similarity between the variances of the target feature vector and the feature vectors of each positive sample data; Determining a third similarity according to the sum of similarities between the target feature vector and the feature vectors of each negative sample data; The limit of the loss function is determined according to the first similarity, the second similarity, and the third similarity, wherein the limit of the loss function is negatively correlated with the first similarity and positively correlated with the sum of the second similarity and the third similarity.

5. The training method according to any one of claims 1 to 4, wherein: The step of calculating the function value of the loss function according to the similarity between the target feature vector and each sample feature vector includes: According to the similarity between the target feature vector and the feature vector of any positive sample data, a sub-loss function corresponding to the positive sample data is determined, wherein the sub-loss function is negatively correlated with the similarity between the target feature vector and the feature vector of the positive sample data, and positively correlated with the sum of the similarities between the target feature vector and the feature vectors of all negative sample data; The loss function is determined according to the weighted sum of the sub-loss functions.

6. The training method according to any one of claims 1 to 4, wherein: The transformation processing includes at least one of rotation processing, noise adding processing, flipping processing, scaling processing, cropping processing, and translation processing.

7. The training method according to any one of claims 1 to 4, wherein: The using the function value to train the machine learning model comprises: The machine learning model is trained according to the weighted average of the function values ​​of each image to be classified in a batch of training data.

8. A method for classifying an image, comprising: Get the image to be classified; The image to be classified is classified using a machine learning model, wherein the machine learning model is trained according to the training method according to any one of claims 1 to 7.

9. A training device for a machine learning model, comprising: A generating unit, configured to transform first positive sample data of an image to be classified to generate a plurality of second positive sample data, wherein the first positive sample data and the plurality of second positive sample data together constitute the positive sample data of the image to be classified; An extraction unit, used to extract the feature vector of the image to be classified as a target feature vector, and extract the feature vector of each sample data as each sample feature vector by using a machine learning model, wherein each sample data includes the positive sample data and the negative sample data; A calculation unit, used to calculate the function value of the loss function according to the similarity between the target feature vector and each sample feature vector; A training unit is used to train the machine learning model using the function value to classify the image to be classified, wherein: The extraction unit uses a first machine learning model to extract the target feature vector, and uses a second machine learning model to extract each sample feature vector. The training unit uses the function value to adjust the parameters of the first machine learning model, and adjusts the parameters of the second machine learning model according to the parameters of the first machine learning model.

10. An image classification device, comprising: An acquisition unit, used for acquiring an image to be classified; A classification unit is used to classify the image to be classified using a machine learning model, wherein the machine learning model is trained according to the training method according to any one of claims 1 to 7.

11. An electronic device, comprising: Memory; and A processor coupled to the memory, the processor being configured to execute the training method of the machine learning model described in any one of claims 1-7, or the image classification method described in claim 8, based on instructions stored in the memory.

12. A non-volatile computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for training a machine learning model as described in any one of claims 1 to 7, or the method for classifying an image as described in claim 8.

Citation Information

Patent Citations

  • Method and device for generating image recognition model

    CN110516737A