Data classification method, device and computer readable storage medium

By random sampling and reverse sampling of training samples, feature fusion and data enhancement, the problem of small category samples being ignored in machine learning algorithms is solved, and the recognition accuracy of small category data and the model's classification of imbalanced data are improved. ability.

CN112465031BActive Publication Date: 2024-09-17江苏云从曦和人工智能有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011364058.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-27
Publication Date
2024-09-17
Estimated Expiration
2040-11-27

AI Technical Summary

Technical Problem

In machine learning algorithms, when the number of small category samples in the training set is small, the classification model tends to give up or reduce the classification learning of small category samples, resulting in a reduction in the recognition accuracy of small category data.

Method used

By random sampling and reverse sampling of training samples, the characteristics of random sampling samples and reverse sampling samples are fused, and the fusion results are used to train the data classification model to ensure that the weight of small category samples is increased, thereby increasing their attention in model training, and Increase the number of samples of each category through data augmentation processing.

Benefits of technology

On the premise of ensuring the recognition accuracy of large category data, the recognition accuracy of small category data is improved, and the model's classification learning ability for imbalanced training samples is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112465031B
    Figure CN112465031B
Patent Text Reader

Abstract

The present invention relates to the technical field of data classification processing, and specifically provides a data classification method, device and computer-readable storage medium, aiming to solve the technical problem of how to improve the accuracy of data classification. To this end, according to the method of an embodiment of the present invention, a data classification model trained based on the feature fusion results of samples obtained by random sampling and reverse sampling of training samples can be used to classify the data to be classified, and the data category of the data to be classified is obtained according to the results of the data classification. Optimizing the model according to the characteristics of the reverse sampling samples can improve the model's classification learning ability for small category samples in unbalanced training samples; optimizing the model according to the characteristics of the randomly sampled samples can improve the model's classification learning ability for large category samples in unbalanced training samples, so that the trained data classification model can accurately classify the data to be identified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data classification processing, and in particular to a data classification method, device and computer-readable storage medium. Background Art

[0002] When using the training set to train the classification model, the distribution of sample categories in the training set will greatly affect the training effect of the classification model. Specifically, if the number of samples of a certain category (referred to as small categories) in the training set is much smaller than the number of samples of other categories (referred to as large categories), then when using the machine learning algorithm to train the classification model, since the classification model can significantly improve the classification accuracy of the model by only performing classification learning on large category samples, the machine learning algorithm will cause the classification model to abandon or reduce the classification learning of small category samples, which will eventually lead to the classification of the test sample belonging to the small category when the trained classification model is used to classify the test sample belonging to the small category. For example: if the training set includes 1 class A sample and 99 class B samples, since only performing classification learning on class B samples will enable the classification model to obtain the highest classification accuracy of 99%, the machine learning algorithm will cause the classification model to abandon the classification learning of class A samples, resulting in the trained model being unable to recognize class A data. Summary of the invention

[0003] In order to overcome the above-mentioned defects, the present invention is proposed to provide a data classification method, device and computer-readable storage medium that solve or at least partially solve the technical problem of how to improve the accuracy of data classification.

[0004] In a first aspect, a data classification method is provided, the method comprising:

[0005] Obtain data to be classified;

[0006] Classifying the data to be classified using a preset data classification model to obtain data categories of the data to be classified;

[0007] The preset data classification model is obtained by training based on the feature fusion results of samples obtained by random sampling and inverse sampling of training samples, and the number of samples of some categories in the training samples is much smaller than the number of samples of other categories.

[0008] In a technical solution of the above data classification method, the preset data classification model includes a data input module, a feature extraction module, a feature fusion module and a classifier; the feature extraction module includes a plurality of feature extraction submodules connected in sequence, and the first feature extraction submodule is connected to the data input module, and the last feature extraction submodule is connected to the feature fusion module; the last feature extraction submodule includes a main feature extraction unit and an auxiliary feature extraction unit with the same structure;

[0009] The feature extraction module is configured to extract data features of input data;

[0010] The feature fusion module is configured to perform feature fusion on the data features output by the main feature extraction unit and the auxiliary feature extraction unit to obtain a feature fusion result;

[0011] The classifier is configured to perform data classification according to the feature fusion result.

[0012] In a technical solution of the above data classification method, the preset data classification model is trained in the following manner:

[0013] Perform random sampling and reverse sampling on the training samples respectively to obtain random sampling samples and reverse sampling samples;

[0014] Using the model loss function L shown in the following formula and according to the feature fusion results of the random sampling samples and the inverse sampling samples output by the feature fusion module, the model loss value of the data classification model is calculated;

[0015] L=α1L CE (P mix ,y normal )+(1-α1)L CE (P mix ,y reverse )

[0016] Among them, the P mix represents the category prediction value output by the classifier for data classification based on the feature fusion result, and the y normal represents the class label value of the randomly sampled sample, the y reverse represents the category label value of the reverse sampling sample, and the L CE (P mix ,y normal ) represents the category prediction value P mix With the class label value y normal The error function and L CE (P mix ,y normal )=-y normal LqCymix , the L CE (P mix ,y reverse ) represents the category prediction value P mix With the class label value y reverse The error function and L CE (P mix ,y reverse )=-y reverse oeLh mix ; The α1 represents the weight of the model loss function and The i epoch Indicates the number of iterations of the current iteration training, the n epoch Represents the total number of iterations of training;

[0017] According to the model loss value, the gradient corresponding to each model parameter in the data classification model is calculated, and the model parameters of the data classification model are updated according to the gradient back propagation to perform model optimization to complete the current iterative training;

[0018] Determine whether the iteration stop condition is met;

[0019] If yes, stop training; if no, execute the next iteration training.

[0020] In a technical solution of the above data classification method, the step of "de-sampling the training samples" specifically includes:

[0021] Obtain the category weights corresponding to each type of training samples respectively according to the method shown in the following formula;

[0022]

[0023] Among them, the w i represents the category weight of the i-th category training sample, and the n i represents the number of training samples of the i-th category, the n max Indicates the number of training samples of the largest category;

