General adversarial perturbation generation method, medium and computer device based on steganography

By steganography-based methods, the disturbance is steganographically embedded into the original sample, and an early stopping mechanism and loss function are added in the optimization process, which solves the problem of difficulty in balancing versatility and concealment in the existing technology, and achieves a high attack success rate. and covert adversarial example attacks.

CN114758187BActive Publication Date: 2024-09-17XIDIAN UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202210019738.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-10
Publication Date
2024-09-17
Estimated Expiration
2042-01-10

AI Technical Summary

Technical Problem

Existing general-purpose countermeasure perturbation generation methods are difficult to balance the versatility and concealment of perturbations, resulting in a decrease in the success rate of perturbation attacks and the inability to perform effective attacks without being noticed.

Method used

Using a steganography-based method, the disturbance is steganographed into the original sample through a deep steganography model, and an early stopping mechanism and loss function are added in the optimization process to ensure the concealment and versatility of the disturbance. At the same time, the Adam optimizer is used to optimize the mask. codes and patterns to generate more aggressive and covert perturbations.

Benefits of technology

It realizes the adversarial sample attack with high attack success rate without being noticed, ensures the versatility and concealment of the perturbation, overcomes the shortcomings of existing methods that cannot take into account both, and improves the attack effect of adversarial samples.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114758187B
    Figure CN114758187B
Patent Text Reader

Abstract

The present invention belongs to the field of deep learning security technology, and discloses a general adversarial perturbation generation method based on steganography, a medium and a computer device, wherein the general adversarial perturbation generation method based on steganography includes obtaining an original sample set, a target model and a steganalysis model; initializing a mask and a pattern; calculating a perturbation, and steganographically writing the perturbation into the original sample to obtain an adversarial sample; calculating a loss, optimizing a mask and a pattern; judging whether a termination condition is met; checking whether an early stopping mechanism is triggered, and performing a new round of iterations; calculating and saving the final perturbation. The present invention can be applied to various image classification scenarios such as image recognition, autonomous driving, and biometric recognition. Through a deep steganographic model, local adversarial noise is steganographically written into the global range of a target sample, and an attack is launched on an artificial intelligence system without being detected, affecting the normal function of the system, promoting defense with attack, and promoting the development of artificial intelligence systems in a more robust direction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of deep learning security technology, and in particular, relates to a universal adversarial disturbance generation method based on steganography, a medium and a computer device. Background Art

[0002] At present, deep neural networks are widely used in image recognition, intelligent speech recognition, spam filtering, machine translation, autonomous driving systems and other fields. While deep neural networks play a huge role in various fields, their security issues are gradually exposed. A large number of studies have found that deep neural networks are susceptible to adversarial samples, that is, they are easily fooled by disturbances that are not easily perceived by humans, causing the neural network to output wrong predictions with high confidence.

[0003] Most existing adversarial perturbation generation methods generate specific adversarial perturbations for each sample. Such perturbations are only applicable to specific samples and cannot be transferred between samples. Such adversarial perturbation generation methods are time-consuming and difficult to deploy in practical application scenarios. The latest research shows that universal adversarial perturbations achieve the universality of perturbations. There is no need to generate specific adversarial perturbations for each sample, and no need to obtain information about the target model to perform attacks during the test phase, which poses a greater threat to neural networks. Currently, universal adversarial perturbation generation methods have two main goals: (1) achieving the universality of perturbations. During the test phase, applying the generated universal adversarial perturbations to samples in the same dataset as the training samples can achieve a high attack success rate. The universal adversarial perturbations have good transferability on different datasets or different models; (2) achieving the concealment of perturbations. The generated universal adversarial perturbations should be difficult for humans to detect.

[0004] Existing general adversarial perturbation generation methods generally find it difficult to balance the generality and concealment of the perturbation. For example, an invention patent application with application publication number CN111680292A and titled “A method for generating adversarial samples based on highly concealed general perturbations” discloses a method for generating adversarial samples based on highly concealed general perturbations. The method first maximizes the loss of a batch of training samples to obtain a general loss function to achieve basic general perturbation generation. Then, a correction to samples outside the target attack class is added to the general loss function to construct a loss function for generating non-targeted and targeted general adversarial perturbations. The loss function is optimized and trained using a gradient descent method to obtain a preliminary general perturbation. Finally, the preliminary general perturbation is filtered using a low-pass filter to remove high-frequency noise and obtain the final general adversarial perturbation. The defect of this method is that after obtaining the preliminary universal disturbance, low-pass filtering is used to improve the concealment of the disturbance. However, the process of removing high-frequency noise causes the success rate of the universal adversarial disturbance attack to drop significantly, and the universality of the disturbance cannot be guaranteed. That is, this method cannot take into account both the universality and the concealment of the disturbance.

[0005] Through the above analysis, the problems and defects of the existing technology are: the existing general adversarial perturbation generation method cannot take into account both the universality and the concealment of the perturbation.

[0006] The difficulty in solving the above problems and defects is that the universality of the perturbation and the concealment of the perturbation are mutually constrained. The improvement of the universality of the perturbation comes at the expense of the concealment of the perturbation. The improvement of concealment will inevitably sacrifice the universality of the perturbation. It is difficult for existing methods to balance the relationship between the two. In order to ensure the universality of the perturbation, that is, the adversarial samples after adding perturbations can achieve a high attack success rate, most of the existing perturbations are added to the samples in a way that is visible to the human eye, and the perturbations are easily detected, while the existing highly concealed perturbations cannot meet the universality requirement.

[0007] The significance of solving the above problems and defects is that adversarial samples that take into account the universality and concealment of disturbances can perform attacks without being detected, posing a serious security risk to artificial intelligence systems. Solving the above problems and defects will promote the development of the adversarial sample attack field, promote defense through offense, and build a more robust artificial intelligence system. Summary of the invention

