A method and device for generating adversarial samples
By distinguishing the target area and non-target area and allocating noise to the original sample in the generation of adversarial samples, the problem that noise is easy to be eliminated and easily detected in the existing technology is solved, and the aggressiveness of the adversarial samples and the network model are improved. robustness.
Patent Information
- Application Number
- CN202111370606.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-18
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-11-18
AI Technical Summary
The nature of noise in existing adversarial sample generation methods is small, high-frequency perturbations, which are easily eliminated by defense methods such as high-frequency filtering. Increasing the amplitude of the perturbation is easily detected by the naked eye, making it difficult to improve the aggressiveness of adversarial samples without being perceptible by the naked eye. .
By dividing the original sample into a target area and a non-target area, dynamically allocating different step sizes and gradient noise, and adding interference noise to the target area and non-target area respectively, the interference intensity of the non-target area is stronger than that of the target area, so as to achieve better visual performance in the human eye. Increase the disturbance noise amplitude and noise information energy intensity without being easily noticed.
It improves the aggressiveness of adversarial samples, makes the trained network model more robust, overcomes the deficiencies of traditional methods, and enhances the irregularity of noise distribution and noise without significantly increasing the sensitivity of the naked eye. signal energy.
Smart Images

Figure CN114169409B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an adversarial sample generation method, device, equipment and storage medium. Background Art
[0002] In the field of computer vision technology, deep neural network technology is widely used in target recognition applications, with representative examples being face recognition and autonomous driving recognition. With the continuous development of target recognition technology and its introduction into more and more production and life fields, the security issues of target recognition technology have gradually been exposed and have attracted increasing attention. The security of deep neural network models faces many challenges. Adversarial sample attacks target the defects of deep neural networks and generate adversarial samples by adding interference noise that is difficult for the naked eye to detect, causing the network model to misjudge the recognition of adversarial samples and mislead the behavior of the target recognition system, thereby achieving the effect of escape or misleading the direction of target recognition results.
[0003] In the prior art, adversarial sample generation methods include fast gradient sign method (FGSM), projected gradient descent (PGD) and other attack methods. The core theory is to construct adversarial attack samples by adding directional gradient noise to the network model loss, thereby reducing the probability of correct recognition results and increasing the probability of incorrect recognition results. This type of adversarial sample noise is essentially a small, high-frequency disturbance, which is easily defended by noise elimination defense methods such as high-frequency filtering, and a simple increase in the disturbance amplitude is easily detected by the naked eye.
[0004] Therefore, how to improve the aggressiveness of adversarial samples in a way that is difficult to detect with the naked eye is a technical problem that needs to be solved urgently by technicians in this field. Summary of the invention
[0005] In view of this, the purpose of the present invention is to provide an adversarial sample generation method, device, equipment and storage medium, which can increase the disturbance noise amplitude and noise information energy intensity without being easily perceived by the human eye, so as to improve the aggressiveness of the adversarial sample and make the trained network model more robust.
[0006] The specific plan is as follows:
[0007] The first aspect of the present application provides a method for generating adversarial samples, comprising:
[0008] Divide the area in the original sample into a target area and a non-target area; wherein the target area is an area with high attention of the visual system, and the non-target area is an area with low attention of the visual system;
[0009] Determine the gradient noise of the original sample, and dynamically assign different step sizes to the target area and the non-target area respectively;
[0010] Based on the step size and the gradient noise, interference noise is added to the target area and the non-target area respectively to obtain an adversarial sample corresponding to the original sample; wherein the interference intensity of the non-target area is stronger than the interference intensity of the target area.
[0011] Optionally, dividing the region in the original sample into a target region and a non-target region includes:
[0012] The original sample is processed by using a target detection algorithm to obtain the target area and the non-target area of the original sample, and the target recognition type in the target area is determined.
[0013] Optionally, determining the gradient noise of the original sample includes:
[0014] If the generated adversarial sample is used in a targeted attack scenario, the target recognition type weight in the targeted attack scenario is used to perform a derivative calculation on the matrix corresponding to the original sample to obtain a gradient matrix of the original sample;
[0015] If the generated adversarial sample is used in an untargeted attack scenario, the target recognition type weight of the original sample is used to derive the matrix corresponding to the original sample and the calculation result is inverted to obtain the gradient matrix of the original sample.
[0016] Optionally, the dynamically allocating different step sizes to the target area and the non-target area respectively includes:
[0017] A step length matrix having an initial value of a first preset threshold is set, and the step length matrix is transformed and calculated based on the number of elements of the matrix corresponding to the target area, the number of elements of the gradient matrix and the preset maximum interference amplitude to obtain the step length matrix after transformation and calculation; wherein the step length matrix after transformation and calculation includes the step lengths dynamically allocated to the target area and the non-target area.
[0018] Optionally, the transforming and calculating the step size matrix based on the number of elements of the matrix corresponding to the target area, the number of elements of the gradient matrix, and a preset maximum interference amplitude includes:
[0019] Performing transformation calculation on the step size matrix based on the number of elements of the target area corresponding matrix, the number of elements of the gradient matrix, a preset maximum interference amplitude and a first relationship;
[0020] The first relation is:
[0021]
[0022] Among them, L ij is the element of the i-th row and j-th column in the step size matrix, N is the number of elements of the matrix corresponding to the target area, M is the number of elements of the gradient matrix, T is the preset maximum interference amplitude, B1 is the matrix corresponding to the target area, and B2 is the matrix corresponding to the non-target area.
[0023] Optionally, adding interference noise to the target area and the non-target area based on the step size and the gradient noise respectively to obtain an adversarial sample corresponding to the original sample includes:
[0024] The gradient matrix and the transformed step size matrix are used to perform noise weighted calculation on the matrix corresponding to the original sample to obtain an adversarial sample corresponding to the original sample.
[0025] Optionally, performing noise weighted calculation on the original sample corresponding matrix using the gradient matrix and the transformed step size matrix includes:
[0026] Using the gradient matrix and the transformed step size matrix, based on a second relational expression, a noise weighted calculation is performed on the original sample corresponding matrix;
[0027] The second relation is:
[0028]
[0029] Among them, X' ij is the original sample after noise weighting calculation, G ij is the gradient matrix, L ij is the step size matrix after transformation calculation.
[0030] Optionally, after adding interference noise to the target area and the non-target area based on the step size and the gradient noise respectively, the method further includes:
[0031] Determine whether the target recognition type in the target area in the original sample after adding the interference noise is a preset type, and if so, determine the original sample after adding the interference noise as an adversarial sample corresponding to the original sample;
[0032] If not, the original sample after adding the interference noise is used as an input sample for iterative calculation, so that the target recognition type in the target area is a preset type.
[0033] Optionally, after taking the original sample after adding the interference noise as the input sample for iterative calculation, the method further includes:
[0034] Determine whether the number of iterations is greater than a second preset threshold. If so, determine that the adversarial sample generation has failed. If not, continue the iterative calculation.
[0035] A second aspect of the present application provides an adversarial sample generation device, comprising:
[0036] A division module, used to divide the area in the original sample into a target area and a non-target area; wherein the target area is an area with high attention of the visual system, and the non-target area is an area with low attention of the visual system;
[0037] A dynamic allocation module, used for determining the gradient noise of the original sample and dynamically allocating different step sizes to the target area and the non-target area respectively;
[0038] A noise adding module is used to add interference noise to the target area and the non-target area respectively based on the step size and the gradient noise to obtain an adversarial sample corresponding to the original sample; wherein the interference intensity of the non-target area is stronger than the interference intensity of the target area.
[0039] A third aspect of the present application provides an electronic device, comprising a processor and a memory; wherein the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the aforementioned adversarial sample generation method.
[0040] The fourth aspect of the present application provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are loaded and executed by a processor, the aforementioned adversarial sample generation method is implemented.
[0041] In the present application, the regions in the original sample are first divided into target regions and non-target regions; wherein the target region is a region with high visual system attention, and the non-target region is a region with low visual system attention; then the gradient noise of the original sample is determined, and different step sizes are dynamically allocated to the target region and the non-target region respectively; finally, interference noise is added to the target region and the non-target region based on the step size and the gradient noise respectively, so as to obtain an adversarial sample corresponding to the original sample; wherein the interference intensity of the non-target region is stronger than the interference intensity of the target region. It can be seen that the present application achieves the effect of small disturbance in the target region and high disturbance in the non-target region by dynamically allocating different step sizes to the target region and the non-target region of the original sample in combination with the corresponding gradient noise to add interference noise, so as to increase the disturbance noise amplitude and the noise information energy intensity without being easily perceived by the human eye, so as to improve the aggressiveness of the adversarial sample and make the trained network model more robust. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0043] Figure 1 A flow chart of an anti-sample generation method provided in this application;
[0044] Figure 2 A schematic diagram of the structure of an anti-sample generating device provided in this application;
[0045] Figure 3 A structural diagram of an anti-sample generation electronic device provided in this application. DETAILED DESCRIPTION
[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] The noise added by the existing methods for generating adversarial samples is essentially small, high-frequency disturbances, which are easily defended by noise elimination defense methods such as high-frequency filtering, and simply increasing the disturbance amplitude is very easy to be detected by the naked eye. In response to the above technical defects, the present application provides an adversarial sample generation scheme, which increases the disturbance noise amplitude and noise information energy intensity in a way that is not easily perceived by the human eye by making small disturbances in the target area and high disturbances in the non-target area, so as to improve the aggressiveness of the adversarial sample and make the trained network model more robust.
[0048] Figure 1 A flow chart of a method for generating adversarial samples provided in an embodiment of the present application. Figure 1 As shown, the adversarial sample generation method includes:
[0049] S11: Divide the area in the original sample into a target area and a non-target area; wherein the target area is an area with high attention of the visual system, and the non-target area is an area with low attention of the visual system.
[0050] In this embodiment, the area in the original sample is divided into a target area and a non-target area; wherein the target area is an area with high attention of the visual system, and the non-target area is an area with low attention of the visual system. The original sample X can be processed using a target detection algorithm to obtain the target area and the non-target area of the original sample X, and determine the target recognition type in the target area. Different from the traditional adversarial sample generation method based on gradient attack, which makes noise disturbance to the input data as a whole, this embodiment is based on the attention mechanism of the brain signal processing that pays more attention to the detection target area with the naked eye and pays less attention to the areas outside the detection target. By performing target detection on the original sample X, the target detection can use the existing target recognition neural network model to obtain the target area B1, the non-target area B2 and the target recognition type Y.
[0051] Generally speaking, the generation process of adversarial samples is the result of iterative calculation. Therefore, if it is the first iteration, the original sample X is used as input to perform target recognition reasoning to obtain the target recognition type Y and the target area B1 and the non-target area B2. If it is not the first iteration, the sample X' obtained after the last noise weighting is used as input to perform target recognition reasoning to obtain the new target recognition type Y. In addition, the target area B1 and the non-target area B2 exist in the form of a matrix, and the corresponding target box is retained as the standard for the dynamic generation of noise step size determination range in the subsequent iteration process, and different dynamic step size calculation methods are performed inside and outside the B1 range.
[0052] S12: Determine the gradient noise of the original sample, and dynamically allocate different step sizes to the target area and the non-target area respectively.
[0053] In this embodiment, the gradient noise of the original sample is first determined, and then different step sizes are dynamically allocated to the target area and the non-target area, respectively. The gradient noise of the original sample is the gradient noise of the target area B1 and the non-target area B2. In this embodiment, different output Y classification results are used to derive X according to whether there is a target attack, and the current input gradient matrix G is obtained, and the G matrix is symbolized, for example, matrix elements greater than 0 are set to 1, matrix elements equal to 0 are set to 0, and matrix elements less than 0 are set to -1.
[0054] In one embodiment, if the generated adversarial sample is used in a targeted attack scenario, the target recognition type weight in the targeted attack scenario is used to derive the matrix corresponding to the original sample to obtain the gradient matrix G of the original sample. That is, if the attack is a targeted attack, that is, an attack method that explicitly replaces the recognition result Y[i] with Y[j], the gradient matrix G is calculated by deriving X with the recognition score of Y[j]. In another embodiment, if the generated adversarial sample is used in an untargeted attack scenario, the target recognition type weight of the original sample is used to derive the matrix corresponding to the original sample and the calculation result is negated to obtain the gradient matrix G of the original sample. That is, if the attack is an untargeted attack, the recognition result Y[i] is replaced with Y[~i], and the gradient of X is derived and negated with the recognition score of Y[i] to obtain the gradient matrix G. It should be noted that the recognition type Y output by the training model in the targeted attack scenario is a preset type, and the recognition type Y output by the training model in the untargeted attack scenario is not limited to a preset type.
[0055] In this embodiment, regarding the step size allocation process, first set the step size matrix with an initial value of the first preset threshold, such as setting the step size matrix L and initializing it to a fixed value of 0.07. Of course, the first preset threshold can also be flexibly configured according to the learning speed. Then, the step size matrix is transformed and calculated based on the number of elements of the matrix corresponding to the target area, the number of elements of the gradient matrix, and the preset maximum interference amplitude to obtain the step size matrix after the transformation calculation; wherein, the step size matrix after the transformation calculation contains the step sizes dynamically allocated to the target area and the non-target area. In order to realize the dynamic allocation of step sizes for the identification target area and non-target area of the input sample, adjust the noise distribution and energy intensity, and iteratively generate adversarial samples against the defense method based on high-frequency filtering.
[0056] Specifically, the step size matrix is transformed and calculated based on the number of elements of the matrix corresponding to the target area, the number of elements of the gradient matrix, the preset maximum interference amplitude and the first relationship.
[0057] Assuming that the number of elements in the B1 matrix is N and the number of elements in the G matrix is M, the L matrix is transformed, T is a preset maximum interference amplitude threshold, which can be set to 0.1, or can be flexibly configured to a threshold greater than the initial step value of L according to actual conditions, then the first relationship is:
[0058]
[0059] Among them, L ijis the element of the i-th row and j-th column in the step size matrix, N is the number of elements of the matrix corresponding to the target area, M is the number of elements of the gradient matrix, T is the preset maximum interference amplitude, B1 is the matrix corresponding to the target area, and B2 is the matrix corresponding to the non-target area.
[0060] S13: adding interference noise to the target area and the non-target area respectively based on the step size and the gradient noise to obtain an adversarial sample corresponding to the original sample; wherein the interference intensity of the non-target area is stronger than the interference intensity of the target area.
[0061] In this embodiment, interference noise is added to the target area and the non-target area based on the step size and the gradient noise, respectively, to obtain an adversarial sample corresponding to the original sample. Different step sizes are set inside and outside the target area B and weighted with the generated gradient noise and added to the original image as an adversarial sample. Among them, the interference intensity of the non-target area is stronger than the interference intensity of the target area. By adjusting the noise weights in different areas of the original sample in a targeted manner, the interference intensity of the target area is reduced, and the interference intensity of the non-target area is enhanced. Under the premise of not significantly increasing the sensitivity of the naked eye, the irregularity of the overall noise distribution and the energy intensity of the noise signal are increased, thereby overcoming the defect of the traditional adversarial sample generation method based on gradient noise that is easily targeted for defense.
[0062] In this embodiment, the gradient matrix and the step length matrix after transformation calculation are used to perform noise weighted calculation on the matrix corresponding to the original sample to obtain an adversarial sample corresponding to the original sample. Specifically, the gradient matrix and the step length matrix after transformation calculation are used to perform noise weighted calculation on the matrix corresponding to the original sample based on the second relational expression. The second relational expression is:
[0063]
[0064] Among them, X' ij is the original sample after noise weighting calculation, G ij is the gradient matrix, L ij is the step size matrix after transformation calculation.
[0065] On this basis, in a targeted attack scenario, it is also necessary to determine whether the target recognition type in the target area of the original sample after adding the interference noise is a preset type. If yes, the original sample after adding the interference noise is determined as an adversarial sample corresponding to the original sample. If not, the original sample after adding the interference noise is used as an input sample for iterative calculation to make the target recognition type in the target area a preset type. Repeat the above sample generation steps until Y is the target attack effect with / without the previous iteration, indicating that a successful attack sample is obtained. In the iterative adversarial sample generation process, the above operation can be repeated many times, and finally the effect of slight disturbance to the target area and high disturbance outside the target area is obtained. However, since the naked eye is more sensitive to changes in the target area, it is difficult to detect the attack behavior.
[0066] In addition, if the number of iterations exceeds the preset maximum number of iterations, the attack sample fails to be obtained. Therefore, it is necessary to determine whether the number of iterations is greater than the second preset threshold. If yes, it is determined that the adversarial sample generation fails. If not, the iterative calculation continues. The samples generated by each iteration are inferred, gradient calculated, step matrix updated, and new noise attack samples are added to generate until an adversarial sample that meets the attack target is generated or the predetermined number of iterations is reached and terminated.
[0067] It can be seen that the embodiment of the present application first divides the area in the original sample into a target area and a non-target area; wherein the target area is an area with high attention of the visual system, and the non-target area is an area with low attention of the visual system; then the gradient noise of the original sample is determined, and different step sizes are dynamically allocated to the target area and the non-target area respectively; finally, interference noise is added to the target area and the non-target area based on the step size and the gradient noise respectively to obtain an adversarial sample corresponding to the original sample; wherein the interference intensity of the non-target area is stronger than the interference intensity of the target area. The embodiment of the present application achieves the effect of small disturbance in the target area and high disturbance in the non-target area by dynamically allocating different step sizes to the target area and the non-target area of the original sample in combination with the corresponding gradient noise to add interference noise, thereby increasing the disturbance noise amplitude and the noise information energy intensity without being easily perceived by the human eye, so as to improve the aggressiveness of the adversarial sample and make the trained network model more robust.
[0068] See also Figure 2 As shown, the embodiment of the present application also discloses a device for generating adversarial samples, including:
[0069] A division module 11 is used to divide the area in the original sample into a target area and a non-target area; wherein the target area is an area with high attention of the visual system, and the non-target area is an area with low attention of the visual system;
[0070] A dynamic allocation module 12, used to determine the gradient noise of the original sample and dynamically allocate different step sizes to the target area and the non-target area respectively;
[0071] The noise adding module 13 is used to add interference noise to the target area and the non-target area respectively based on the step size and the gradient noise to obtain an adversarial sample corresponding to the original sample; wherein the interference intensity of the non-target area is stronger than the interference intensity of the target area.
[0072] It can be seen that the embodiment of the present application first divides the area in the original sample into a target area and a non-target area; wherein the target area is an area with high attention of the visual system, and the non-target area is an area with low attention of the visual system; then the gradient noise of the original sample is determined, and different step sizes are dynamically allocated to the target area and the non-target area respectively; finally, interference noise is added to the target area and the non-target area based on the step size and the gradient noise respectively to obtain an adversarial sample corresponding to the original sample; wherein the interference intensity of the non-target area is stronger than the interference intensity of the target area. The embodiment of the present application achieves the effect of small disturbance in the target area and high disturbance in the non-target area by dynamically allocating different step sizes to the target area and the non-target area of the original sample in combination with the corresponding gradient noise to add interference noise, thereby increasing the disturbance noise amplitude and the noise information energy intensity without being easily perceived by the human eye, so as to improve the aggressiveness of the adversarial sample and make the trained network model more robust.
[0073] In some specific embodiments, the segmentation module 11 is specifically used to process the original sample using a target detection algorithm to obtain the target area and the non-target area of the original sample, and determine the target recognition type in the target area.
[0074] In some specific embodiments, the dynamic allocation module 12 specifically includes:
[0075] A first determining unit is configured to, if the generated adversarial sample is used in a targeted attack scenario, perform a derivative calculation on the matrix corresponding to the original sample with the target recognition type weight in the targeted attack scenario to obtain a gradient matrix of the original sample;
[0076] A second determination unit is configured to, if the generated adversarial sample is used for a non-target attack scenario, perform a derivative calculation on the matrix corresponding to the original sample with the target recognition type weight of the original sample and invert the calculation result to obtain a gradient matrix of the original sample;
[0077] A step length allocation unit is used to set a step length matrix whose initial value is a first preset threshold, and transform the step length matrix based on the number of elements of the matrix corresponding to the target area, the number of elements of the gradient matrix and the preset maximum interference amplitude to obtain the step length matrix after the transformation calculation; wherein the step length matrix after the transformation calculation contains the step lengths dynamically allocated to the target area and the non-target area.
[0078] In some specific embodiments, the step size allocation unit is specifically used to transform and calculate the step size matrix based on the number of elements of the target area corresponding matrix, the number of elements of the gradient matrix, the preset maximum interference amplitude and the first relationship;
[0079] The first relation is:
[0080]
[0081] Among them, L ij is the element of the i-th row and j-th column in the step size matrix, N is the number of elements of the matrix corresponding to the target area, M is the number of elements of the gradient matrix, T is the preset maximum interference amplitude, B1 is the matrix corresponding to the target area, and B2 is the matrix corresponding to the non-target area.
[0082] In some specific embodiments, the noise adding module 13 is specifically used to perform noise weighted calculation on the matrix corresponding to the original sample using the gradient matrix and the step size matrix after transformation calculation, so as to obtain an adversarial sample corresponding to the original sample.
[0083] In some specific embodiments, the noise adding module 13 is further configured to perform noise weighted calculation on the original sample corresponding matrix based on a second relational expression using the gradient matrix and the transformed step length matrix;
[0084] The second relation is:
[0085]
[0086] Among them, X' ij is the original sample after noise weighting calculation, G ij is the gradient matrix, L ij is the step size matrix after transformation calculation.
[0087] In some specific embodiments, the adversarial sample generating device further includes:
[0088] A judgment module, used for judging whether the target recognition type in the target area in the original sample after adding the interference noise is a preset type, and if so, determining the original sample after adding the interference noise as an adversarial sample corresponding to the original sample;
[0089] The iterative module is used for, if not, taking the original sample after adding the interference noise as the input sample for iterative calculation, so that the target recognition type in the target area is a preset type.
[0090] In some specific embodiments, the iteration module is further used to determine whether the number of iterations is greater than a second preset threshold. If so, it is determined that the adversarial sample generation has failed. If not, the iterative calculation continues.
[0091] Furthermore, an embodiment of the present application also provides an electronic device. Figure 3 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.
[0092] Figure 3 A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the adversarial sample generation method disclosed in any of the aforementioned embodiments.
[0093] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0094] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon may include an operating system 221, a computer program 222 and data 223, etc. The storage method can be temporary storage or permanent storage.
[0095] Among them, the operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20 to realize the operation and processing of the massive data 223 in the memory 22 by the processor 21, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the adversarial sample generation method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks. The data 223 can include the original samples collected by the electronic device 20.
[0096] Furthermore, an embodiment of the present application also discloses a storage medium, in which a computer program is stored. When the computer program is loaded and executed by a processor, the steps of the adversarial sample generation method disclosed in any of the aforementioned embodiments are implemented.
[0097] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0098] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0099] The adversarial sample generation method, device, equipment and storage medium provided by the present invention are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for generating adversarial samples, characterized in that: include: Divide the area in the original sample into a target area and a non-target area; wherein the target area is an area with high attention of the visual system, and the non-target area is an area with low attention of the visual system; Determine the gradient noise of the original sample, and dynamically assign different step sizes to the target area and the non-target area respectively; Based on the step size and the gradient noise, interference noise is added to the target area and the non-target area respectively to obtain an adversarial sample corresponding to the original sample; wherein the interference intensity of the non-target area is stronger than the interference intensity of the target area.
2. The adversarial sample generation method according to claim 1, characterized in that: The dividing of the region in the original sample into the target region and the non-target region comprises: The original sample is processed by using a target detection algorithm to obtain the target area and the non-target area of the original sample, and the target recognition type in the target area is determined.
3. The adversarial sample generation method according to claim 2, characterized in that: The determining of the gradient noise of the original sample comprises: If the generated adversarial sample is used in a targeted attack scenario, the target recognition type weight in the targeted attack scenario is used to perform a derivative calculation on the matrix corresponding to the original sample to obtain a gradient matrix of the original sample; If the generated adversarial sample is used in an untargeted attack scenario, the target recognition type weight of the original sample is used to derive the matrix corresponding to the original sample and the calculation result is inverted to obtain the gradient matrix of the original sample.
4. The adversarial sample generation method according to claim 3, characterized in that: The dynamically allocating different step sizes to the target area and the non-target area respectively comprises: A step length matrix having an initial value of a first preset threshold is set, and the step length matrix is transformed and calculated based on the number of elements of the matrix corresponding to the target area, the number of elements of the gradient matrix and the preset maximum interference amplitude to obtain the step length matrix after transformation and calculation; wherein the step length matrix after transformation and calculation includes the step lengths dynamically allocated to the target area and the non-target area.
5. The adversarial sample generation method according to claim 4, characterized in that: The transform calculation of the step size matrix based on the number of elements of the target area corresponding matrix, the number of elements of the gradient matrix and the preset maximum interference amplitude includes: Performing transformation calculation on the step size matrix based on the number of elements of the target area corresponding matrix, the number of elements of the gradient matrix, a preset maximum interference amplitude and a first relationship; The first relation is: ; in, is the element of the i-th row and j-th column in the step size matrix, N is the number of elements of the matrix corresponding to the target area, M is the number of elements of the gradient matrix, T is the preset maximum interference amplitude, B1 is the matrix corresponding to the target area, and B2 is the matrix corresponding to the non-target area.
6. The adversarial sample generation method according to claim 5, characterized in that: The adding interference noise to the target area and the non-target area based on the step size and the gradient noise respectively to obtain an adversarial sample corresponding to the original sample includes: The gradient matrix and the transformed step size matrix are used to perform noise weighted calculation on the matrix corresponding to the original sample to obtain an adversarial sample corresponding to the original sample.
7. The adversarial sample generation method according to claim 6, characterized in that: The step of performing noise weighted calculation on the original sample corresponding matrix by using the gradient matrix and the transformed step size matrix comprises: Using the gradient matrix and the transformed step size matrix, based on a second relational expression, a noise weighted calculation is performed on the original sample corresponding matrix; The second relation is: ; in, is the original sample after noise weighting calculation, is the gradient matrix, is the step size matrix after transformation calculation.
8. The adversarial sample generation method according to any one of claims 1 to 7, characterized in that: After adding interference noise to the target area and the non-target area based on the step size and the gradient noise respectively, the method further includes: Determine whether the target recognition type in the target area in the original sample after adding the interference noise is a preset type, and if so, determine the original sample after adding the interference noise as an adversarial sample corresponding to the original sample; If not, the original sample after adding the interference noise is used as an input sample for iterative calculation, so that the target recognition type in the target area is a preset type.
9. The adversarial sample generation method according to claim 8, characterized in that: After the original sample after adding the interference noise is used as the input sample for iterative calculation, the method further includes: Determine whether the number of iterations is greater than a second preset threshold. If so, determine that the adversarial sample generation has failed. If not, continue the iterative calculation.
10. An adversarial sample generation device, characterized in that: include: A division module, used to divide the area in the original sample into a target area and a non-target area; wherein the target area is an area with high attention of the visual system, and the non-target area is an area with low attention of the visual system; A dynamic allocation module, used for determining the gradient noise of the original sample and dynamically allocating different step sizes to the target area and the non-target area respectively; A noise adding module is used to add interference noise to the target area and the non-target area respectively based on the step size and the gradient noise to obtain an adversarial sample corresponding to the original sample; wherein the interference intensity of the non-target area is stronger than the interference intensity of the target area.
Citation Information
Patent Citations
Video watermarking method based on visual attention mechanism
CN104168484A
A step size self-adaptive attack resisting method based on model extraction
CN109948663A