[0024] According to the category weight, the sampling probability corresponding to each category of training samples is obtained; the sampling probability is positively correlated with the category weight and the sum of the sampling probabilities of all categories of training samples is 1;

[0025] De-sampling the training samples according to the sampling probability;

[0026] And / or, before the step of “calculating the model loss value of the data classification model”, the method further includes:

[0027] Data enhancement processing is performed on the random sampling samples and the inverse sampling samples respectively, so as to optimize the data classification model by using the random sampling samples and the inverse sampling samples after the data enhancement processing.

[0028] In a technical solution of the above data classification method, before the step of “calculating the model loss value of the data classification model”, the method further includes:

[0029] Controlling the main feature extraction unit to extract sample features of the randomly sampled samples, and controlling the subsidiary feature extraction unit to extract sample features of the inversely sampled samples;

[0030] The feature fusion module is controlled to obtain the feature fusion weight and perform feature fusion on the sample features output by the main feature extraction unit and the subsidiary feature extraction unit according to the method shown in the following formula:

[0031] f mix_1 =α2f normal +(1-α2)f reverse

[0032] Among them, the f mix_1 represents the feature fusion result of the random sampling sample and the inverse sampling sample, and the f normal represents the sample features output by the main feature extraction unit, and the f reverse represents the sample feature output by the subsidiary feature extraction unit, α2 represents the feature fusion weight and

[0033] In a technical solution of the above data classification method, before the step of “classifying the data to be classified using a preset data classification model”, the method further includes:

[0034] Controlling the main feature extraction unit and the subsidiary feature extraction unit to respectively extract data features of the data to be classified;

[0035] The feature fusion module is controlled to perform feature fusion on the data features of the data to be classified output by the main feature extraction unit and the subsidiary feature extraction unit according to the method shown in the following formula:

[0036] f mix_2 =0.5×f re_1 +0.5×f re_2

[0037] Among them, the f mix_2 represents the feature fusion result of the data to be classified, and the f re_1 represents the data feature of the data to be classified output by the main feature extraction unit, the fre_2 Represents the data features of the data to be classified output by the subsidiary feature extraction unit.

[0038] In a second aspect, a data classification device is provided, the device comprising:

[0039] A data acquisition module, configured to acquire data to be classified;

[0040] A data classification module, which is configured to classify the data to be classified using a preset data classification model to obtain a data category of the data to be classified;

[0041] The preset data classification model is obtained by training based on the feature fusion results of samples obtained by random sampling and inverse sampling of training samples, and the number of samples of some categories in the training samples is much smaller than the number of samples of other categories.

[0042] In a technical solution of the above-mentioned data classification device, the preset data classification model includes a data input module, a feature extraction module, a feature fusion module and a classifier; the feature extraction module includes a plurality of feature extraction submodules connected in sequence, and the first feature extraction submodule is connected to the data input module, and the last feature extraction submodule is connected to the feature fusion module; the last feature extraction submodule includes a main feature extraction unit and an auxiliary feature extraction unit with the same structure;

[0043] The feature extraction module is configured to extract data features of input data;

[0044] The feature fusion module is configured to perform feature fusion on the data features output by the main feature extraction unit and the auxiliary feature extraction unit to obtain a feature fusion result;

[0045] The classifier is configured to perform data classification according to the feature fusion result.

[0046] In a technical solution of the above data classification device, the device further includes a model training module, and the model training module includes a data sampling submodule, a model optimization submodule and a training stop judgment submodule;

[0047] The data sampling submodule is configured to perform random sampling and reverse sampling on the training samples respectively to obtain random sampling samples and reverse sampling samples;

[0048] The model optimization submodule is configured to calculate the model loss value of the data classification model according to the feature fusion result of the random sampling sample and the inverse sampling sample output by the feature fusion module by using the model loss function L shown in the following formula;

[0049] L=α1LCE (P mix ,y normal )+(1-α1)L CE (P mix ,y reverse )

[0050] Among them, the P mix represents the category prediction value output by the classifier for data classification based on the feature fusion result, and the y normal represents the class label value of the randomly sampled sample, the y reverse represents the category label value of the reverse sampling sample, and the L CE (P mix ,y normal ) represents the category prediction value P mix With the class label value y normal The error function and L CE (P mix ,y normal )=-y normal oeLh mix , the L CE (P mix ,y reverse ) represents the category prediction value P mix With the class label value y reverse The error function and L CE (P mix ,y reverse )=-y reverse oeLh mix ; The α1 represents the weight of the model loss function and The i epoch Indicates the number of iterations of the current iteration training, the n epoch Represents the total number of iterations of training;

[0051] According to the model loss value, the gradient corresponding to each model parameter in the data classification model is calculated, and the model parameters of the data classification model are updated according to the gradient back propagation to perform model optimization to complete the current iterative training;

[0052] The training stop judgment submodule is configured to judge whether the iteration stop condition is met after completing one iteration training; if so, stop the training; if not, perform the next iteration training.

[0053] In a technical solution of the above data classification device, the data sampling submodule is further configured to perform the following operations:

[0054] Obtain the category weights corresponding to each type of training samples respectively according to the method shown in the following formula;

[0055]

[0056] Among them, the w i represents the category weight of the i-th category training sample, and the n i represents the number of training samples of the i-th category, and the n max Indicates the number of training samples of the largest category;

[0057] According to the category weight, the sampling probability corresponding to each category of training samples is obtained; the sampling probability is positively correlated with the category weight and the sum of the sampling probabilities of all categories of training samples is 1;

[0058] De-sampling the training samples according to the sampling probability;

[0059] And / or, the model optimization submodule is further configured to perform data enhancement processing on the random sampling samples and the inverse sampling samples respectively, so as to optimize the data classification model using the random sampling samples and the inverse sampling samples after the data enhancement processing.

[0060] In a technical solution of the above data classification device, the model optimization submodule is further configured to perform the following operations:

[0061] Controlling the main feature extraction unit to extract sample features of the randomly sampled samples, and controlling the subsidiary feature extraction unit to extract sample features of the inversely sampled samples;

[0062] The feature fusion module is controlled to obtain the feature fusion weight and perform feature fusion on the sample features output by the main feature extraction unit and the subsidiary feature extraction unit according to the method shown in the following formula:

[0063] f mix_1 =α2f normal +(1-α2)f reverse

[0064] Among them, the f mix_1 represents the feature fusion result of the random sampling sample and the inverse sampling sample, and the f normal represents the sample features output by the main feature extraction unit, and the f reverse represents the sample feature output by the subsidiary feature extraction unit, α2 represents the feature fusion weight and

[0065] In a technical solution of the above data classification device, the data classification module is further configured to perform the following operations:

[0066] Controlling the main feature extraction unit and the subsidiary feature extraction unit to respectively extract data features of the data to be classified;

[0067] The feature fusion module is controlled to perform feature fusion on the data features of the data to be classified output by the main feature extraction unit and the subsidiary feature extraction unit according to the method shown in the following formula:

[0068] f mix_2 =0.5×f re_1 +0.5×f re_2

[0069] Among them, the f mix_2 represents the feature fusion result of the data to be classified, and the f re_1 represents the data feature of the data to be classified output by the main feature extraction unit, the f re_2 Represents the data features of the data to be classified output by the subsidiary feature extraction unit.

[0070] According to a third aspect, a control device is provided, which includes a processor and a storage device, wherein the storage device is suitable for storing multiple program codes, and the program codes are suitable for being loaded and run by the processor to execute the data classification method described in any one of the technical solutions of the above-mentioned data classification method.

[0071] In a fourth aspect, a computer-readable storage medium is provided, wherein a plurality of program codes are stored in the computer-readable storage medium, wherein the program codes are suitable for being loaded and run by a processor to execute the data classification method described in any one of the technical solutions of the above-mentioned data classification method.

[0072] The above one or more technical solutions of the present invention have at least one or more of the following beneficial effects:

[0073] In the technical solution of the present invention, a data classification model trained based on the feature fusion results of samples obtained by random sampling and reverse sampling of training samples can be used to classify the data to be classified, and the data category of the data to be classified can be obtained according to the data classification results. The weight of each type of training sample can be set by reverse sampling of the training samples. If the weight of a certain type of training sample is larger, the sampling probability of the training sample of this type is also larger. Therefore, for an unbalanced training set, the weight of small category samples can be increased to increase their sampling probability, so that the classification model can pay more attention to the category learning of small category samples during model training. However, this will also cause the classification model to reduce the category learning of large category samples, which may eventually cause the trained classification model to identify data belonging to large categories as data belonging to small categories. In order to overcome the above-mentioned defects, the method according to the embodiment of the present invention can not only perform inverse sampling on the training samples, but also perform random sampling on the training samples to ensure that the collection probability of each training sample is the same, and then extract the features of the inverse sampling samples and the features of the random sampling samples, and perform category classification learning based on the feature fusion results of the inverse sampling samples and the random sampling samples. In this way, the recognition accuracy of the model for small category data can be improved while ensuring that the model has a high recognition accuracy for large category data.

[0074] Furthermore, in the technical solution of the present invention, after random sampling and inverse sampling, sample expansion can be performed on the random sampling samples and inverse sampling samples obtained by sampling, respectively, to increase the number of samples of each category, and then subsequent model optimization and other steps can be performed to further improve the model's classification learning ability for each category of samples in the unbalanced training samples. BRIEF DESCRIPTION OF THE DRAWINGS

[0075] The specific embodiments of the present invention are described below with reference to the accompanying drawings, in which:

[0076] Figure 1 is a flowchart of main steps of a data classification method according to an embodiment of the present invention;

[0077] Figure 2 It is a main structural block diagram of a data classification device according to an embodiment of the present invention.

[0078] List of reference numerals:

[0079] 11: Data acquisition module; 12: Data classification module. DETAILED DESCRIPTION

[0080] Some embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.

[0081] In the description of the present invention, "module" and "processor" may include hardware, software or a combination of the two. A module may include hardware circuits, various suitable sensors, communication ports, and memories, and may also include software parts, such as program codes, or a combination of software and hardware. The processor may be a central processing unit, a microprocessor, an image processor, a digital signal processor, or any other suitable processor. The processor has data and / or signal processing functions. The processor may be implemented in software, hardware, or a combination of the two. Non-temporary computer-readable storage media include any suitable medium that can store program codes, such as a magnetic disk, a hard disk, an optical disk, a flash memory, a read-only memory, a random access memory, and the like. The term "A and / or B" means all possible combinations of A and B, such as only A, only B, or A and B. The term "at least one A or B" or "at least one of A and B" has a similar meaning to "A and / or B", and may include only A, only B, or A and B. The singular terms "one" and "the" may also include plural forms.

[0082] In the field of machine learning technology, the classification model is mainly trained using a training set containing samples of different categories, so that the trained classification model can be used to identify the category of the data to be identified, such as the test sample. However, for an unbalanced training set in which the number of samples of a certain category (small category) is much smaller than the number of samples of other categories (large category), using such a training set for model training will cause the trained classification model to misidentify the data belonging to the small category as belonging to the large category. In an embodiment of the present invention, a data classification model trained based on the feature fusion results of the samples obtained by random sampling and inverse sampling of the training samples can be used to classify the data to be classified, and the data category of the data to be classified can be obtained according to the result of the data classification. By reverse sampling the training samples, the weight of each type of training samples can be set. If the weight of a certain type of training samples is larger, the sampling probability of the training samples of this type is also larger. Therefore, for an unbalanced training set, the weight of the small category samples can be increased to increase their sampling probability, so that the classification model can pay more attention to the category learning of the small category samples during model training. However, this will also cause the classification model to reduce the category learning of the large category samples, which may eventually cause the trained classification model to identify the data belonging to the large category as belonging to the small category. In order to overcome the above defects, according to the method of the embodiment of the present invention, in addition to reverse sampling the training samples, the training samples can also be randomly sampled to ensure that the acquisition probability of each training sample is the same, and then the features of the reverse sampling samples and the features of the random sampling samples are extracted. Classification learning is performed based on the feature fusion results of the reverse sampling samples and the random sampling samples, so that the model can improve the recognition accuracy of the small category data (using the features of the reverse sampling samples) while ensuring that the model has a high recognition accuracy of the large category data (achieved by the features of the random sampling samples).