[0008] In view of the problems existing in the prior art, the present invention provides a universal adversarial perturbation generation method, medium and computer device based on steganography.

[0009] The present invention is implemented as follows: a universal steganographic-based adversarial perturbation generation method, the universal steganographic-based adversarial perturbation generation method comprising:

[0010] Step 1: Get the original sample set, target model and steganographic model: Prepare the dataset and model required to generate perturbations.

[0011] Step 2: Initialize the mask and pattern; provide the initial values ​​of the mask and pattern when performing step 3 to calculate the perturbation for the first time.

[0012] Step three, calculate the perturbation from the mask and pattern, and steganographically write the perturbation into the original sample to obtain the adversarial sample: obtain the adversarial sample for training to optimize the mask and pattern in step four.

[0013] Step 4: Calculate the loss and optimize the mask and pattern: Use two loss functions to optimize the attack performance and concealment of the perturbation respectively, incorporate the perturbation steganography into the training process, and obtain a more universal and concealed perturbation.

[0014] Step 5: epoch increments. If epoch is less than the total number of iterations epochs, execute step 6, otherwise execute step 7, where epoch represents the current number of iterations, the initial value of epoch is 0, and epochs ≥ 500; control the number of iterations, and terminate the iteration when a certain number of iterations is executed.

[0015] Step 6: Check whether the early stopping mechanism is triggered. If the early stopping conditions are met, execute step 7. If not, repeat steps 3 to 6 to perform a new round of iterations. Use the early stopping mechanism to obtain better generalization performance and save training time costs.

[0016] Step seven, calculate and save the final disturbance to achieve the purpose of the solution.

[0017] Furthermore, in step 1, the original sample set, the target model and the steganalysis model are obtained, and the specific process is as follows:

[0018] The first step is to select samples from the target dataset containing M categories, randomly select N non-repeated samples for each category in the dataset, transform these selected samples into the same size W*H*C, and form an original sample set X of size M×N. The ImageNet dataset is used as the target dataset, M=1000, N=10, W=224, H=224;

[0019] The second step is to obtain the network structure and weights of the pre-trained target model, obtain the target model, and use VGG16 as the target model;

[0020] The third step is to obtain the network structure and weights of the pre-trained steganographic model to obtain the steganographic model; the steganographic model HNet(·) converts the data formats of the original sample and the universal adversarial perturbation image into Format, C represents the channel, H represents the height of the image, and W represents the width of the image; the concat() function is used to concatenate the original image and the perturbed image in the dimension where C is located, and the concatenated image is used as the input of the steganography model.

[0021] Further, in step 2, the mask and pattern are initialized, and the specific process is:

[0022] a. Use the random() function to randomly generate a single-channel mask image mask of the same size W*H as the original sample, and limit the value of each element in the mask to the given upper and lower bounds; where the upper bound MASK_MAX = 1 and the lower bound MASK_MIN = 0;

[0023] b. Use the random() function to randomly generate an RGB image pattern of the same size W*H as the original sample, and limit the value of each element in the pattern to the given upper and lower bounds; where the upper bound PATTERN_MAX = 255 and the lower bound PATTERN_MIN = 0.

[0024] Furthermore, in step 3, the perturbation is calculated by mask and pattern, and the perturbation is steganographically written into the original sample to obtain an adversarial sample. The specific process is as follows:

[0025] A. Multiply the elements at the corresponding positions of mask and pattern, expressed as mask⊙pattern, to obtain the perturbed image;

[0026] B. Use the pre-trained steganography model to steganographically write the universal adversarial perturbation into the original sample to obtain the adversarial sample; the implementation method of steganography is x adv =HNet(mask⊙pattern,x), that is, the original sample x and the universal adversarial perturbation mask⊙pattern are spliced ​​according to the third step in step S101, the spliced ​​image is sent to the steganalysis model for steganography, and the universal adversarial perturbation mask⊙pattern is steganographically written into the original sample x to obtain the adversarial sample after the steganographic perturbation;

[0027] C. Perform perturbation steganography on each sample in the sample set in the same manner as in step B, that is, step B needs to be repeated M×N times.

[0028] Furthermore, in step 4, the loss is calculated and the mask and pattern are optimized. The specific process is as follows:

[0029] 1) Input a batch of samples with perturbations into a pre-trained target model to obtain prediction values. The number of samples in this batch is M×N, and calculate the average attack success rate acc of this batch of samples;

[0030] 2) Calculate the regularization loss loss_reg between the original samples and the perturbed samples. Use the L2 regularization method, and then substitute loss_reg, the prediction value of the target model for the perturbed samples, and the true labels of the samples into the untargeted loss function to obtain the total loss loss;

[0031] 3) Minimize the loss loss, and use an optimizer to optimize mask and pattern. Use the Adam optimizer for optimization;

[0032] 4) When both conditions acc < ε and loss_reg < reg_best are satisfied, let mask_best = mask, pattern_best = pattern, and reg_best = loss_reg, where ε is the attack threshold, and it is required that 0 < ε ≤ 1. reg_best is the best regularization value, and its initial value is infinity. mask_best and pattern_best are the current best mask and pattern respectively, and the initial values of their respective elements are all 0, and ε = 0.9999.

[0033] Furthermore, the untargeted attack loss function:

[0034]

[0035] where x is the original sample, x adv is the sample after adding the universal perturbation, y true is the true category of the sample, in the form of a one-hot vector, f(·) is the pre-trained target model, and f(x adv ) represents the classification result of the target model for the perturbed sample x adv , CE(·) is the cross-entropy loss, and L p (·) represents the L adv distance between the original sample x and the perturbed sample x p , where the value of p is 2.

