A training method, system and application of adversarial sample defense model

By constructing the initial defense model of the generator, discriminator and classifier, generating inverse perturbations and reconstructing adversarial samples, we solve the problem of poor defense effect of adversarial samples in the existing technology, achieve efficient adversarial sample processing, and significantly improve Classification accuracy.

CN113723564BActive Publication Date: 2024-09-06YANSHAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111072894.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-14
Publication Date
2024-09-06
Estimated Expiration
2041-09-14

AI Technical Summary

Technical Problem

Adversarial sample defense methods in the existing technology mainly focus on detection defense and robust defense. Detection defense cannot effectively handle adversarial samples, while robust defense is ineffective and consumes too much time and resources.

Method used

By building an initial defense model, including a generator, a discriminator, and a classifier, adversarial samples are used to generate inverse perturbations, and approximate real samples are reconstructed, and then the defense model is trained to eliminate adversarial perturbations and avoid classification errors.

Benefits of technology

It significantly improves the classification accuracy of adversarial samples, avoids misclassification of the classification model caused by adversarial perturbations, and does not require a large number of data samples or modification of the classifier model, reducing time and resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113723564B
    Figure CN113723564B
Patent Text Reader

Abstract

The present invention relates to an adversarial sample defense model training method, system and application thereof. First, a training set is obtained, and the training set includes adversarial samples and real samples. Then an initial defense model is constructed, and the initial defense model includes a generator, a discriminator and a classifier. Finally, the initial defense model is trained using the training set to obtain a defense model. The present invention reconstructs adversarial samples by constructing corresponding inverse perturbations to obtain reconstructed samples that are similar to real samples, thereby obtaining a better adversarial sample defense effect. When classifying adversarial samples, the above-mentioned defense model is first used to eliminate adversarial perturbations on adversarial samples to be classified to obtain reconstructed samples. The obtained reconstructed samples can be approximated to real samples. The reconstructed samples are input into a classification model, which can enable the classification model to correctly classify, avoid the problem of misclassification of the classification model caused by adversarial perturbations, and significantly improve the classification accuracy of the classification model for adversarial samples.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image classification, and in particular to a method and system for training an adversarial sample defense model and applications thereof. Background Art

[0002] In just a few years, deep learning has gradually become an important engine driving the accelerated development of various fields in the economy and society from mechanization and digitization to intelligence. Deep Neural Networks (DNN) have shown amazing results in solving complex problems, such as face recognition and autonomous driving. In 2014, Szegedy et al. found that adding slightly perturbed images would lead the DNN model to misclassify, proving that there are potential hidden dangers in deep learning that humans are not yet aware of. The images modified by perturbations are called adversarial samples. The weak perturbations added to adversarial samples are usually not detectable by the human visual system, but can cause the DNN model to output an erroneous result with high confidence, and even the same adversarial sample can induce multiple DNN models to misclassify. This discovery reflects that the DNN model itself has many risks and has not yet been properly secured.

[0003] Although scholars at home and abroad have begun to pay attention to the deep learning security issues caused by adversarial samples, among the existing defense methods, detective defense only detects the existence of adversarial samples and does not effectively deal with adversarial samples. Although robust defense can deal with adversarial samples, the defense effect is not good. Summary of the invention

[0004] The purpose of the present invention is to provide an adversarial sample defense model training method, system and application thereof, which can train a defense model with good defense effect. After using the defense model to process the adversarial sample, the problem of classifier misclassifying the adversarial sample can be avoided.

[0005] To achieve the above object, the present invention provides the following solutions:

[0006] In a first aspect, the present invention is used to provide a method for training an adversarial sample defense model, the training method comprising:

[0007] Acquire a training set; the training set includes adversarial samples and real samples; the adversarial samples are obtained by adding adversarial perturbations to the real samples;

