Construction method of robust image classification model

By using a generative model in the image classification model for image purification, combining multiple loss functions and attack strategies, the problem of noise processing difficulties in adversarial training is solved, and the image classification accuracy and model robustness are improved.

CN119091224AInactive Publication Date: 2024-12-06HENAN UNIVERSITY OF TECHNOLOGY
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411265502.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-10
Publication Date
2024-12-06
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, it is difficult to process adversarial noise signals during adversarial training, resulting in low accuracy of classification results of image classification models in the image purification processing part.

Method used

The generative model is used as the image purification module, and the generative model is updated by minimizing the differential loss function between the purified image and the original image and the total loss function between the classification results of the purified image and the real label. Jump connections, layer normalization, Leaky Relu activation function and Dropout submodule, use a variety of gradient attack methods and attack intensity to generate adversarial samples for training.

Benefits of technology

The accuracy of the classification results of the image classification model in the image purification processing part is improved, the processing ability to combat sample attack noise is enhanced, and the robustness and generalization ability of the model are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119091224A_ABST
    Figure CN119091224A_ABST
Patent Text Reader

Abstract

The invention belongs to the field of deep neural network classification prediction, and particularly relates to a method for constructing a robust image classification model, which comprises the following steps: taking a trained generative model as an image purification module of the image classification model, and enabling an image processed by the image purification module to pass through a classification module to obtain a classification result; the training of the generative model comprises the following steps: 1) inputting an original image sample or an adversarial image sample in a training set into the generative model to obtain a purified image; processing the obtained purified image through a set attack model, and inputting the processed purified image into the classification module to obtain a classification result; (2) updating the generative model by taking a total loss function as a target, wherein the total loss function is obtained by minimizing a loss function corresponding to a difference between a classification result of the step (1) and a real classification label, wherein the loss function superposition serves as a regularization item and corresponds to a loss function corresponding to a difference between an image processed by an image purification module and an original image sample; and iterating the steps 1)-2) until an iteration stop condition is met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of deep neural network classification model defense, and specifically relates to a method for constructing a robust image classification model. Background Art

[0002] As a widely used method in the field of artificial intelligence, deep learning has shown excellent performance in solving various complex problems. Its powerful feature learning ability continues to promote the implementation of intelligent scene applications, covering multiple fields such as image recognition, speech recognition, and natural language processing. In particular, generative AI (GAN / Diffusion, etc.) based on deep learning continues to develop, the feasibility and effectiveness of large-scale model training are constantly verified, and artificial intelligence generated content (AIGC) is gradually emerging. These models and technologies have played an important role in improving social productivity and promoting industrial upgrading and transformation. However, its ability to imitate the real thing inevitably brings a series of potential problems, including data privacy and security issues, model attacks and deception issues, ethical and social issues, etc. For adversarial attacks and classification deception, Hassan M et al. found that using gradient attack noise to interfere with natural images can affect the prediction results of deep neural network (DNN) models. Wei X et al. further used unified adversarial patches to block key parts of the image to interfere with the classification results of the DNN model. Kang M et al. realized unrestricted attacks on images based on the diffusion model and generated adversarial samples with transferability and imperceptibility. These studies all show that deep learning models are vulnerable to adversarial attacks, and research on the security and robustness of deep learning models has important scientific significance and potential application value.

[0003] At present, most of the research on the robustness of deep learning models is based on constructing appropriate adversarial samples and single model adversarial training. Its essence is to learn robust feature representations and decision rules by minimizing adversarial losses, so that the model can have good robustness and generalization at the same time. However, the generation and optimization of suitable adversarial samples are cumbersome, the model adversarial training process has high computational cost, and the model optimized by adversarial training still has limited generalization problems when dealing with cross-domain samples. In order to simplify the adversarial sample optimization process and reduce the computational cost of adversarial training, Zhou D et al. proposed a model cross-attack generalization improvement method based on adversarial feature learning mechanism, and Minjong Le et al. studied a model robustness improvement method based on diffusion model purification image. Compared with traditional methods, the training process of these methods perceives attack noise and purifies input images through DNN models, which can not only realize end-to-end online training of data and reduce the cost of adversarial sample training process, but also improve the diversity of training data, so that the model has stronger generalization ability. However, these methods have only been experimentally verified on small dataset classification tasks (such as CIFAR-10), and have not fully considered the effectiveness and generalization of the model on complex classification tasks. It can be seen that there is still a lack of research on the robustness of deep learning models on large-scale datasets, and there is an urgent need to further study adversarial training methods that are adapted to the needs of large-scale data processing on the Internet.

