A method and device for detecting adversarial samples based on layer-by-layer correlation propagation

The layer-by-layer correlation propagation detection method solves the shortcomings of adversarial sample detection in the existing technology, achieves fast and accurate detection of deep learning models, improves the security of the model, and protects the model from interference by adversarial samples.

CN113378985BActive Publication Date: 2024-10-15ZHEJIANG UNIV OF TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202110761503.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-06
Publication Date
2024-10-15
Estimated Expiration
2041-07-06

AI Technical Summary

Technical Problem

Existing adversarial sample detection methods lack the detection of abnormal activation patterns within deep learning models and cannot effectively resist unknown attack strategies. Moreover, the migration of adversarial samples causes the model to still be deceived in the face of new attacks.

Method used

Using a detection method based on layer-by-layer correlation propagation, by calculating the layer-by-layer neuron correlation scores of image samples, using the correlation score distribution of benign samples to determine the threshold range, detecting whether the sample to be tested is an adversarial sample, and realizing the deep learning model rapid and accurate detection.

Benefits of technology

By analyzing the activation transfer state within the model and detecting and screening based on regular transfer connections, the accuracy of adversarial sample detection and the security of the deep learning model are improved, and the model is protected from interference by adversarial samples.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113378985B_ABST
    Figure CN113378985B_ABST
Patent Text Reader

Abstract

The present invention discloses an adversarial sample detection method and device based on layer-by-layer correlation propagation, including: obtaining image samples, using the image samples to train a deep learning model; inputting benign image samples into the trained deep learning model, and calculating the correlation score of each benign image sample, wherein the correlation score of the benign image sample is calculated by the correlation score of the pixel point, and the correlation score of the pixel point is calculated by reverse layer-by-layer transmission based on the correlation of the neuron; determining the discrimination basis of the adversarial sample by statistically analyzing the correlation score distribution of most benign image samples; inputting the image sample to be tested into the trained deep learning model, calculating the correlation score of the image sample to be tested, and detecting whether the image sample to be tested is an adversarial sample based on the discrimination basis. This enables rapid and accurate detection of various adversarial samples of various deep learning models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of data security, and specifically relates to an adversarial sample detection method and device based on layer-by-layer correlation propagation. Background Art

[0002] Deep neural networks (DNNs) have been widely used and played a significant role in various scientific fields, from natural language processing and computer vision to smart healthcare and smart transportation. DNNs have shown excellent accuracy, but studies have shown that they are particularly vulnerable to adversarial examples: carefully crafted input perturbations that cause machine learning algorithms to misclassify, and the input perturbations are imperceptible to the naked eye.

[0003] DNNs have been widely used in many safety-critical scenarios. However, the latest deep learning systems have various vulnerabilities that may lead to serious consequences when applied to real-world applications. The emergence of adversarial examples has brought great challenges to the safe use of deep learning, especially in security-sensitive fields such as autonomous driving and facial payment. The existence of adversarial examples has brought more uncertainty to the technology itself and its implementation. Adversarial examples have now become a hot topic in the field of deep learning security. The generation, characteristics, detection and correction methods of adversarial examples are all current research focuses.

[0004] At present, the research on adversarial samples can be mainly divided into two aspects: attack and defense. Attack, that is, the generation of adversarial samples, is divided into white-box attack and black-box attack according to the knowledge required when generating adversarial samples. The difference lies in whether the attacker can obtain the internal parameters of the model when generating adversarial samples. The defense method can be divided into adversarial sample detection, adversarial sample restoration and improving the robustness of the model. Another very important feature of adversarial samples is its transferability: adversarial samples generated for a certain model are also offensive to many other models. At present, many defense methods have been proposed for adversarial sample attacks, among which adversarial training is the most effective method to improve the robustness of neural networks. However, no matter how robust the model is, when a new adversarial attack appears, the deep model will still be deceived. Therefore, it is necessary to propose a flexible and effective adversarial sample detection method.

[0005] For the detection of adversarial samples, most of the existing adversarial sample detection methods are based on sample detection, which requires the preparation of a large number of adversarial samples in advance and the generation of adversarial sample detectors based on the features of adversarial samples. There is a lack of detection of abnormal activation patterns of models from adversarial samples, and when the defender's attack strategy is unknown, it is impossible to resist the attack. Summary of the invention

[0006] In view of the above problems, the present invention proposes an adversarial sample detection method and device based on layer-by-layer correlation propagation, so as to achieve fast and accurate detection of various adversarial samples of various deep learning models.

[0007] In a first aspect, an embodiment provides an adversarial sample detection method based on layer-by-layer correlation propagation, comprising the following steps:

[0008] Obtain image samples and use them to train a deep learning model;