[0083] In an example of an application scenario of the present invention, video surveillance information on a certain section of a traffic road within a period of time is obtained, images of people driving vehicles such as motorcycles and electric bicycles in the video surveillance information are extracted and these images are used as training samples, and a first category label of wearing a helmet and a second label of not wearing a helmet are set for each image according to whether the driver in the image wears a helmet, wherein the number of images wearing a helmet is much smaller than the number of images not wearing a helmet. Using a data classification method according to an embodiment of the present invention, the above training samples are randomly sampled and reversely sampled respectively, and a data classification model is trained according to the feature fusion results of the random sampling samples and the reverse sampling samples, so that the data classification model can accurately identify the category of the image to be identified (wearing a helmet or not wearing a helmet). Then, the above trained data classification model is used to perform image classification analysis on the monitoring images of the target area to determine whether there are vehicle drivers who are not wearing helmets in the target area; if so, a reminder message can be output so that the monitoring personnel can take timely and effective measures to remind the relevant vehicle drivers to wear helmets in time to prevent traffic accidents that endanger personal safety.

[0084] See attached Figure 1 , Figure 1 FIG. 1 is a flow chart of the main steps of a data classification method according to an embodiment of the present invention. Figure 1 As shown, the data classification method in the embodiment of the present invention mainly includes the following steps:

[0085] Step S101: Obtain data to be classified.

[0086] The data to be classified refers to data that needs to be identified as belonging to a specific category. In this embodiment, the data to be classified includes but is not limited to: image data to be classified and voice data to be classified.

[0087] Step S102: classify the data to be classified using a preset data classification model to obtain data categories of the data to be classified.

[0088] The preset data classification model refers to a model trained based on feature fusion results of samples obtained by random sampling and inverse sampling of training samples.

[0089] In this embodiment, the training samples may be unbalanced samples with uneven distribution of sample categories, that is, the number of samples of a part of categories in the training samples is much smaller than (<<) the number of samples of other categories. Specifically, the difference between the above-mentioned "number of samples of a part of categories" and the above-mentioned "number of samples of other categories" is greater than or equal to the preset difference. In one implementation, the preset difference may be a value that is smaller than the number of the above-mentioned "number of samples of other categories" and close to the number. An example: The training sample includes 1 class A sample and 99 class B samples, and the preset difference may be 80. Since the difference between the number of class A samples and class B samples is greater than the preset difference, it is determined that the current training sample belongs to an unbalanced sample.

[0090] In an embodiment of the present invention, a preset data classification model may include a data input module, a feature extraction module, a feature fusion module and a classifier. The feature extraction module may include a plurality of feature extraction submodules connected in sequence, and the first feature extraction submodule is connected to the data input module, and the last feature extraction submodule is connected to the feature fusion module; the last feature extraction submodule may include a main feature extraction unit and an auxiliary feature extraction unit with the same structure. In one embodiment, the feature extraction module may be configured to extract data features of the input data. The feature fusion module may be configured to perform feature fusion on the data features output by the main feature extraction unit and the auxiliary feature extraction unit to obtain a feature fusion result. The classifier may be configured to perform data classification according to the feature fusion result.

[0091] It should be noted that, in this embodiment, a conventional model structure in the field of machine learning technology can be used, and the model structure can be improved to form the above-mentioned feature extraction module. For example: the ResNet50 model structure includes four feature extraction submodules 1-4 connected in sequence, and the number of feature extraction submodules 4 can be set to 2, that is, two feature extraction submodules with the same structure (main feature extraction unit and auxiliary feature extraction unit), and these two feature extraction submodules are connected to the feature extraction submodule 3 at the same time, and the output results of these two feature extraction submodules are the output results of the feature extraction module. In addition, in this embodiment, a conventional classification model in the field of machine learning technology can be used as a classifier. Conventional classification models include, but are not limited to: Perception, multilayer perceptron, and support vector machine, etc.

[0092] When training the data classification model, the main feature extraction unit can be configured to extract the features of the random sampling samples separately, and the auxiliary feature extraction unit can be configured to extract the features of the reverse sampling samples separately, so that the feature fusion module can fuse the features of the random sampling samples and the reverse sampling samples to complete the subsequent model optimization. Specifically, in one implementation, the data classification model can be iteratively trained according to the following steps 11-13, so as to use the trained data classification model to classify the data to be classified.

[0093] Step 11: Perform random sampling and reverse sampling on the training samples respectively to obtain random sampling samples and reverse sampling samples.

[0094] In this embodiment, a conventional random sampling method in the field of data sampling technology may be used to randomly sample training samples, which will not be described in detail for the sake of brevity.

[0095] In this embodiment, the class weights corresponding to each class of training samples can be obtained according to the method shown in the following formula (1), and then the sampling probability corresponding to each class of training samples can be obtained according to the class weights. The sampling probability is positively correlated with the class weights, and the sum of the sampling probabilities of all class training samples is 1. Finally, a conventional inverse sampling method in the field of data sampling technology is used to inversely sample the training samples according to the above sampling probabilities. For the sake of brevity, the specific sampling process of inverse sampling will not be described in detail here.

[0096]

[0097] The meanings of the parameters in formula (1) are as follows:

[0098] w i represents the category weight of the i-th category training sample, n i represents the number of training samples of the i-th category, n max Indicates the number of training samples of the largest category. An example: the training set includes 1 training sample of category A, 48 training samples of category B and 51 training samples of category C. Then, according to formula (1), the category weights corresponding to the training samples of categories A, B and C are 51, 1.0625 and 1, respectively. It should be noted that, in this embodiment, a conventional probability calculation method can be used. According to the principle that the greater the weight, the greater the probability, the sampling probability corresponding to each category of training samples is calculated according to the category weight corresponding to each category of training samples. For example: if the category weights corresponding to the training samples of categories A, B and C are 51, 1.0625 and 1, respectively, then the sampling probabilities corresponding to the training samples of categories A, B and C can be 0.8, 0.1 and 0.1, respectively.

