Disturbance estimation and denoising-based confrontation sample detection method
Through a detection method based on perturbation estimation and denoising, autoencoders and fully connected neural networks are used to estimate and remove the perturbation of adversarial samples, which solves the problems of poor versatility and misclassification of adversarial sample detection in the existing technology, and improves detection accuracy. and efficiency.
Patent Information
- Application Number
- CN202410741534.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-10-01
AI Technical Summary
Existing adversarial sample detection methods have poor versatility, and image processing technology may damage the original information of the sample, resulting in misclassification and low recall rate.
Design an adversarial sample detection method based on disturbance estimation and denoising, estimate the disturbance intensity through autoencoders and fully connected neural networks, add noise and perform denoising processing, and use the target model prediction results to determine the sample type.
It improves the accuracy and efficiency of adversarial sample detection, effectively removes residual disturbances, balances information retention and disturbance elimination, and reduces misclassification and false positive rates.
Smart Images

Figure CN118734900A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of adversarial sample detection, and in particular to an adversarial sample detection method based on perturbation estimation and denoising. Background Art
[0002] Adversarial sample detection refers to the process of identifying samples that are affected by adversarial perturbations by analyzing the features of input samples. However, existing methods use image features to detect adversarial samples, which are usually unable to cope with adversarial samples of various types and intensities. Currently, methods based on model prediction inconsistency have attracted widespread attention. This type of method uses some image processing techniques to reduce the impact of adversarial samples on the model, and then detects adversarial samples based on the inconsistency of the model's predictions of samples before and after processing. There is no need for complex threshold settings, and image processing is random, which can avoid being bypassed by attacks. It is suitable for different types of data and attack methods.
[0003] However, the current detection methods based on model prediction inconsistency have problems: image processing technology may damage the original information of its samples, resulting in misclassification and increased false positive detection rate; image processing technology does not take into account residual adversarial perturbations, thereby affecting the recall rate of adversarial samples. Summary of the invention
[0004] The present invention provides an adversarial sample detection method based on disturbance estimation and denoising, so as to solve the technical problems that the existing adversarial sample detection method has poor versatility and the image processing technology affects the detection accuracy.
[0005] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0006] Design a method for detecting adversarial examples based on perturbation estimation and denoising, including the following steps:
[0007] S1: Use different attack methods including FGSM, PGD, CW, DeepFool, AutoAttack to create adversarial samples x adv , and with the same number of benign samples x beg Composed training set X train , where the label is the perturbation intensity ∈ and the corresponding benign sample x b , select the target model F().
[0008] S2: Construct an autoencoder PEA(), using the training set D train Train the autoencoder PEA(), input the sample to be tested x, and output the estimated perturbation ∈ of the same size p .
[0009] S3: Construct a fully connected neural network FCN(), where FCN() is based on the perturbation intensity I(∈p ) outputs a value σ as the noise variance, and adds Gaussian noise n~G(0,σ) to the sample x to be tested in S2 to obtain x n .
[0010] S4: Construct a denoising autoencoder D() and input the noisy sample x in S3 n Perform denoising and output x d
[0011] S5: Use S1 X train Training will be S3 FCN () and S4 D (), S4 x d With X train The corresponding benign sample x in b The difference between them is used as the loss to update the parameters of the FCN() in S3 and the D() model in S4.
[0012] S6: Input the sample x to be tested into PEA() in S2, and get ∈ p , and calculate the disturbance intensity I(∈ p ), compare I(∈ p ) and threshold λ, I(∈ p ) is less than the threshold λ, it is judged as a two-type sample. p ) is greater than or equal to the threshold λ, then subsequent operations are performed for further judgment.
[0013] S7: I(∈ p ) is input into S3 FCN() to obtain the noise variance σ, and Gaussian noise n~G(0,σ) is added to x to obtain x n , x n Input to S4 D(), denoise to get x d , use F() in S1 to compare x and x d Make a prediction and get the result F(x)=F(x d ), then x is considered a benign sample; if F(x)≠F(x d ), then x is judged as an adversarial sample.
[0014] Furthermore, in step S2, the autoencoder PEA() is a U-Net structure, including three stages of downsampling and upsampling, the loss adopts mean square error, and the output and input sizes of PEA() are the same.
[0015] Furthermore, in step S3, FCN() includes three fully connected layers, after injecting the corresponding noise into the sample x to obtain xn, the noise n' of the same intensity is added to the predicted disturbance ∈p, and concatenated to the sample xn.
[0016] Furthermore, in step S5, the reconstruction loss uses the mean square error of the sample to be tested x and the benign sample xb, and in order to constrain the noise level to make it as large as possible, a noise constraint term 1 / σ+1 is added to the loss.
[0017] Compared with the prior art, the beneficial technical effects of the present invention are:
[0018] 1. The present invention trains a denoising autoencoder by estimating the prior knowledge of adversarial perturbations and noise levels. The goal of this autoencoder is to remove noise and residual adversarial perturbations from samples. By using prior knowledge, i.e., the estimated adversarial perturbations and noise levels, to train a denoising autoencoder, noise and residual adversarial perturbations can be removed more effectively, thereby improving the accuracy of adversarial sample detection.
[0019] 2. Before performing the denoising and de-noising process, the present invention first selects a threshold value according to the disturbance intensity, which can avoid subsequent processing for some easily identifiable benign samples, thereby improving the detection efficiency without affecting the overall accuracy.
[0020] 3. The present invention overcomes the limitations of previous denoising methods in removing residual adversarial disturbances. By adding noise to the image and then performing non-blind denoising processing, the noise and residual disturbances can be effectively eliminated, thereby balancing the problem between retaining the original information and eliminating adversarial disturbances, and reducing the possible incomplete denoising. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 This is a diagram of the architecture of the adversarial sample detection method of the present invention.
[0022] Figure 2 It is the detection accuracy of the adversarial sample detection method used in the present invention.
[0023] Figure 3 This is a comparison of the accuracy of the adversarial sample detection method used in the present invention and other detection methods.
[0024] Figure 4 This is to verify the effectiveness of the perturbation estimation autoencoder PEA() of the present invention.
[0025] Figure 5 The prediction confidence of samples at each stage in the present invention demonstrates the effectiveness principle of the present invention.
[0026] Figure 6 This is the noise change predicted by the present invention for adversarial samples of different strengths, as well as the change in confidence of the correct label. DETAILED DESCRIPTION
[0027] The specific implementation modes of the present invention are described below in conjunction with the accompanying drawings and examples. However, the following examples are only used to illustrate the present invention in detail and do not limit the scope of the present invention in any way.
[0028] Example 1: A method for detecting adversarial samples based on perturbation estimation and denoising, see Figure 1 The method consists of two stages: first, train the perturbation estimation autoencoder PEA to estimate the perturbation; add noise and concatenate the denoising prior with the sample; then use the trained denoising module D() to denoise the sample and restore it to a benign sample; detect the adversarial sample based on the prediction results of the target model.
[0029] 1) Training the perturbation estimation autoencoder PEA part: see Figure 1 The left half of the middle part is PerturbationEstimation (PEA), which uses a three-layer U-Net structure to predict adversarial perturbations ∈ according to the input sample x. The output of PEA is a tensor ∈ with the same size as the input sample x. p .
[0030] 2) Noise addition and denoising priors and sample concatenation: see Figure 1 In the middle right part, a fully connected neural network FCN() is used to predict the required noise variance based on the perturbation strength ∈ of the sample. The obtained noise is represented as a random vector that follows a Gaussian distribution and is added to the sample to be tested to generate another set of noise n' with the same distribution as the noise added to the image, which is consistent with the estimated perturbation ∈ p Add together to get a noise perturbation mixed feature n'+∈ p . Then the noisy version of the original image x n Mixed features n'+∈ with noise perturbation p Concatenate to form input features.
[0031] 3) Denoising module D() training part: L2 loss and noise constraint. L2 loss is x d With x b The pixel-level L2 distance between d and the corresponding benign image x b The noise constraint term 1 / (1+σ) prevents the model from predicting too small a noise variance in order to make denoising easier. This loss function can constrain both the denoising module and the denoising module, updating the parameters of the two modules so that the noise added by the denoising module is not too large to destroy the original information, and ensures that the denoising module can remove the noise, making the denoised image as similar as possible to the benign image.
[0032] 4) Adversarial sample detection part: see Figure 1In the middle and lower parts, the target model F() is used to analyze the samples x and x before and after processing. d Classify and compare the prediction results. If F(x)≠F(x d ), then x is regarded as an adversarial sample.
[0033] This paper uses FGSM, PGD, CW, DeepFool, and AutoAttack attack methods to generate adversarial samples and benign samples from three datasets, MINIST, CIFAR10, and ImageNet, to form training and test sets. This paper uses a variety of evaluation indicators to quantify the performance of adversarial sample detection methods. Among them, the main evaluation indicators include detection accuracy, recall, and false positive rate. The test results are shown in Figure 2 The present invention is compared with other advanced detection methods such as FS (Feature squeezing), LID (Local intrinsic dimensionality), MagNet, ADDITION, etc. The results are shown in Table 3.
[0034] The present invention needs to predict the adversarial perturbation in the sample, and the FGSM attack method generates MINIST adversarial samples. The attack strength includes ε = {32 / 255, 64 / 255, 96 / 255}, a total of 100 adversarial samples, and calculates the true perturbation strength of these adversarial samples, and compares the perturbation strength of the perturbation estimate of PEA. The results are shown in Figure 4 As shown in the figure, each point represents an adversarial sample, the horizontal axis represents the actual perturbation intensity of the sample, and the vertical axis represents the perturbation intensity predicted by PEA.
[0035] The present invention obtains a suitable noise level according to the intensity of the disturbance, adds it to the sample and performs denoising, predicts the samples before and after the processing, and detects adversarial samples according to the prediction inconsistency. In order to demonstrate the detection principle of the method, the confidence of the model prediction for benign samples, corresponding adversarial samples, adversarial sample noisy versions, and adversarial sample noisy and denoised versions is statistically analyzed. Figure 4 The x-axis of the middle bar graph represents the sample type (benign image, adversarial sample, adversarial sample after adding noise, adversarial sample after denoising), and the y-axis represents the classification confidence. Each column represents the confidence of a class of samples in different categories.
[0036] Compared with the ADDITION method with the same principle, the present invention can take into account the residual adversarial perturbation in the denoising process, and use FGSM attack to generate CIFAR10 image adversarial samples with different perturbation levels. The noise variance required for adversarial samples with different perturbation levels, as well as the correct label confidence and incorrect label confidence after processing are respectively counted. The results are as follows: Figure 5 shown.
[0037] Finally, in the model training of the present invention, we use benign and adversarial samples as training data in a ratio of 1:1, and set the batch size to 256. PEA and NAD modules are trained separately. α=0.01, the stochastic gradient descent (SGD) optimization algorithm is used, the initial learning rate is lr=10-1, and the momentum is set to 0.9. Through experimental research, it is found that setting the threshold λ to 0.001 can preliminarily screen out some adversarial samples and ensure that there are no false negatives in this step. A smaller threshold λ may be required for adversarial samples with smaller perturbation intensity. In order to dynamically adjust the learning rate, exponential decay is used with a decay rate (gamma) of 0.99, and 1000 epochs are performed during training.
[0038] The present invention has been described in detail above with reference to the accompanying drawings and embodiments. However, those skilled in the art will appreciate that, without departing from the spirit of the present invention, the specific parameters in the above embodiments may be changed to form a plurality of specific embodiments, which are all within the common variation range of the present invention and will not be described in detail herein.
Claims
1. A method for detecting adversarial samples based on perturbation estimation and denoising, characterized in that: The following steps are involved: S1: Use different attack methods including FGSM, PGD, CW, DeepFool, AutoAttack to create adversarial samples x adv , and with the same number of benign samples x beg Composed training set X train , where the label is the perturbation intensity ∈ and the corresponding benign sample x b , select the target model F(). S2: Construct an autoencoder PEA(), using the training set D train Train the autoencoder PEA(), input the sample to be tested x, and output the estimated perturbation ∈ of the same size p . S3: Construct a fully connected neural network FCN(), where FCN() is based on the perturbation intensity I(∈ p ) outputs a value σ as the noise variance, and adds Gaussian noise n~G(0,σ) to the sample x to be tested in S2 to obtain x n . S4: Construct a denoising autoencoder D() and input the noisy sample x in S3 n Perform denoising and output x d S5: Use S1 X train Training will be S3 FCN () and S4 D (), S4 x d The benign sample x corresponding to Xtrain b The difference between them is used as the loss to update the parameters of the FCN() in S3 and the D() model in S4. S6: Input the sample x to be tested into PEA() in S2, and get ∈ p , and calculate the disturbance intensity I(∈ p ), compare I(∈ p ) and threshold λ, I(∈ p ) is less than the threshold λ, it is judged as a two-type sample. p ) is greater than or equal to the threshold λ, then subsequent operations are performed for further judgment. S7: I(∈ p ) is input into S3 FCN() to obtain the noise variance σ, and Gaussian noise n~G(0,σ) is added to x to obtain x n , x n Input to S4 D(), denoise to get x d , use F() in S1 to compare x and x d Make a prediction and get the result F(x)=F(x d ), then x is considered a benign sample; if F(x)≠F(x d ), then x is judged as an adversarial sample.
2. The method for domain named entity recognition based on hybrid prompt learning and rules according to claim 1, characterized in that: In step S2, the autoencoder PEA() is a U-Net structure, including three stages of downsampling and upsampling, the loss adopts mean square error, and the output and input sizes of PEA() are the same.
3. The method for domain named entity recognition based on hybrid prompt learning and rules according to claim 1, characterized in that: In step S3, FCN() includes three fully connected layers, and after injecting the corresponding noise into the sample x, x is obtained. n , the noise n' of the same intensity is combined with the predicted disturbance ∈ p Add and in sample x n Splicing.
4. The method for domain named entity recognition based on hybrid prompt learning and rules according to claim 1, characterized in that: In step S5, the reconstruction loss is calculated by using the test sample x and the benign sample x b And in order to constrain the noise level to be as large as possible, a noise constraint term 1 / σ+1 is added to the loss.