[0036] Furthermore, in step six, check whether the early stopping mechanism is triggered. If the early stopping condition is met, execute step seven. If not, repeat steps three to six for a new round of iteration. The specific process is as follows:

[0037] The initial values ​​of acc_up, acc_down and early_stop_counter are all 0, the initial value of early_stop_reg_best is infinity, the initial values ​​of acc_up_flag and acc_down_flag are all False, and patience = 10, early_stop_patience = 20 are selected;

[0038] When the average attack success rate acc is greater than the attack threshold ε, acc_up is incremented and acc_down is set to zero. Otherwise, acc_down is incremented and acc_up is set to zero. If acc_up is greater than the set constant value patience, acc_up is set to zero and acc_up_flag is set to True.

[0039] If acc_down is greater than patience, acc_down is set to zero and acc_down_flag is set to True; if reg_best is greater than or equal to early_stop_reg_best, early_stop_counter is incremented, otherwise, early_stop_counter is set to zero;

[0040] Use the min() function to obtain the smaller value between reg_best and early_stop_reg_best, and assign it to early_stop_reg_best; if the values ​​of acc_up_flag and acc_down_flag are both True, and early_stop_counter is greater than early_stop_patience, the early stopping condition is met.

[0041] Furthermore, in step seven, the final disturbance is calculated and saved, and the specific process is as follows:

[0042] (1) Determine whether the values ​​of mask_best and pattern_best are None. If they are None, execute step (2); if they are not None, execute (3);

[0043] (2) Get the mask and pattern of the last iteration, and assign the value of mask to mask_best and the value of pattern to pattern_best;

[0044] (3) Multiply the corresponding elements of mask_best and pattern_best to calculate the final universal adversarial perturbation;

[0045] (4) Use image processing methods to save the universal adversarial perturbation as an image. The array_to_img() function converts the universal adversarial perturbation in array format into a picture form, and the save() function is used to save the perturbed picture.

[0046] Another object of the present invention is to provide a storage medium for receiving a user input program, wherein the stored computer program enables an electronic device to execute the universal steganographic-based adversarial perturbation generation method comprising the following steps:

[0047] Step 1: Get the original sample set, target model and steganalysis model:

[0048] Step 2: Initialize the mask and pattern;

[0049] Step 3: Calculate the perturbation from the mask and pattern, and write the perturbation into the original sample to obtain the adversarial sample:

[0050] Step 4: Calculate the loss and optimize the mask and pattern:

[0051] Step 5: epoch increments. If epoch is less than the total number of iterations epochs, then execute step 6. Otherwise, execute step 7. epoch represents the current number of iterations. The initial value of epoch is 0, and epochs ≥ 500.

[0052] Step 6: Check whether the early stopping mechanism is triggered. If the early stopping condition is met, execute step 7. If not, repeat steps 3 to 6 to perform a new round of iteration.

[0053] Step 7: Calculate and save the final perturbation.

[0054] Another object of the present invention is to provide a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the steganography-based general adversarial perturbation generation method.

[0055] Combined with all the above technical solutions, the advantages and positive effects of the present invention are as follows: the present invention uses a deep steganography model to steganographically record disturbances that are easily perceived by humans into the target sample, and the perturbations after steganography are not easily perceived, thereby achieving the concealment of the perturbations. The present invention adds a deep steganography module to the general adversarial perturbation optimization process, optimizes the samples after the perturbation steganography, ensures that the generated perturbations can achieve a high attack success rate and good mobility, and achieves the universality of the perturbations. The present invention overcomes the defect that the existing perturbation generation method cannot take into account both the universality and the concealment of the perturbations, and can achieve adversarial sample attacks with a high attack success rate without being detected. The present invention fills the gap in the perturbation generation method that takes into account both universality and concealment, and explores the hidden features of deep neural networks, that is, these features are related to the data distribution in an unobvious way, exposing the vulnerability of machine learning or deep learning algorithms, and posing a serious potential threat to artificial intelligence systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 It is a flow chart of a general adversarial perturbation generation method based on steganography provided in an embodiment of the present invention.

[0057] Figure 2 It is a schematic diagram of a universal adversarial perturbation generation process based on steganography provided in an embodiment of the present invention.

[0058] Figure 3 is a schematic diagram of a general anti-disturbance state generated according to an embodiment of the present invention;

[0059] Figure 4 This is a sample effect diagram after steganographic disturbance provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0060] In order 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 embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0061] In view of the problems existing in the prior art, the present invention provides a general steganographic-based adversarial perturbation generation method, medium and computer device, and the present invention is described in detail below with reference to the accompanying drawings.

[0062] The general steganographic-based anti-disturbance generation method provided by the present invention can also be implemented by other steps by ordinary technicians in the industry. Figure 1 The general adversarial perturbation generation method based on steganography provided by the present invention is only a specific embodiment.

[0063] like Figure 1 As shown, the general steganographic-based adversarial perturbation generation method provided by the embodiment of the present invention includes:

[0064] S101: Get the original sample set, target model and steganalysis model:

[0065] S102: Initialize mask and pattern;

[0066] S103: Calculate the perturbation from the mask and pattern, and write the perturbation into the original sample to obtain the adversarial sample:

[0067] S104: Calculate loss, optimize mask and pattern:

[0068] S105: epoch increments. If epoch is less than the total number of iterations epochs, execute S106, otherwise execute S107, where epoch represents the current number of iterations, the initial value of epoch is 0, and epochs ≥ 500;

[0069] S106: Check whether the early stopping mechanism is triggered. If the early stopping condition is met, execute S107. If not, repeat S103-S106 to perform a new round of iteration.

[0070] S107: Calculate and save the final disturbance.