[0004] Since adversarial attacks for different tasks have different action spaces and attack effects, robust defense for specific attack tasks can improve model stability and thus optimize the model's classification effect. However, in actual practice, adversarial training for large-scale data cannot achieve good convergence under conventional loss function optimization, mainly because the optimization direction of model parameters is limited, so that adversarial noise signals cannot be resolved during the model convergence process. Therefore, the adversarial training effect is poor, resulting in low accuracy of classification results obtained by the image classification model when the model trained by adversarial training is applied to the image purification processing part of the image classification model. Summary of the invention

[0005] The purpose of the present invention is to provide a method for constructing a robust image classification model, which is used to solve the problem in the prior art that it is difficult to process adversarial noise signals during adversarial training, resulting in low accuracy of classification results obtained by the image classification model when the trained model is applied to the image purification processing part of the image classification model.

[0006] In order to achieve the above object, the present invention provides a method for constructing a robust image classification model, wherein the trained generative model is used as an image purification module of the image classification model, and the image processed by the image purification module is passed through the classification module of the image classification model to obtain a classification result; the training steps of the generative model include:

[0007] 1) Inputting the original image samples or adversarial image samples in the training set into the generative model to obtain a purified image; processing the obtained purified image through the set attack model and then inputting it into the classification module to obtain a classification result;

[0008] 2) The generative model is updated with the goal of minimizing the total loss function obtained by superimposing the loss function corresponding to the difference between the purified image and the original image sample as the regularization term and the loss function corresponding to the difference between the classification result of step 1) and the true classification label; iterate steps 1)-2) until the iteration stop condition is met.

[0009] Furthermore, the generative model is a Unet model comprising encoder modules and decoder modules with symmetrical dimensions, wherein the encoder modules and decoder modules respectively comprise convolution submodules for downsampling convolution and upsampling convolution; in the generative model, feature fusion is performed between encoder modules and decoder modules with symmetrical dimensions through jump connections.

[0010] Furthermore, each adversarial image sample in the training set is obtained by attacking the image corresponding to the original sample according to at least two attack intensities using a set gradient attack method;

[0011] Alternatively, each adversarial image sample in the training set is obtained by attacking the image corresponding to the original sample respectively according to the same attack intensity using at least two set gradient attack methods;

[0012] Alternatively, each adversarial image sample in the training set is obtained by respectively attacking the image corresponding to the original sample using at least two set gradient attack methods, and the two set gradient attack methods respectively attack the image corresponding to the original sample according to different attack intensities.

[0013] Furthermore, both the encoder module and the decoder module of the generative model include a normalization submodule for performing layer normalization on the output results of the convolution submodule therein.

[0014] Furthermore, both the encoder module and the decoder module of the generative model include a Leaky Relu activation function for processing the result after layer normalization.

[0015] Furthermore, the encoder module and the decoder module of the generative model both include a GRN submodule that performs GRN processing on the result after the Leaky Relu activation function is processed.

[0016] Furthermore, both the encoder module and the decoder module of the generative model include a Dropout submodule for performing Dropout processing on the result after GRN processing.

[0017] Furthermore, when training the generative model, each iteration selects original image samples or adversarial image samples in the training set according to the sampling probability controlled by the random operator to input into the generative model.

[0018] Furthermore, if each adversarial image sample in the training set is obtained by attacking the image corresponding to the original sample according to the same attack intensity through at least two set gradient attack methods, or each adversarial image sample in the training set is obtained by attacking the image corresponding to the original sample according to different attack intensities through at least two set gradient attack methods, then when obtaining each adversarial image sample, it is obtained by selecting a different set gradient attack method according to the selection probability controlled by a random operator to attack the image corresponding to the original sample.

[0019] Furthermore, the loss function corresponding to the difference between the classification result of step 1) and the true classification label adopts a cross entropy loss function.