[0009] Input the benign image samples into the trained deep learning model and calculate the relevance score of each benign image sample, where the relevance score of the benign image sample is calculated by the relevance score of the pixel points, and the relevance score of the pixel points is calculated by reverse transmission layer by layer based on the relevance of the neurons;

[0010] Statistically analyze the correlation score distribution of most benign image samples to determine the basis for distinguishing adversarial samples;

[0011] The image sample to be tested is input into the trained deep learning model, the correlation score of the image sample to be tested is calculated, and whether the image sample to be tested is an adversarial sample is detected based on the discrimination basis.

[0012] Preferably, the correlation score f(x) of the benign image sample is:

[0013]

[0014] in, is the correlation score of the p-th pixel, Indicates that the pixel has an impact on the prediction result, otherwise it has no impact.

[0015] Preferably, the correlation scores of the pixels are calculated by reversely transferring the correlation of neurons layer by layer and include:

[0016] The correlation of neuron i in layer l is expressed as: the correlation of all neurons in layer l+1 is decomposed and then summed. The specific formula is as follows:

[0017]

[0018] in, It means that if neuron i in layer l contributes to neuron j in layer l+1, then neuron i in layer l should account for the correlation of neuron j in layer l+1. The large share of, that is, neuron i collects the contribution of neuron j connected to the next layer, The calculation formula is as follows:

[0019]

[0020] Among them, z ij represents the weighted activation of neuron i in layer l to neuron j in layer l+1, z j is the weighted activation of all neurons in the lth layer to the neuron j in the l+1th layer, ε represents a constant coefficient, and sign() is a sign function.

[0021] Preferably, the basis for determining the adversarial sample by statistically analyzing the correlation score distribution of the majority of benign image samples includes:

[0022] The threshold range formed by the correlation scores of most benign image samples is counted and used as the basis for judgment.

[0023] Preferably, when the correlation score of the image sample to be tested exceeds a threshold range formed by the correlation scores of most benign image samples, the image sample to be tested is considered to be an adversarial sample.

[0024] Preferably, the Lenet model is trained using image samples from the MNIST dataset;

[0025] Train the VGG16 model using image samples from the CIFAR10 dataset;

[0026] The ResNet-34 model is trained using image samples from the ImageNet dataset.

[0027] Preferably, a cross entropy function is used as a loss function to train the deep learning model.

[0028] In a second aspect, an embodiment provides an adversarial sample detection device based on layer-by-layer correlation propagation, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned adversarial sample detection method based on layer-by-layer correlation propagation when executing the computer program.

[0029] The technical solution provided by the above embodiment has at least the following beneficial effects: by analyzing the activation transfer state layer by layer within the model, and based on the regular transfer connections existing within the model, adversarial samples can be detected and identified to protect the deep learning model. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. 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.

[0031] Figure 1 is a flowchart of an adversarial sample detection method based on layer-by-layer correlation propagation provided by an embodiment;

[0032] Figure 2 It is a schematic diagram of layer-by-layer correlation propagation provided by an embodiment. DETAILED DESCRIPTION

[0033] To make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific implementation methods described herein are only used to explain the present invention and do not limit the scope of protection of the present invention.

[0034] Faced with the security threat of adversarial samples to deep learning models and the problems of existing adversarial sample detection methods lacking internal mechanism explanations and high cost. In order to improve the security of deep models and prevent adversarial samples from interfering with and threatening deep models, the embodiment provides an adversarial sample detection method based on layer-by-layer correlation propagation, which analyzes the layer-by-layer neuron activation transmission state inside the model and transmits connections based on the regularity inside the model, so as to detect and identify adversarial samples and protect deep learning models.

[0035] Figure 1 is a flow chart of an adversarial sample detection method based on layer-by-layer correlation propagation provided by an embodiment. Figure 1 As shown, the adversarial sample detection method based on layer-by-layer correlation propagation provided by the embodiment includes the following steps:

[0036] Step 1: Obtain image samples and perform preprocessing.

[0037] In the embodiment, image datasets are used for performance verification, including small datasets MNIST dataset and CIFAR-10 dataset, and the large dataset uses ImageNet dataset. Specific introduction of the dataset: The training set of the MNIST dataset has ten categories, 6000 samples in each category, ten categories in the training set, 1000 samples in each category, the pixels of each sample are 28×28, and each sample is a single channel. The training set of the CIFAR-10 dataset has ten categories, 5000 samples in each category, ten categories in the training set, 1000 samples in each category, the pixels of each sample are 32×32, and each sample is three channels. The ImageNet dataset has 1000 categories, each category contains 1000 samples, the pixels of each sample are 224×224, and each sample is three channels. 30% of the pictures are randomly selected from each category as the test set, and the remaining pictures are used as the training set. Onehot encode the categories of the data to obtain the corresponding category label sequence for easy training and testing.