[0071] In S101 provided in the embodiment of the present invention, the original sample set, the target model and the steganalysis model are obtained, and the specific process is as follows:

[0072] The first step is to select samples from the target dataset containing M categories, randomly select N non-repeated samples for each category in the dataset, transform these selected samples into the same size W*H*C, and form an original sample set X of size M×N. The ImageNet dataset is used as the target dataset, M=1000, N=10, W=224, H=224;

[0073] The second step is to obtain the network structure and weights of the pre-trained target model to obtain the target model; VGG16 is used as the target model;

[0074] The third step is to obtain the network structure and weights of the pre-trained steganographic model to obtain the steganographic model; the steganographic model HNet(·) converts the data formats of the original sample and the universal adversarial perturbation image into In the format, C represents the channel, h represents the height of the image, and W represents the width of the image. The concat() function is used to concatenate the original image and the perturbed image in the dimension where C is located, and the concatenated image is used as the input of the steganography model.

[0075] In S102 provided in the embodiment of the present invention, the mask and the pattern are initialized, and the specific process is as follows:

[0076] a. Use the random() function to randomly generate a single-channel mask image mask of the same size W*H as the original sample, and limit the value of each element in the mask to the given upper and lower bounds; where the upper bound MASK_MAX = 1 and the lower bound MASK_MIN = 0;

[0077] b. Use the random() function to randomly generate an RGB image pattern of the same size W*H as the original sample, and limit the value of each element in the pattern to the given upper and lower bounds; where the upper bound PATTERN_MAX = 255 and the lower bound PATTERN_MIN = 0.

[0078] In S103 provided in the embodiment of the present invention, the perturbation is calculated by the mask and the pattern, and the perturbation is steganographically written into the original sample to obtain the adversarial sample. The specific process is as follows:

[0079] A. Multiply the elements at the corresponding positions of mask and pattern, expressed as mask⊙pattern, to obtain the perturbed image;

[0080] B. Use the pre-trained steganography model to steganographically write the universal adversarial perturbation into the original sample to obtain the adversarial sample; the implementation method of steganography is x adv =HNet(mask⊙pattern,x), that is, the original sample x and the universal adversarial perturbation mask⊙pattern are spliced ​​according to the third step in step S101, the spliced ​​image is sent to the steganalysis model for steganography, and the universal adversarial perturbation mask⊙pattern is steganographically written into the original sample x to obtain the adversarial sample after the steganographic perturbation;

[0081] C. Perform perturbation steganography on each sample in the sample set in the same manner as in step B, that is, step B needs to be repeated M×N times.

[0082] In S104 provided in the embodiment of the present invention, the loss is calculated and the mask and pattern are optimized. The specific process is as follows:

[0083] 1) Input a batch of samples with added disturbances into the pre-trained target model to obtain the predicted value. The number of samples in this batch is M×N. Calculate the average attack success rate acc of this batch of samples;

[0084] 2) Calculate the regularization loss loss_reg of the original sample and the perturbed sample. Use the L2 regularization method, and then substitute loss_reg, the prediction value of the target model for the perturbed sample, and the true label of the sample into the untargeted loss function to obtain the total loss loss; Untargeted attack loss function:

[0085]

[0086] where x is the original sample, x adv is the sample after adding the universal perturbation, y true is the true class of the sample, in the form of a one-hot vector, f(·) is the pre-trained target model, f(x adv ) represents the classification result of the target model for the perturbed sample x adv , CE(·) is the cross-entropy loss, L p (·) represents the L adv distance between the original sample x and the perturbed sample x p , where the value of p is 2;

[0087] 3) Minimize the loss loss, use the optimizer to optimize mask and pattern, and optimize with the Adam optimizer;

[0088] 4) When both conditions acc < ε and loss_reg < reg_best are satisfied, let mask_best = mask, pattern_best = pattern, reg_best = loss_reg, where ε is the attack threshold, and it is required that 0 < ε ≤ 1, reg_best is the best regularization value, whose initial value is infinity, mask_best and pattern_best are the current best mask and pattern respectively, and the initial values of their respective elements are all 0, ε = 0.9999.

[0089] In S106 provided by the embodiment of the present invention, it is checked whether the early stopping mechanism is triggered. If the early stopping condition is met, S107 is executed. If not, S103 - S106 are repeated for a new round of iteration. The specific process is as follows:

[0090] The initial values of acc_up, acc_down, and early_stop_counter are all 0, the initial value of early_stop_reg_best is infinity, the initial values of acc_up_flag and acc_down_flag are both False, and patience = 10, early_stop_patience = 20 are selected;

[0091] When the average attack success rate acc is greater than the attack threshold ε, acc_up is incremented and acc_down is set to zero. Otherwise, acc_down is incremented and acc_up is set to zero. If acc_up is greater than the set constant value patience, acc_up is set to zero and acc_up_flag is set to True.

[0092] If acc_down is greater than patience, acc_down is set to zero and acc_down_flag is set to True; if reg_best is greater than or equal to early_stop_reg_best, early_stop_counter is incremented, otherwise, early_stop_counter is set to zero;

[0093] Use the min() function to obtain the smaller value between reg_best and early_stop_reg_best, and assign it to early_stop_reg_best; if the values ​​of acc_up_flag and acc_down_flag are both True, and early_stop_counter is greater than early_stop_patience, the early stopping condition is met.

[0094] In S107 provided in the embodiment of the present invention, the final disturbance is calculated and saved, and the specific process is as follows:

[0095] (1) Determine whether the values ​​of mask_best and pattern_best are None. If they are None, execute step (2); if they are not None, execute (3);

[0096] (2) Get the mask and pattern of the last iteration, and assign the value of mask to mask_best and the value of pattern to pattern_best;