[0020] The above-mentioned technical scheme of the present invention provides a new method for constructing a robust image classification model, and its beneficial effects include: by combining the loss function of the original purification of the input original image sample or the adversarial image sample (that is, the loss function corresponding to the difference between the purified image after purification by the generative model and the original image sample) with the loss term of the adversarial sample for gradient attack (that is, the loss function corresponding to the difference between the classification result of the purified image after purification by the generative model as a regularization term and the true classification label), the image purification module (that is, the generative model) of the image classification model is trained, which not only utilizes the ability of the original loss function to restore the main features of the image, but also suppresses the optimization direction of the adversarial noise error updating gradient in the generative model training process through the newly added loss function that constrains the attack sample obtained by attacking the purified image processed by the generative model, and correspondingly improves the ability of the image purification module of the image classification model to convert the adversarial sample attack noise (that is, adversarial noise) into irrelevant noise, so that the accuracy of the classification result obtained by the image classification model when the trained generative model is applied to the image purification processing part in the image classification model can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 It is a flowchart of a method for constructing an image classification model in an embodiment of a method for constructing a robust image classification model of the present invention;

[0022] Figure 2This is an example diagram comparing the classification accuracy of an image classification model using a generative model trained with Mse as a loss function and a generative model trained with an improved C-Mse total loss function as an image purification module in a training process in an embodiment of a method for constructing a robust image classification model of the present invention;

[0023] Figure 3 This is an example diagram comparing the loss values ​​of using Mse as the loss function to train a generative model and using the improved C-Mse total loss function to train a generative model in the training process in an embodiment of the method for constructing a robust image classification model of the present invention;

[0024] Figure 4 It is a structural schematic diagram of a generative model of an image classification model used as an image purification module in an embodiment of a method for constructing a robust image classification model of the present invention. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is further described in detail below with reference to the accompanying drawings and embodiments.

[0026] Example of a method for constructing a robust image classification model

[0027] This embodiment provides a technical solution for a method for constructing a robust image classification model. The method uses samples of clean images (original image samples) and attack samples (adversarial image samples) as images in a training set to train a generative model to obtain an image purification module of the image classification model; during the training process, the optimization direction of the training process is controlled by constraints on the difference between the purified image after purification by the generative model and the original image sample, and the difference between the classification result of the purified image after purification by the generative model and the true classification label, so that the trained model can purify the clean image and the attack sample towards the clean sample; and in the generative model adopted, the dimensionally symmetric encoder and decoder modules are connected by jump connections to improve the convergence speed of the model training process, thereby avoiding gradient explosion during the training process; and the encoder and decoder modules are both added with sub-modules for realizing layer normalization, Leaky Relu activation function, GRN and Dropout on the basis of convolution, so as to improve the model's tolerance to attack noise and enhance the model's anti-attack perception and restoration capabilities.

[0028] Specifically, refer to Figure 1 The method uses the trained generative model as the image purification module of the image classification model, and the image processed by the image purification module is passed through the classification module of the image classification model to obtain the classification result; wherein the training steps of the generative model (i.e., the image purification module of the image classification model) include:

[0029] 1) The original image samples or adversarial image samples in the training set are input into the generative model to obtain a purified image; the obtained purified image is processed by the set attack model and then input into the classification module to obtain the classification result; wherein, the "adversarial image samples" mentioned in this embodiment actually refer to image samples obtained after the original normal image is subjected to a gradient attack, and the "original image samples" refer to image samples corresponding to the original normal image that has not been subjected to a gradient attack.

[0030] 2) The first loss term calculates the Mse loss between the purified image and the original image sample, and the second loss term calculates the cross entropy loss between the classification result of the purified image after passing through the set attack model and the true classification label. The generative model is updated with the goal of minimizing the total loss function obtained by superimposing the loss function corresponding to the difference between the purified image and the original image sample as the regularization term and the loss function corresponding to the difference between the classification result of step 1) and the true classification label; iterate steps 1)-2) until the iteration stop condition is met. The iteration stop condition used in this embodiment can be that the value of the total loss function is less than the corresponding set threshold, or the number of iterations is greater than the set upper limit.

[0031] Therefore, by inputting original image samples and adversarial image samples for training, the trained generative model can be used as the image purification module of the image classification model to purify both the purified image and the attacked image (i.e., the attack sample) towards the clean sample; by combining the loss function of the original purification of the input original image sample or the adversarial image sample (i.e., the loss function corresponding to the difference between the purified image and the original image sample) with the loss term of the adversarial sample for gradient attack (i.e., the total loss function obtained by the loss function corresponding to the difference between the classification result of the purified image after purification as a regularization term and the true classification label), the image purification module (i.e., the generative model) of the image classification model is trained, which not only utilizes the original loss function to purify the image The ability to restore the main features is constrained by a newly added loss function that constrains the attack samples obtained by attacking the purified image processed by the generative model. This is equivalent to constraining the iterative update direction of the generative model training process according to the loss information between the adversarial noise caused by the attack and the true category label, thereby suppressing the optimization direction of the adversarial noise error update gradient in the generative model training process, and correspondingly improving the image purification module of the image classification model to convert the adversarial sample attack noise (i.e., adversarial noise) into irrelevant noise. The ability, therefore, can ensure that adversarial training improves the ability of the generative model to solve adversarial noise, thereby improving the accuracy of the classification results obtained by the image classification model when the trained generative model is applied to the image purification processing part of the image classification model.