[0099] Step 12: Calculate the model loss value of the data classification model (the calculation result of the model loss function L) using the model loss function L of the following formula (2) and based on the feature fusion results of the random sampling samples and the inverse sampling samples output by the feature fusion module.

[0100] L=α1L CE (P mix ,y normal )+(1-α1)L CE (P mix ,y reverse ) (2)

[0101] The meanings of the parameters in formula (2) are as follows:

[0102] P mix It represents the category prediction value of the classifier according to the feature fusion result. normal Represents the class label value of the randomly sampled sample, y reverse Represents the category label value of the reverse sampling sample, L CE (P mix ,y normal ) represents the category prediction value P mix With the class label value y normal The error function and L CE (P mix ,y normal )=-y normal LqCy mix , L CE (P mix ,y reverse ) represents the category prediction value P mix With the class label value y reverse The error function and L CE (P mix ,y reverse )=-y reverse LqCy mix ; α1 represents the weight of the model loss function and i epoch Indicates the number of iterations of the current iteration training, n epoch Indicates the total number of iterations of training.

[0103] After the model loss value is calculated according to formula (2) (forward propagation is completed), the gradient corresponding to each model parameter in the data classification model is calculated according to the model loss value, and the model parameters of the data classification model are updated according to the gradient back propagation to perform model optimization to complete the current iterative training. It should be noted that in this embodiment, the conventional method of using parameter gradients to update parameters in the field of machine learning technology can be used to optimize the model. For example, the gradient descent method (Gradient Descend) can be used to back propagate and update the model parameters in the data classification model according to the calculated gradient of the model parameters. For the sake of simplicity, the working principle and specific process of the above parameter updating method will not be described in detail here.

[0104] As can be seen from the foregoing, the classifier in this embodiment can adopt a conventional classification model in the field of machine learning technology, so this classification model can obtain the prediction probability of each data category corresponding to the input data according to the data features of the input data, and then encode each prediction probability to obtain the category prediction value of the input data, that is, the category prediction value P output by the classifier according to the feature fusion result. mix An example: If the sample categories include A, B, and C, and the predicted probabilities of A, B, and C corresponding to a certain input data are 0.8, 0.1, and 0.1, respectively, then the category prediction value P output by the classifier is mix It can be a one-dimensional vector [1 0 0]. It should be noted that although the present invention only provides a method for obtaining a category prediction value P according to the prediction probability mix However, those skilled in the art can understand that the protection scope of the present invention is not limited to this specific encoding method. Those skilled in the art can adopt other encoding methods to encode the prediction probability according to actual needs, and changes or replacements to the encoding method should fall within the protection scope of the present invention.

[0105] Step 13: Determine whether the iteration stop condition is met. If the iteration stop condition is met, stop training. If the iteration stop condition is not met, perform the next iteration training, that is, go to step 11 and repeat steps 11-13.

[0106] In this embodiment, the iteration stop condition may be that the calculation result (model loss value) of the model loss function L is less than a preset value, or the number of iterations reaches a preset number, such as 50. Those skilled in the art may flexibly set the specific content of the iteration stop condition according to actual needs, and the change or replacement of the iteration stop condition falls within the protection scope of the present invention.

[0107] From the above analysis, it can be seen that by reverse sampling the training samples and optimizing the model according to the characteristics of the reverse sampling samples, the model's classification learning ability for small category samples in the unbalanced training samples can be improved. By randomly sampling the training samples and optimizing the model according to the characteristics of the randomly sampled samples, the model's classification learning ability for large category samples in the unbalanced training samples can be improved. In order to further improve the model's classification learning ability for each category of samples in the unbalanced training samples, after random sampling and reverse sampling, the sampled random sampling samples and reverse sampling samples can be expanded respectively to increase the number of samples of each category, and then subsequent model optimization and other steps can be performed. Specifically, in one implementation, before executing step 12, the following step 120 can be performed first.

[0108] Step 120: Perform data enhancement processing on the random sampling samples and the reverse sampling samples respectively, and then input the data enhanced random sampling samples and reverse sampling samples into the classification data model, so that the feature extraction module in the classification data model can extract the features of these samples, and perform feature fusion on the random sampling samples and the reverse sampling samples.

[0109] It should be noted that, in this embodiment, a conventional data enhancement method in the field of data processing technology can be used to enhance the data of random sample samples and reverse sample samples. For example, if the sample is an image sample, the data enhancement method includes but is not limited to: image cropping, scaling, flipping and splicing. For the sake of brevity, the specific principles and working process of the data enhancement method will not be described in detail here.

[0110] Further, from the above analysis, it can be known that when training the data classification model, the main feature extraction unit can be configured to extract the features of the random sampling samples alone, and the subsidiary feature extraction unit can be configured to extract the features of the reverse sampling samples alone, so that the feature fusion module can perform feature fusion on the random sampling samples and the reverse sampling samples to complete the subsequent model optimization. Therefore, before executing step 12, the main feature extraction unit can be controlled to extract the sample features of the random sampling samples, and the subsidiary feature extraction unit can be controlled to extract the sample features of the reverse sampling samples, and then the feature fusion module can be controlled to perform feature fusion on the random sampling samples and the reverse sampling samples. Specifically, in one embodiment, after executing step 120, the following steps 121-122 can be executed first, and then step 12 can be executed.

[0111] Step 121: Control the main feature extraction unit to extract sample features of the randomly sampled samples, and control the subsidiary feature extraction unit to extract sample features of the inversely sampled samples.

[0112] Step 122: Control the feature fusion module to obtain the feature fusion weight and perform feature fusion on the sample features output by the main feature extraction unit and the auxiliary feature extraction unit according to the method shown in the following formula (3):

[0113] f mix_1 =α2f normal +(1-α2)f reverse (3)

[0114] The meanings of the parameters in formula (3) are as follows:

[0115] f mix_1 represents the feature fusion result of random sampling samples and reverse sampling samples, f normal Represents the sample features output by the main feature extraction unit, fr everse represents the sample features output by the subsidiary feature extraction unit, α2 represents the feature fusion weight and i epoch Indicates the number of iterations of the current iteration training, n epoch Indicates the total number of iterations of training.