[0097] (3) Multiply the corresponding elements of mask_best and pattern_best to calculate the final universal adversarial perturbation;

[0098] (4) Use image processing methods to save the universal adversarial perturbation as an image. The array_to_img() function converts the universal adversarial perturbation in array format into a picture form, and the save() function is used to save the perturbed picture.

[0099] The technical solution of the present invention is described in detail below in conjunction with specific embodiments.

[0100] like Figure 2As shown, the specific process of generating a universal adversarial perturbation based on steganography provided by an embodiment of the present invention is:

[0101] Step (1), obtain the original sample set, target model and steganalysis model:

[0102] Step (1a), select samples from a target dataset containing M categories, randomly select N non-repeated samples for each category in the dataset, transform the selected samples into the same size W*H*C, and form an original sample set X of size M×N. In this example, the ImageNet dataset is preferably used as the target dataset, M=1000, N=10, W=224, H=224.

[0103] Step (1b), obtaining the network structure and weights of the pre-trained target model to obtain the target model. In this example, VGG16 is preferably used as the target model.

[0104] Step (1c), obtain the network structure and weights of the pre-trained steganographic model to obtain the steganographic model. In this example, the preferred steganographic model HNet(·) is used. This model requires that the data formats of the original sample and the universal adversarial perturbation image are converted to Format, C represents the channel, H represents the height of the image, and W represents the width of the image; the concat() function is used to concatenate the original image and the perturbed image in the dimension where C is located, and the concatenated image is used as the input of the steganography model.

[0105] Step (2), initialize the mask and pattern:

[0106] Step (2a), use the random() function to randomly generate a single-channel mask image mask of the same size W*H as the original sample, and limit the value of each element in the mask to the given upper and lower bounds, where the upper bound MASK_MAX=1 and the lower bound MASK_MIN=0.

[0107] Step (2b), use the random() function to randomly generate an RGB image pattern of the same size W*H as the original sample, and limit the value of each element in the pattern to given upper and lower bounds, where the upper bound PATTERN_MAX=255 and the lower bound PATTERN_MIN=0.

[0108] Step (3), calculate the perturbation from the mask and pattern, and write the perturbation into the original sample to obtain the adversarial sample:

[0109] Step (3a), multiply the elements at corresponding positions of mask and pattern, expressed as mask⊙pattern, to obtain the perturbed image.

[0110] Step (3b), use the pre-trained steganography model to steganographically transform the universal adversarial perturbation into the original sample to obtain the adversarial sample. The steganography implementation in this example is x adv =HNet(mask⊙pattern,x), that is, the original sample x and the universal adversarial perturbation mask⊙pattern are spliced ​​according to the requirements in step (1c), the spliced ​​image is sent to the steganography model for steganography, and the universal adversarial perturbation mask⊙pattern is steganographically written into the original sample x to obtain the adversarial sample after the steganographic perturbation;

[0111] Step (3c): perform perturbation steganography on each sample in the sample set in the same manner as step (3b), that is, step (3b) needs to be repeated M×N times.

[0112] Step (4), calculate the loss and optimize the mask and pattern:

[0113] Step (4a), input a batch of samples with added disturbances into the pre-trained target model to obtain prediction values, the number of this batch of samples is M×N, and calculate the average attack success rate acc of this batch of samples.

[0114] Step (4b), calculate the regularized loss loss_reg of the original sample and the perturbed sample, use the L2 regularization method, and then substitute loss_reg, the target model's predicted value for the perturbed sample, and the true label of the sample into the non-targeted loss function to obtain the total loss loss. In this example, the non-targeted attack loss function is:

[0115]

[0116] Among them, x is the original sample, x adv is the sample after adding the universal perturbation, y true is the true category of the sample in the form of a one-hot vector, f(·) is the pre-trained target model, and f(x adv ) represents the target model's response to the perturbation sample x adv The classification result, CE(·) is the cross entropy loss, L p (·) represents the original sample x and the perturbation sample x adv L p distance, where the value of p is 2.

[0117] Step (4c), minimize the loss, and use the optimizer to optimize the mask and pattern. In this example, the Adam optimizer is preferred for optimization.

[0118] Step (4d): When both conditions acc < ε and loss_reg < reg_best are satisfied, let mask_best = mask, pattern_best = pattern, and reg_best = loss_reg, where ε is the attack threshold with the requirement 0 < ε ≤ 1, reg_best is the best regularization value with its initial value being infinity, mask_best and pattern_best are the current best mask and pattern respectively, and the initial values of their respective elements are all 0. In this example, ε = 0.9999 is preferably used.

[0119] Step (5): Increment epoch. If epoch is less than the total number of iterations epochs, then execute Step (6), otherwise execute Step (7), where epoch represents the current iteration number with its initial value being 0 and epochs ≥ 500. In this example, epochs = 500 is preferably used.

[0120] Step (6): Check whether the early stopping mechanism is triggered. If the early stopping condition is met, then execute Step (7). If not, repeat Steps (3)-(6) for a new round of iteration. In this example, the initial values of acc_up, acc_down, and early + stop_counter are all 0, the initial value of early_stop_reg_best is infinity, the initial values of acc_up_flag and acc_down_flag are both False, and patience = 10 and early_stop_patience = 20 are preferably used. When the average attack success rate acc is greater than the attack threshold ε, increment acc_up and set acc_down to zero. Otherwise, increment acc_down and set acc_up to zero. If acc_up is greater than the set constant value patience, then set acc_up to zero and set acc_up_flag to True. If acc_down is greater than patience, then set acc_down to zero and set acc_down_flag to True. If reg_best is greater than or equal to early_stop_reg_best, then increment early_stop_counter. Otherwise, set early_stop_counter to zero. Use the min() function to obtain the smaller value between reg_best and early_stop_reg_best and assign it to early_stop_reg_best. If the values of acc_up_flag and acc_down_flag are both True and early_stop_counter is greater than early_stop_patience, then the early stopping condition is met.