[0008] Constructing an initial defense model; the initial defense model includes a generator, a discriminator and a classifier; the generator is connected to the discriminator and the classifier respectively; the generator is used to take the adversarial sample as input, generate an inverse perturbation, and obtain a reconstructed sample according to the inverse perturbation; the discriminator is used to take the real sample and the reconstructed sample as input, and discriminate the reconstructed sample; the classifier is used to take the reconstructed sample as input, and classify the reconstructed sample;

[0009] The initial defense model is trained using the training set to obtain a defense model.

[0010] A system for training an adversarial sample defense model, the training system comprising:

[0011] A first acquisition module is used to acquire a training set; the training set includes adversarial samples and real samples; the adversarial samples are obtained by adding adversarial perturbations to the real samples;

[0012] A construction module is used to construct an initial defense model; the initial defense model includes a generator, a discriminator and a classifier; the generator is connected to the discriminator and the classifier respectively; the generator is used to take the adversarial sample as input, generate an inverse perturbation, and obtain a reconstructed sample according to the inverse perturbation; the discriminator is used to take the real sample and the reconstructed sample as input, and discriminate the reconstructed sample; the classifier is used to take the reconstructed sample as input, and classify the reconstructed sample;

[0013] The training module is used to train the initial defense model using the training set to obtain a defense model.

[0014] In a second aspect, the present invention is used to provide an adversarial sample defense method, the defense method comprising:

[0015] Obtain adversarial samples to be classified;

[0016] Taking the adversarial sample to be classified as input, and obtaining a reconstructed sample using the defense model;

[0017] The reconstructed samples are classified using a classification model to obtain a classification result; the classification model adopts a deep neural network model.

[0018] A system for defending against adversarial samples, the system comprising:

[0019] The second acquisition module is used to obtain adversarial samples to be classified;

[0020] A reconstruction module, used to take the adversarial sample to be classified as input and obtain a reconstructed sample using a defense model;

[0021] The classification module is used to classify the reconstructed samples using a classification model to obtain a classification result; the classification model adopts a deep neural network model.

[0022] An adversarial sample defense device, comprising:

[0023] Processor; and

[0024] a memory storing computer readable program instructions,

[0025] Wherein, when the computer-readable program instructions are executed by the processor, the above-mentioned training method is executed, or the above-mentioned defense method is executed.

[0026] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the above-mentioned training method; or implements the steps of the above-mentioned defense method.

[0027] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:

[0028] The present invention is used to provide a training method, system and application of an adversarial sample defense model. First, a training set is obtained, and the training set includes adversarial samples and real samples. Then an initial defense model is constructed, and the initial defense model includes a generator, a discriminator and a classifier. The generator is used to take the adversarial sample as input, generate an inverse perturbation, and obtain a reconstructed sample according to the inverse perturbation. Finally, the initial defense model is trained using the training set to obtain a defense model. According to the adversarial sample attack principle, the present invention reversely thinks about the existence value of adversarial perturbations, determines to eliminate adversarial perturbations as the starting point of research, reconstructs adversarial samples by constructing corresponding inverse perturbations, and obtains reconstructed samples that are similar to real samples, thereby obtaining a better adversarial sample defense effect. When classifying adversarial samples, the above-mentioned defense model is first used to eliminate adversarial perturbations on adversarial samples to be classified, and reconstructed samples are obtained. The obtained reconstructed samples can be approximated to real samples. The reconstructed samples are input into the classification model, which can enable the classification model to correctly classify, avoid the problem of misclassification of the classification model caused by adversarial perturbations, and significantly improve the classification accuracy of the classification model for adversarial samples. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. The following drawings are not deliberately scaled according to the actual size, and the focus is on illustrating the main purpose of the present invention.

[0030] Figure 1A method flow chart of the training method provided in Example 1 of the present invention;

[0031] Figure 2 A schematic diagram of the network architecture of the initial defense model provided in Example 1 of the present invention;

[0032] Figure 3 A system block diagram of a training system provided by Embodiment 2 of the present invention;

[0033] Figure 4 A method flow chart of the defense method provided by Embodiment 3 of the present invention;

[0034] Figure 5 A schematic diagram of the defense principle provided by Example 3 of the present invention;