[0032] Among them, when training the generative model, the image input into the generative model in each iteration is controlled according to the set sampling strategy, whether it is the original image sample or the adversarial image sample; specifically, the set sampling strategy is: in each iteration, according to the sampling probability controlled by the random operator, the original image sample or the adversarial image sample in the training set is selected to be input into the generative model; for example, the sampling probability controlled by the random operator is 0.4 for the original image sample and 0.6 for the adversarial image sample, then in each iteration, the image input into the generative model has a 40% probability of being the original image sample in the training set and a 60% probability of being the adversarial image sample in the training set; if the sampling probability controlled by the random operator is 0.5 for the original image sample and 0.5 for the adversarial image sample, then in each iteration, the probability of the image input into the generative model being the original image sample or the adversarial image sample in the training set is the same.

[0033] In this embodiment, the loss function corresponding to the difference between the image processed by the image purification module and the original image sample adopts the commonly used Mse loss function (i.e., mean square error loss function); after analysis, only the Mse loss of the difference between the image processed by the image purification module and the original image sample is used for training. For convergence constraints found during training, such as Figure 2 , Figure 3 As shown; Figure 2 In the figure, the horizontal axis represents the number of iterations, the vertical axis represents the classification accuracy, Acc(refer) represents the auxiliary reference line of the recognition accuracy of the image classification model before the attack, the blue curve represents the classification accuracy of the image classification model of the image purification module using the generative model trained with the Mse loss in the process of training with the training set containing the original image samples or the attacked adversarial image samples, and the red represents the classification accuracy of the image classification model of the image purification module using the generative model trained with the Mse loss as the image classification model of the image purification module using the total loss function (referred to as C-Mse) obtained by superimposing the loss function corresponding to the difference between the image processed by the image purification module and the original image sample as the regularization term and the loss function corresponding to the difference between the classification result of step 1) and the true classification label as the regularization term in the process of training with the training set containing the original image samples or the attacked adversarial image samples; Figure 3In the figure, the horizontal axis represents the number of iterations, and the vertical axis represents the loss function value. The blue curve represents the loss value of the generative model trained with the loss function Mse of the difference between the image processed by the image purification module and the original image sample during the training process with the training set containing the original image samples or the attacked adversarial image samples. The red curve represents the loss value of the generative model trained with the total loss function (abbreviated as C-Mse) obtained by superimposing the loss function corresponding to the difference between the classification result of step 1) and the true classification label as the regularization term, using the Mse loss function between the purified image processed by the image purification module and the original image sample during the training process with the training set containing the original image samples or the attacked adversarial image samples. Figure 2 It can be seen that when the above MSE loss function is used for training, when the Acc (classification accuracy) is increased to 71%, the generative model cannot converge further; specifically, when the above MSE is used as the loss function for training, it is observed that the optimization process of the generative model weakens the noise signal, but the aggressiveness of the noise still exists, that is, only using the MSE of the difference between the image processed by the image purification module and the original image sample as the loss function has an upper limit on the defensive effect. Figure 2 , Figure 3 It can be seen from the red curve in the figure that after training with the total loss function obtained by superimposing the loss function corresponding to the difference between the classification result of step 1) and the true classification label as a regularization term on the MSE, the Acc (classification accuracy) of the generative model can be improved to a level close to 90% while still maintaining the ability to converge further, and the value of the total loss function can be reduced to below 0.025. Compared with the case where only MSE is used as the loss function, the training effect is significantly better.

[0034] Specifically, the corresponding loss function of the difference between the image processed by the image purification module and the original image sample adopts the cross entropy loss function, and the formula of the total loss function is expressed as follows:

[0035]