[0121] Step (7), calculate and save the final perturbation:

[0122] Step (7a), determine whether the values ​​of mask_best and pattern_best are None, if they are None, execute step (7b), if not None, execute step (7c).

[0123] Step (7b), obtain the mask and pattern of the last iteration, and assign the value of mask to mask_best, and the value of pattern to pattern_best.

[0124] Step (7c), multiply the corresponding position elements of mask_best and pattern_best to calculate the final universal adversarial perturbation.

[0125] Step (7d), using an image processing method to save the universal adversarial perturbation as an image. In this example, the array_to_img() function is preferably used to convert the universal adversarial perturbation in array format into a picture form, and the save() function is used to save the perturbed picture.

[0126] In combination with the application of the present invention in the field of autonomous driving and traffic sign recognition, the specific process of generating a universal adversarial perturbation based on steganography provided by an embodiment of the present invention is as follows:

[0127] Step (1), obtain the original sample set, target model and steganalysis model:

[0128] Step (1a), select samples from the target data set containing M categories, randomly select N non-repeated samples for each category in the data set, transform the selected samples into the same size W*H*C, and form an original sample set X of size M×N. In this example, the German traffic sign data set is preferably used as the target data set, M=43, N=1000, W=32, H=32.

[0129] Step (1b), obtaining the network structure and weights of the pre-trained target model to obtain the target model. In this example, VGG19 is preferably used as the target model, that is, the deep neural network model of the autonomous driving recognition system.

[0130] Step (1c), obtain the network structure and weights of the pre-trained steganographic model to obtain the steganographic model. In this example, the preferred steganographic model HNet(·) is used. This model requires that the data formats of the original sample and the universal adversarial perturbation image are converted to Format, C represents the channel, H represents the height of the image, and W represents the width of the image; the concat() function is used to concatenate the original image and the perturbed image in the dimension where C is located, and the concatenated image is used as the input of the steganography model.

[0131] Step (2), initialize the mask and pattern:

[0132] Step (2a), use the random() function to randomly generate a single-channel mask image mask of the same size W*H as the original sample, and limit the value of each element in the mask to the given upper and lower bounds, where the upper bound MASK_MAX=1 and the lower bound MASK_MIN=0.

[0133] Step (2b), use the random() function to randomly generate an RGB image pattern of the same size W*H as the original sample, and limit the value of each element in the pattern to given upper and lower bounds, where the upper bound PATTERN_MAX=255 and the lower bound PATTERN_MIN=0.

[0134] Step (3), calculate the perturbation from the mask and pattern, and write the perturbation into the original sample to obtain the adversarial sample:

[0135] Step (3a), multiply the elements at corresponding positions of mask and pattern, expressed as mask⊙pattern, to obtain the perturbed image.

[0136] Step (3b), use the pre-trained steganography model to steganographically transform the universal adversarial perturbation into the original sample to obtain the adversarial sample. The steganography implementation in this example is x adv =HNet(mask⊙pattern,x), that is, the German traffic sign sample x and the universal adversarial perturbation mask⊙pattern are spliced ​​according to the requirements in step (1c), the spliced ​​image is sent to the steganalysis model for steganography, and the universal adversarial perturbation mask⊙pattern is steganographically written into the original sample x to obtain the adversarial sample after the steganographic perturbation;

[0137] Step (3c): perform perturbation steganography on each sample of the German traffic sign dataset in the same manner as step (3b), that is, step (3b) needs to be repeated M×N times.

[0138] Step (4), calculate the loss and optimize the mask and pattern:

[0139] Step (4a), input a batch of samples with added disturbances into the pre-trained target model to obtain prediction values, the number of this batch of samples is M×N, and calculate the average attack success rate acc of this batch of samples.

[0140] Step (4b): Calculate the regularization loss loss_reg of the original sample and the perturbed sample using the L2 regularization method. Then substitute loss_reg, the prediction value of the target model for the perturbed sample, and the true label of the sample into the target loss function to obtain the total loss loss. In this example, the target attack loss function is selected to recognize traffic signs into a specified category:

[0141]

[0142] where x is the original sample, x adv is the sample after adding the universal perturbation, y target is the target classification category, preferably y target = 0, in the form of a one-hot vector, f(·) is the pre-trained target model, f(x adv ) represents the classification result of the target model for the perturbed sample x adv , CE(·) is the cross-entropy loss, L p (·) represents the L adv distance between the original sample x and the perturbed sample x p , where p is selected as 2 in this embodiment.

[0143] Step (4c): Minimize the loss loss, and use the optimizer to optimize mask and pattern. In this example, the Adam optimizer is preferably used for optimization.

[0144] Step (4d): When both conditions acc < ε and loss_reg < reg_best are satisfied, let mask_best = mask, pattern_best = pattern, reg_best = loss_reg, where ε is the attack threshold, 0 < ε ≤ 1 is required, reg_best is the best regularization value, whose initial value is infinity, mask_best and pattern_best are the current best mask and pattern respectively, and the initial values of each element of both are 0. In this example, ε = 0.9999 is preferably selected.

[0145] Step (5): Increment epoch. If epoch is less than the total number of iterations epochs, execute step (6), otherwise execute step (7), where epoch represents the current number of iterations, the initial value of epoch is 0, and epochs ≥ 500. In this example, epochs = 500 is preferably selected.