[0035] Figure 6 This is a system block diagram of the defense system provided in Example 4 of the present invention. DETAILED DESCRIPTION

[0036] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0037] Flowcharts are used in the present invention to illustrate the operations performed. It should be understood that the preceding or following operations are not necessarily performed precisely in order. On the contrary, various steps may be processed in reverse order or simultaneously as required. At the same time, other operations may also be added to these processes, or one or more operations may be removed from these processes.

[0038] The purpose of the present invention is to provide an adversarial sample defense model training method, system and application thereof, which can train a defense model with good defense effect. After using the defense model to process the adversarial sample, the problem of classifier misclassifying the adversarial sample can be avoided.

[0039] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0040] Embodiment 1:

[0041] Existing neural network model defense methods can be divided into two categories according to the way of defending against adversarial samples: detective defense and robust defense. Detective defense detects the input samples and removes adversarial samples before inputting them into the neural network. Commonly used detective defense methods include: 1. Constructing the MagNet framework to train the DNN model to detect adversarial samples by approximating the distribution of real samples; 2. Using the feature compression method to detect adversarial samples by checking the prediction consistency between the original sample and the compressed sample. Detective defense is independent of other defense methods and can be used alone to detect adversarial samples, or it can be added to other defense methods for combined use.

[0042] Compared with detection defense, robust defense can make deep neural networks still correctly predict and classify when attacked by adversarial samples, and its research proportion is also greater than that of detection defense methods. Commonly used robust defense methods include: 1. Adopting the defense idea of ​​adversarial training, by injecting fully annotated adversarial samples into the training data set, guiding the DNN model to learn adversarial perturbation loss, thereby ensuring that the model can obtain the same prediction classification as the real sample when facing a specific adversarial sample attack, but this method mainly brings defense performance improvement by gradient masking, and cannot resist other types of attack methods, and it is easy to cause DNN model overfitting. 2. Propose the APE-GAN defense method, define the elimination of adversarial perturbations as the problem of learning the manifold mapping from adversarial samples to real samples, and eliminate the adversarial perturbations of the adversarial samples input to the DNN model by training the Generative Adversarial Network (GAN), so as to achieve the ultimate goal of defending against adversarial attacks. However, APE-GAN directly eliminates the perturbations of adversarial samples through the generator model. Combined with the problem that the generator model learning has a high degree of freedom, APE-GAN needs to consume higher computing power resources during training to control the range of perturbation modification.

[0043] Although scholars at home and abroad have begun to pay attention to the deep learning security issues caused by adversarial samples, among the existing defense methods, the detection defense only detects the existence of adversarial samples and does not effectively deal with adversarial samples, while the robust defense is either based on large-scale data samples or requires modifying the classifier model, which consumes too much time and resources and has poor results. Therefore, this embodiment is used to propose an adversarial sample defense model training method based on the inverse perturbation idea, which is a robust defense method to solve the above existing problems.

[0044] like Figure 1 As shown, the training method of this embodiment includes:

[0045] S1: Obtain a training set; the training set includes adversarial samples and real samples; the adversarial samples are obtained by adding adversarial perturbations to the real samples;

[0046] Specifically, the real sample can be a handwritten digital sample, and the handwritten digital sample comes from a handwritten digital data set (MNIST). Of course, the real sample of this embodiment can also be any animal image sample, such as lions, elephants, tigers and other animals, any human face image sample, and any plant image sample. The corresponding adversarial sample is an image sample obtained by adding adversarial perturbations to the real sample. The purpose of the training method provided in this embodiment is to train a defense model, and the adversarial sample is processed by the defense model to obtain a reconstructed sample. After the reconstructed sample is input into the classification model, the problem of the adversarial sample causing the classification model to misclassify can be avoided, and the classification model can correctly classify the adversarial sample. The classification model can be a deep learning model for animal image classification, face recognition or plant image classification.

