An adversarial defense method based on difficulty-guided variable attack strategy
Dynamically adjusting the generation of adversarial samples through difficulty-guided variable attack strategies solves the trade-off problem between robustness and accuracy in adversarial training, enhances the robustness of deep learning models and maintains the integrity of the data structure.
Patent Information
- Application Number
- CN202310831043.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-07
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2043-07-07
AI Technical Summary
When existing adversarial training methods improve the robustness of deep learning models, they usually lead to a reduction in natural data test accuracy, and there is a difficult trade-off between the robustness and accuracy of adversarial sample generation, making it difficult to maintain the integrity of the data structure. sex.
Adopting a variable attack strategy based on difficulty guidance, by dynamically adjusting the attack steps and disturbance intensity of adversarial samples, adversarial samples are generated according to the difficulty threshold of the image, and the difficulty of adversarial samples is continuously increased during the training process to enhance the robustness of the model property, while filtering misclassified samples and maintaining the integrity of the data structure.
The robustness and accuracy of the deep neural network are improved. Through each sample's consistent contribution to the model, the damage to the data structure caused by adversarial samples is reduced, and a balance between robustness and accuracy is achieved.
Smart Images

Figure CN116883736B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of adversarial defense technology, and more specifically, relates to an adversarial defense method based on difficulty-guided variable attack strategies. Background Art
[0002] Deep neural networks have demonstrated remarkable performance in both academic and industrial fields, however, they are easily misled by adversarial examples, which are created by introducing almost imperceptible perturbations to benign images. In recent years, many studies have focused on generating adversarial examples, and several practical applications of deep networks have been shown to be vulnerable to adversarial examples, such as image classification, object detection, and neural machine translation. The sensitivity of deep networks to adversarial examples has raised concerns about the security of artificial intelligence and brought new challenges to the implementation of deep learning.
[0003] The goal of adversarial defense methods is to improve the vulnerability of existing deep learning target networks when attacked. Existing methods for dealing with adversarial examples can be broadly classified into three categories: preprocessing methods, improving neural network structures, and using external information to enhance the target network. Preprocessing methods aim to improve the robustness of the target network by applying data augmentation or filtering techniques during training; improving neural network structures involves modifying the architecture or training methods to increase robustness; using external information to enhance the target network involves using external target networks or knowledge to enhance the robustness of the target network.
[0004] At present, adversarial training is considered to be the most effective method to improve the robustness of deep learning target networks, and is a method of using external information to enhance the target network. Adversarial Training Adversarial Examples (AEs) generated by attack methods such as Fast Gradient Sign Method (FGSM) and Projected Gradient Descent (PGD) are incorporated into the training data for target network enhancement. FGSM calculates the gradient of the target network to create adversarial examples, while PGD is a more advanced multi-step version of FGSM that further improves the robustness of the target network. Although the effectiveness of adversarial training has been demonstrated, many experiments have shown that it is more challenging than ordinary training.
[0005] A common phenomenon faced by adversarial training is that, despite being able to enhance the robustness of adversarial samples, it usually leads to a reduction in standard accuracy when tested on natural non-adversarial data. This trade-off between robustness and accuracy is an important concern in the field of adversarial learning. It not only affects the practicality of existing methods, but also highlights the competitive relationship caused by the inconsistent distribution of adversarial and natural data in adversarial training, which may have a significant impact on the training process and bring considerable difficulties. A large number of existing studies have attempted to explain the potential causes of this phenomenon from the perspective of the training stage, including sharp losses, gradient masking, etc. From the perspective of adversarial sample generation, two main factors lead to this problem. First, the individual variability of clean samples leads to different adversarial samples generated using the same attack strategy, which makes different contributions to the robustness of the target network during adversarial training (the offensive data is closer to the decision boundary, and the protected data is farther away from the decision boundary). Second, the introduction of adversarial perturbations destroys the basic structure of the original data, which in turn affects the accuracy of the target network. Therefore, how to address these two factors is crucial to improving robustness and accuracy. Summary of the invention
[0006] The purpose of the present invention is to overcome the shortcomings of the prior art and provide an adversarial defense method based on a difficulty-guided variable attack strategy, so that each clean sample can make a consistent contribution to the robustness of the deep neural network, better learn the attack information to enhance the robustness of the deep neural network, and at the same time, alleviate the damage to the original data structure of the clean sample and improve the accuracy of the deep neural network.
[0007] To achieve the above-mentioned object of the invention, the present invention is based on a difficulty-guided variable attack strategy confrontation defense method, characterized in that it includes the following steps:
[0008] (1) Determine the maximum number of training times T, the initial number of training times t = 1
[0009] (2) Difficulty-guided adversarial sample generation
[0010] 2.1) Generate attack strategies related to samples
[0011] In the training data set, take out a batch of n images, for the i-th image x i , given an image x under standard adversarial attack i Initial attack strategy Generate initial adversarial examples through standard adversarial attacks where g(·) is the standard adversarial sample generator, is the perturbation, θ is the trainable parameter of the target network, and the target network is a deep neural network designed for image classification. represents the number of initial attack steps, represents the initial maximum disturbance intensity;
[0012] Then, generate the image x i Related attack strategies When the initial adversarial sample x i in Classification results Equal to the clean sample, i.e. image x i Classification results Attack strategy for:
[0013]
[0014]
[0015] When the initial adversarial sample x i in Classification results Not equal to the clean sample, i.e. image x i Classification results Attack strategy for:
[0016]
[0017]
[0018] Among them, I i is the number of attack steps, ∈ i is the maximum disturbance intensity, f θ () represents the predicted probability value of the target network with trainable parameters θ for the input sample, K I represents the maximum number of attack steps that can be selected in the attack strategy, K ∈ represents the upper limit of the maximum perturbation intensity that can be selected in the attack strategy, clamp(·, min, max) means limiting the value of variable · to the range [min, max], ρ i is the difficulty threshold. The larger the difficulty threshold, the greater the image difficulty. i The classification loss function Sure:
[0019]
[0020] Among them, β, γ are scaling weights used to ensure the difficulty threshold ρ i satisfy:
[0021]
[0022] 2.2) Generate adversarial samples
[0023] Sample correlation is image x i The adversarial example x′ i The generation process is:
[0024]
[0025] (3) Target network training
[0026] The image x i Input to the target network for classification and get image x i Classification results If the classification result Not equal to image x i The true classification value y i , then the adversarial sample x′ i Replace with image x i The adversarial sample x′ i Discard the image x i As adversarial example x′ i , and then use n adversarial samples x′ i Update the trainable parameters θ of the target network;
[0027] Then, take another batch of n images from the training data set and generate n adversarial samples x′ according to the method of steps 2.1) and 2.2). i And update the trainable parameters θ of the target network, and continue to update until all images in the training data set are taken out and the training is completed in sequence;
[0028] (4) Determine whether the number of training times t is equal to the maximum number of training times T. If so, the target network training is completed. Otherwise, t = t + 1, return to step (2), take out the images in the training data set in batches again to generate adversarial samples and train the target network.
[0029] The object of the present invention is achieved in that:
[0030] The present invention is based on a difficulty-guided variable attack strategy adversarial defense method, first according to the image x i The classification loss function Determine the difficulty threshold ρ of the image i , and then according to the difficulty threshold ρ of the image i Dynamically adjust attack strategies Attack Steps I i and the maximum disturbance intensity ∈ i , attack strategy No longer relying on fixed parameters, the generation of adversarial samples is improved. From the perspective of spatial distribution, each sample has a consistent contribution to the robustness of the target network, and can better learn attack information to enhance the robustness of the target network. At the same time, the difficulty threshold ρ of the present invention is i It will increase as the number of training times t increases, so that the difficulty of the adversarial samples used for adversarial training needs to increase continuously as the training progresses, so that the robustness of the target network converges and approaches the robust boundary. In addition, the present invention excludes images that are misclassified as outliers, thereby reducing the negative impact of misclassification on the overall improvement of the robustness of the target network, maintaining the original data structure as much as possible, thereby reducing the attenuation of the classification accuracy of the target network. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 It is a schematic diagram of the adversarial training process;
[0032] Figure 2 A flowchart of a specific implementation of the adversarial defense method based on difficulty-guided variable attack strategy of the present invention;
[0033] Figure 3 It is a schematic diagram of a specific implementation of the adversarial defense method based on difficulty-guided variable attack strategy of the present invention;
[0034] Figure 4 This is a schematic diagram of the relationship between difficulty threshold and distance. DETAILED DESCRIPTION
[0035] The specific implementation of the present invention is described below in conjunction with the accompanying drawings so that those skilled in the art can better understand the present invention. It should be noted that in the following description, when the detailed description of known functions and designs may dilute the main content of the present invention, these descriptions will be omitted here.
[0036] The standard adversarial training (AT) method is defined as a minimax optimization problem, where the objective function includes minimizing the target network loss function for all examples and maximizing the loss of the worst-case adversarial example in the perturbation set. The effectiveness of adversarial training methods usually depends on the attack strength of the generated adversarial examples. Although current defense methods have made significant progress in improving robustness, most methods still use fixed parameters to generate adversarial examples, such as PGD (Projected Gradient Descent) or its variants, and it is difficult to control the attack strength of the generated adversarial examples. Some studies have explored different attack strategies for improving robustness in different training stages, such as curriculum adversarial training (CAT), dynamic adversarial training (DART), and friendly adversarial training (FAT). These methods aim to enhance the robustness of the target network against adversarial attacks. They use manually designed metrics to evaluate the difficulty of adversarial examples, but do not consider the potential advantages that more customized and adaptive adversarial example generation methods may bring. Therefore, most methods that control the adversarial strength of adversarial examples by manually formulating attack strategies not only require expert knowledge, but also have limited improvement in robustness. At the same time, most existing methods treat the generated adversarial examples uniformly when updating the target network parameters during adversarial training, without distinguishing their individual characteristics. In addition, from a temporal perspective, existing methods do not take into account the evolution characteristics of adversarial examples at different training stages. These limitations seriously affect the effectiveness of the training process.
[0037] Learnable strategy adversarial learning methods automatically generate sample-based attack strategies to obtain information about specific samples and overcome the impact of statistical differences between samples. However, it does not consider the fundamental problems of adversarial training and therefore does not provide a guided attack strategy: 1) the variability of clean samples that leads to different adversarial examples generated using the same attack strategy; 2) the damage caused by adversarial perturbations to the underlying data structure.
[0038] To solve the above problems, the present invention innovatively proposes a novel adversarial training framework that integrates the concept of "difficulty-guided attack strategy". The present invention aims to improve the generation of adversarial samples by dynamically adjusting attack parameters according to the difficulty or degree of difficulty of each sample, rather than relying on fixed parameters. Not all adversarial samples have the same importance in adversarial training. Some data points may be geometrically far away from the class boundary, making them easy to classify. On the contrary, other data points may be close to the class boundary, making them difficult to classify. This patent defines the difficulty of a sample based on the likelihood that the sample is misclassified. Samples that are more easily misclassified are considered to be more difficult, and they tend to be close to the class boundary.
[0039] like Figure 1 As shown, under the assumption that the target network has an accurate robust boundary θ* In the case of , the process of adversarial training can be regarded as a continuous approximation of the boundary by the target network f. Therefore, the difficulty of the samples used for adversarial training needs to increase continuously as the training progresses so that the robustness of the target network converges and approaches the robust boundary. From the perspective of spatial distribution, the present invention hopes that each sample has a consistent contribution to the robustness of the target network in order to verify the direct impact of the attack method on the target network and better learn the attack information to enhance the robustness of the target network. The method proposed in the present invention uses the value predicted by the target network to indirectly represent the strength of the sample, and obtains a sample-based attack strategy based on the above constraints. In addition, in order to alleviate the damage to the original data structure, the present invention filters the samples according to the classification results of the clean samples. By utilizing two types of constraints constructed from the perspective of time and spatial distribution, the present invention directly learns the impact of the attack method on the target network, rather than the indirect impact related to the sample distribution. The present invention improves the generation of adversarial text to enhance the robustness and accuracy of DNN.
[0040] 1. Rethinking the Adversarial Training Process
[0041] First, we revisit the relationship between adversarial training and standard training. Let θ and are the trainable parameters and loss function of the DNN network f. Given an input sample And its related label y, we can construct a C-type dataset in In the context of natural training, many machine learning tasks can be formulated as optimization problems:
[0042]
[0043] The main goal of standard training is to obtain a neural network with minimal empirical risk of misclassification when faced with inputs from the natural data distribution. However, target networks trained with standard training exhibit weak robustness, making them vulnerable to adversarial examples, which has been documented in the literature. Adversarial attacks add perturbations δ to the input that are imperceptible to humans. i , to deceive DNN, generate adversarial examples x i +δ i , whose goals are usually as follows:
[0044]
[0045] Among them, f θ (x i +δ i ) represents the output of the network, is the loss function. ∈ is the adversarial perturbation Norm restrictions. {δ i∈Δ:||δ i || p ≤∈}, where p can be 1, 2, ∞.
[0046] Adversarial training is an effective method to improve the robustness of a target network by training it on adversarial examples. The main learning goal of standard adversarial training (AT) is to train a neural network to minimize the risk of misclassifying input samples under a predefined perturbation strength. The adversary introduces adversarial perturbations into each sample during the adversarial training process. Transformed into To mitigate the vulnerability of machine learning target networks to adversarial attacks, traditional adversarial training methods usually aim to optimize the following objective function:
[0047]
[0048] As mentioned above, the adversarial training process proposed in this invention involves two types of constraints: 1) From the perspective of time, the difficulty of the samples used for adversarial training needs to gradually increase as the training progresses. 2) From the perspective of spatial distribution, the contribution of each sample to the robustness of the target network should be consistent, and the difficulty of different adversarial samples in the same training stage should be consistent. Let h(x′ i )∈[0,1], ρ and t∈{0,1,...,T} represent adversarial samples x′ respectively. i =x i +δ i The difficulty, adversarial sample difficulty threshold and number of training times, where 1 / ρ∈[0,1], then our new representation of AT can be defined as:
[0049]
[0050]
[0051] 2. Difficulty-guided Adversarial Training
[0052] The flowchart and principle schematic diagram of the method proposed by the present invention are as follows: Figure 2 , 3 As shown. The present invention includes two key components: a difficulty-guided adversarial sample generation process and an adversarial training process based on robust convergence rules. These two parts work together to improve the robustness of the target network against adversarial examples. The first process uses a difficulty-based attack strategy to generate adversarial examples targeting specific features of each sample, while the adversarial training process iteratively updates the target network parameters and controls the overall difficulty of the samples to ensure that the target network converges to the robust boundary. Overall, these components constitute a new framework for enhancing the robustness of the target network to resist adversarial attacks.
[0053] Specifically, in this embodiment, if Figure 2 , 3 As shown, the adversarial defense method based on the difficulty-guided variable attack strategy of the present invention includes the following steps:
[0054] Step S1: Initialization
[0055] Determine the maximum number of training times T, and the initial number of training times t=1.
[0056] Step S2: Difficulty-guided adversarial sample generation
[0057] Difficulty-guided adversarial sample generation. The proposed difficulty-guided sample-dependent attack strategy generator generates different strategies for different samples according to the classification effect and robustness of the target network at different training stages. Represents x i where M represents the number of parameters of the attack strategy, depending on the attack method used. In HGSD-AT, the difficulty of a sample is defined as the distance of the sample to the classification hyperplane. The process of adding adversarial perturbations aims to move the original sample towards the classification boundary and beyond the boundary. Therefore, we can observe that as the difficulty of the sample increases, the distance of the adversarial perturbation also increases. Therefore, we choose the parameters that have the strongest correlation with the moving distance to construct the policy set.
[0058] Our method adjusts two key parameters (attack steps and the maximum disturbance intensity ∈ i ∈∈={0,1,...,K ∈ -1})) to guide the generation of adversarial samples and improve the robustness of the target network. The two parameters selected are closely related to the difficulty of the sample and are included in most attack methods. The options for these two parameters are K I and K ∈ .
[0059] In order to achieve the goal of formula (4), it is necessary to obtain the relationship between the sample difficulty h(·) and the attack strategy S through the difficulty difference between the initial adversarial sample and the original sample. First, the larger the parameter value of the attack strategy, the farther the distance between the adversarial sample and the original sample. Second, the generation strategy of all these initial adversarial samples is the same, such as Figure 4 As shown in Figure 2. Therefore, as the difficulty changes less, a longer distance is required to move to the target difficulty, and the corresponding policy parameters are larger. For adversarial samples that are far from the decision boundary, the difficulty of the sample needs to be increased; conversely, for samples close to the decision boundary, the difficulty needs to be reduced.
[0060] Directly using the distance between the sample and the classification boundary to measure the difficulty is too complicated because we do not need a specific distance value. Instead, we can use the predicted probability value as a more practical measure. Next, we will explain in detail the process of obtaining new adversarial samples based on the predicted probability value. :
[0061] Step S2.1: Generate attack strategies associated with samples
[0062] In the training data set, take out a batch of n images, for the i-th image x i , given an image x under standard adversarial attack i Initial attack strategy Generate initial adversarial examples through standard adversarial attacks where g(·) is the standard adversarial sample generator, is the perturbation, θ is the trainable parameter of the target network, and the target network is a deep neural network designed for image classification. represents the number of initial attack steps, represents the initial maximum disturbance intensity;
[0063] Then, generate the image x i Related attack strategies When the initial adversarial sample x i in Classification results Equal to the clean sample, i.e. image x i Classification results Attack strategy for:
[0064]
[0065]
[0066] When the initial adversarial sample x i in Classification results Not equal to the clean sample, i.e. image x i Classification results Attack strategy for:
[0067]
[0068]
[0069] Among them, I i is the number of attack steps, ∈ i is the maximum disturbance intensity, f θ() represents the predicted probability value of the target network with trainable parameters θ for the input sample, K I represents the maximum number of attack steps that can be selected in the attack strategy, K ∈ represents the upper limit of the maximum perturbation intensity that can be selected in the attack strategy, clamp(·, min, max) means limiting the value of variable · to the range [min, max], ρ i is the difficulty threshold. The larger the difficulty threshold, the greater the image difficulty. i The classification loss function Sure:
[0070]
[0071] Among them, β, γ are scaling weights used to ensure the difficulty threshold ρ i satisfy:
[0072]
[0073] Step S2.2: Generate adversarial examples
[0074] Sample correlation is image x i The adversarial example x′ i The generation process is:
[0075]
[0076] Step S3: Target network training
[0077] The image x i Input to the target network for classification and get image x i Classification results If the classification result Not equal to image x i The true classification value y i , then the adversarial sample x′ i Replace with image x i The adversarial sample x′ i Discard the image x i As adversarial example x′ i , and then use n adversarial samples x′ i Update the trainable parameters θ of the target network.
[0078] Then, take another batch of n images from the training data set and generate n adversarial samples x′ according to the method of steps S2.1 and S2.2. i And update the trainable parameters θ of the target network, and continue to update in this way until all images in the training data set are taken out and the training is completed in sequence.
[0079] Step S3: Determine whether the number of training times t is equal to the maximum number of training times T. If it is, the training of the target network is completed. Otherwise, t=t+1, return to step S2, take out the images in the training data set in batches again to generate adversarial samples and train the target network.
[0080] Experimental verification
[0081] In order to evaluate the effectiveness of the present invention, experiments were conducted on three different databases in this experimental verification: CIFAR10, CIFAR100 and Tiny ImageNet. In the experimental part, PGD-AT with early stopping was used as the basic model to verify the adversarial defense method of the present invention based on the difficulty-guided variable attack strategy. The same training settings were used for the present invention and the basic model, including data partitioning, target network training loss and training parameter settings. The present invention (HGSD-AT) was compared with several baseline methods, such as PGDAT, TRADES, SAT, MART, CAT, DART, FAT, GAIRAT, AWP, LBGAT and LASAT. In addition, the present invention (HGSD-AT) was also compared with two comprehensive defense methods that combined LASAT with two existing representative methods. In this way, the effectiveness of the adversarial defense method of the present invention based on the difficulty-guided variable attack strategy against a combination of multiple existing technologies can be evaluated. In addition, in this experimental verification, methods such as CAT, DART, FAT and LASAT were selected, which used different attack strategies in different training stages to conduct more targeted comparison and analysis. Comparing the sample-dependent method of the present invention with these sample-independent methods further demonstrates that the present invention utilizes the concept of sample correlation to eliminate the influence of data distribution on adversarial training, enabling the target network to learn the direct influence of the attack method on the target network.
[0082] In order to reflect the overall improvement of the test items, the test accuracy is used to evaluate the classification results in this experimental verification. It represents the proportion of correct predictions of the target network among all predictions. In this experimental verification, a variety of adversarial attack techniques, such as FGSM, PGD, and C&W, are selected to test the trained target network. We set the maximum perturbation intensity to 8, the attack step size to 2 for all attack methods, and the number of attack steps to 20 under the L∞ norm, following the standard settings of adversarial training, using clean accuracy and robust accuracy as evaluation metrics. In order to evaluate the adversarial robustness of the target network, a normalized score calculated by a set of white-box attacks is used, called the Average Robusmess Score (ARS). ARS measures the success rate of defense against a series of white-box attacks, and the higher the value, the better. The attack method set of ARS includes FGSM, PGD, and C&W. In this experimental verification, the degree of decrease in classification accuracy (D-degree) relative to the original non-robust target network is also calculated.
[0083] Experimental Results
[0084]
[0085] Table 1
[0086]
[0087] Table 2
[0088] The experimental results of this experimental verification on CIFAR-10 and CIFAR-100 are shown in Tables 1 and 2. In addition, since the comparison methods are all based on the improvement of PGD-AT, in this experimental verification, the results of AT are regarded as the benchmark, and the difference in test accuracy (Diff.) is reported. The present invention (HGSD-AT) shows excellent performance in most attack scenarios and solves the trade-off between accuracy and robustness. The present invention (HGSD-AT) achieves the best robust performance in all attack scenarios. For example, when WRN34-10 is used as the target network on CIFAR-10, the present invention improves the robustness of the basic method PGD-AT by about 20.36% and 20.11% corresponding to PGD and C&W attacks respectively. At the same time, its accuracy only dropped by 3.65% compared with the original data, making it the most accurate target network. Compared with the most advanced method AWP, the present invention (HGSD-AT) also achieved excellent performance in terms of average robustness score (ARS), reaching 18.09%. We attribute these improvements to the use of hardness-guided generation-based attack strategies, rather than unguided attack strategies.
[0089] In addition, from the perspective of the degree of effectiveness improvement, the robustness improvement of the present invention (HGSD-AT) in CIFAR-100 is more significant than that in CIFAR-10, because CIFAR-100 has a higher number of categories and more complex attack scenarios. Specifically, compared with the best method LBGAT in the comparison method on CIFAR-100, the accuracy of the present invention (HGSD-AT) in the face of PGD attack is improved by 9.64%, and the accuracy in the face of C&W attack is improved by 12.08%. This shows that the present invention can successfully generate adversarial samples that better reflect the attack strategy information.
[0090] Compared with other existing defense methods based on non-fixed strategies to generate adversarial samples, LASAT is currently the most effective method. However, the performance of the present invention (HGSD-AT) exceeds that of LASAT on both CIFAR-10 and CIFAR-100 datasets. Specifically, on CIFAR-10, the robustness of HGSD-AT under PGD and C&W attacks is improved by 18.95% and 18.29% respectively compared with LASAT, and by 11.62% and 11.61% respectively on CIFAR-100. We further compare the present invention (HGSD-AT) with the combination of LASAT and other methods (TRADES and AWP) using fixed adversarial sample generation strategies. The present invention (HGSD-AT) outperforms TRADES+LASAT and AWP+LASAT, with the robustness scores (ARS) improved by 18.00% and 15.59% on the CIFAR-10 dataset, and by 13.49% and 8.95% on the CIFAR-100 dataset, respectively. The experimental results verified in this experiment clearly show that the present invention (HGSD-AT) is very effective in improving the robustness of the deep learning model, i.e. the target network, which is an important step in addressing the adversarial attack vulnerabilities faced by the target network. By having superior performance compared to other existing defense methods, the present invention (HGSD-AT) has the potential to improve the security and reliability of deep learning methods.
[0091]
[0092] Table 3
[0093] This experimental verification also evaluated the present invention (HGSD-AT) on Tiny ImageNet, using PreActResNet18 as the target network. Since Tiny ImageNet has more categories than CIFAR-10 and CIFAR-100, defense against adversarial samples becomes more challenging. In order to evaluate the effectiveness of the present invention (HGSD-AT), this experimental verification was tested on four benchmark models and the results were compared with the previous state-of-the-art methods. The results are shown in Table 3. It is worth noting that the present invention (HGSD-AT) shows improvements in clean data and adversarial robustness on all four benchmark models, which shows its effectiveness in enhancing the robustness of the model to adversarial samples on challenging datasets.
[0094] The present invention (HGSD-AT) has achieved significant improvements in robustness, increasing by 7.47% and 8.93% compared to PGT-AT and TRADES in the face of C&W attacks. In addition, in the face of C&W attacks, its robustness improvement over the other two methods is more than one-fifth. Compared with existing methods, the present invention (HGSD-AT) still shows superior performance under other adversarial attack methods. For example, when using FGSM and PGD attacks, its performance exceeds TRADES by 12.08% and 10.33%, respectively. The results on Tiny ImageNet verify that HGSD-AT has also achieved promising results on high-quality image datasets and multiple categories.
[0095] Although the above describes the illustrative specific embodiments of the present invention to facilitate those skilled in the art to understand the present invention, it should be clear that the present invention is not limited to the scope of the specific embodiments. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations using the concept of the present invention are protected.
Claims
1. An adversarial defense method based on difficulty-guided variable attack strategy, characterized in that: The following steps are involved: (1) Determine the maximum number of training times T, the initial number of training times t = 1 (2) Difficulty-guided adversarial sample generation 2.1) Generate attack strategies related to samples In the training data set, take out a batch of n images, for the i-th image x i , given an image x under standard adversarial attack i Initial attack strategy Generate initial adversarial examples through standard adversarial attacks where g(·) is the standard adversarial sample generator, is the perturbation, θ is the trainable parameter of the target network, and the target network is a deep neural network designed for image classification. represents the number of initial attack steps, represents the initial maximum disturbance intensity; Then, generate the image x i Related attack strategies When the initial adversarial sample x i in Classification results Equal to the clean sample, i.e. image x i Classification results Attack strategy for: When the initial adversarial sample x i in Classification results Not equal to the clean sample, i.e. image x i Classification results Attack strategy for: in, I i is the number of attack steps, ∈ i is the maximum disturbance intensity, f θ () represents the predicted probability value of the target network with trainable parameters θ for the input sample, K I represents the maximum number of attack steps that can be selected in the attack strategy, K ∈ represents the upper limit of the maximum perturbation intensity that can be selected in the attack strategy, clamp(·,min,max) means limiting the value of variable · to the range [min,max], ρ i is the difficulty threshold. The larger the difficulty threshold, the greater the image difficulty. i The classification loss function Sure: Among them, β,γ are scaling weights used to ensure the difficulty threshold ρ i satisfy: 2.2) Generate adversarial samples Sample correlation is image x i Adversarial example x i ′ The generation process is: (3) Target network training The image x i Input to the target network for classification and get image x i Classification results If the classification result Not equal to image x i The true classification value y i , then the adversarial sample x i ′ Replace with image x i The adversarial sample x i ′ Discard the image x i As an adversarial example x i ′ , and then use n adversarial samples x i ′ Update the trainable parameters θ of the target network; Then, take another batch of n images from the training data set and generate n adversarial samples x according to the method of steps 2.1) and 2.2). i ′ And update the trainable parameters θ of the target network, and continue to update until all images in the training data set are taken out and the training is completed in sequence; (4) Determine whether the number of training times t is equal to the maximum number of training times T. If so, the target network training is completed. Otherwise, t = t + 1, return to step (2), take out the images in the training data set in batches again to generate adversarial samples and train the target network.