[0146] Step (6), check whether the early stop mechanism is triggered. If the early stop condition is met, execute step (7). If not, repeat steps (3)-(6) to perform a new round of iteration. In this example, the initial values ​​of acc_up, acc_down and early_stop_counter are all 0, the initial value of early_stop_reg_best is infinity, the initial values ​​of acc_up_flag and acc_down_flag are both False, and preferably patience = 10 and early_stop_patience = 20. When the average attack success rate acc is greater than the attack threshold ε, acc_up is incremented and acc_down is set to zero. Otherwise, acc_down is incremented and acc_up is set to zero. If acc_up is greater than the set constant value patience, acc_up is set to zero and acc_up_flag is set to True. If acc_down is greater than patience, acc_down is set to zero and acc_down_flag is set to True. If reg_best is greater than or equal to early_stop_reg_best, early_stop_counter is incremented, otherwise, early_stop_counter is set to zero. Use the min() function to get the smaller value of reg_best and early_stop_reg_best, and assign it to early_stop_reg_best. If the values ​​of acc_up_flag and acc_dwon_flag are both True, and early_stop_counter is greater than early_stop_patience, the early stop condition is met.

[0147] Step (7), calculate and save the final perturbation:

[0148] Step (7a), determine whether the values ​​of mask_best and pattern_best are None, if they are None, execute step (7b), if not None, execute step (7c).

[0149] Step (7b), obtain the mask and pattern of the last iteration, and assign the value of mask to mask_best, and the value of pattern to pattern_best.

[0150] Step (7c), multiply the corresponding position elements of mask_best and pattern_best to calculate the final universal adversarial perturbation.

[0151] Step (7d), using an image processing method to save the universal adversarial perturbation as an image. In this example, the array_to_img() function is preferably used to convert the universal adversarial perturbation in array format into a picture form, and the save() function is used to save the perturbed picture.

[0152] The technical effects of the present invention are described in detail below in conjunction with experiments.

[0153] The universal perturbation generation method of the present invention was applied to carry out non-targeted attacks on four deep neural network models and test the attack success rate and transferability, and was compared with the existing SUAP universal adversarial perturbation generation method. SUAP was experimented on 5 different secret images and four models. The results show that for the ResNet50 and Inception-v3 models, the method of the present invention is almost close to the best results of SUAP, with a difference of only about 2%, and the attack success rate on the remaining four secret images is better than SUAP. However, the SUAP method has considerable limitations, and its attack effect is heavily dependent on the content of the steganography. The perturbation generated by the present invention has weak dependence on the steganographic content, can achieve a high attack success rate while ensuring concealment, and is significantly better than the existing methods.

[0154] Table 1

[0155]

[0156]

[0157] It should be noted that the embodiments of the present invention can be implemented by hardware, software, or a combination of software and hardware. The hardware part can be implemented using dedicated logic; the software part can be stored in a memory and executed by an appropriate instruction execution system, such as a microprocessor or dedicated design hardware. It can be understood by a person of ordinary skill in the art that the above-mentioned devices and methods can be implemented using computer executable instructions and / or contained in a processor control code, such as a carrier medium such as a disk, CD or DVD-ROM, a programmable memory such as a read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. Such code is provided on the carrier medium. The device and its modules of the present invention can be implemented by hardware circuits such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, etc., or programmable hardware devices such as field programmable gate arrays, programmable logic devices, etc., can also be implemented by software executed by various types of processors, and can also be implemented by a combination of the above-mentioned hardware circuits and software, such as firmware.

[0158] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by any technician familiar with the technical field within the technical scope disclosed by the present invention and within the spirit and principle of the present invention should be covered by the protection scope of the present invention.

Claims

1. A universal adversarial perturbation generation method based on steganography, It is characterized in that The universal adversarial perturbation generation method based on steganography comprises: Step 1: Obtain the original sample set, target model and steganalysis model; Step 2: Initialize the mask and pattern; Step 3: Calculate the perturbation based on the mask and pattern, and write the perturbation into the original sample to obtain the adversarial sample. Step 4: Calculate the loss and optimize the mask and pattern; Step 5: epoch increments. If epoch is less than the total number of iterations epochs, then execute step 6. Otherwise, execute step 7. epoch represents the current number of iterations. The initial value of epoch is 0, and epochs ≥ 500. Step 6: Check whether the early stopping mechanism is triggered. If the early stopping condition is met, execute step 7. If not, repeat steps 3 to 6 to perform a new round of iteration. Step 7: Calculate and save the final disturbance; the process of obtaining the original sample set, target model and steganalysis model in step 1 is: The first step is to select samples from the target dataset containing M categories, randomly select N non-repeated samples for each category in the dataset, transform these selected samples into the same size W*H*C, and form an original sample set X of size M×N. The ImageNet dataset is used as the target dataset, M=1000, N=10, W=224, H=224; The second step is to obtain the network structure and weights of the pre-trained target model, obtain the target model, and use VGG16 as the target model; The third step is to obtain the network structure and weights of the pre-trained steganography model to obtain the steganography model; the steganography model HNet(·) uses the transpose() function to convert the data formats of the original sample and the universal adversarial perturbation image into the [C, H, W] format, where C represents the channel, H represents the height of the image, and W represents the width of the image; the concat() function is used to concatenate the original image and the perturbation image in the dimension where C is located, and the concatenated image is used as the input of the steganography model; In step 3, the perturbation is calculated by mask and pattern, and the perturbation is steganographically written into the original sample to obtain the adversarial sample process: A. Multiply the elements at the corresponding positions of mask and pattern, expressed as mask⊙pattern, to obtain the perturbed image; B. Use the pre-trained steganography model to steganographically write the universal adversarial perturbation into the original sample to obtain the adversarial sample; the implementation method of steganography is x adv =HNet(mask⊙pattern,x), that is, concatenate the original sample x and the universal adversarial perturbation mask⊙pattern according to the third step in step 1, send the concatenated image to the steganography model for steganography, and steganographically concatenate the universal adversarial perturbation mask⊙pattern into the original sample x to obtain the adversarial sample after steganographic perturbation; C. Perform perturbation steganography on each sample in the sample set in the same manner as in step B, i.e., step B needs to be repeated M×N times; The loss is calculated in step 4, and the process of optimizing mask and pattern is as follows: 1) Input a batch of samples with added disturbances into the pre-trained target model to obtain the predicted value. The number of samples in this batch is M×N. Calculate the average attack success rate acc of this batch of samples; 2) Calculate the regularization loss loss_reg of the original sample and the perturbation sample, using L 2 Regularization method, then substitute loss_reg, the target model's predicted value for the perturbation sample, and the true label of the sample into the non-target loss function to obtain the total loss loss; 3) Minimize the loss, use the optimizer to optimize the mask and pattern, and use the Adam optimizer for optimization; 4) When both conditions of acc<ε and loss_reg<reg_best are met, let mask_best=mask, pattern_best=pattern, reg_best=loss_reg, where ε is the attack threshold, requiring 0<ε≤1, reg_best is the best regularized value, and its initial value is infinity. Mask_best and pattern_best are the current best mask and pattern respectively, and the initial value of each element of the two is 0, ε=0.9999.