[0036] Among them, ||.|| 2 represents the L2 norm, y pred is the purified image obtained by inputting the original image sample or adversarial image sample in the training set into the generative model, and y is the true label (i.e., X in The corresponding original image before the attack, that is, the original image sample), X in represents the image sample input to the generative model, y' predrepresents the classification result of the purified image obtained by gradient attacking the purified image using the set attack model and then inputting it into the classification module (i.e., the classification result obtained after the purified image is processed by the set attack model and then input into the classification module), y i Indicates the true classification label corresponding to the input image, that is, X in The corresponding true classification label, λ 1 It is a hyperparameter that controls the mean square error and cross entropy loss. The specific setting method belongs to the existing technology and will not be repeated here; It is the square of the difference between the predicted value (i.e., the image sample input into the generative model) and the target value y (i.e., the true label), i.e., the mse loss function; It is the cross entropy loss corresponding to the difference between the classification result obtained after the purified image after the generative model is purified, processed by the set attack model, and then input into the classification module and the true classification label. is the total loss.

[0037] This embodiment specifically uses Resnest50 as the set attack model, which is also used to generate adversarial samples, and is called Model Adv, i.e., fixed attack parameter model A; adversarial noise is calculated based on the parameters of Resnest50, and is highly aggressive and versatile. In addition, experimental results show that the attacked image cannot be completely restored to a clean image. By calculating the cross entropy loss of the classification result of the purified image processed by the fixed parameter Model A, the optimization direction for suppressing the adversarial noise error update gradient can be obtained, thereby solving the convergence limitation problem. This is equivalent to introducing a new optimization direction based on the original loss function to solve the convergence problem in the generative model training process.

[0038] In this embodiment, the generative model is a Unet model including encoder modules and decoder modules with symmetric dimensions, wherein the encoder module and the decoder module respectively include convolution submodules for downsampling convolution and upsampling convolution; and feature fusion is performed through jump connections between encoder modules and decoder modules with symmetric dimensions in the generative model. The Unet model with symmetric encoder modules and decoder modules can ensure the symmetry and rationality of the generative model structure of the image purification module used as an image classification model. The specific structure can be seen in Figure 4 .