[0116] Through the above steps, the model training of the data classification model can be completed, so that the trained data classification model can accurately classify the data to be classified. When using the trained data classification model for data classification, since the data to be classified is no longer randomly sampled and reversely sampled, but the data to be classified is directly input into the data classification model, there is no need to control the main feature extraction unit to extract the sample features of the randomly sampled samples, and control the auxiliary feature extraction unit to extract the sample features of the reversely sampled samples. At this time, the main feature extraction unit and the auxiliary feature extraction unit can be controlled to extract the data features of the data to be classified respectively, and then the feature fusion module is controlled to perform feature fusion on the data features of the data to be classified output by the main feature extraction unit and the auxiliary feature extraction unit. Specifically, in one embodiment, step S102 may include the following steps: S1021-step S1022.

[0117] Step S1021: Control the main feature extraction unit and the subsidiary feature extraction unit to respectively extract data features of the data to be classified.

[0118] Step S1022: Control the feature fusion module to perform feature fusion on the data features of the data to be classified output by the main feature extraction unit and the auxiliary feature extraction unit according to the method shown in the following formula (4):

[0119] f mix_2 =0.5×f re_1 +0.5×f re_2 (4)

[0120] The meanings of the parameters in formula (4) are as follows:

[0121] f mix_2 represents the feature fusion result of the data to be classified (the result of feature fusion of the data features of the data to be classified output by the main feature extraction unit and the auxiliary feature extraction unit), f re_1 represents the data features of the data to be classified output by the main feature extraction unit, f re_2 Represents the data features of the data to be classified output by the subsidiary feature extraction unit.

[0122] It should be pointed out that although the various steps in the above embodiments are described in a specific order, those skilled in the art can understand that in order to achieve the effects of the present invention, different steps do not have to be performed in such an order. They can be performed simultaneously (in parallel) or in other orders. These changes are within the scope of protection of the present invention.

[0123] Furthermore, the present invention also provides a data classification device.

[0124] See attached Figure 2 , Figure 2 FIG. 1 is a main structural block diagram of a data classification device according to an embodiment of the present invention. Figure 2 As shown, the data classification device in the embodiment of the present invention mainly includes a data acquisition module 11 and a data classification module 12. In some embodiments, the data acquisition module 11 can be configured to acquire data to be classified. The data classification module 12 can be configured to classify the data to be classified using a preset data classification model to obtain the data category of the data to be classified. Among them, the preset data classification model can be trained based on the feature fusion results of the samples obtained by random sampling and inverse sampling of the training samples, and the number of samples of a part of the categories in the training samples is much smaller than the number of samples of other categories. In one embodiment, the description of the specific implementation function can be referred to the description of steps S101-step S102.

[0125] In one embodiment, the preset data classification model may include a data input module, a feature extraction module, a feature fusion module and a classifier. In this embodiment, the feature extraction module may include a plurality of feature extraction submodules connected in sequence and the first feature extraction submodule is connected to the data input module, and the last feature extraction submodule is connected to the feature fusion module; the last feature extraction submodule may include a main feature extraction unit and an auxiliary feature extraction unit with the same structure. The feature extraction module may be configured to extract data features of the input data. The feature fusion module may be configured to perform feature fusion on the data features output by the main feature extraction unit and the auxiliary feature extraction unit to obtain a feature fusion result. The classifier may be configured to perform data classification according to the feature fusion result. In one embodiment, the description of the specific implementation function may refer to step S102.

[0126] In one embodiment, the data classification device may further include a model training module. In this embodiment, the model training module may include a data sampling submodule, a model optimization submodule, and a training stop judgment submodule. The data sampling submodule may be configured to perform random sampling and reverse sampling on the training samples respectively to obtain random sampling samples and reverse sampling samples; the model optimization submodule may be configured to calculate the model loss value of the data classification model using the model loss function L shown in formula (2) and according to the feature fusion results of the random sampling samples and reverse sampling samples output by the feature fusion module; according to the model loss value, the gradient corresponding to each model parameter in the data classification model is calculated, and the model parameters of the data classification model are updated according to the gradient back propagation to perform model optimization to complete the current iterative training; the training stop judgment submodule may be configured to determine whether the iterative stop condition is met after completing one iterative training; if so, stop the training; if not, perform the next iterative training. In one embodiment, the description of the specific implementation function can be found in steps 11 to 13.

[0127] In one embodiment, the data sampling submodule can be further configured to perform the following operations: obtain the class weights corresponding to each class of training samples according to the method shown in formula (1); obtain the sampling probability of each class of training samples according to the class weights, the sampling probability is positively correlated with the class weights and the sum of the sampling probabilities of all class training samples is 1; perform reverse sampling on the training samples according to the sampling probability. In one embodiment, the description of the specific implementation function can be found in step 11.

[0128] In one embodiment, the model optimization submodule can be further configured to: perform data enhancement processing on the random sampling samples and the reverse sampling samples respectively, so as to optimize the data classification model using the random sampling samples and the reverse sampling samples after the data enhancement processing. In one embodiment, the description of the specific implementation function can be referred to in step 120.

[0129] In one embodiment, the model optimization submodule can be further configured to perform the following operations: control the main feature extraction unit to extract sample features of the randomly sampled samples, and control the subsidiary feature extraction unit to extract sample features of the inversely sampled samples; control the feature fusion module to obtain feature fusion weights and perform feature fusion on the sample features output by the main feature extraction unit and the subsidiary feature extraction unit according to the method shown in formula (3). In one embodiment, the description of the specific implementation function can be found in step 121-step 122.

[0130] In one embodiment, the data classification module 12 may be further configured to perform the following operations: control the main feature extraction unit and the subsidiary feature extraction unit to extract data features of the data to be classified respectively; control the feature fusion module to perform feature fusion on the data features of the data to be classified output by the main feature extraction unit and the subsidiary feature extraction unit according to the method shown in formula (4). In one embodiment, the description of the specific implementation function can be referred to the description of step S102.

