Image adversarial sample generation method and system
By masking the original image and obtaining gradient information through a self-attention mechanism, and dynamically updating the perturbation value, the problem of low success rate of adversarial sample transfer attacks generated by the VIT model is solved, and efficient transfer attacks between VIT and CNN models are achieved.
Patent Information
- Application Number
- CN202310258685.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-16
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-03-16
AI Technical Summary
In existing technologies, the success rate of adversarial sample transfer attacks generated by VIT models is not high, especially when the effect drops significantly when transferred to models with very different structures.
By masking the original image, gradient information is obtained using the self-attention mechanism of the VIT model, the gradient threshold is calculated and a perturbation scaling mask is generated, the perturbation value is dynamically updated, adversarial examples are generated, and a dual dynamic mechanism and momentum mechanism are introduced to enhance the utilization of gradient information.
It improves the success rate of VIT models in transfer attacks, especially significantly improving the transfer attack effect between VIT and CNN models.
Smart Images

Figure CN116188874B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method and system for generating adversarial examples in images. Background Technology
[0002] With the widespread application of deep learning technology, more and more researchers are beginning to worry about its security and reliability. Due to the enormous number of parameters in deep learning, its working principle has become unpredictable and elusive. Although the efficiency of models has been greatly improved in terms of task accuracy, security is a major concern.
[0003] Adding imperceptible perturbations to images can disable deep learning models; these perturbated images are called adversarial examples. The emergence of adversarial examples demonstrates both the inherent security vulnerabilities of deep learning models and spurs their development. Therefore, research into the offensive capabilities of adversarial examples is an indispensable step in improving the security of deep learning models; the more powerful the adversarial example, the better it can guide the design of more secure deep learning models.
[0004] Existing methods for generating adversarial examples primarily target CNN models as the local target of the attack, and are highly dependent on the correlation between the attacking local model and the attacked black-box model. Directly applying these methods to the structurally different VIT (VisionTransformer) models significantly reduces the transfer success rate. Furthermore, existing methods only optimize the model structure, gradient backpropagation method, and gradient information acquisition, without utilizing gradient information, making it difficult to significantly improve the transfer success rate. Summary of the Invention
[0005] Based on the above analysis, the embodiments of the present invention aim to provide an image adversarial sample generation method and system to solve the problem of low success rate of migration attacks of adversarial samples generated by existing VIT models.
[0006] On one hand, embodiments of the present invention provide a method for generating adversarial examples in images, comprising the following steps:
[0007] Obtain the original image and input it into the VIT model;
[0008] The following iterative operations are performed on the original image: Masking is applied to the original image to obtain the input sample; gradient information of the input sample is obtained based on the self-attention mechanism of the VIT model; a gradient threshold is calculated based on the gradient information, and a perturbation scaling mask is generated based on the gradient threshold; the gradient information is updated based on the perturbation scaling mask; the perturbation value is updated based on the updated gradient information, and the perturbation value is added to the original image to update the original image; the next iteration is performed on the updated original image until the iteration ends; the final updated original image is the adversarial example of the original image.
[0009] Based on the further improvement of the above method, the original image is masked to obtain the input sample, including:
[0010] Based on the size of the original image and the length of each image block set in the VIT model, the original image is divided to obtain a set of image blocks; according to a preset number, image blocks are randomly selected and their masks are set to 1, while the masks of the remaining image blocks are set to 0. After performing masking operations on the image blocks, the resulting set of image blocks is used as the input sample.
[0011] Further improvements to the above method, based on the self-attention mechanism of the VIT model, obtain the gradient information of the input samples, including:
[0012] In the forward propagation, the output result corresponding to the input sample is obtained according to the weights of the query vector, key vector and value vector in the self-attention mechanism;
[0013] In backpropagation, the query vector and key vector in the self-attention mechanism are ignored. The gradient information of the output result with respect to the input sample is obtained by taking the derivative.
[0014] Based on the further improvement of the above method, the gradient information of the output result with respect to the input sample is obtained by differentiating the following formula:
[0015]
[0016] Among them, g k The gradient information in the k-th iteration operation includes the gradient information of each pixel in the input image, x' k Let V be the output result corresponding to the input sample x in the k-th iteration operation, V be the weight of the value vector in the self-attention mechanism, and A be the self-attention weight. Let represent the identity matrix whose diagonal elements are all 1. T Indicates matrix transpose. This represents the product of Kronecker.
[0017] Based on further improvements to the above method, the gradient threshold is calculated according to the gradient information, including:
[0018] The mean of the non-zero gradient information is calculated based on the sum of the gradient information of all pixels and the number of non-zero gradient information in the gradient information, and is used as the gradient threshold.
[0019] Based on the above method, a perturbation scaling mask is generated according to the gradient threshold using the following formula:
[0020]
[0021] in, Let a0 be the perturbation scaling mask for pixel (i,j) in the input sample during the k-th iteration, where a0 is the preset perturbation vector scaling factor, and inc is the dynamic growth step size. The gradient threshold for the k-th iteration operation; This provides the gradient information of pixel (i,j) on the input sample during the k-th iteration.
[0022] Based on a further improvement of the above method, the dynamic growth step size is obtained by dividing the square of the maximum perturbation value by the total number of iterations.
[0023] Based on the above method, a further improvement is made, and the gradient information is updated according to the perturbation scaling mask using the following formula:
[0024]
[0025] Among them, g' k This represents the updated gradient information in the k-th iteration, where μ is the preset momentum iteration coefficient, and g... k Let ||·||1 be the gradient information in the k-th iteration operation, and let ||·||1 be the 1 norm.
[0026] Based on the further improvement of the above method, the perturbation value is updated according to the updated gradient information using the following formula:
[0027] δ k+1 =clip ∈ (δ k +α·sign(g' k ))
[0028] Where, δ k+1 For the updated perturbation value, δ k Let α be the perturbation value in the current k-th iteration, α be the step size of a single perturbation update, sign(·) be the sign function, and clip be the perturbation value in the current k-th iteration. ∈ (·) is the clipping function, which means clipping the perturbation value to the range [-∈, ∈].
[0029] On the other hand, embodiments of the present invention provide an image adversarial example generation system, comprising:
[0030] The image acquisition module is used to acquire the raw image and input the raw image into the VIT model;
[0031] The adversarial example generation module performs the following iterative operations on the original image: masking the original image to obtain the input sample; acquiring the gradient information of the input sample based on the self-attention mechanism of the VIT model; calculating the gradient threshold based on the gradient information and generating a perturbation scaling mask based on the gradient threshold; updating the gradient information based on the perturbation scaling mask; updating the perturbation value based on the updated gradient information and adding the perturbation value to the original image to update the original image; performing the next iteration operation on the updated original image until the iteration ends; the final updated original image is the adversarial example of the original image.
[0032] Compared with existing technologies, the present invention can achieve at least one of the following beneficial effects: by randomly masking the image, the diversity of input samples is increased, and overfitting is avoided; and a dual dynamic mechanism is introduced, which uses a dynamic attention mechanism to select high-importance points in the sample image, and then uses a momentum mechanism to perform an effective scaling attack. While maximizing the preservation of the original image features, the utilization of spatial gradient information and temporal gradient information is enhanced, thereby improving the success rate of transfer attacks in the VIT scenario.
[0033] In this invention, the above-described technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of this invention will be set forth in the following description, and some advantages may become apparent from the description or be learned by practicing the invention. The objects and other advantages of this invention can be realized and obtained from what is particularly pointed out in the description and drawings. Attached Figure Description
[0034] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts.
[0035] Figure 1 This is a flowchart of an image adversarial sample generation method in Embodiment 1 of the present invention. Detailed Implementation
[0036] Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which form part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not intended to limit the scope of the present invention.
[0037] Example 1
[0038] A specific embodiment of the present invention discloses an image adversarial example generation method, such as... Figure 1 As shown, it includes the following steps:
[0039] S11: Obtain the original image and input it into the VIT model.
[0040] It should be noted that the original image x∈X=[0,1] m×n×w The image consists of m×n pixel positions and w channels. The original image can be taken from the ImageNet Large-Scale Visual Recognition Challenge (ILSVRC) dataset, which has 1000 categories. Each image is 299×299 pixels in size and has 3 color channels.
[0041] The VIT model consists of three modules: an embedding layer, a Transformer encoding layer, and an MLP Head layer. The embedding layer converts the 3D image into a 2D matrix. The Transformer encoding layer is composed of multiple stacked encoding blocks, each of which includes a multi-head self-attention mechanism module, skip connections (Add), and layer normalization (Norm). The MLP Head layer extracts classification information from the output of the Transformer encoding layer to obtain the classification result.
[0042] It should be noted that if the original image and the input image of the VIT model are not the same size, the original image should be adjusted. For example, if the original image size is 299×299×3 (representing the length, width, and number of RGB channels of the image, respectively), while the ViT-B / 16 model in the VIT model requires an image size of 224×224×3, then the original image should be adjusted to 224×224×3 before being input into the VIT model.
[0043] It should be noted that the acquired raw images can be further divided into training and testing sets. The training set is used to train the VIT model, and the testing set is used to test the performance of the VIT model to prevent overfitting and undertraining of the VIT model to the training set. The use of training and testing sets is standard practice and will not be elaborated on separately in this embodiment.
[0044] S12: Perform the following iterative operations on the original image: mask the original image to obtain the input sample; obtain the gradient information of the input sample based on the self-attention mechanism of the VIT model; calculate the gradient threshold based on the gradient information, and generate a perturbation scaling mask based on the gradient threshold; update the gradient information based on the perturbation scaling mask; update the perturbation value based on the updated gradient information, and add the perturbation value to the original image to update the original image; perform the next iteration operation on the updated original image until the iteration ends; the final updated original image is the adversarial sample of the original image.
[0045] It should be noted that this step iteratively updates the perturbation value through steps S120-S125 to obtain adversarial examples.
[0046] S120: Initialization parameters, including: setting the initial value of perturbation δ to 0, the maximum perturbation value ∈, the number of image blocks selected in image masking, the perturbation vector scaling factor a0, the momentum iteration factor μ, the number of current iteration operations k, the total number of iteration operations K, i.e. the maximum number of iterations, which is usually set to a multiple of 10.
[0047] S121: Mask the original image to obtain the input sample.
[0048] In existing technologies, the VIT model first divides the input original image into individual image patches. In this embodiment, to increase the input diversity of samples and improve the transferability of adversarial examples, the original image is masked before being used as input samples to the embedding layer, including:
[0049] Based on the size of the original image and the length of each image block set in the VIT model, the original image is divided to obtain a set of image blocks; according to a preset number, image blocks are randomly selected and their masks are set to 1, while the masks of the remaining image blocks are set to 0. After performing masking operations on the image blocks, the resulting set of image blocks is used as the input sample.
[0050] S122: A self-attention mechanism based on the VIT model to obtain gradient information of input samples.
[0051] It should be noted that the Embedding layer adds category tokens and location encoding information to the input samples, converts them into vectors, and then feeds them into the Transformer encoding layer. The Transformer encoding layer then extracts rich image patch features through a multi-head self-attention mechanism. This multi-head self-attention mechanism combines the outputs of multiple single-head self-attention modules.
[0052] It is worth noting that the optimization objective of generating adversarial examples is to maximize the model's loss function under the constraint of the infinite norm, thereby causing the output classification result to be incorrect. Typically, the loss function is reduced using the gradient descent algorithm. This embodiment calculates gradient information by improving the gradient propagation method and fully utilizes this gradient information to select regions of interest during classification. Perturbations are then added and amplified in these regions, thereby improving the attack effect of the adversarial examples.
[0053] Specifically, in the forward propagation of each single-head self-attention mechanism module, the output result is calculated by multiplying the input sample by the weight of the value vector and then by the self-attention weight, based on the weights of the query vector, key vector, and value vector in the self-attention mechanism. This is expressed by the following formula:
[0054] x' k =A(x k V) Formula (1)
[0055]
[0056] Where, x' k For the input sample x in the k-th iteration operation k The corresponding output results It is the self-attention weight. These represent the weights of the query vector, key vector, and value vector in the self-attention mechanism, respectively, where N is the number of image patches in the input sample, and D... h Let D be the dimension of the self-attention head, and D be the dimension of each image patch feature. T represents the matrix transpose, and softmax(·) represents the normalization function.
[0057] Furthermore, during the backpropagation of each single-head self-attention mechanism module, ignoring the query vector and key vector in the self-attention mechanism, the gradient information of the output result with respect to the input sample is obtained by differentiating the following formula:
[0058]
[0059] Among them, g k This refers to the gradient information in the k-th iteration, including the gradient information of each pixel in the input image. This represents the identity matrix whose diagonal elements are all 1. This represents the product of Kronecker.
[0060] It's important to note that the query vector and key vector from the self-attention mechanism are ignored during backpropagation. This is to focus on the backpropagation of the input sample itself, rather than the backpropagation of features represented by the self-attention mechanism. This gives the backpropagation gradient of the input sample greater versatility, effectively shielding it from the influence of the VIT model's own structural design, thereby improving the success rate of transfer attacks.
[0061] S123: Calculate the gradient threshold based on the gradient information, and generate a perturbation scaling mask based on the gradient threshold.
[0062] After obtaining the gradient information, regions with gradients greater than a threshold are selected as regions of interest for classification. Specifically, the mean of the non-zero gradient information is calculated based on the sum of the gradient information of all pixels and the number of non-zero gradient values, and this value is used as the gradient threshold. The formula is as follows:
[0063]
[0064] in, The gradient threshold for the k-th iteration operation. The gradient information of pixel (i,j) on the input sample is used in the k-th iteration operation. Let be a Boolean function, representing when If the value is not 0, the function value is 1. If the value is 0, the function value is 0.
[0065] For element positions greater than the gradient threshold, increase the perturbation in each iteration; for element positions less than or equal to the gradient threshold, decrease the perturbation. The perturbation scaling mask is generated using the following formula:
[0066]
[0067] in, is the perturbation scaling mask for pixel (i,j) on the input sample in the k-th iteration operation, a0 is the preset perturbation vector scaling factor, and inc is the dynamic growth step size, which is obtained by dividing the square of the maximum perturbation value by the total number of iteration operations.
[0068] S124: Update gradient information based on the perturbation scaling mask; update perturbation value based on the updated gradient information, and add the perturbation value to the original image to update the original image.
[0069] Furthermore, based on the momentum mechanism, the gradient information is updated according to the perturbation scaling mask using the following formula:
[0070]
[0071] Among them, g' k This represents the updated gradient information in the k-th iteration, where μ is the preset momentum iteration coefficient, and g... k Let ||·||1 be the gradient information in the k-th iteration operation, and let ||·||1 be the 1 norm.
[0072] Furthermore, based on the updated gradient information, the perturbation value is updated, including: converting the updated gradient information into a perturbation unit direction vector with a fixed step size, adding it to the perturbation value in the current iteration, and constraining it within the upper and lower bounds of the infinity norm perturbation to obtain the perturbation value in the next iteration operation, as expressed by the following formula:
[0073] δ k+1 =clip ∈ (δ k +α·sign(g' k )) Formula (7)
[0074] Where, δ k+1 For the updated perturbation value, δk Let g' be the perturbation value in the current k-th iteration, α be the single perturbation update step size, obtained by dividing the maximum perturbation value by the total number of iterations; sign(·) is the sign function: when g' k When g' is greater than 0, the sign function value is 1; when g' k When g' equals 0, the sign function value is 0; when g' k When the value is less than 0, the sign function value is -1; clip ∈ (·) is the clipping function, which means clipping the perturbation value to the range [-∈, ∈].
[0075] The updated perturbation value δ k+1 The pixel values are added to the original image according to their positions, thus updating the original image.
[0076] S125: Increment the iteration count k. If the maximum iteration count k is not reached, return to step S121 and perform the next iteration operation on the updated original image. Otherwise, the iteration ends, and the final updated original image is the adversarial example of the original image.
[0077] In practice, adversarial samples generated from attacking the local VIT model (white-box model) are input into the attacked VIT model and CNN model (black-box model), respectively. The effectiveness of the transfer attack is verified by calculating the classification success rate of the black-box model. Considering that samples generated from attacking one white-box model are often used to attack multiple black-box models, the success rate includes the attack success rate (ASR) for attacking a single black-box model and the average attack success rate (AASR) for attacking multiple black-box models, as shown in the following formula:
[0078]
[0079]
[0080] Wherein, ASR represents the ratio of the original sample x to the total sample size in a dataset of size H. r After adding the perturbation δ, the classifier's final classification f(x) r +δ) and the ratio of the number of different original class y to the total number of samples H; AASR represents the average success rate after samples generated by the white-box model attack M black-box models.
[0081] In this embodiment, when generating adversarial examples by attacking the local VIT model, the maximum perturbation value ∈ under the infinite norm is set to 16, the loss function is the cross-entropy loss function, and the total number of iterations is 10. Therefore, the single perturbation update step size α is 1.6, and the dynamic growth step size inc is 2.56. The image patch length is 16, so a 224×224 image is divided into 196 patches. The selected VIT models include: ViT-B / 16, DeiT-B, TNT-S, LeViT-256, PiT-B, CaiT-S-24, ConViT-B, and Visformer-S.
[0082] In the VIT scenario, where both the attacking local white-box model and the attacked black-box model are VIT models, the attack success rates ASR and AASR obtained using the method in this embodiment are shown in Table 1.
[0083] Table 1 Success Rate Results in VIT Scenarios
[0084]
[0085] As can be seen from Table 1, when the white-box model and the black-box model are the same on the diagonal of the table, the attack success rate is over 95%. Even without considering this ideal situation, the calculated average AASR is 63.71%.
[0086] Under the same VIT scene parameter settings, the method of this embodiment is compared with other algorithms, and the results are shown in Table 2.
[0087] Table 2 Comparison of Algorithms in VIT Scenarios
[0088]
[0089]
[0090] As can be seen from the results in Table 2, in scenarios where both the white-box and black-box models are VIT models, the method in this embodiment has a higher average success rate (AASR) than other black-box attack algorithms in the table.
[0091] In the CNN scenario, where the attacking local white-box model is a VIT model and the attacked black-box model is a CNN model, the attack success rates (ASR and AASR) obtained using the method in this embodiment are shown in Table 3. Among them, Inc-v3, Inc-v4, IncRes-V2, and ResNet-V2 are the original CNN models, which have not been trained with adversarial examples.
[0092] Table 3 Success Rate Results in CNN Scenarios
[0093]
[0094] As can be seen from the results in Table 3, the average AASR of this embodiment reached 44.45% in the CNN model scenario. This shows that the adversarial examples generated when the local white-box model is a VIT model can also achieve good results when transferring attacks to CNN models.
[0095] Under the same CNN scene parameter settings, the method of this embodiment is compared with other algorithms, and the results are shown in Table 4.
[0096] Table 4 Comparison of Algorithms in CNN Scenarios
[0097]
[0098]
[0099] As can be seen from the results in Table 4, the method in this embodiment also has certain advantages compared with other algorithms in the CNN model scenario.
[0100] Compared with existing technologies, the image adversarial sample generation method provided in this embodiment increases the diversity of input samples and avoids overfitting by randomly masking the image; and introduces a dual dynamic mechanism, which uses a dynamic attention mechanism to select high-importance points in the sample image, and then uses a momentum mechanism to perform effective scaling attacks. While maximizing the preservation of the original image features, it enhances the utilization of spatial gradient information and temporal gradient information, thereby improving the success rate of transfer attacks in VIT scenarios.
[0101] Example 2
[0102] Another embodiment of the present invention discloses an image adversarial example generation system, thereby implementing the image adversarial example generation method in Embodiment 1. The specific implementation of each module is described in the corresponding description in Embodiment 1. The system includes:
[0103] The image acquisition module is used to acquire the raw image and input the raw image into the VIT model;
[0104] The adversarial example generation module performs the following iterative operations on the original image: masking the original image to obtain the input sample; acquiring the gradient information of the input sample based on the self-attention mechanism of the VIT model; calculating the gradient threshold based on the gradient information and generating a perturbation scaling mask based on the gradient threshold; updating the gradient information based on the perturbation scaling mask; updating the perturbation value based on the updated gradient information and adding the perturbation value to the original image to update the original image; performing the next iteration operation on the updated original image until the iteration ends; the final updated original image is the adversarial example of the original image.
[0105] Since the image adversarial example generation system in this embodiment and the aforementioned image adversarial example generation method can draw on each other's aspects, this description is redundant and will not be repeated here. Because this system embodiment shares the same principle as the aforementioned method embodiment, it also possesses the corresponding technical effects of the aforementioned method embodiment.
[0106] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware, and the program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.
[0107] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for generating adversarial examples in images, characterized in that, Includes the following steps: Obtain the original image and input it into the VIT model; Perform the following iterative operation on the original image: randomly mask the original image to obtain the input sample; The self-attention mechanism based on the VIT model obtains the gradient information of the input sample, including: in forward propagation, obtaining the output result corresponding to the input sample according to the weights of the query vector, key vector, and value vector in the self-attention mechanism; in backpropagation, ignoring the query vector and key vector in the self-attention mechanism, obtaining the gradient information of the output result with respect to the input sample by differentiation; calculating the gradient threshold based on the gradient information, and generating a perturbation scaling mask based on the gradient threshold; updating the gradient information based on the perturbation scaling mask; updating the perturbation value based on the updated gradient information, including: converting the updated gradient information into a perturbation unit direction vector with a fixed step size, adding it to the perturbation value in the current iteration and constraining it within the upper and lower bounds of the infinity norm to obtain the perturbation value in the next iteration operation, adding the updated perturbation value to the original image to update the original image, performing the next iteration operation on the updated original image until the iteration ends; the final updated original image is the adversarial example of the original image.
2. The image adversarial example generation method according to claim 1, characterized in that, The process of masking the original image to obtain the input sample includes: Based on the size of the original image and the length of each image block set in the VIT model, the original image is divided to obtain a set of image blocks; according to a preset number, image blocks are randomly selected and their masks are set to 1, while the masks of the remaining image blocks are set to 0. After performing masking operations on the image blocks, the resulting set of image blocks is used as the input sample.
3. The image adversarial example generation method according to claim 1, characterized in that, The gradient information of the output result with respect to the input sample can be obtained by taking the derivative of the following formula: in, For the first k The gradient information in each iteration includes the gradient information of each pixel in the input image. For the first k Input samples in the next iteration x The corresponding output results V The weights of the value vector in the self-attention mechanism. A For self-attention weights, This represents the identity matrix whose diagonal elements are all 1. Indicates matrix transpose. This represents the product of Kronecker.
4. The image adversarial example generation method according to claim 3, characterized in that, The step of calculating the gradient threshold based on the gradient information includes: The mean of the non-zero gradient information is calculated based on the sum of the gradient information of all pixels and the number of non-zero gradient information in the gradient information, and is used as the gradient threshold.
5. The image adversarial example generation method according to claim 4, characterized in that, The perturbation scaling mask is generated based on the gradient threshold using the following formula: in, For the first k In the next iteration, the input sample pixels Perturbation scaling mask, The preset scaling factor for the perturbation vector. For dynamic growth step size, For the first k The gradient threshold for the next iteration; For the first k In the next iteration, the input sample pixels The gradient information.
6. The image adversarial example generation method according to claim 5, characterized in that, The dynamic growth step size is obtained by dividing the square of the maximum perturbation value by the total number of iterations.
7. The image adversarial example generation method according to claim 5, characterized in that, The gradient information is updated based on the perturbation scaling mask using the following formula: in, For the first k The gradient information updated in the next iteration. These are preset momentum iteration coefficients. For the first k Gradient information in the next iteration. It is a norm of 1.
8. The image adversarial example generation method according to claim 7, characterized in that, The perturbation value is updated based on the updated gradient information using the following formula: in, The updated perturbation value, For the current number k The perturbation value in the next iteration operation. This is the step size for updating perturbation. For symbolic functions, Here is the clipping function, which means clipping the perturbation value to... scope.
9. An image adversarial example generation system, characterized in that, include: The image acquisition module is used to acquire the raw image and input the raw image into the VIT model; The adversarial example generation module is used to perform the following iterative operation on the original image: randomly mask the original image to obtain input samples; The self-attention mechanism based on the VIT model obtains the gradient information of the input sample, including: in forward propagation, obtaining the output result corresponding to the input sample according to the weights of the query vector, key vector, and value vector in the self-attention mechanism; in backpropagation, ignoring the query vector and key vector in the self-attention mechanism, obtaining the gradient information of the output result with respect to the input sample by differentiation; calculating the gradient threshold based on the gradient information, and generating a perturbation scaling mask based on the gradient threshold; updating the gradient information based on the perturbation scaling mask; updating the perturbation value based on the updated gradient information, including: converting the updated gradient information into a perturbation unit direction vector with a fixed step size, adding it to the perturbation value in the current iteration and constraining it within the upper and lower bounds of the infinity norm to obtain the perturbation value in the next iteration operation, adding the updated perturbation value to the original image to update the original image, performing the next iteration operation on the updated original image until the iteration ends; the final updated original image is the adversarial example of the original image.
Citation Information
Patent Citations
Adversarial sample generation method and system based on general disturbance
CN113627597A
Confrontation sample generation method based on belief attack and salient region disturbance limitation
CN114399630A