[0039] Reference Figure 4 , X in is the image sample (original image sample or adversarial image sample) input to the generative model, X outThe image is purified by the generative model. The resolution of the image input to the generative model is 224*224. The Encoder module is used for downsampling. The dimension reduction method with a step size of 2 is used (such as Figure 4 The "Conv2D" in the Encoder module in the image is gradually reduced to 7*7 to complete feature extraction; then the Decoder (decoder module) is used to increase the dimension in steps of 2 (such as Figure 4 "Conv2DTranspose" in the Decoder module in the decoder) is gradually upsampled to the original resolution; the convolution kernel size for upsampling and downsampling is 3 by default; after analysis, when the automatic encoder is used to verify the theoretical method, it is found that the generative model of this structure still converges slowly, which makes the training process prone to gradient explosion. Therefore, this embodiment also solves this problem by using multi-layer feature fusion (skip connection) between the Encoder and Decoder of symmetric dimensions. This can effectively alleviate the convergence limitation problem caused by the conflict between clean signals and noise signals in the model training stage, and further improve the model convergence speed, avoiding gradient explosion in the training process. Through the optimization of the above-mentioned jump connection, the adversarial influence of the attack noise data points on the generative model can be further eliminated, the perception ability of the generative model to tiny attack noise can be enhanced, and the healthy convergence of the model can be ensured, thereby increasing the convergence speed of the model and the ability to purify attack signals. Among them, although using Add for feature fusion can greatly improve the efficiency of training, the primary task of the generative model of the image purification module used as an image classification model in this embodiment is to defend against attack noise. Therefore, according to the results of the ablation experiment, Concat is finally selected for jump connection between the encoder module and the decoder module in mutually symmetrical dimensions.

[0040] In addition, refer to Figure 4 , the encoder module and the decoder module of the generative model both contain a normalization submodule for normalizing the output of the convolution submodule (e.g. Figure 4 The Encoder module in the decoder module and the "Layer Norm" in the decoder module), the Leaky Relu activation function that processes the result after layer normalization (such as Figure 4 The Encoder module in the decoder module and the "LeakyRelu" in the decoder module, the GRN submodule that performs GRN processing on the result after the Leaky Relu activation function is processed, and the Dropout submodule that performs Dropout processing on the result after the GRN processing (such as Figure 4 The Encoder module in the example and the “GRN+Dropout” in the Decoder module in the example), the Dropout loss rate is set to 0.2 by default.

[0041] It can be seen that the encoder module and decoder module of the generative model use convolution to efficiently capture local features and restore high-level semantic information to pixel-level output; layer normalization can constrain the prominent noise signal of the model to ensure the stability and robustness of training; the use of Leaky Relu activation function can improve the expressiveness of the generative model, enabling it to capture complex features and attack noise in the data; the use of GRN (including three steps: global feature aggregation, feature normalization, and feature calibration) can increase the contrast and selectivity between channels, thereby increasing the channel competitiveness of the generative model for attack signals, and the combination of "GRN" and "layer normalization" can increase the model depth, thereby improving the noise decoupling ability of the entire model; using Dropout in the last layer of the encoder and decoder can ensure the generalization effect of the model. Since how to perform layer normalization, Leaky Relu activation function, GRN processing, and Dropout processing on the neural network structure are all existing technologies, they will not be repeated here.

[0042] In this embodiment, in order to improve the robustness of the generative model during the training process and effectively generate adversarial samples, thereby ensuring the comprehensiveness of the attack, a variable attack strategy is used to generate adversarial image samples in the training set when training the generative model. After analysis, adversarial samples generated by different attack intensities and different attack methods can improve the defense capability of the model. The variable attack strategy can be reflected in at least one aspect of variable attack intensity and variable attack method; specifically, in this embodiment, each adversarial image sample in the training set is obtained by respectively attacking the image corresponding to the original sample through at least two set gradient attack methods and the two set gradient attack methods respectively attack the image according to different attack intensities (both the attack method and the attack intensity are variable);

[0043] Alternatively, in other embodiments, each adversarial image sample in the training set is obtained by attacking the image corresponding to the original sample according to at least two attack intensities using a set gradient attack method (only the attack intensity is variable);

[0044] Alternatively, in other embodiments, each adversarial image sample in the training set is obtained by attacking the image corresponding to the original sample respectively according to the same attack intensity using at least two set gradient attack methods (only the attack method is variable).

[0045] The attack intensity is changed by controlling the parameters of the maximum distortion of the adversarial sample in the gradient attack method.

[0046] In this embodiment, the above-mentioned set gradient attack method includes at least two of the white box attack methods of FGSM, I-FGSM, PGD and MI-FGSM; and, for the image obtained by performing a gradient attack on the purified image used to input the classification module to obtain the attacked classification result, the strategy for performing a gradient attack is the same as the attack strategy used to generate the adversarial image samples in the training set, that is, the image obtained by performing a gradient attack on the purified image used to input the classification module to obtain the attacked classification result can also be obtained through the above-mentioned variable attack strategy.

[0047] In order to further improve the randomness of the variable attack strategy and the comprehensiveness of the attack, so as to generate more comprehensive adversarial image samples, if each adversarial image sample in the training set is obtained by attacking the image corresponding to the original sample with the same attack strength through at least two set gradient attack methods, or each adversarial image sample in the training set is obtained by attacking the image corresponding to the original sample with different attack strengths through at least two set gradient attack methods (i.e., the attack method is variable), then when obtaining each adversarial image sample, it is obtained by selecting different set gradient attack methods according to the selection probability controlled by the random operator to attack the image corresponding to the original sample. The variable perturbation of the attack sample (i.e., the adversarial image sample) leads to the uncertainty of data set expansion, i.e., the adversarial image sample can have a geometric multiple relationship with the original sample.

[0048] Combined with the above sampling strategy of "when training the generative model, each iteration selects whether to input the original image sample or the adversarial image sample in the training set into the generative model according to the sampling probability controlled by the random operator", the way to obtain the purified image after inputting the original image sample or the adversarial image sample in the training set into the generative model can be expressed by the following formula:

[0049]

[0050] Where F(.) represents the attack method, that is, F fgsm (.) Corresponding to FGSM attack method, F mim (.) Corresponding MIM attack method, F bim (.) Corresponding BIM attack method, F pgd (.) corresponds to the PGD attack method. The specific formulas of each attack method can be found in the subsequent introduction. It should be noted that the parameters in each attack method, namely F fgsm (.), F mim (.), F bim (.) and F pgd The parameters in the brackets (.) have the same meaning, but they represent the parameters in the corresponding attack methods, and their values ​​are not related.0 represents the clean sample (i.e., the original image sample) used in the corresponding attack method, x 1 represents the sample (i.e., adversarial image sample) generated by attacking using the above variable attack strategy, X in represents the sample of the input model data stream, ε represents the maximum distortion of the adversarial sample in the corresponding attack method, and the default value range is 0.05-0.3. The attack strength of the gradient attack method is changed by adjusting ε; α represents the step size of each attack iteration in the corresponding attack method, and the default value is 0.06; n represents the number of attack iterations in the corresponding attack method, and the default value is 10; μ represents the attenuation coefficient of the momentum term in the corresponding attack method, and the default value is 1; p represents the sampling probability hyperparameter that controls the attack strategy, and the sampling probability hyperparameter is the sampling probability controlled by the random operator; in this embodiment, F clean The value of p in (.) is 0.1; F fgsm (.) and F mim The value of p in (.) is 0.2. Since MIM and PGD are the most difficult to defend against during training, the highest sampling probability hyperparameter value is set, i.e., F bim (.) and F pgd The value of p in (.) is 0.25.

[0051] The four white-box attack methods mentioned above are exemplified as follows (for example only. Since the specific contents and principles of various white-box attack methods belong to the prior art, they will not be described in detail in this embodiment):

[0052] The FGSM algorithm is implemented by the following formula:

[0053]

[0054] Use the classification model M to ori Perform forward propagation and calculate the loss function value Use the sign function sign() to extract the direction of the gradient and use the parameter ε(||η|| ∞ <ε) controls the amplitude of the attack noise, and x ori Adding to achieve FGSM

[0055] attack.

[0056] The I-FGSM / BIM algorithm is implemented by the following formula:

[0057]

[0058] FGSM only adds one perturbation step along the direction of increasing gradient, while BIM performs multiple small perturbations along the direction of increasing gradient in an iterative manner (the amplitude of the perturbation is controlled by α in the formula), and recalculates the gradient direction after each small step. Compared with FGSM, it can construct more accurate perturbations, but at the cost of increased calculation amount.

[0059] The MI-FGSM / MIM algorithm is implemented by the following formula:

[0060]

[0061] When MI-FGSM is iterating, the perturbation of each round is not only related to the current gradient direction, but also to the previously calculated gradient direction. The attenuation factor μ(0, 1) is used to adjust the correlation. The smaller μ is, the less influence the gradient calculated earlier in the iteration will have on the current gradient direction.

[0062] The PGD algorithm is implemented by the following formula:

[0063]

[0064] PGD ​​is based on BIM. It randomly perturbs the original sample in its neighborhood as the initial input of the algorithm. After multiple iterations, it generates adversarial samples. Its performance is significantly improved, and it has good migration and anti-destruction capabilities. Different from BIM's Clip, proj will project each updated adversarial sample to ε-L ∞ Neighborhood and prescribed range.

[0065] The present invention has the following characteristics:

[0066] 1) By inputting original image samples and adversarial image samples for training, the trained generative model as the image purification module of the image classification model can purify both the purified image and the attacked image (i.e., the attack sample) towards the clean sample; by combining the original loss function for purification of the input original image sample or adversarial image sample (i.e., the loss function corresponding to the difference between the purified output image and the original image sample) with the loss term of the adversarial sample for gradient attack (i.e., the total loss function obtained by the loss function corresponding to the difference between the classification result of the purified image and the true classification label as a regularization term), the image purification module (i.e., the generative model) of the image classification model is trained, which not only utilizes the ability of the original loss function to restore the main features of the image, but also suppresses the optimization direction of the adversarial noise error updating gradient in the generative model training process through the newly added loss function that constrains the attack sample obtained by attacking the purified image processed by the generative model, and correspondingly improves the ability of the image purification module of the image classification model to convert the adversarial sample attack noise (i.e., adversarial noise) into irrelevant noise, so that the accuracy of the classification result obtained by the image classification model when the trained generative model is applied to the image purification processing part in the image classification model can be improved.

[0067] 2) The generative model adopts the Unet model with symmetrical encoder modules and decoder modules, which can ensure the symmetry and rationality of the generative model structure of the image purification module used as an image classification model; by using jump connections between the Encoder and Decoder with symmetrical dimensions, the convergence limitation problem caused by the conflict between clean signals and noise signals in the model training stage can be effectively alleviated, and the model convergence speed can be further improved to avoid gradient explosion in the training process.