[0047] By using any existing adversarial sample generation method to process real samples, adversarial samples can be obtained. Specifically, the Fast Gradient Sign Method (FGSM), Project Gradient Descent (PGD) and C&W method can be used to process real samples to obtain effective adversarial samples. Of course, this embodiment can also select other methods to generate adversarial samples. This embodiment does not limit the specific adversarial sample generation method. Then, a training set including adversarial samples and real samples can be constructed to provide a reliable training data set for the subsequent training of the defense model.

[0048] The relationship between adversarial samples and real samples can be expressed as follows:

[0049] x adv =x true +r adv ; (1)

[0050] In formula (1), x adv is an adversarial sample; x true is the real sample; r adv To counter disturbances.

[0051] S2: construct an initial defense model; the initial defense model includes a generator, a discriminator and a classifier; the generator is connected to the discriminator and the classifier respectively; the generator is used to take the adversarial sample as input, generate an inverse perturbation, and obtain a reconstructed sample according to the inverse perturbation; the discriminator is used to take the real sample and the reconstructed sample as input, and discriminate the reconstructed sample; the classifier is used to take the reconstructed sample as input, and classify the reconstructed sample;

[0052] This embodiment draws on the idea of ​​generative adversarial networks to build an initial defense model. Figure 2 As shown, it schematically shows the network architecture of the initial defense model. In this embodiment, the initial defense model mainly involves the generator G IPCM , discriminator D and classifier M. Among them, the generator G IPCM The model is constructed for the inverse perturbation to be trained. It is mainly used to simulate the adversarial perturbation distribution of the adversarial sample to obtain the inverse perturbation, and to perform pixel-by-pixel subtraction between the adversarial sample and the inverse perturbation to eliminate the adversarial perturbation in the adversarial sample and obtain the reconstructed sample. The input of the discriminator D consists of two parts, namely the real sample and the reconstructed sample. The output is the probability value of the discriminator D predicting that the input sample (real sample and reconstructed sample) comes from the real sample. The discriminator D is responsible for guiding the generator G. IPCM Construct an effective inverse perturbation so that the generator G IPCM The output reconstructed sample is as similar to the real sample as possible. The classifier M takes the reconstructed sample as the model input and outputs the predicted classification result of the reconstructed sample. The classifier M is responsible for guiding the generator G IPCM Construct an effective inverse perturbation so that the reconstructed samples can be correctly classified by the classifier.

[0053] This embodiment draws on the excellent data simulation ability of the generative adversarial network and uses the generator architecture as the inverse perturbation construction model to generate inverse perturbations, which is specifically expressed as follows:

[0054] r IP =G IPCM (x adv ); (2)

[0055] In formula (2), r IP is the inverse perturbation; G IPCM For the generator.

[0056] The calculation formula for reconstructing samples is as follows:

[0057] x RE =x adv -r IP ; (3)

[0058] In formula (3), x RE To reconstruct the sample.

[0059] The discriminator of this embodiment inputs the feedback result into the inverse perturbation construction model to guide the training process of the inverse perturbation construction model, so that the reconstructed samples after inverse perturbation processing can be close to the real samples, ensuring the human visual perception effect.

[0060] In order to better constrain the inverse perturbation construction process, a classifier is introduced in the training process of the inverse perturbation construction model. The classification results of the reconstructed samples are used to guide the construction direction of the inverse perturbation, so that the reconstructed samples can be correctly identified by the classifier.

[0061] S3: Using the training set to train the initial defense model to obtain a defense model.

[0062] S3 can include:

[0063] 1) Construct the generator loss function and the discriminator loss function respectively;

[0064] When constructing the generator loss function, the method used includes: first constructing the mean square error loss function, the adversarial loss function and the reconstruction loss function respectively, and then taking the weighted sum of the mean square error loss function, the adversarial loss function and the reconstruction loss function as the generator loss function. Then, the generator loss function is used to effectively guide the training process of the generator.

[0065] The generator directly generates inverse perturbations based on adversarial samples, and introduces mean square error loss to approximate adversarial perturbations to ensure the similarity between reconstructed samples and real samples. The mean square error loss function is as follows:

[0066]

[0067] In formula (4), L MSE is the mean square error loss function; (c, w, h) is the pixel coordinate of the perturbed image. It should be noted that the perturbed image is the image formed after the adversarial perturbation visualization, or the image formed after the inverse perturbation visualization. The pixels of the image formed after the adversarial perturbation visualization and the image formed after the inverse perturbation visualization are one-to-one corresponding; c is the number of layers where the pixel of the perturbed image is located; c = 1, 2, ..., C, C is the maximum number of layers of the perturbed image; w is the horizontal coordinate of the pixel, w = 1, 2, ..., W, W is the maximum horizontal coordinate of the perturbed image; h is the vertical coordinate of the pixel, h = 1, 2, ..., H, H is the maximum vertical coordinate of the perturbed image; when the perturbed image is a two-dimensional image, C is 1. IP (c, w, h) is the pixel value with coordinates (c, w, h) in the image formed after inverse perturbation visualization; r adv (c, w, h) is the pixel value with coordinates (c, w, h) in the image formed after adversarial perturbation visualization.

[0068] The adversarial loss function includes:

[0069]

[0070] In formula (5), L GAN To combat the loss function; is the expected value of the distribution function obeyed by the adversarial sample; P fake is the adversarial sample distribution; D is the discriminator; D(x RE ) is the output value of the discriminator for the reconstructed sample, that is, the output value of the discriminator when the reconstructed sample is used as input.

[0071] In the training process of the generative adversarial network, a classifier is introduced to predict and classify the reconstructed samples to determine whether the constructed reconstructed samples can be correctly classified, thereby guiding the inverse perturbation construction direction of the generator to guide the generator to construct effective inverse perturbations. The reconstruction loss function is as follows:

[0072]

[0073] In formula (6), is the reconstruction loss function; L ce (.) is the cross entropy loss function; M is the classifier; M(x RE ) is the predicted classification result of the classifier for the reconstructed sample, which is the output of the classifier; y true is the true category label of the reconstructed sample.

[0074] Based on equations (4), (5) and (6), the generator loss function of this embodiment is as follows:

[0075]

[0076] In formula (7), is the generator loss function; α, β, and γ are all hyperparameters, α is the weight corresponding to the adversarial loss function; β is the weight corresponding to the reconstruction loss function; γ is the weight corresponding to the mean square error loss.

[0077] The discriminator loss function is as follows:

[0078]

[0079] In formula (8), L D is the discriminator loss function; is the expected value of the distribution function obeyed by the real sample; P data is the real sample distribution; D(x true ) is the output value of the discriminator for the real sample, that is, the output value of the discriminator when the real sample is used as input.

[0080] The total loss function during the initial defense model training process is as follows:

[0081]

[0082] 2) Taking the training set as input, according to the generator loss function and the discriminator loss function, the parameters of the generator and the discriminator are iteratively updated by back propagation until a preset termination condition is reached, and the updated generator obtained in the last iteration is selected as the defense model.

[0083] Since the classifier already has mature sample prediction and classification capabilities, the overall model optimization process does not include optimizing and updating the model parameters in the classifier. In the process of training the initial defense model based on the training set, only the parameters of the generator and discriminator are iteratively updated.

[0084] The method of iteratively updating the parameters of the generator and the discriminator by back propagation according to the generator loss function and the discriminator loss function specifically includes: in one iterative update, first fix the parameters of the generator, update the parameters of the discriminator according to the discriminator loss function, and obtain the updated discriminator; then fix the parameters of the updated discriminator, and update the parameters of the generator according to the generator loss function to obtain the updated generator. The updated discriminator and the updated generator are used as the discriminator and the generator in the next iteration until the preset termination condition is reached, then the iteration is terminated, and the updated generator in the last iteration is selected as the defense model. The defense model obtained by the above training method is used to generate inverse perturbation, specifically, the adversarial sample input to the generator (defense model) is simulated through the convolution layer-deconvolution layer to simulate the adversarial perturbation added in the adversarial sample, so as to obtain the inverse perturbation, and the adversarial perturbation is eliminated by pixel-by-pixel subtraction operation according to the inverse perturbation to achieve the effect of reconstructing the adversarial sample, and obtain the reconstructed sample, so that the classification model can correctly identify and classify the adversarial sample.