[0038] Step 2: Use image samples to train the deep learning model.

[0039] Different model structures are used for training for different image datasets. The MNIST dataset uses the Lenet model, the CIFAR10 dataset uses the VGG16 model, and the ImageNet dataset uses the pre-trained ResNet-34 model. The training sets unified hyperparameters: stochastic gradient descent (SGD), adam optimizer, learning rate of 0.2, and num epochs. epoch , batch size is num batch .

[0040] Cross entropy is used as the loss function during training:

[0041]

[0042] Among them, y i is the true label of category i, p i is the probability value of category i calculated by the softmax function; k is the number of categories, and N is the total number of samples. The calculation formula of the state Softmax is:

[0043]

[0044] Among them, the numerator is the exponential of the predicted output of category i to be calculated, and the denominator is the exponential sum of the predicted outputs of all categories. The model parameters are saved after training.

[0045] Step 3: Input the benign image samples into the trained deep learning model and calculate the relevance score of each benign image sample.

[0046] In the embodiment, the correlation score of the benign image sample is calculated by the correlation score of the pixel points, and the correlation score of the pixel points is calculated by reverse transmission layer by layer based on the correlation of neurons.

[0047] For a deep learning model consisting of multiple layers of neurons, the neurons in each layer of the neural network are:

[0048]

[0049] Among them, x j represents the output of neuron j, g represents the activation function of neuron j, and w ij is the connection weight from neuron i to j, and b represents the connection bias.

[0050] In the embodiment, the correlation score f(x) of the benign image sample is:

[0051]

[0052] in, is the correlation score of the p-th pixel, It means that the pixel point has an impact on the prediction result, otherwise it has no impact. The correlation score f(x) is used as the prediction value of the input sample.

[0053] like Figure 2 As shown, the correlation of neurons is passed layer by layer. For the known correlation of neuron j in the l+1th layer, This correlation can be Decomposed into all neurons in the lth layer, the specific formula is as follows:

[0054]

[0055] The correlation of neuron i in the lth layer can be expressed as: the correlation of all neurons in the l+1th layer is decomposed and then summed. The specific formula is as follows:

[0056]

[0057] in, The meaning is that if a neuron i in layer l makes a major contribution to a neuron j in layer l+1, then neuron i in layer l should account for the correlation of neuron j in layer l+1. , i.e. neuron i collects its contribution to neuron j connected to the next layer. The calculation formula is as follows:

[0058]

[0059] Among them, z ij It is represented as the weighted activation of neuron i in layer l to neuron j in layer l+1, z j is the weighted activation of all neurons in layer l to neuron j in layer l+1. ε represents a constant coefficient, and sign() is a sign function.

[0060] Step 4: Input the adversarial sample into the trained deep learning model and calculate the relevance score of the adversarial sample.

[0061] For different data sets and corresponding models, use a variety of methods to attack and generate corresponding adversarial samples S adv , the specific attack methods include:

[0062] FGSM: Use the loss function J(Θ,x,y) to perform adversarial attacks on the input feature vector. The generation of adversarial samples is expressed as:

[0063]

[0064] Among them, ε is an adjustment coefficient, sign() is a symbol function, θ is a model parameter, x represents the sample input to the model, and y represents the output class label of sample x. When the value is greater than 0, it is 1; when it is equal to 0, it is 0; when it is less than 0, it is -1. It represents the gradient of x, and J(.) represents the loss function of the training model.

[0065] MI-FGSM: A method to accelerate the gradient descent algorithm, which accumulates velocity vectors along the gradient direction of the loss function during iteration, uses the idea of ​​momentum to generate adversarial samples, and obtains good results. Generate non-target adversarial samples x from benign samples x * , in satisfying L ∞ In the case of norm bounds, the gradient-based method seeks adversarial samples by solving a constrained optimization problem, and the generation formula is as follows:

[0066]

[0067] Among them, ε is the size of the adversarial perturbation, and the momentum is integrated into the iterative MI-FGSM to stabilize the update direction and avoid falling into local maximum.

[0068] CW: CW attack is an optimization-based adversarial attack technique that completes the attack by approximately solving the following optimization problem:

[0069]

[0070] Among them, L is a loss function used to measure the distance between the predicted value and the true value, and the constant λ is used to balance the two loss ratios.

[0071] For different data set models, the generated adversarial samples are saved in sequence.

[0072] Step 5: Detect adversarial samples using the adversarial sample discrimination basis determined by statistically analyzing the correlation score distribution of the majority of benign image samples.

[0073] In the embodiment, the layer-by-layer correlation scores of a large number of benign samples are counted, and the correlation score distribution of benign samples is calculated as the basis for distinguishing adversarial samples. When the layer-by-layer correlation score of an unknown sample does not meet the range of the statistical benign sample representation, it is determined to be an attack sample.