[0068] 3) Both the encoder module and the decoder module of the generative model include a normalization submodule for layer normalization of the output results of the convolution submodule, a Leaky Relu activation function for processing the results after layer normalization, a GRN submodule for GRN processing of the results after the Leaky Relu activation function processing, and a Dropout submodule for Dropout processing of the results after the GRN processing; layer normalization can constrain the prominent noise signal of the model to ensure the stability and robustness of the training; the use of the Leaky Relu activation function can improve the expressiveness of the generative model, enabling it to capture the complex features and attack noise in the data; the use of GRN (including three steps: global feature aggregation, feature normalization and feature calibration) can increase the contrast and selectivity between channels, thereby increasing the channel competitiveness of the generative model for attack signals, and the combination of "GRN" and "layer normalization" processing can increase the model depth, thereby improving the noise decoupling ability of the entire model; using Dropout in the last layer of the encoder and decoder can ensure the generalization effect of the model.

[0069] 4) When training the generative model, a variable attack strategy is used to generate adversarial image samples in the training set, and the model's defense capability is improved by adversarial samples generated by different attack intensities and different attack methods.

[0070] It should be understood that the above specific embodiments of the present invention are only used to illustrate or explain the principles of the present invention, but do not constitute a limitation to the present invention.

Claims

1. A method for constructing a robust image classification model, characterized in that: The trained generative model is used as an image purification module of the image classification model, and the image processed by the image purification module is passed through the classification module of the image classification model to obtain a classification result; The training steps of the generative model include: 1) Inputting the original image samples or adversarial image samples in the training set into the generative model to obtain a purified image; processing the obtained purified image through the set attack model and then inputting it into the classification module to obtain a classification result; 2) The generative model is updated with the goal of minimizing the total loss function obtained by superimposing the loss function corresponding to the difference between the purified image and the original image sample as the regularization term and the loss function corresponding to the difference between the classification result of step 1) and the true classification label; iterate steps 1)-2) until the iteration stop condition is met.