[0085] The inverse perturbation is a pixel-level perturbation that approximates the adversarial perturbation. Assuming that the inverse perturbation is used to eliminate the adversarial perturbation, the reconstructed sample obtained can approximate the real sample, which means that the inverse perturbation is feasible for the adversarial sample defense task. The proof process is given below:

[0086] Proof: It is known that the existing adversarial sample generation method can be expressed as for the real sample x true Perform pixel-level perturbation modification to obtain adversarial samples that can be misclassified by the DNN model, which is specifically expressed as

[0087] x adv =x true +r adv ; (10)

[0088] According to the starting point of the present embodiment, the adversarial perturbation added to the sample is eliminated by performing an inverse operation opposite to the adversarial sample generation process. The inverse operation is expressed as

[0089] x RE =x adv -r IP ; (11)

[0090] Combined with the meaning of inverse perturbation, formula (11) can be further expressed as

[0091]

[0092] Substituting formula (10) into formula (12), we can further obtain

[0093]

[0094] From formula (13), we can see that if r IP tend to r adv , then

[0095]

[0096] Furthermore, the idea of ​​using inverse perturbation to reconstruct adversarial samples to approximate real samples described in this embodiment is established, that is, the assumption is established. Therefore, it can be seen that it is feasible to use inverse perturbation for adversarial sample defense tasks, and it can successfully resist the impact of adversarial perturbation on the non-robust features of samples.

[0097] This embodiment is based on the principle of adversarial sample attack, reversely thinks about the value of adversarial disturbance, determines to eliminate adversarial disturbance as the starting point of research, and reconstructs adversarial samples by constructing corresponding inverse disturbances to obtain reconstructed samples that are close to real samples, thereby obtaining better adversarial sample defense effects. The method of this embodiment is efficient. This method does not need to be based on a large number of data samples, nor does it need to modify the classifier model. It can solve the problem that existing defense methods consume too much time and resources and have poor effects. Applying it to the field of adversarial sample attack and defense can effectively make up for the current gaps in adversarial sample defense technology and has universality in target detection. The defense model trained in this embodiment can be added as an additional network before the classification model predicts the classification, and is used to effectively reconstruct the adversarial sample so that it can be correctly classified.

[0098] Embodiment 2:

[0099] This embodiment is used to provide an adversarial sample defense model training system, such as Figure 3 As shown, the training system comprises:

[0100] A first acquisition module M1 is used to acquire a training set; the training set includes adversarial samples and real samples; the adversarial samples are obtained by adding adversarial perturbations to the real samples;

[0101] A construction module M2 is used to construct an initial defense model; the initial defense model includes a generator, a discriminator and a classifier; the generator is connected to the discriminator and the classifier respectively; the generator is used to take the adversarial sample as input, generate an inverse perturbation, and obtain a reconstructed sample according to the inverse perturbation; the discriminator is used to take the real sample and the reconstructed sample as input, and discriminate the reconstructed sample; the classifier is used to take the reconstructed sample as input, and classify the reconstructed sample;

[0102] The training module M3 is used to train the initial defense model using the training set to obtain a defense model.

[0103] Embodiment 3:

[0104] This embodiment is used to provide a method for defending against adversarial samples. Figure 4 and Figure 5 As shown, the defense method includes:

[0105] T1: Obtain adversarial samples to be classified;

[0106] The adversarial samples to be classified may be known in advance, or may be detected by existing detection defense methods before the samples to be classified are input into the classification model.

[0107] T2: Taking the adversarial sample to be classified as input, the defense model is used to obtain a reconstructed sample;