[0131] The data classification device is used to perform Figure 1 The data classification method embodiment shown in the figure has similar technical principles, technical problems solved and technical effects produced. Technical personnel in this technical field can clearly understand that for the convenience and conciseness of description, the specific working process and related instructions of the data classification device can refer to the contents described in the embodiment of the data classification method, which will not be repeated here.

[0132] It is understood by those skilled in the art that the present invention implements all or part of the processes in the method of the above embodiment, and can also be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of each of the above method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device, medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory, random access memory, electric carrier signal, telecommunication signal and software distribution medium that can carry the computer program code. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0133] Furthermore, the present invention also provides a computer-readable storage medium. In a computer-readable storage medium embodiment according to the present invention, the computer-readable storage medium can be configured to store a program for executing the data classification method of the above method embodiment, and the program can be loaded and run by the processor to implement the above data classification method. For ease of explanation, only the parts related to the embodiment of the present invention are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present invention. The computer-readable storage medium can be a storage device formed by various electronic devices. Optionally, the computer-readable storage medium in the embodiment of the present invention is a non-temporary computer-readable storage medium.

[0134] Furthermore, the present invention also provides a control device. In an embodiment of a control device according to the present invention, the control device includes a processor and a storage device, the storage device can be configured to store a program for executing the data classification method of the above method embodiment, and the processor can be configured to execute the program in the storage device, which includes but is not limited to the program for executing the data classification method of the above method embodiment. For ease of explanation, only the parts related to the embodiment of the present invention are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present invention. The control device can be a control device device formed by various electronic devices.

[0135] Further, it should be understood that since the setting of each module is only for illustrating the functional units of the system of the present invention, the physical devices corresponding to these modules can be the processor itself, or a part of the software in the processor, a part of the hardware, or a part of the combination of software and hardware. Therefore, the number of each module in the figure is only schematic.

[0136] Those skilled in the art will appreciate that the modules in the system may be adaptively split or merged. Such splitting or merging of specific modules will not cause the technical solution to deviate from the principle of the present invention, and therefore, the technical solutions after splitting or merging will fall within the protection scope of the present invention.

[0137] So far, the technical solution of the present invention has been described in conjunction with an embodiment shown in the accompanying drawings, but it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.

Claims

1. A data classification method, applied to image classification, characterized in that: The method comprises: Acquire data to be classified, wherein the data to be classified is an image; Classifying the data to be classified using a preset data classification model to obtain data categories of the data to be classified; The preset data classification model is obtained by training based on the feature fusion results of samples obtained by random sampling and inverse sampling of training samples, the number of samples of a part of categories in the training samples is much smaller than the number of samples of other categories, and the training samples are images; The preset data classification model includes a data input module, a feature extraction module, a feature fusion module and a classifier; the feature extraction module includes a plurality of feature extraction submodules connected in sequence, and the first feature extraction submodule is connected to the data input module, and the last feature extraction submodule is connected to the feature fusion module; the last feature extraction submodule includes a main feature extraction unit and an auxiliary feature extraction unit with the same structure; The feature extraction module is configured to extract data features of input data; The feature fusion module is configured to perform feature fusion on the data features output by the main feature extraction unit and the auxiliary feature extraction unit to obtain a feature fusion result; The classifier is configured to perform data classification according to the feature fusion result.

2. The data classification method according to claim 1, characterized in that: The preset data classification model is trained by the following method: Perform random sampling and reverse sampling on the training samples respectively to obtain random sampling samples and reverse sampling samples; Using the model loss function L shown in the following formula and according to the feature fusion results of the random sampling samples and the inverse sampling samples output by the feature fusion module, the model loss value of the data classification model is calculated; L=α1L CE (P mix ,y normal )+(1-α1)L CE (P mix ,y reverse ) Among them, the P mix represents the category prediction value output by the classifier for data classification based on the feature fusion result, and the y normal represents the class label value of the randomly sampled sample, the y reverse represents the category label value of the reverse sampling sample, and the L CE (P mix ,y normal ) represents the category prediction value P mix With the class label value y normal The error function and L CE (P mix ,y normal )=-y normal LqCy mix , the L CE (P mix ,y reverse ) represents the category prediction value P mix With the class label value y reverse The error function and L CE (P mix ,y reverse )=-y reverse LqCy mix ; The α1 represents the weight of the model loss function and The i epoch Indicates the number of iterations of the current iteration training, the n epoch Represents the total number of iterations of training; According to the model loss value, the gradient corresponding to each model parameter in the data classification model is calculated, and the model parameters of the data classification model are updated according to the gradient back propagation to perform model optimization to complete the current iterative training; Determine whether the iteration stop condition is met; If yes, stop training; if no, execute the next iteration training.

3. The data classification method according to claim 2, characterized in that: The steps of "de-sampling training samples" specifically include: Obtain the category weights corresponding to each type of training samples respectively according to the method shown in the following formula; Among them, the w i represents the category weight of the i-th category training sample, and the n i represents the number of training samples of the i-th category, and the n max Indicates the number of training samples of the largest category; According to the category weight, the sampling probability corresponding to each category of training samples is obtained; the sampling probability is positively correlated with the category weight and the sum of the sampling probabilities of all categories of training samples is 1; De-sampling the training samples according to the sampling probability; and / or, Before the step of "calculating the model loss value of the data classification model", the method further includes: Data enhancement processing is performed on the random sampling samples and the inverse sampling samples respectively, so as to optimize the data classification model by using the random sampling samples and the inverse sampling samples after the data enhancement processing.