2. The method for constructing a robust image classification model according to claim 1, characterized in that: The generative model is a Unet model including encoder modules and decoder modules with symmetrical dimensions, wherein the encoder modules and decoder modules respectively include convolution submodules for downsampling convolution and upsampling convolution; in the generative model, feature fusion is performed between encoder modules and decoder modules with symmetrical dimensions through jump connections.

3. The method for constructing a robust image classification model according to claim 1, characterized in that: Each adversarial image sample in the training set is obtained by attacking the image corresponding to the original sample according to at least two attack intensities using a set gradient attack method; Alternatively, each adversarial image sample in the training set is obtained by attacking the image corresponding to the original sample respectively according to the same attack intensity using at least two set gradient attack methods; Alternatively, each adversarial image sample in the training set is obtained by respectively attacking the image corresponding to the original sample using at least two set gradient attack methods, and the two set gradient attack methods respectively attack the image corresponding to the original sample according to different attack intensities.

4. The method for constructing a robust image classification model according to claim 2, characterized in that: The encoder module and the decoder module of the generative model both include a normalization submodule for performing layer normalization on the output results of the convolution submodule therein.

5. The method for constructing a robust image classification model according to claim 4, characterized in that: The encoder module and the decoder module of the generative model both include a Leaky Relu activation function for processing the results of layer normalization.

6. The method for constructing a robust image classification model according to claim 5, characterized in that: The encoder module and the decoder module of the generative model both include a GRN submodule that performs GRN processing on the result processed by the Leaky Relu activation function.

7. The method for constructing a robust image classification model according to claim 6, characterized in that: The encoder module and the decoder module of the generative model both include a Dropout submodule for performing Dropout processing on the result after GRN processing.

8. The method for constructing a robust image classification model according to claim 3, characterized in that: When training the generative model, each iteration selects whether to input the original image sample or the adversarial image sample in the training set into the generative model according to the sampling probability controlled by the random operator.

9. The method for constructing a robust image classification model according to claim 3 or 8, characterized in that: If each adversarial image sample in the training set is obtained by attacking the image corresponding to the original sample according to the same attack intensity through at least two set gradient attack methods, or each adversarial image sample in the training set is obtained by attacking the image corresponding to the original sample according to different attack intensities through at least two set gradient attack methods.

10. The method for constructing a robust image classification model according to claim 1, characterized in that: The loss function corresponding to the difference between the classification result of step 1) and the true classification label adopts the cross entropy loss function.

Citation Information

Cited By

  • Robustness improvement method and system for target detection in complex power scene

    CN121033401A