[0108] T2 may include: taking the adversarial sample to be classified as input, generating an inverse perturbation using a defense model; performing pixel-level subtraction between the adversarial sample to be classified and the inverse perturbation to obtain a reconstructed sample.

[0109] T3: Classify the reconstructed samples using a classification model to obtain a classification result; the classification model adopts a deep neural network model.

[0110] This embodiment can be used for image classification. The adversarial sample to be classified is the image sample to be classified after the adversarial perturbation is added. The defense model is used to construct the inverse perturbation. The adversarial perturbation of the adversarial sample to be classified is eliminated by the inverse perturbation to obtain a reconstructed sample. The reconstructed sample can be approximated to the real sample. The reconstructed sample is input into the classification model, which can enable the classification model to correctly classify and avoid the problem of misclassification of the classification model caused by the adversarial perturbation, thereby significantly improving the classification accuracy of the classification model for the adversarial sample.

[0111] Embodiment 4:

[0112] This embodiment is used to provide an adversarial sample defense system, such as Figure 6 As shown, the defense system includes:

[0113] The second acquisition module M4 is used to obtain adversarial samples to be classified;

[0114] A reconstruction module M5, used to take the adversarial sample to be classified as input and obtain a reconstructed sample using a defense model;

[0115] The classification module M6 is used to classify the reconstructed samples using a classification model to obtain a classification result; the classification model adopts a deep neural network model.

[0116] Embodiment 5:

[0117] This embodiment is used to provide an adversarial sample defense device, including:

[0118] Processor; and

[0119] a memory storing computer readable program instructions,

[0120] When the computer-readable program instructions are executed by the processor, the training method described in Example 1 is executed, or the defense method described in Example 3 is executed.

[0121] Embodiment 6:

[0122] This embodiment is used to provide a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the steps of the training method described in Example 1 are implemented; or the steps of the defense method described in Example 3 are implemented.

[0123] Those skilled in the art will appreciate that various aspects of the present invention may be illustrated and described by a number of patentable categories or situations, including any new and useful process, machine, product or combination of substances, or any new and useful improvements thereto. Accordingly, various aspects of the present invention may be performed entirely by hardware, entirely by software (including firmware, resident software, microcode, etc.), or by a combination of hardware and software. The above hardware or software may be referred to as "data blocks", "modules", "engines", "units", "components" or "systems". In addition, various aspects of the present invention may be represented as a computer product located in one or more computer-readable media, which includes computer-readable program code.

[0124] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the invention belongs. It should also be understood that terms such as those defined in common dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant technology and should not be interpreted in an idealized or extremely formal sense, unless explicitly defined as such herein.

[0125] The above is an explanation of the present invention and should not be considered as a limitation thereof. Although several exemplary embodiments of the present invention have been described, it will be readily appreciated by those skilled in the art that many modifications may be made to the exemplary embodiments without departing from the novel teachings and advantages of the present invention. Therefore, all such modifications are intended to be included within the scope of the present invention as defined in the claims. It should be understood that the above is an explanation of the present invention and should not be considered as being limited to the specific embodiments disclosed, and modifications to the disclosed embodiments and other embodiments are intended to be included within the scope of the appended claims. The present invention is defined by the claims and their equivalents.

Claims

1. A method for training an adversarial sample defense model, characterized in that: The training method comprises: Acquire a training set; the training set includes adversarial samples and real samples; the adversarial samples are obtained by adding adversarial perturbations to the real samples; Constructing an initial defense model; the initial defense model includes a generator, a discriminator and a classifier; the generator is connected to the discriminator and the classifier respectively; the generator is used to take the adversarial sample as input, generate an inverse perturbation, and obtain a reconstructed sample according to the inverse perturbation; the discriminator is used to take the real sample and the reconstructed sample as input, and discriminate the reconstructed sample; the classifier is used to take the reconstructed sample as input, and classify the reconstructed sample; Using the training set to train the initial defense model to obtain a defense model; The generator architecture is used as the inverse perturbation construction model to generate inverse perturbations, which is specifically expressed as follows: r IP =G IPCM (x adv ); Among them, r IP is the inverse perturbation; G IPCM is a generator; x adv For adversarial examples; The calculation formula for reconstructing samples is as follows: x RE =x adv -r IP ; Among them, x RE To reconstruct the sample.

