A global optimization model for imbalanced data classification based on CGLOW
By modifying the Z-prior distribution of the GLOW model and using a conditionally controlled CGLOW generation model, combined with ResNet for global optimization, the classification accuracy problem caused by imbalanced data was solved, higher quality samples were generated, and the classification accuracy was improved.
Patent Information
- Application Number
- CN202311727382.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-14
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2043-12-14
AI Technical Summary
Existing deep learning classification models suffer from poor classification results when faced with imbalanced data, as data is scarce for certain categories, thus affecting the overall performance of the model.
By modifying the Z-prior distribution of the GLOW model, using a conditionally controlled CGLOW model, and combining it with ResNet as a classifier, global optimization is performed to generate more samples and optimize the model, thereby improving classification accuracy.
Under imbalanced data conditions, higher quality samples are generated, improving classification accuracy and reducing the tedious work of classifying and generating models in stages in traditional methods, achieving end-to-end optimization.
Smart Images

Figure CN117726863B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of imbalanced image data classification, and in particular to an imbalanced data classification model based on CGLOW global optimization. Background Art
[0002] In recent years, with the increasing speed of industrial integration, deep learning has been applied more and more widely in industry, among which data-driven classification models have been widely used in actual production and manufacturing. However, most classification models are based on balanced data for classification tasks. In actual image classification scenarios, there is a shortage of data in certain classes, which leads to data imbalance between classes, which greatly affects the classification effect of the model. Therefore, research on imbalanced data classification is of great value. In order to solve this practical problem, researchers have conducted in-depth research. In general, the solutions to data imbalance can be divided into three categories: data processing methods, model building methods, and training optimization methods.
[0003] Therefore, a global optimization model for imbalanced data classification based on CGLOW is provided. Summary of the invention
[0004] The purpose of the present invention is to provide an imbalanced data classification model based on CGLOW global optimization, which generates more samples to supplement the imbalanced categories by training the generative model with scarce data classes, and proposes a conditionally controlled CGLOW (reversible convolution generative flow model). On this basis, a set of global optimization model frameworks is established, and resnet is used as the final classifier. The final classification loss is used to guide CGLOW to generate higher quality samples. During the entire training process, CGLOW and resnet are optimized simultaneously, which further improves the classification accuracy of imbalanced data and provides an end-to-end solution for imbalanced data classification.
[0005] To achieve the above object, the present invention provides an unbalanced data classification model based on CGLOW global optimization, comprising the following steps:
[0006] S1: Modify the prior distribution of Z in the GLOW model to obtain a CGLOW model with conditional control;
[0007] S2: Perform a simple pre-augmentation on the labeled imbalanced dataset, use the forward CGLOW model as the encoder, input the samples of the preprocessed dataset component batches into the encoder for calculation, and obtain the encoder's loss function value, and the mean and variance vectors of n categories;
[0008] S3: Based on the loss function of the encoder, the gradient information is calculated using the gradient descent algorithm. When the gradient is back-propagated, the internal parameters of the encoder are updated to optimize CGLOW.
[0009] S4: Resample using the means and variances of different categories to obtain the latent variable z corresponding to each category. Use the inverse CGLOW model as a decoder, input the latent variable z into the decoder, and obtain generated samples with a balanced number of categories.
[0010] S5: Input the generated samples into the classifier resnet for classification, obtain the classification results, and calculate the loss function of the classifier. When the gradient is back-propagated, the gradient information is transmitted from the classifier resnet to the decoder, thereby completing the update of the classifier parameters and the decoder parameters, realizing the first optimization of the classifier and the second optimization of CGLOW;
[0011] S6: When the loss function value of CGLOW no longer decreases, the classification model training is completed.
[0012] Preferably, in step S1, the specific process of modifying the estimation of the prior distribution part of Z of the encoder in the GLOW model is as follows:
[0013] The original multidimensional standard normal distribution in GLOW is modified, and the modified prior distribution probability density function of Z is as follows:
[0014]
[0015] Where l is a discrete variable representing category information, μ is the mean, and σ is the variance.
[0016] Preferably, in step S2, the method of pre-augmenting the labeled imbalanced data set includes normalization, translation, scaling and adding noise.
[0017] Preferably, in step S2, the specific process of calculating the loss function of the encoder is as follows:
[0018] The loss function of the original model is as follows:
[0019]
[0020] Using maximum likelihood to fit and modify the prior distribution of Z, the loss_logP obtained is:
[0021]
[0022] The loss function of the encoder is obtained as follows:
[0023] lossMLE=loss_logdet+loss_logP
[0024] In the above formula, loss_logdet is the original loss function, and loss_logP is the newly added loss function.
[0025] Preferably, in step S5, the process of calculating and generating the sample classification loss function is as follows:
[0026] Generate samples and input them into resnet for classification, and calculate the classification loss of this batch. The formula for the cross entropy loss calculated in this process is as follows:
[0027]
[0028] In the above formula, n represents the number of samples in a batch, y i is the one-hot encoded vector of each sample, is the output vector of each sample corresponding to the model output.
[0029] Therefore, the present invention adopts a global optimization imbalanced data classification model based on CGLOW using the above method, which has the following advantages:
[0030] (1) In the present invention, in the CGLOW model, the diversity and accuracy of the generated samples are retained while limiting the latent variables to generate samples of a specified category, making the generation controllable;
[0031] (2) In the present invention, the classification loss is used to guide the generation process, which filters out noise samples and generates samples with higher quality. At the same time, the classification accuracy is also improved. This global training framework eliminates the tedious work of traditionally requiring the coordination of the classification model and the generation model.
[0032] (3) In the present invention, a global optimization architecture is used to overcome the impact of sample imbalance. Various types of balanced sample data are generated through a generation method. The classification loss participates in the optimization of the generation process. Classification and generation are optimized together. The classification loss guides the generation of higher quality samples. Higher quality samples enable classification to achieve better accuracy.
[0033] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 A CGLOW model structure diagram in an imbalanced data classification model based on CGLOW global optimization of the present invention;
[0035] Figure 2A multi-scale stream module in an imbalanced data classification model based on CGLOW global optimization of the present invention;
[0036] Figure 3 It is an additive coupling layer in an unbalanced data classification model based on CGLOW global optimization of the present invention;
[0037] Figure 4 A schematic diagram of a model generation process in an imbalanced data classification model based on CGLOW global optimization of the present invention;
[0038] Figure 5 Generate a MNIST data sample graph in an unbalanced data classification model based on CGLOW global optimization of the present invention;
[0039] Figure 6 Generate a FASIONMNIST data sample graph in a CGLOW-based global optimization imbalanced data classification model of the present invention;
[0040] Figure 7 Generate a CIFAR10 data set sample graph in a CGLOW-based global optimization imbalanced data classification model of the present invention;
[0041] Figure 8 It is the classification confusion matrix obtained on the test set without any processing on the UOC dataset, with the imbalance ratio of the training set set set to 50:1;
[0042] Fig. 9 It is the classification confusion matrix obtained on the UOC test set under the same circumstances using the method proposed by the present invention;
[0043] Fig.10 A model framework based on CGLOW global optimization in an imbalanced data classification model based on CGLOW of the present invention;
[0044] Fig.11 This is the classification confusion matrix obtained on the test set with the imbalance ratio of the training set set to 50:1 on the SEU dataset;
[0045] Fig.12 It is the classification confusion matrix obtained on the SEU test set under the same circumstances using the method proposed in the present invention. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0047] Example
[0048] like Figure 1-3 The present invention provides a global optimization imbalanced data classification model based on CGLOW, comprising the following steps:
[0049] S1: Modify the estimation of the prior distribution of Z in the GLOW model to obtain a CGLOW model with conditional control;
[0050] The specific process of modifying the estimation of the prior distribution part of Z of the encoder in the GLOW model is as follows:
[0051] The original multidimensional standard normal distribution in GLOW is modified, and the modified prior distribution probability density function of Z is as follows:
[0052]
[0053] Where l is a discrete variable, indicating category information, μ is the mean, and σ is the variance;
[0054] S2: Preprocess the labeled imbalanced dataset, including normalization, translation, scaling and adding noise. Use the forward CGLOW model as the encoder, input the samples of the preprocessed dataset into the encoder for calculation, and obtain the encoder's loss function value and the mean and variance vectors of n categories.
[0055] The specific process of calculating the encoder's loss function value is as follows:
[0056] The loss function of the original model is as follows:
[0057]
[0058] Use maximum likelihood to fit and modify the prior distribution of Z, calculate the newly added loss function, and the loss_logP obtained is:
[0059]
[0060] The loss function of the encoder is obtained as follows:
[0061] loss MLE=loss_logdet+loss_logP
[0062] In the above formula, loss_logdet is the original loss function, and loss_logP is the newly added loss function.
[0063] S3: Based on the loss function of the encoder, the gradient information is calculated using the gradient descent algorithm, and the internal parameters of the encoder are updated using the gradient information to optimize CGLOW.
[0064] S4: Resample the means and variances of different categories to obtain the latent variable z corresponding to each category. Use the inverse CGLOW model as a decoder, input the latent variable z into the decoder, and obtain the generated samples with balanced number of categories.
[0065] S5: Input the generated samples into the classifier resnet for classification, obtain the classification results, and calculate the loss function of the classifier. When the gradient is back-propagated, the gradient information is transmitted from the classifier resnet to the decoder, thereby completing the update of the classifier parameters and the decoder parameters, realizing the first optimization of the classifier and the second optimization of CGLOW;
[0066] The process of calculating the generated sample classification loss function is as follows:
[0067] Generate samples and input them into resnet for classification, and calculate the classification loss of this batch. The formula for the cross entropy loss calculated in this process is as follows:
[0068]
[0069] In the above formula, n represents the number of samples in a batch, y i is the one-hot encoded vector of each sample, is the output vector of each sample corresponding to the model output.
[0070] S6: When the loss function value of CGLOW no longer decreases, the classification model training is completed.
[0071] Because the original intention of the traditional glow generative model is to use a probability model to map a known probability distribution (prior distribution) to the distribution of given data, so as to achieve the purpose of generating data, but neural networks can only fit functions, not probability distributions. The unified representation of the probability density function of discrete random variables and continuous random variables is:
[0072]
[0073] Among them, k is the number of all random variables, P iis the probability value of the occurrence of the i-th random variable, δ(x) is the impulse function, of course, if x i is a continuous random variable, k tends to infinity, and it is clearer to use integral here. The formula is as follows:
[0074] P (x) =∫P (x') δ(x-x')dx' (2)
[0075] Where P (x ' ) is the probability density function of the continuous random variable x'. The above formula actually replaces the probability density function of x' with a variable to obtain the probability density function of x, except that x'=x here, so P (x) =P (x') . Back to the original intention of generating models, but neural networks can only fit functions. Suppose there is a function g (z) = x', and requires that this g (z) Reversible, that is, z = f(x'), This allows sampling of the prior distribution z through After obtaining the generated data x, the above formula (2) can be changed as follows:
[0076] P (x) =∫P (z) δ(xg (z) )dz (3)
[0077] We choose the prior distribution of z as the multidimensional standard normal distribution, the formula is as follows:
[0078]
[0079] Formula (3) actually transforms the probability density function of z into the probability density function of the real data x through variable substitution through integration. The formula is as follows:
[0080]
[0081] Note that variable substitution in the probability density function requires computing the determinant of the Jacobian matrix D is the dimension of the random variable. Formula (3) is the general framework of the flow type model. Note that f is a hypothetical function fitted by a neural network, so it has parameters. The f fitted by the neural network is required to be reversible and the corresponding Jacobian determinant is easy to calculate. Since the objective function is presented in the form of probability, the maximum likelihood estimation is used for optimization, and it is easy to obtain the objective function to be optimized. The formula is as follows:
[0082] max(logP (x) ) (6)
[0083] The corresponding loss function formula is as follows:
[0084]
[0085] The loss function obtained is the inverse of formula (6). Combined with the above GLOW formula, it is modified to CGLOW and the training process is as follows:
[0086] like Figure 1 As shown in the figure, the encoder module is actually f(x). The forward process of f is equivalent to the encoding process, and the reverse decoding process is actually the generation process. The fitting ability of f depends on the degree of maximum likelihood optimization. In theory, the optimal estimate is reached when the loss function value drops to saturation. In GLOW, the Z output by the encoder is actually the Z calculated at multiple scales. The Z of different scales are not equal in status, so they cannot be directly set to fit a standard normal distribution of the whole. It is unreasonable to force them to be equal. CGLOW assumes the prior distribution of Z of each scale to be a multidimensional conditional normal distribution at different scales, that is, the prior distribution probability density function of Z at each scale is:
[0087]
[0088] Where l is a discrete variable, indicating category information, which controls the mean μ and variance σ of z for each category, and sets the mean and variance vectors equal to the number of categories. As for the mean and variance of each category, the model is fitted. The purpose of this is to make Z of each category finally obey the mean and variance of each category. The maximum likelihood is also used for fitting, and the loss_logP obtained is:
[0089]
[0090] This part corresponds to Figure 1 The dotted box part.
[0091] This gives the total loss function of CGLOW:
[0092] loss MLE =loss_logdet+loss_logP (10)
[0093] In the above formula, loss_logdet is the original loss function, and loss_logP is the newly added loss function.
[0094] Finally, based on CGLOW, we establish Fig.10The global optimization framework shown in the figure, because CGLOW is lossless and reversible, the encoder uses the forward process of CGLOW and the decoder uses the reverse process of CGLOW.
[0095] First, the unbalanced data set with labels is simply expanded by pre-translation, scaling and other pre-augmentation methods, and then input to the encoder for calculation to obtain the mean and variance of n categories. Then, resampling is used to obtain various types of balanced latent variables Z, which are input to the decoder to obtain generated samples. This batch of generated samples is input into resnet for classification, and the classification loss of this generated sample is calculated. The cross entropy loss calculated during the classification process is:
[0096]
[0097] Where n represents the number of samples in a batch, y i is the one-hot encoded vector of each sample, is the output vector of each sample corresponding to the model output.
[0098] Through the loss functions of the encoder and decoder, in the process of gradient back propagation, because the encoder uses the forward CGLOW model and the decoder uses the reverse CGLOW model, and the encoder and decoder always maintain an inverse function relationship, the CGLOW model will be optimized twice. The first is to form a conditional generation control effect on the sample, and the second is that the decoder continues to update and optimize during the gradient back propagation process of the classification loss calculation. Under the guidance of the classification loss, the generated samples with higher classification accuracy are generated.
[0099] In the specific use process, the first step is the calculation process, which normalizes the labeled image data set, performs pre-sample augmentation on these unbalanced samples, and then adds random noise of appropriate intensity. The addition of noise can effectively prevent overfitting and improve the quality of generated images.
[0100] The data is input into the encoder. Under the optimization of the loss function of formula (9), the data of each type of sample is encoded into a latent variable Z that obeys the multidimensional normal distribution of the mean and variance within each class, and the mean and variance vector of the latent variable Z within the class are obtained.
[0101] In the encoder, Z_in first transforms the dimension to make the original image c*h*w, and then increases the dimension along the channel axis to 4c*h / 2*w / 2. This is done to facilitate the use of the convolution layer later, and shuffle and split along the channel axis, and then normalize the data through the normalization operation (actnorm), and then shuffle along the channel axis through the shuffle axis operation to fully mix the information and improve the nonlinear fitting ability of the model. Then, it is split in half along the channel axis to obtain Z1 and Z2. The present invention retains the original additive coupling layer, such as Figure 3 As shown in , it is this structure that makes the transformation from h to z completely reversible, and the changing Jacobian matrix is a triangular matrix, which is convenient for calculating the determinant of the matrix. Then the two separated tensors are spliced along the channel axis to their original size, and this cycle is repeated K times, which is called K flow operations.
[0102] exist Figure 2 The first scale flow module (block) operation is completed in , and then the output Z is divided in half along the channel axis, Z_new is used as the output Z1 of the first scale, and Z_out enters the next flow module (block) operation, and so on, to obtain ZL of the Lth scale. On the one hand, the number of mean and variance vectors is set to be the same as the number of categories, and set as trainable parameters. Each sample uses the unique encoding vector Y of the label to select the mean and variance of the prior distribution of the corresponding encoding vector Z, that is, select from the several mean and variance vectors just set, that is, μ in formula (8) i =Yi@μ,μ is Figure 1 The mu1, mu2…@ in denoted matrix multiplication, and the same is true for σ.
[0103] By calculating formula (8), the Y vector is used to select the mean and variance vector that is unique to the class to which this sample belongs from the n mean and variance vectors to calculate formula (8).
[0104] Then, the reverse CGLOW generation operation is used. In the previous principle section, it has been said that since f is reversible, Figure 1 The encoder output in becomes the input, and the original input becomes the output, just as Figure 4 As shown, the mean and variance of each class obtained from model training are sampled to obtain Z that obeys their respective distributions, which are input into the encoder to obtain generated samples of each category.
[0105] like Fig.10As shown in Figure 1, when a batch of samples is input into CGLOW for training, the mean and variance vectors of each class are obtained, and then the corresponding hidden variables Z that obey their respective normal distributions are obtained by resampling, which are input into the decoder to calculate a batch of balanced generated samples of each class, and then input into resnet for classification. This completes the first round of training, and so on. When the loss of formula (9) drops to saturation, the training is stopped, and the classification effect of the obtained resnet is tested.
[0106] CGLOW is used in combination with resnet. CGLOW modifies the estimation of the prior distribution of Z based on GLOW. In fact, it reduces the amount of calculation on the original basis and achieves the effect of conditional control generation. In order to verify the effect of conditional control generation of CGLOW, experiments were conducted on MNIST and FASION_MNIST. Figure 5 Shown is the experimental result using the MNIST dataset. Figure 6 This is an experiment using the FASION_MNIST dataset. The above are all single-channel black and white image datasets. In order to verify the effect of the model on the three-channel color dataset, the cifar10 dataset is used to train the model. Figure 7 shown.
[0107] In order to verify the classification effect of the entire model on imbalanced data, Figure 8 and Fig. 9 The classification effects before and after using the CGLOW model on UOC imbalance are shown respectively. Fig.11 and Fig.12 The classification effects before and after the proposed model on the SEU imbalanced dataset are shown respectively, and the imbalance ratio is set to 50:1.
[0108] The experimental results show that in the case of data imbalance, the classification accuracy of resnet in the SEU and UOC data sets is only 48% and 31%, while the accuracy of the experimental results combined with the method proposed by the present invention is 92.8% and 98.2%. The classification model based on CGLOW global optimization proposed by the present invention for imbalanced data classification has good classification performance and solves the adverse effects of data imbalance on the classification model.
[0109] Therefore, the present invention adopts an unbalanced data classification model based on global optimization of CGLOW, determines the objective function through a probabilistic method, and takes the maximum value of the objective function as the optimization direction, namely, maximum likelihood estimation, and uses conditional control to generate various types of samples. A global optimization unbalanced classification model framework based on CGLOW is proposed, and the effect of conditional control generation is achieved on the mnist and fasion_mnist datasets, and good classification accuracy is achieved in experiments on the UOC and SEU datasets under unbalanced conditions.
[0110] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that they can still modify or replace the technical solution of the present invention with equivalents, and these modifications or equivalent replacements cannot cause the modified technical solution to deviate from the spirit and scope of the technical solution of the present invention.
Claims
1. A method for imbalanced data classification based on CGLOW global optimization, characterized by: The following steps are involved: S1: Modify the prior distribution of Z in the GLOW model to obtain a CGLOW model with conditional control; The specific process of modifying the estimation of the prior distribution part of Z of the encoder in the GLOW model is as follows: The original multidimensional standard normal distribution in GLOW is modified, and the modified prior distribution probability density function of Z is as follows: Where l is a discrete variable, indicating category information, μ is the mean, and σ is the variance; S2: Perform simple pre-augmentation on the labeled unbalanced image dataset. The pre-augmentation methods include normalization, translation, scaling, and adding noise. Use the forward CGLOW model as the encoder, input the samples of the preprocessed dataset into batches for calculation, and obtain the encoder's loss function value and the mean and variance vectors of n categories. The specific process of calculating the encoder's loss function is as follows: The loss function of the original model is as follows: Using maximum likelihood to fit and modify the prior distribution of Z, the loss_logP obtained is: The loss function of the encoder is obtained as follows: loss MLE =loss_logdet+loss_logP In the above formula, loss_logdet is the original loss function, and loss_logP is the newly added loss function; S3: Based on the loss function of the encoder, the gradient information is calculated using the gradient descent algorithm. When the gradient is back-propagated, the internal parameters of the encoder are updated to optimize CGLOW. S4: Resample using the means and variances of different categories to obtain the latent variable z corresponding to each category. Use the inverse CGLOW model as a decoder, input the latent variable z into the decoder, and obtain generated samples with a balanced number of categories. S5: Input the generated samples into the classifier resnet for classification, obtain the classification results, and calculate the loss function of the classifier. When the gradient is back-propagated, the gradient information is transmitted from the classifier resnet to the decoder, thereby completing the update of the classifier parameters and the decoder parameters, realizing the first optimization of the classifier and the second optimization of CGLOW; The process of calculating the generated sample classification loss function is as follows: Generate samples and input them into resnet for classification, and calculate the classification loss of this batch. The formula for the cross entropy loss calculated in this process is as follows: In the above formula, n represents the number of samples in a batch, y i is the one-hot encoded vector of each sample, is the output vector of each sample corresponding to the model output; S6: When the loss function value of CGLOW no longer decreases, the classification model training is completed.
Citation Information
Patent Citations
Report encoding model generation method and system based on Glow network and equipment
CN111613287A
Mechanical equipment unsupervised fault diagnosis method based on adversarial flow model
CN113935406A
Drug hidden target spot prediction system and method based on flow generation model
CN114360635A
Unbalanced hyperspectral image classification method
CN114882368A
Intelligent diagnosis method for vibration signal of rotating equipment under unbalanced data
CN114897022A