4. The data classification method according to claim 2, characterized in that: Before the step of "calculating the model loss value of the data classification model", the method further includes: Controlling the main feature extraction unit to extract sample features of the randomly sampled samples, and controlling the subsidiary feature extraction unit to extract sample features of the inversely sampled samples; The feature fusion module is controlled to obtain the feature fusion weight and perform feature fusion on the sample features output by the main feature extraction unit and the subsidiary feature extraction unit according to the method shown in the following formula: f mix_1 =α2f normal +(1-α2)f reverse Among them, the f mix_1 represents the feature fusion result of the random sampling sample and the inverse sampling sample, and the f normal represents the sample features output by the main feature extraction unit, and the f reverse represents the sample feature output by the subsidiary feature extraction unit, α2 represents the feature fusion weight and 5. The data classification method according to claim 1, characterized in that: Before the step of "classifying the data to be classified using a preset data classification model", the method further includes: Controlling the main feature extraction unit and the subsidiary feature extraction unit to respectively extract data features of the data to be classified; The feature fusion module is controlled to perform feature fusion on the data features of the data to be classified output by the main feature extraction unit and the subsidiary feature extraction unit according to the method shown in the following formula: f mix_2 =0.5×f re_1 +0.5×f re_2 Among them, the f mix_2 represents the feature fusion result of the data to be classified, and the f re_1 represents the data feature of the data to be classified output by the main feature extraction unit, and the f re_2 Represents the data features of the data to be classified output by the subsidiary feature extraction unit.

6. A data classification device, applied to image classification, characterized in that: The device comprises: A data acquisition module, configured to acquire data to be classified, wherein the data to be classified is an image; A data classification module, which is configured to classify the data to be classified using a preset data classification model to obtain a data category of the data to be classified; The preset data classification model is obtained by training based on the feature fusion results of samples obtained by random sampling and inverse sampling of training samples, the number of samples of a part of categories in the training samples is much smaller than the number of samples of other categories, and the training samples are images; The preset data classification model includes a data input module, a feature extraction module, a feature fusion module and a classifier; the feature extraction module includes a plurality of feature extraction submodules connected in sequence, and the first feature extraction submodule is connected to the data input module, and the last feature extraction submodule is connected to the feature fusion module; the last feature extraction submodule includes a main feature extraction unit and an auxiliary feature extraction unit with the same structure; The feature extraction module is configured to extract data features of input data; The feature fusion module is configured to perform feature fusion on the data features output by the main feature extraction unit and the auxiliary feature extraction unit to obtain a feature fusion result; The classifier is configured to perform data classification according to the feature fusion result.

7. The data classification device according to claim 6, characterized in that: The device also includes a model training module, which includes a data sampling submodule, a model optimization submodule and a training stop judgment submodule; The data sampling submodule is configured to perform random sampling and reverse sampling on the training samples respectively to obtain random sampling samples and reverse sampling samples; The model optimization submodule is configured to calculate the model loss value of the data classification model according to the feature fusion result of the random sampling sample and the inverse sampling sample output by the feature fusion module by using the model loss function L shown in the following formula; L=α1L CE (P mix ,y normal )+(1-α1)L CE (P mix ,y reverse ) Among them, the P mix represents the category prediction value output by the classifier for data classification based on the feature fusion result, and the y normal represents the class label value of the randomly sampled sample, the y reverse represents the category label value of the reverse sampling sample, and the L CE (P mix ,y normal ) represents the category prediction value P mix With the class label value y normal The error function and L CE (P mix ,y normal )=-y normal LqCy mix , the L CE (P mix ,y reverse ) represents the category prediction value P mix With the class label value y reverse The error function and L CE (P mix ,y reverse )=-y reverse LqCy mix ; The α1 represents the weight of the model loss function and The i epoch Indicates the number of iterations of the current iteration training, the n epoch Represents the total number of iterations of training; According to the model loss value, the gradient corresponding to each model parameter in the data classification model is calculated, and the model parameters of the data classification model are updated according to the gradient back propagation to perform model optimization to complete the current iterative training; The training stop judgment submodule is configured to judge whether the iteration stop condition is met after completing one iteration training; if so, stop the training; if not, perform the next iteration training.

8. The data classification device according to claim 7, characterized in that: The data sampling submodule is further configured to perform the following operations: Obtain the category weights corresponding to each type of training samples respectively according to the method shown in the following formula; Among them, the w i represents the category weight of the i-th category training sample, and the n i represents the number of training samples of the i-th category, and the n max Indicates the number of training samples of the largest category; According to the category weight, the sampling probability corresponding to each category of training samples is obtained; the sampling probability is positively correlated with the category weight and the sum of the sampling probabilities of all categories of training samples is 1; De-sampling the training samples according to the sampling probability; and / or, The model optimization submodule is further configured to perform data enhancement processing on the random sampling samples and the inverse sampling samples respectively, so as to optimize the data classification model using the random sampling samples and the inverse sampling samples after the data enhancement processing.

9. The data classification device according to claim 7, characterized in that: The model optimization submodule is further configured to perform the following operations: Controlling the main feature extraction unit to extract sample features of the randomly sampled samples, and controlling the subsidiary feature extraction unit to extract sample features of the inversely sampled samples; The feature fusion module is controlled to obtain the feature fusion weight and perform feature fusion on the sample features output by the main feature extraction unit and the subsidiary feature extraction unit according to the method shown in the following formula: f mix_1 =α2f normal +(1-α2)f reverse Among them, the f mix_1 represents the feature fusion result of the random sampling sample and the inverse sampling sample, and the f normal represents the sample features output by the main feature extraction unit, and the f reverse represents the sample feature output by the subsidiary feature extraction unit, α2 represents the feature fusion weight and 10. The data classification device according to claim 6, characterized in that: The data classification module is further configured to perform the following operations: Controlling the main feature extraction unit and the subsidiary feature extraction unit to respectively extract data features of the data to be classified; The feature fusion module is controlled to perform feature fusion on the data features of the data to be classified output by the main feature extraction unit and the subsidiary feature extraction unit according to the method shown in the following formula: f mix_2 =0.5×f re_1 +0.5×f re_2 Among them, the f mix_2 represents the feature fusion result of the data to be classified, and the f re_1 represents the data feature of the data to be classified output by the main feature extraction unit, and the f re_2 Represents the data features of the data to be classified output by the subsidiary feature extraction unit.

11. A control device, comprising a processor and a storage device, wherein the storage device is suitable for storing a plurality of program codes, characterized in that: The program code is suitable for being loaded and executed by the processor to execute the data classification method according to any one of claims 1 to 5.

12. A computer-readable storage medium storing a plurality of program codes, characterized in that: The program code is suitable for being loaded and run by a processor to execute the data classification method according to any one of claims 1 to 5.