2. The training method according to claim 1, characterized in that: The using the training set to train the initial defense model to obtain the defense model specifically includes: Construct the generator loss function and the discriminator loss function respectively; Taking the training set as input, according to the generator loss function and the discriminator loss function, the parameters of the generator and the discriminator are iteratively updated by back propagation until a preset termination condition is reached, and the updated generator obtained in the last iteration is selected as the defense model.

3. The training method according to claim 2, characterized in that: The construction of the generator loss function specifically includes: Construct mean square error loss function, adversarial loss function and reconstruction loss function respectively; The weighted sum of the mean square error loss function, the adversarial loss function and the reconstruction loss function is used as the generator loss function.

4. The training method according to claim 2, characterized in that: The iterative updating of the parameters of the generator and the discriminator by back propagation according to the generator loss function and the discriminator loss function specifically includes: In one iterative update, the parameters of the generator are fixed, and the parameters of the discriminator are updated according to the discriminator loss function to obtain an updated discriminator; The parameters of the updated discriminator are fixed, and the parameters of the generator are updated according to the generator loss function to obtain an updated generator.

5. A system for training an adversarial sample defense model, characterized in that: The training system comprises: A first acquisition module is used to acquire a training set; the training set includes adversarial samples and real samples; the adversarial samples are obtained by adding adversarial perturbations to the real samples; A construction module is used to construct an initial defense model; the initial defense model includes a generator, a discriminator and a classifier; the generator is connected to the discriminator and the classifier respectively; the generator is used to take the adversarial sample as input, generate an inverse perturbation, and obtain a reconstructed sample according to the inverse perturbation; the discriminator is used to take the real sample and the reconstructed sample as input, and discriminate the reconstructed sample; the classifier is used to take the reconstructed sample as input, and classify the reconstructed sample; A training module, used to train the initial defense model using the training set to obtain a defense model; The generator architecture is used as the inverse perturbation construction model to generate inverse perturbations, which is specifically expressed as follows: r IP =G IPCM (x adv ); Among them, r IP is the inverse perturbation; G IPCM is a generator; x adv For adversarial examples; The calculation formula for reconstructing samples is as follows: x RE =x adv -r IP ; Among them, x RE To reconstruct the sample.

6. A method for defending against adversarial samples, characterized in that: The defense methods include: Obtain adversarial samples to be classified; Taking the adversarial sample to be classified as input, a defense model is used to obtain a reconstructed sample; the defense model is trained using the training method described in any one of claims 1 to 4; The reconstructed samples are classified using a classification model to obtain a classification result; the classification model adopts a deep neural network model.

7. The defense method according to claim 6, characterized in that: The step of taking the adversarial sample to be classified as input and obtaining the reconstructed sample by using the defense model specifically includes: Taking the adversarial sample to be classified as input, generating an inverse perturbation using a defense model; Perform pixel-level subtraction on the adversarial sample to be classified and the inverse perturbation to obtain a reconstructed sample.

8. An adversarial sample defense system, characterized in that: The defense system includes: The second acquisition module is used to obtain adversarial samples to be classified; A reconstruction module, used to use the adversarial sample to be classified as input and obtain a reconstructed sample using a defense model; the defense model is trained using the training method described in any one of claims 1 to 4; The classification module is used to classify the reconstructed samples using a classification model to obtain a classification result; the classification model adopts a deep neural network model.

9. An adversarial sample defense device, characterized in that: include: processor; as well as a memory storing computer readable program instructions, Wherein, when the computer-readable program instructions are executed by the processor, the training method as described in any one of claims 1 to 4 is executed, or the defense method as described in any one of claims 6 to 7 is executed.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the training method described in any one of claims 1 to 4 are implemented; or the steps of the defense method described in any one of claims 6 to 7 are implemented.