[0074] Specifically, a threshold range formed by the correlation scores of most benign image samples is counted and used as a basis for judgment. When the correlation score of the image sample to be tested exceeds the threshold range formed by the correlation scores of most benign image samples, the image sample to be tested is considered to be an adversarial sample.

[0075] In order to evaluate the detection effect of the adversarial sample of the above method, the embodiment uses the adversarial sample detection rate ADR, the adversarial sample false positive rate NR and the adversarial sample missed positive rate OR to evaluate the detection effect.

[0076] The embodiment further provides an adversarial sample detection device based on layer-by-layer correlation propagation, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the adversarial sample detection method based on layer-by-layer correlation propagation is implemented, comprising the following steps:

[0077] Step 1: Obtain image samples and perform preprocessing.

[0078] Step 2: Use image samples to train the deep learning model.

[0079] Step 3: Input the benign image samples into the trained deep learning model and calculate the relevance score of each benign image sample.

[0080] Step 4: Input the adversarial sample into the trained deep learning model and calculate the relevance score of the adversarial sample.

[0081] Step 5: Detect adversarial samples using the adversarial sample discrimination basis determined by statistically analyzing the correlation score distribution of the majority of benign image samples.

[0082] The adversarial sample detection and device based on layer-by-layer correlation propagation provided in the above-mentioned embodiments achieves the purpose of detecting and identifying adversarial samples and protecting deep learning models by analyzing the layer-by-layer activation transfer state within the model and according to the regular transfer connections existing within the model.

[0083] The specific implementation methods described above provide a detailed description of the technical solutions and beneficial effects of the present invention. It should be understood that the above is only the most preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, supplements and equivalent substitutions made within the scope of the principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for detecting adversarial examples based on layer-by-layer correlation propagation, It is characterized in that The following steps are involved: Obtain image samples and use them to train a deep learning model; Input the benign image samples into the trained deep learning model and calculate the relevance score of each benign image sample, where the relevance score of the benign image sample is calculated by the relevance score of the pixel points, and the relevance score of the pixel points is calculated by reverse transmission layer by layer based on the relevance of the neurons; Counting the correlation score distribution of most benign image samples to determine the basis for distinguishing adversarial samples, including: counting the threshold range formed by the correlation scores of most benign image samples, and using the range as the basis for distinguishing; The image sample to be tested is input into the trained deep learning model, the correlation score of the image sample to be tested is calculated, and whether the image sample to be tested is an adversarial sample is detected based on the discrimination criteria. When the correlation score of the image sample to be tested exceeds the threshold range formed by the correlation scores of most benign image samples, the image sample to be tested is considered to be an adversarial sample.

2. The adversarial sample detection method based on layer-by-layer correlation propagation as claimed in claim 1, It is characterized in that The relevance score f(x) of the benign image sample is: in, is the correlation score of the p-th pixel, Indicates that the pixel has an impact on the prediction result, otherwise it has no impact.

3. The adversarial sample detection method based on layer-by-layer correlation propagation according to claim 1 or 2, It is characterized in that The correlation scores of the pixels are calculated based on the correlation of neurons and are transferred back layer by layer, including: The correlation of neuron i in layer l is expressed as: the correlation of all neurons in layer l+1 is decomposed and then summed. The specific formula is as follows: in, It means that if neuron i in layer l contributes to neuron j in layer l+1, then neuron i in layer l should account for the correlation of neuron j in layer l+1. The large share of, that is, neuron i collects the contribution of neuron j connected to the next layer, The calculation formula is as follows: Among them, z ij represents the weighted activation of neuron i in layer l to neuron j in layer l+1, z j is the weighted activation of all neurons in the lth layer to the neuron j in the l+1th layer, ε represents a constant coefficient, and sign() is a sign function.

4. The adversarial sample detection method based on layer-by-layer correlation propagation as claimed in claim 1, It is characterized in that Train the Lenet model using image samples from the MNIST dataset; Train the VGG16 model using image samples from the CIFAR10 dataset; The ResNet-34 model is trained using image samples from the ImageNet dataset.

5. The adversarial sample detection method based on layer-by-layer correlation propagation as claimed in claim 1, It is characterized in that The cross entropy function is used as the loss function to train the deep learning model.

6. An adversarial sample detection device based on layer-by-layer correlation propagation, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the adversarial sample detection method based on layer-by-layer correlation propagation according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Defense method for quantitatively identifying countermeasure attacks based on concept sensitivity

    CN111753881A

  • Interpretability-based neural network adversarial sample detection and recovery method

    CN111783853A

  • Hyperspectral image classification method and system for sample relation learning

    CN112651317A