2. The method for generating a universal adversarial perturbation based on steganography as claimed in claim 1, It is characterized in that The process of initializing the mask and pattern in step 2 is: a. Use the random() function to randomly generate a single-channel mask image mask of the same size W*H as the original sample, and limit the value of each element in the mask to the given upper and lower bounds; where the upper bound MASK_MAX = 1 and the lower bound MASK_MIN = 0; b. Use the random() function to randomly generate an RGB image pattern of the same size W*H as the original sample, and limit the value of each element in the pattern to the given upper and lower bounds; where the upper bound PATTERN_MAX = 255 and the lower bound PATTERN_MIN = 0.

3. The universal adversarial perturbation generation method based on steganography as claimed in claim 1, It is characterized in that Untargeted attack loss function: Among them, x is the original sample, x adv is the sample after adding the universal perturbation, y true is the true category of the sample in the form of a one-hot vector, f(·) is the pre-trained target model, and f(x adv ) represents the target model's response to the perturbation sample x adv The classification result, CE(·) is the cross entropy loss, L p (·) represents the original sample x and the perturbation sample x adv L p distance, where the value of p is 2.

4. The method for generating a universal adversarial perturbation based on steganography as claimed in claim 1, It is characterized in that In step 6, check whether the early stopping mechanism is triggered. If the early stopping condition is met, execute step 7. If not, repeat steps 3 to 6 to perform a new round of iteration process: The initial values ​​of acc_up, acc_down and early_stop_counter are all 0, the initial value of early_stop_reg_best is infinity, the initial values ​​of acc_up_flag and acc_down_flag are all False, and patience = 10, early_stop_patience = 20 are selected; When the average attack success rate acc is greater than the attack threshold ε, acc_up is incremented and acc_down is set to zero. Otherwise, acc_down is incremented and acc_up is set to zero. If acc_up is greater than the set constant value patience, acc_up is set to zero and acc_up_flag is set to True. If acc_down is greater than patience, acc_down is set to zero and acc_down_flag is set to True; if reg_best is greater than or equal to early_stop_reg_best, early_stop_counter is incremented, otherwise, early_stop_counter is set to zero; Use the min() function to obtain the smaller value between reg_best and early_stop_reg_best, and assign it to early_stop_reg_best; if the values ​​of acc_up_flag and acc_down_flag are both True, and early_stop_counter is greater than early_stop_patience, the early stopping condition is met.

5. The method for generating a universal adversarial perturbation based on steganography as claimed in claim 1, It is characterized in that The final disturbance process calculated and saved in step 7 is: (1) Determine whether the values ​​of mask_best and pattern_best are None. If they are None, execute step (2); if they are not None, execute (3); (2) Get the mask and pattern of the last iteration, and assign the value of mask to mask_best and the value of pattern to pattern_best; (3) Multiply the corresponding elements of mask_best and pattern_best to calculate the final universal adversarial perturbation; (4) Use image processing methods to save the universal adversarial perturbation as an image. The array_to_img() function converts the universal adversarial perturbation in array format into a picture form, and the save() function is used to save the perturbed picture.

6. A storage medium for receiving user input program, wherein the stored computer program enables an electronic device to execute the steganographic-based universal adversarial perturbation generation method according to any one of claims 1 to 2, comprising the following steps: Step 1: Get the original sample set, target model and steganalysis model: Step 2: Initialize the mask and pattern; Step 3: Calculate the perturbation from the mask and pattern, and write the perturbation into the original sample to obtain the adversarial sample: Step 4: Calculate the loss and optimize the mask and pattern: Step 5: epoch increments. If epoch is less than the total number of iterations epochs, then execute step 6. Otherwise, execute step 7. epoch represents the current number of iterations. The initial value of epoch is 0, and epochs ≥ 500. Step 6: Check whether the early stopping mechanism is triggered. If the early stopping condition is met, execute step 7. If not, repeat steps 3 to 6 to perform a new round of iteration. Step 7: Calculate and save the final perturbation.

7. A computer device, It is characterized in that The computer device includes a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the steganography-based general adversarial perturbation generation method according to any one of claims 1 to 2.

Citation Information

Patent Citations

  • Adversarial sample generation method based on high-concealment general disturbance

    CN111680292A

  • Target attack adversarial sample generation method for deep learning model

    CN112183671A

  • Voice verification code generation method based on generative adversarial network

    CN112287323A

  • Method, apparatus and computer program for operating a machine learning system

    DE102018208763A1