WO2022078218A1 - 对抗样本的生成方法及装置、电子设备和可读存储介质 - Google Patents

对抗样本的生成方法及装置、电子设备和可读存储介质 Download PDF

Info

Publication number
WO2022078218A1
WO2022078218A1 PCT/CN2021/121736 CN2021121736W WO2022078218A1 WO 2022078218 A1 WO2022078218 A1 WO 2022078218A1 CN 2021121736 W CN2021121736 W CN 2021121736W WO 2022078218 A1 WO2022078218 A1 WO 2022078218A1
Authority
WO
WIPO (PCT)
Prior art keywords
gradient
data
sample
adversarial
target
Prior art date
Application number
PCT/CN2021/121736
Other languages
English (en)
French (fr)
Inventor
邓磊
吴郁杰
李国齐
何伟
施路平
祝夭龙
Original Assignee
北京灵汐科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京灵汐科技有限公司 filed Critical 北京灵汐科技有限公司
Publication of WO2022078218A1 publication Critical patent/WO2022078218A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/082Learning methods modifying the architecture, e.g. adding, deleting or silencing nodes or connections

Definitions

  • the present application relates to the field of computers, and in particular, to a method and apparatus for generating an adversarial sample, an electronic device, and a readable storage medium.
  • the spiking neural network since the input of the spiking neural network is a binary pulse signal, it adopts randomly flipping part of the pulse signal of the input sample, and achieves the purpose of adversarial attack through trial and error.
  • the method of generating impulse adversarial samples by trial and error due to the huge search space, it is difficult to find accurate adversarial samples, resulting in a low attack success rate.
  • Embodiments of the present application provide a method and apparatus for generating an adversarial sample, an electronic device, and a readable storage medium.
  • an embodiment of the present application provides a method for generating an adversarial sample, the method comprising: performing gradient descent processing on a first sample to obtain a first gradient of the first sample, wherein the first sample is The sample data in the sample is binary data, and the data in the first gradient is a continuous value; the first gradient is converted into a second gradient, wherein the data in the second gradient is ternary data; The sample data in the first sample is combined with the data in the second gradient to generate a target adversarial sample; wherein, the sample data in the target adversarial sample is binary data.
  • an embodiment of the present application further provides an apparatus for generating an adversarial sample, the apparatus comprising: a processing module configured to perform gradient descent processing on a first sample to obtain a first gradient of the first sample, The sample data in the first sample is binary data, and the data in the first gradient is continuous value; a conversion module is used to convert the first gradient into a second gradient, wherein the The data in the second gradient is ternary data; the generating module is configured to combine the sample data in the first sample with the data in the second gradient to generate a target adversarial sample; wherein the target adversarial The sample data in the sample is binary data.
  • an embodiment of the present application further provides an electronic device, including a processor, a memory, and a program or instruction stored in the memory and executable on the processor, the program or instruction being The processor implements the steps of the method as described in the first aspect when executed.
  • an embodiment of the present application further provides a readable storage medium, where a program or an instruction is stored on the readable storage medium, and when the program or instruction is executed by a processor, the method according to the first aspect is implemented. step.
  • embodiments of the present application further provide a computer program product, comprising computer-readable codes, or a non-volatile computer-readable storage medium carrying computer-readable codes, when the computer-readable codes are stored in an electronic
  • the processor in the electronic device executes the method for generating an adversarial sample described in the first aspect.
  • the first sample whose data type is binary data can be processed by gradient descent to obtain a first gradient whose corresponding data is continuous value, and then the first gradient of continuous value can be converted into data whose data is ternary value.
  • the second gradient of the data and finally combine the sample data in the first sample with the data in the second gradient to generate the target adversarial sample, so that the generated target adversarial sample matches the data type of the first sample, both of which are is binary data.
  • the adversarial sample obtained by the embodiment of the present application is a sample that is consistent with the data type of the original sample. That is to say, the gradient descent method is used to generate easily camouflaged adversarial samples with accurate gradient information, consistent with the original sample data type and with a small amount of change, which achieves the effect of improving the success rate of spiking neural network attacks.
  • FIG. 1 is a flowchart of a method for generating an adversarial sample according to an embodiment of the present application
  • FIG. 2 is a schematic diagram of a gradient descent process according to an embodiment of the present application.
  • FIG. 3 is a schematic diagram of an absolute value normalization process according to an embodiment of the present application.
  • FIG. 4 is a schematic diagram 1 of binary sampling according to an embodiment of the present application.
  • FIG. 5 is a second schematic diagram of binary sampling according to an embodiment of the present application.
  • FIG. 6 is a schematic diagram of taking symbols in an embodiment of the present application.
  • Fig. 7 is the schematic diagram of the limit conversion of the embodiment of the present application.
  • FIG. 8 is a complete schematic diagram of generating an adversarial sample according to an embodiment of the present application.
  • FIG. 9 is a schematic structural diagram of an apparatus for generating an adversarial sample according to an embodiment of the present application.
  • FIG. 1 is a flowchart of the method for generating an adversarial sample according to an embodiment of the present application. As shown in FIG. 1 , the method includes the following steps.
  • Step S102 performing gradient descent processing on the first sample to obtain a first gradient of the first sample, wherein the sample data in the first sample is binary data, and the data in the first gradient is continuous value.
  • Step S104 converting the first gradient into a second gradient, wherein the data in the second gradient is ternary data.
  • Step S106 combining the sample data in the first sample with the data in the second gradient to generate a target adversarial sample; wherein, the sample data in the target adversarial sample is binary data.
  • the first sample whose data type is binary data can be processed by gradient descent to obtain a first gradient whose corresponding data is continuous value, and then the first gradient of continuous value can be obtained.
  • the gradient is converted into a second gradient whose data is ternary data, and finally the sample data in the first sample is combined with the data in the second gradient to generate a target adversarial sample, so that the generated target adversarial sample is different from the first sample.
  • the data types are matched, both are binary data.
  • the adversarial sample obtained by the embodiment of the present application is the sample with the same data type as the original sample.
  • the gradient descent method is used to generate a sample containing accurate gradient information. It avoids the use of randomly flipping part of the pulse signal of the input sample in the prior art, and then searching for the random flip result, but this search space will lead to the problem of low attack success rate of the spiking neural network, on the other hand , by converting the first gradient into an adversarial sample that is consistent with the original sample data type, thereby improving the camouflage ability of the adversarial sample, and achieving the effect of improving the success rate of the spiking neural network attack.
  • the continuous value is data whose data type is continuous, and the continuous value may contain several decimal places.
  • the second gradient is used to characterize the variation of the data in the first sample, therefore, the original sample and the second gradient (variation) can be combined to generate the target adversarial sample.
  • the first sample in the embodiment of the present application is suitable for a neural network that receives a binary input signal, and may be an input sample of Spiking Neuron Networks (SNN) in a specific application scenario.
  • the binary data in the embodiment of the present application is a data type, and the data type means that the data in the sample only consists of ⁇ 0, 1 ⁇ .
  • the first sample in the embodiment of the present application is in a specific application scenario It can be any of the following samples 1 to 4.
  • the above samples 1 to 4 are examples of the first sample, and the specific value of the data in the first sample can be determined according to the actual situation.
  • the ternary data in the embodiment of the present application is also a data type, and the data type means that the data in the sample only consists of ⁇ -1, 0, 1 ⁇ , for example, the gradient (second gradient) of the ternary data It can be gradient 1 to gradient 4 as follows.
  • a sample of binary data can be converted to obtain a corresponding gradient according to the following principles: the data in the original sample is 0, and the corresponding data in the converted gradient is 1 or -1; wherein, for- In the case of 1, subsequent limiting needs to be performed.
  • the data in the original sample gradient is 1, and the corresponding data in the gradient is 0 or 1; among them, if the converted value is 1, subsequent limiting needs to be performed.
  • the above gradients 1 to 4 are examples of ternary data, and the specific ternary data in the embodiments of the present application may be determined according to actual conditions.
  • the continuous values in the first gradient obtained after the first sample is processed by gradient descent take the first sample as sample 2 as an example, as shown in FIG. After the gradient descent process, the first gradient corresponding to sample 2 can be obtained.
  • the data in sample 2 in FIG. 2 is illustrative data
  • the data in the first gradient corresponding to sample 2 obtained by gradient descent is also illustrative data; in some embodiments, the data obtained by gradient descent
  • the data in the first gradient corresponding to sample 2 of may also be other values, and the corresponding first sample is still sample 2.
  • the specific gradient descent processing needs to be processed according to the actual situation.
  • the method of converting the gradient of the first sample into the second gradient involved in step S104 in the embodiment of the present application may further include the following steps.
  • Step S104-11 performing binarization processing on the absolute value of the data in the first gradient to obtain a fourth gradient, where the data in the fourth gradient is binary data.
  • the binarization processing method in the embodiments of the present application may be any of the following methods in optional implementations of the embodiments of the present application: a binary sampling method, a rounding method, a histogram method, The way to calculate the average, etc.
  • the processing step of performing the binarization process on the absolute value of the data in the first gradient may include: making the absolute value of the data in the first gradient larger than the first gradient
  • the data of a critical value is set as a preset maximum value
  • the data whose absolute value of the data in the first gradient is smaller than the first critical value is set as a preset minimum value, thereby realizing binarization.
  • the absolute value of the data in the first gradient is compared with the first critical value such as 0.3, and the absolute value of the data in the first gradient is greater than 0.3.
  • the data of 0.3 is set as a preset maximum value such as 1, and the data whose absolute value of the data in the first gradient is less than 0.3 is set as a preset minimum value such as 0.
  • the absolute value of the data in the first gradient is 2, then the data corresponding to the target position in the corresponding fourth gradient obtained after binarization is 1; for example, the value of the data in the first gradient is 1. If the absolute value is 0.2, the data corresponding to the target position in the corresponding fourth gradient obtained after binarization processing is 0.
  • the first critical value, the preset maximum value and the preset minimum value are only schematic descriptions, and can be set according to actual needs in specific application scenarios.
  • Step S104-12 extract the target symbol of the data at the target position in the first gradient, and add the target symbol to the data corresponding to the target position in the fourth gradient; wherein, the fourth gradient after adding the symbol is the second gradient.
  • the first gradient can be converted into a second gradient, which is used to subsequently combine the sample data in the first sample with the data in the second gradient to generate a target adversarial sample.
  • the method of performing binarization processing on the absolute value of the data in the first gradient involved in step S104-11 of the embodiment of the present application to obtain the fourth gradient further The following steps may be included.
  • Step S104-111 normalize the absolute value of the data in the first gradient to obtain a third gradient; wherein, the data in the third gradient is a continuous value greater than or equal to zero;
  • Steps S104-112 perform binarization processing on the data in the third gradient to obtain the fourth gradient.
  • the absolute value of the data in the first gradient is first normalized to obtain a third gradient.
  • the binarization process can be implemented more conveniently and quickly to obtain the fourth gradient.
  • converting the first gradient into the second gradient may include the following steps.
  • Step S104-21 normalize the absolute value of the data in the first gradient to obtain a third gradient; wherein, the data in the third gradient is a continuous value greater than or equal to zero.
  • the continuous value greater than or equal to zero may be a continuous value between 0 and 1 in a specific application scenario.
  • the absolute value of the data in the first gradient is normalized.
  • the absolute value of each data can be determined first, and then the absolute value of The data with the largest value is normalized to 1, and the number with the largest absolute value is determined as the normalization coefficient, and then other absolute values are divided by the normalization coefficient.
  • the number with the largest absolute value is determined to be 2, that is - The absolute value of 2.0 (ie, 2.0), and the result of normalizing it is 1, and it is determined as the normalization coefficient; then, the result of normalizing 0.8 based on this normalization coefficient is 0.4 , and other data in the first gradient are sequentially normalized, as shown in Figure 3.
  • Step S104-22 performing binarization processing on the data in the third gradient to obtain a fourth gradient, wherein the data in the fourth gradient is binary data.
  • step S104-22 can be further implemented by the following steps.
  • Step S11 determining the gradient value of the data in the third gradient is the sampling probability of binary sampling.
  • Step S12 performing binary sampling on the data in the third gradient based on the sampling probability to obtain the fourth gradient.
  • sampling probability in the embodiment of the present application refers to the probability of obtaining one of the binary data, that is, the probability of 0 in the binary data or the probability of 1 in the binary data; the following will take the sampling as The probability of 1 is used as an example.
  • the sampling probability refers to the probability that each data sample is 1, that is, the probability that the data sample of 0.4 in the third gradient is 1 is 0.4 ; the probability that the data sampling of 0.8 in the third gradient is 1 is 0.8; the probability that the data sampling of 1 in the third gradient is 1 is 1, as shown in Figure 4.
  • FIG. 4 is an example of the sampling result, and the sampling result may also be the result shown in FIG. 5 , or of course other situations; that is, the embodiment of the present application uses FIG. 4 and FIG.
  • the sampling result of value sampling is illustrated as an example.
  • Step S104-23 extract the target symbol of the data of the target position in the first gradient, and add the target symbol to the data corresponding to the target position in the fourth gradient; wherein, the fourth gradient after adding the symbol is the second gradient.
  • the target position refers to any position in the first gradient, that is, the symbols of all the data in the first gradient need to be added to the data of the corresponding fourth gradient.
  • the symbol "-" in -2.0 can be added to the 1 in the corresponding position in the fourth gradient, and the result is "-1", and the symbol "-" represents a negative sign or a negative pole.
  • symbols in other positions are also processed in a similar manner, as shown in FIG. 6 .
  • the method of combining the sample data in the first sample with the data in the second gradient involved in step S106 in the embodiment of the present application, to generate a target adversarial sample may further include the following steps.
  • Step S106-11 Accumulate the data at the same position in the first sample and the second gradient to obtain a first confrontation sample.
  • Step S106-12 performing clipping transformation on the first adversarial sample to generate a target adversarial sample.
  • step S106-12 may further include: step S21, determining the data that does not match the binary data from the first adversarial sample; step S22, converting the data that does not match the binary data in the first adversarial sample into binary data value data to generate target adversarial examples.
  • the limiting conversion can be understood as a data conversion operation.
  • the data conversion operation for the values in the first confrontation sample that are outside the value range of the predetermined value interval, the The numerical value is converted into the interval endpoint value of the predetermined value interval that is closest to the numerical value; and the value within the value range of the predetermined value interval in the first confrontation sample is retained.
  • the predetermined value interval is [0, 1], then the data less than 0 in the first confrontation sample can be converted to be equal to 0, and the data greater than 1 in the first confrontation sample can be converted to be equal to 1; However, values greater than or equal to 0 and less than or equal to 1 are reserved, and no clipping conversion is performed.
  • the clipping in the clipping conversion is determined from binary data in the first sample. That is to say, the data type in the finally generated adversarial sample is consistent with the data type in the first sample.
  • the data in the first adversarial sample may have data of -1, 0, 1, and 2, that is, the data in the first adversarial sample is quaternary data, it is necessary to perform clipping conversion, clipping
  • the purpose of the conversion is to convert the data in the first adversarial sample into binary data, that is, convert the 2 in the first adversarial sample (the data that does not match the binary data in the first adversarial sample) to 1 (binary data), Convert -1 in the first adversarial sample (data that does not match the binary data in the first adversarial sample) to 0 (binary data), thereby obtaining a target adversarial sample that is consistent with the data type in the first adversarial sample.
  • the sample gradient of the continuous value format is used to modify the input sample of the pulse format as the basis for the subsequent generation of the pulse confrontation sample.
  • the difference between the confrontation sample and the original sample is limited by probability sampling, so that This makes it possible to generate easily camouflaged adversarial samples with accurate gradient information, the same data type as the original sample, and a small amount of change.
  • the random flipping results are searched, but the search space is limited.
  • the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is better implementation.
  • the technical solution of the present application can be embodied in the form of a software product in essence or in a part that contributes to the prior art, and the computer software product is stored in a storage medium (such as ROM/RAM, magnetic disk, CD-ROM), including several instructions to make a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) execute the methods of the various embodiments of the present application.
  • a storage medium such as ROM/RAM, magnetic disk, CD-ROM
  • the method for generating an adversarial sample in this embodiment of the present application may be executed by hardware, or the method may be executed by running a computer-executable code through a processor.
  • different embodiments of the present application may be combined with each other, and the descriptions of different embodiments have some emphasis, and for the parts that are not described, reference may be made to the records of other embodiments.
  • FIG. 9 is a schematic structural diagram of the apparatus for generating an adversarial sample in an embodiment of the present application. As shown in FIG. 9 , the apparatus includes the following modules.
  • the processing module 92 is configured to perform gradient descent processing on the first sample to obtain a first gradient of the first sample, wherein the sample data in the first sample is binary data, and the data in the first gradient is continuous numerical value .
  • the conversion module 94 is configured to convert the first gradient into a second gradient, wherein the data in the second gradient is ternary data.
  • the generating module 96 is configured to combine the sample data in the first sample with the data in the second gradient to generate a target adversarial sample; wherein, the sample data in the target adversarial sample is binary data.
  • the first sample in the embodiment of the present application is an input sample of the spiking neural network SNN.
  • the first sample in the embodiment of the present application is obtained by converting at least one of the following: an image sample, a voice sample, and a text sample; or the first sample is data collected by at least one of the following: a dynamic visual sensor, a brain-computer interface. That is, the data collected through the dynamic vision sensor or the brain-computer interface is pulse data, that is, the collected data can be directly used as the first sample.
  • a conversion neural network layer may be used to convert image samples, voice samples, and text samples into the same value as the first sample.
  • each time unit is sampled as 0 or 1, so as to obtain the corresponding 0/1 pulse sequence , that is, converting the pattern samples into pulse sample data, which is consistent with the first sample type; other types of samples are processed in a similar manner, which will not be repeated here.
  • the conversion module 94 in this embodiment of the present application may further include: a sampling unit, configured to perform binarization processing on the absolute value of the data in the first gradient to obtain a fourth gradient, where the The data is binary data; the conversion unit is used to extract the target symbol of the data of the target position in the first gradient, and add the target symbol to the data corresponding to the target position in the fourth gradient; wherein, the fourth gradient after adding the symbol The gradient is the second gradient.
  • a sampling unit configured to perform binarization processing on the absolute value of the data in the first gradient to obtain a fourth gradient, where the The data is binary data
  • the conversion unit is used to extract the target symbol of the data of the target position in the first gradient, and add the target symbol to the data corresponding to the target position in the fourth gradient
  • the fourth gradient after adding the symbol The gradient is the second gradient.
  • the sampling unit in this embodiment of the present application may further include: a normalization subunit, configured to perform normalization processing on the absolute value of the data in the first gradient to obtain a third gradient; wherein, the third gradient The data in is a continuous value greater than or equal to zero; the sampling unit is also used for binarizing the data in the third gradient to obtain the fourth gradient.
  • a normalization subunit configured to perform normalization processing on the absolute value of the data in the first gradient to obtain a third gradient
  • the third gradient The data in is a continuous value greater than or equal to zero
  • the sampling unit is also used for binarizing the data in the third gradient to obtain the fourth gradient.
  • the binarization processing method in the embodiment of the present application includes binary sampling; based on this, the sampling unit in the embodiment of the present application may further include: a determination subunit for determining the gradient of the data in the third gradient The value is the sampling probability of binary sampling; the sampling subunit is used to perform binary sampling on the data in the third gradient based on the sampling probability to obtain the fourth gradient.
  • sampling probability in the embodiment of the present application refers to the probability of obtaining one of the binary data.
  • the generation module in this embodiment of the present application may further include: an accumulation unit, configured to accumulate the data at the same position in the first sample and the second gradient to obtain a first confrontation sample;
  • An adversarial example is clipped to generate a target adversarial example.
  • the clipping in the clipping conversion in the embodiment of the present application is determined according to the binary data in the first sample.
  • the generating unit in this embodiment of the present application may further include: a determining subunit, configured to determine data that does not match the binary data from the first confrontation sample; The data that does not match the binary data is converted into binary data to generate target adversarial samples.
  • the first sample whose data type is binary data can be processed by gradient descent to obtain a first gradient whose corresponding data is continuous value, and then the first gradient of continuous value can be converted into data is the second gradient of the three-valued data. Finally, the sample data in the first sample is combined with the data in the second gradient to generate a target adversarial sample, so that the generated target adversarial sample matches the data type of the first sample. Yes, they are all binary data. If the first sample is the original sample of the spiking neural network, the adversarial sample obtained by the embodiment of the present application is the sample with the same data type as the original sample.
  • the method for generating an adversarial sample in this embodiment of the present application can improve the success rate of a spiking neural network attack.
  • the functions or modules included in the adversarial sample generating apparatus may be used to execute the adversarial sample generating method described in the above method embodiments, and its specific implementation and technical effects may be as follows: Referring to the description of the above method embodiments, for brevity, details are not repeated here.
  • an embodiment of the present application further provides an electronic device, including a processor, a memory, a program or an instruction stored on the memory and executable on the processor, and the program or instruction is executed by the processor to realize the above-mentioned confrontation sample.
  • an electronic device including a processor, a memory, a program or an instruction stored on the memory and executable on the processor, and the program or instruction is executed by the processor to realize the above-mentioned confrontation sample.
  • the electronic devices in the embodiments of the present application include the aforementioned mobile electronic devices and non-mobile electronic devices.
  • the embodiments of the present application further provide a readable storage medium, where a program or an instruction is stored on the readable storage medium.
  • a program or an instruction is stored on the readable storage medium.
  • the processor is the processor in the electronic device described in the above embodiments.
  • the readable storage medium includes a computer-readable storage medium, such as a computer read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk or an optical disk, and the like.
  • Embodiments of the present application also provide a computer program product, including computer-readable codes, or a non-volatile computer-readable storage medium carrying the computer-readable codes, when the computer-readable codes run in a processor of an electronic device , the processor in the electronic device executes the method for generating an adversarial sample for implementing the above embodiment.
  • modules or steps of the present application can be implemented by a general-purpose computing device, and they can be centralized on a single computing device, or distributed in a network composed of multiple computing devices Alternatively, they may be implemented in program code executable by a computing device, such that they may be stored in a storage device and executed by the computing device, and in some cases, in a different order than here
  • the steps shown or described are performed either by fabricating them separately into individual integrated circuit modules, or by fabricating multiple modules or steps of them into a single integrated circuit module.
  • the present application is not limited to any particular combination of hardware and software.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Molecular Biology (AREA)
  • Artificial Intelligence (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • User Interface Of Digital Computer (AREA)
  • Machine Translation (AREA)

Abstract

一种对抗样本的生成方法及装置、电子设备和可读存储介质,涉及计算机领域;其中,该方法包括:对第一样本进行梯度下降处理,得到第一样本的第一梯度,其中,第一样本中的样本数据为二值数据,第一梯度中的数据为连续数值(S102);将第一梯度转换为第二梯度,其中,第二梯度中的数据为三值数据(S104);将第一样本中的样本数据与第二梯度中的数据结合,以生成目标对抗样本;其中,目标对抗样本中的样本数据的为二值数据(S106)。

Description

对抗样本的生成方法及装置、电子设备和可读存储介质 技术领域
本申请涉及计算机领域,具体涉及一种对抗样本的生成方法及装置、电子设备和可读存储介质。
背景技术
目前,对于脉冲神经网络产生对抗样本的方式,由于脉冲神经网络的输入是二值脉冲信号,所以采用的是随机翻转输入样本的部分脉冲信号,通过试错的方式达到对抗攻击的目的。但是,通过试错法产生脉冲对抗样本的方法,由于搜索空间巨大,难以找到准确的对抗样本,使得攻击成功率较低。
发明内容
本申请实施例提供了一种对抗样本的生成方法及装置、电子设备和可读存储介质。
第一方面,本申请实施例提供了一种对抗样本的生成方法,该方法包括:对第一样本进行梯度下降处理,得到所述第一样本的第一梯度,其中,所述第一样本中的样本数据为二值数据,所述第一梯度中的数据为连续数值;将所述第一梯度转换为第二梯度,其中,所述第二梯度中的数据为三值数据;将所述第一样本中的样本数据与所述第二梯度中的数据结合,以生成目标对抗样本;其中,所述目标对抗样本中的样本数据的为二值数据。
第二方面,本申请实施例还提供了一种对抗样本的生成装置,该装置包括:处理模块,用于对第一样本进行梯度下降处理,得到所述第一样本的第一梯度,其中,所述第一样本中的样本数据为二值数据,所述第一梯度中的 数据为连续数值;转换模块,用于将所述第一梯度转换为第二梯度,其中,所述第二梯度中的数据为三值数据;生成模块,用于将所述第一样本中的样本数据与所述第二梯度中的数据结合,以生成目标对抗样本;其中,所述目标对抗样本中的样本数据的为二值数据。
第三方面,本申请实施例还提供了一种电子设备,包括处理器,存储器及存储在所述存储器上并可在所述处理器上运行的程序或指令,所述程序或指令被所述处理器执行时实现如第一方面所述的方法的步骤。
第四方面,本申请实施例还提供了一种可读存储介质,所述可读存储介质上存储程序或指令,所述程序或指令被处理器执行时实现如第一方面所述的方法的步骤。
第五方面,本申请实施例还提供了一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备的处理器中运行时,所述电子设备中的处理器执行用于实现第一方面所述的对抗样本的生成方法。
通过本申请实施例,可以将数据类型为二值数据的第一样本通过梯度下降处理后得到对应的数据为连续数值的第一梯度,进而将连续数值的第一梯度转换为数据为三值数据的第二梯度,最后将第一样本中的样本数据与第二梯度中的数据结合以生成目标对抗样本,从而使得生成的目标对抗样本与第一样本的数据类型是匹配的,都是二值数据。如果第一样本为脉冲神经网络的原始样本,则通过本申请实施例得到的对抗样本,是与原始样本的数据类型一致的样本。也就是说,利用梯度下降的方式产生了含有准确梯度信息、与原始样本数据类型一致且改变量较小的易伪装的对抗样本,达到了提高脉冲神经网络攻击成功率的效果。
附图说明
图1是本申请实施例的对抗样本的生成方法流程图;
图2是本申请实施例的梯度下降处理的示意图;
图3是本申请实施例的绝对值归一化处理的示意图;
图4是本申请实施例的二值采样的示意图一;
图5是本申请实施例的二值采样的示意图二;
图6是本申请实施例的取符号的示意图;
图7是本申请实施例的限幅转换的示意图;
图8是本申请实施例的生成对抗样本的完整示意图;
图9是本申请实施例的对抗样本的生成装置的结构示意图。
具体实施方式
下面将结合本申请一些实施例中的附图,对本申请一些实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请实施例的保护的范围。
在本申请的描述中,需要理解的是,术语“第一”、“第二”仅由于描述目的,且不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。因此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者多个该特征。本申请实施例的描述中,除非另有说明,“多个”的含义是两个或两个以上。
下面结合附图,通过具体的实施例及其应用场景对本申请实施例提供的对抗样本的生成方法进行详细地说明。
本申请实施例提供了一种对抗样本的生成方法,图1是本申请实施例的对抗样本的生成方法流程图,如图1所示,该方法包括如下步骤。
步骤S102,对第一样本进行梯度下降处理,得到第一样本的第一梯度,其中,第一样本中的样本数据为二值数据,第一梯度中的数据为连续数值。
步骤S104,将第一梯度转换为第二梯度,其中,第二梯度中的数据为三值数据。
步骤S106,将第一样本中的样本数据与第二梯度中的数据结合,以生成目标对抗样本;其中,目标对抗样本中的样本数据为二值数据。
通过本申请实施例的上述步骤S102至步骤S106,可以将数据类型为二值数据的第一样本通过梯度下降处理后得到对应的数据为连续数值的第一梯度,进而将连续数值的第一梯度转换为数据为三值数据的第二梯度,最后将第一样本中的样本数据与第二梯度中的数据结合以生成目标对抗样本,从而使得生成的目标对抗样本与第一样本的数据类型是匹配的,都是二值数据。
如果第一样本为脉冲神经网络的原始样本,则通过本申请实施例得到的对抗样本,则是与原始样本的数据类型一致的样本,一方面,利用梯度下降的方式生成了含有准确梯度信息的第一梯度,避免了现有技术中采用随机翻转输入样本的部分脉冲信号,再对随机翻转结果进行搜索,但该搜索空间大会导致脉冲神经网络的攻击成功率较低的问题,另一方面,通过对第一梯度进行处理转化为与原始样本数据类型一致的对抗样本,从而提高对抗样本的伪装能力,达到了提高脉冲神经网络攻击成功率的效果。
在本申请实施例中,连续数值是数据类型为连续型的数据,在连续数值中可以包含若干位小数。
需要说明的是,第二梯度是用于表征第一样本中数据的变化量,因此,原始样本和第二梯度(变化量)可以结合以生成目标对抗样本。
需要说明的是,本申请实施例中的第一样本适用于接收二值输入信号的神经网络,在具体应用场景中可以是脉冲神经网络(Spiking Neuron Networks,SNN)的输入样本。本申请实施例中的二值数据是一种数据类型,该数据类型是指样本中的数据仅由{0,1}组成,例如,本申请实施例中的第一样本在具体应用场景中可以是如下样本1至样本4中的任一种。
Figure PCTCN2021121736-appb-000001
当然,上述样本1至样本4是对第一样本的举例说明,具体第一样本中的数据的取值可以根据实际情况来确定。
此外,本申请实施例中的三值数据也是一种数据类型,该数据类型是指样本中的数据仅由{-1,0,1}组成,例如,三值数据的梯度(第二梯度)可以是如下梯度1至梯度4。
Figure PCTCN2021121736-appb-000002
也就是说,在本申请实施例中对于二值数据的样本可以通过以下原则来转换得到对应梯度:原样本中的数据为0,转换后梯度中对应数据为1或-1;其中,对于-1的情况后续需要进行限幅。原样本梯度中的数据为1,梯度中对应数据为0或1;其中,对于转换后为1的情况后续需要进行限幅。
当然,上述梯度1至梯度4是对三值数据的举例说明,具体本申请实施例中的三值数据可以根据实际情况来确定。
另外,本申请实施例中对第一样本进行梯度下降进行处理后的得到的第一梯度中的连续数值,以第一样本为样本2为例,如图2所示,对样本2进行梯度下降处理后,可以得到样本2所对应的第一梯度。但图2中的样本2中的数据为举例说明的数据,经梯度下降处理得到的样本2所对应的第一梯度中的数据也是举例说明的数据;在一些实施例中,经梯度下降处理得到的样本2所对应的第一梯度中的数据也可能是其他取值,其对应的第一样本依然是样本2。具体的梯度下降处理,需要根据实际情况进行处理。
在本申请实施例中的可选实施方式中,本申请实施例中的步骤S104中涉及到的将第一样本的梯度转换为第二梯度的方式,进一步可以包括如下步骤。
步骤S104-11,对第一梯度中的数据的绝对值进行二值化处理,得到第四梯度,其中,第四梯度中的数据为二值数据。
其中,本申请实施例中的二值化处理的方式在本申请实施例的可选实施方式中可以是如下方式中的任一种:二值采样的方式、四舍五入的方式、直方图的方式、计算平均值的方式等。
在一些实施例中,当二值化处理为二值采样时,对第一梯度中的数据的 绝对值进行二值化处理的处理步骤可以包括:将第一梯度中的数据的绝对值大于第一临界值的数据设为预设极大值,并将第一梯度中的数据的绝对值小于第一临界值的数据设为预设极小值,从而实现二值化。
示例性地,以上述图2中第一梯度的具体取值为例,将第一梯度中的数据的绝对值与第一临界值例如0.3进行对比,将第一梯度中的数据的绝对值大于0.3的数据设为预设极大值例如1,将第一梯度中的数据的绝对值小于0.3的数据设为预设极小值例如0。在具体应用场景中,例如第一梯度中的数据的绝对值为2,则经二值化处理后得到对应的第四梯度中与目标位置对应的数据为1;例如第一梯度中的数据的绝对值为0.2,则经二值化处理后得到对应的第四梯度中与目标位置对应的数据为0。
应理解,该第一临界值、预设极大值和预设极小值仅仅是示意性说明,在具体应用场景中,可以根据实际需要进行设定。
步骤S104-12,提取第一梯度中目标位置的数据的目标符号,并将目标符号添加到第四梯度中与目标位置对应的数据上;其中,添加符号后的第四梯度为第二梯度。
通过上述步骤S104-11和S104-12,可以将第一梯度转换为第二梯度,以用于后续将第一样本中的样本数据与第二梯度中的数据结合,生成目标对抗样本。
在本申请实施例中的可选实施方式中,本申请实施例的步骤S104-11中涉及到的对第一梯度中的数据的绝对值进行二值化处理,得到第四梯度的方式,进一步可以包括如下步骤。
步骤S104-111,对第一梯度中的数据的绝对值进行归一化处理,得到第三梯度;其中,第三梯度中的数据为大于或等于零的连续数值;
步骤S104-112,对第三梯度中的数据进行二值化处理,得到第四梯度。
通过上述步骤S104-111至步骤S104-113,先对第一梯度中的数据的绝对值进行归一化处理,得到第三梯度,在归一化处理得到的第三梯度中的数据的基础上,可以更加便捷快速的实现二值化处理,以得到第四梯度。
为了便于理解,下面通过具体实施例描述将第一梯度转换为第二梯度的具体流程。在该实施例中,将第一梯度转换为第二梯度可以包括如下步骤。
步骤S104-21,对第一梯度中的数据的绝对值进行归一化处理,得到第三梯度;其中,第三梯度中的数据为大于或等于零的连续数值。
需要说明的是,该大于或等于零的连续数值在具体应用场景中可以是0到1之间的连续数值。
以上述图2中第一梯度的具体取值为例,对第一梯度中的数据的绝对值进行归一化处理,在具体应用场景中可以是:先确定各个数据的绝对值,然后将绝对值最大的数据归一化为1,并确定绝对值最大的数为归一化系数,进而将其他绝对值除以归一化系数,具体可以是:确定绝对值最大的数为2,即-2.0的绝对值(即,2.0),并将其进行归一化处理的结果为1,并确定为归一化系数;然后,基于该归一化系数对0.8进行归一化处理的结果为0.4,第一梯度中其他数据依次进行归一化处理的结果,具体如图3所示。
步骤S104-22,对第三梯度中的数据进行二值化处理,得到第四梯度,其中,第四梯度中的数据为二值数据。
下面将以二值化处理的方式为二值采样的方式为例,对本申请进行举例说明。
在二值化处理的方式为二值采样的方式的情况下,上述步骤S104-22进一步可以通过以下步骤来实现。
步骤S11,确定第三梯度中的数据的梯度值为二值采样的采样概率。
步骤S12,基于采样概率对第三梯度中的数据进行二值采样,得到第四梯度。
需要说明的是,本申请实施例中的采样概率是指得到二值数据中其中之一的概率,即为二值数据中0的概率或是二值数据中1的概率;下面将以采样为1的概率为例进行说明。
对于上述步骤S104-22,以上述图3中的第三梯度为例,即采样概率则是指每一个数据采样为1的概率,即第三梯度中为0.4的数据采样为1的概率为0.4;第三梯度中为0.8的数据采样为1的概率为0.8;第三梯度中为1的数据采样为1的概率为1,具体如图4所示。需要说明的是,图4是采样结果的一个示例,采样结果也有可能是如图5所示的结果,当然也可能是其他情况;也就是说,本申请实施例通过图4和图5对二值采样的采样结果进 行示例说明。
步骤S104-23,提取第一梯度中目标位置的数据的目标符号,并将目标符号添加到第四梯度中与目标位置对应的数据上;其中,添加符号后的第四梯度为第二梯度。
对于上述步骤S104-23,其目标位置是指第一梯度中的任一位置,即需要将第一梯度中的所有数据的符号添加到对应的第四梯度的数据中,以上述图4中的第四梯度为例,可以将-2.0中的符号“-”添加到第四梯度中对应位置的1中,得到的结果为“-1”,符号“-”表示负数符号或负极。依次类推,对于其他位置的符号也是类似的处理方式,具体可以如图6所示。
在本申请实施例中的可选实施方式中,对于本申请实施例中步骤S106中涉及到的将第一样本中的样本数据与第二梯度中的数据结合,以生成目标对抗样本的方式,进一步可以包括如下步骤。
步骤S106-11,将第一样本与第二梯度中相同位置的数据进行累加得到第一对抗样本。
步骤S106-12,对第一对抗样本进行限幅转换以生成目标对抗样本。
其中,步骤S106-12进一步可以包括:步骤S21,从第一对抗样本中确定出与二值数据不匹配的数据;步骤S22,将第一对抗样本中与二值数据不匹配的数据转换为二值数据,生成目标对抗样本。
需要说明的是,限幅(Limiting)转换可以理解为是一种数据转换操作,在该数据转换操作中,对于第一对抗样本中的在预定取值区间取值范围之外的数值,将该数值转换为预定取值区间的与该数值距离最近的区间端点值;而对第一对抗样本中的在预定取值区间取值范围内的数值则予以保留。
示例性地,该预定取值区间为[0,1],则可以将第一对抗样本中的小于0的数据转化为等于0,将第一对抗样本中的大于1的数据转换为等于1;而对于大于或等于0且小于或等于1的数值予以保留,不执行限幅转换。
应理解,上述预定取值区间的具体取值范围仅仅是示意性说明,在具体应用场景中可以根据需要进行自定义设置。
在一些实施例中,限幅转换中的限幅是根据第一样本中的二值数据确定的。也就是说,最后生成的对抗样本中的数据类型是与第一样本中的数据类 型一致的。如图7所示,由于第一对抗样本中的数据可能存在-1、0、1、以及2的数据,即第一对抗样本中的数据为四值数据,因此需要进行限幅转换,限幅转换的目的是将第一对抗样本中的数据转换为二值数据,即将第一对抗样本中的2(第一对抗样本中与二值数据不匹配的数据)转换为1(二值数据),将第一对抗样本中的-1(第一对抗样本中与二值数据不匹配的数据)转换为0(二值数据),从而得到了与第一样本中数据类型一致的目标对抗样本。
对于上述步骤S102至步骤S106,在具体应用场景中,整个生成对抗样本的过程如图8所示。
通过本申请实施例,利用梯度下降以产生与原始样本(第一样本)对应的脉冲对抗样本(目标对抗样本),实现了高成功率的脉冲神经网络攻击;在利用梯度下降以产生与原始样本对应的脉冲对抗样本的过程中,利用了连续值格式的样本梯度修改脉冲格式的输入样本,作为后续产生脉冲对抗样本的基础,其中,通过概率采样限制对抗样本与原始样本的差别大小,从而使得可以产生含有准确梯度信息、与原始样本数据类型一致且改变量较小的易伪装的对抗样本,相比采用随机翻转输入样本的部分脉冲信号,再对随机翻转结果进行搜索,但该搜索空间会导致脉冲神经网络的攻击成功率较低的方案,本申请实施例的对抗样本的生成方法可以提高脉冲神经网络攻击成功率。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到根据上述实施例的方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例的方法。
需要说明的是,本申请实施例的对抗样本的生成方法可以由硬件执行,或者该方法可以由通过处理器运行计算机可执行代码的方式来执行。在不违背逻辑的情况下,本申请不同实施例之间可以相互结合,不同实施例描述有所侧重,未侧重描述的部分可参见其他实施例的记载。
本申请实施例还提供了一种对抗样本的生成装置,图9是本申请实施例 中的对抗样本的生成装置的结构示意图,如图9所示,该装置包括如下模块。
处理模块92,用于对第一样本进行梯度下降处理,得到第一样本的第一梯度,其中,第一样本中的样本数据为二值数据,第一梯度中的数据为连续数值。
转换模块94,用于将第一梯度转换为第二梯度,其中,第二梯度中的数据为三值数据。
生成模块96,用于将第一样本中的样本数据与第二梯度中的数据结合,以生成目标对抗样本;其中,目标对抗样本中的样本数据的为二值数据。
需要说明的是,本申请实施例中的第一样本为脉冲神经网络SNN的输入样本。
此外,本申请实施例中的第一样本为以下至少一项转换得到:图像样本、语音样本、文字样本;或第一样本为以下至少之一所采集的数据:动态视觉传感器、脑机接口。即通过动态视觉传感器或脑机接口所采集的数据为脉冲数据,即所采集的数据可以直接作为第一样本。而对于图像样本、语音样本、文字样本需要先对其进行转换,在本申请实施例的具体应用场景可以是一个转换神经网络层,将图像样本、语音样本、文字样本转换为与第一样本类型一样的数据,以图像样本为例,对图像中的像素强度进行归一化处理,然后进行概率采样的方式,每个时间单位采样为0或1,从而得到对应的0/1的脉冲序列,即将图样样本转换为脉冲样本数据,即与第一样本类型一致;其他类型的样本类似的处理的方式,在此不再赘述。
可选地,本申请实施例中的转换模块94进一步可以包括:采样单元,用于对第一梯度中的数据的绝对值进行二值化处理,得到第四梯度,其中,第四梯度中的数据为二值数据;转换单元,用于提取第一梯度中目标位置的数据的目标符号,并将目标符号添加到第四梯度中与目标位置对应的数据上;其中,添加符号后的第四梯度为第二梯度。
可选地,本申请实施例中的采样单元进一步可以包括:归一化子单元,用于对第一梯度中的数据的绝对值进行归一化处理,得到第三梯度;其中,第三梯度中的数据为大于或等于零的连续数值;采样单元,还用于对第三梯度中的数据进行二值化处理,得到第四梯度。
可选地,本申请实施例中的二值化处理的方式包括二值采样;基于此,本申请实施例中的采样单元进一步可以包括:确定子单元,用于确定第三梯度中数据的梯度值为二值采样的采样概率;采样子单元,用于基于采样概率对第三梯度中的数据进行二值采样,得到第四梯度。
需要说明的是,本申请实施例中的采样概率是指得到二值数据中其中之一的概率。
可选地,本申请实施例中的生成模块进一步可以包括:累加单元,用于将第一样本与第二梯度中相同位置的数据进行累加得到第一对抗样本;生成单元,用于对第一对抗样本进行限幅转换以生成目标对抗样本。
需要说明的是,本申请实施例中的限幅转换中的限幅是根据第一样本中的二值数据确定的。
可选地,本申请实施例中的生成单元进一步可以包括:确定子单元,用于从第一对抗样本中确定出与二值数据不匹配的数据;生成子单元,用于将第一对抗样本中与二值数据不匹配的数据转换为二值数据,生成目标对抗样本。
通过本申请实施例中的装置,可以将数据类型为二值数据的第一样本通过梯度下降处理后得到对应的数据为连续数值的第一梯度,进而将连续数值的第一梯度转换为数据为三值数据的第二梯度,最后将第一样本中的样本数据与第二梯度中的数据结合以生成目标对抗样本,从而使得生成的目标对抗样本与第一样本的数据类型是匹配的,都是二值数据。如果第一样本为脉冲神经网络的原始样本,则通过本申请实施例得到的对抗样本,则是与原始样本的数据类型一致的样本,也就是说,利用梯度下降的方式产生了含有准确梯度信息、与原始样本数据类型一致且改变量较小的易伪装的对抗样本,相比采用随机翻转输入样本的部分脉冲信号,再对随机翻转结果进行搜索,但该搜索空间大会导致脉冲神经网络的攻击成功率较低的方案,本申请实施例的对抗样本的生成方法可以提高脉冲神经网络攻击的成功率。
在本申请一些实施例中,本申请实施例提供的对抗样本的生成装置具有的功能或包含的模块可以用于执行上文方法实施例描述的对抗样本的生成方法,其具体实现和技术效果可参照上文方法实施例的描述,为了简洁,这里 不再赘述。
可选地,本申请实施例还提供一种电子设备,包括处理器,存储器,存储在存储器上并可在处理器上运行的程序或指令,该程序或指令被处理器执行时实现上述对抗样本的生成方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。
需要注意的是,本申请实施例中的电子设备包括上述的移动电子设备和非移动电子设备。
本申请实施例还提供一种可读存储介质,可读存储介质上存储有程序或指令,该程序或指令被处理器执行时实现上述对抗样本的生成方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。
其中,处理器为上述实施例中所述的电子设备中的处理器。所述可读存储介质,包括计算机可读存储介质,如计算机只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等。
本申请实施例还提供了一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当计算机可读代码在电子设备的处理器中运行时,电子设备中的处理器执行用于实现上述实施例的对抗样本的生成方法。
显然,本领域的技术人员应该明白,上述的本申请的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,可选地,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本申请不限制于任何特定的硬件和软件结合。
以上所述仅为本申请的可选实施例而已,并不用于限制本申请,对于本领域的技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护 范围之内。

Claims (17)

  1. 一种对抗样本的生成方法,其特征在于,包括:
    对第一样本进行梯度下降处理,得到所述第一样本的第一梯度,其中,所述第一样本中的样本数据为二值数据,所述第一梯度中的数据为连续数值;
    将所述第一梯度转换为第二梯度,其中,所述第二梯度中的数据为三值数据;
    将所述第一样本中的样本数据与所述第二梯度中的数据结合,以生成目标对抗样本;其中,所述目标对抗样本中的样本数据为二值数据。
  2. 根据权利要求1所述的方法,其特征在于,所述将所述第一梯度转换为第二梯度,包括:
    对所述第一梯度中的数据的绝对值进行二值化处理,得到第四梯度,其中,所述第四梯度中的数据为二值数据;
    提取所述第一梯度中目标位置的数据的目标符号,并将所述目标符号添加到所述第四梯度中与所述目标位置对应的数据上;其中,添加符号后的第四梯度为所述第二梯度。
  3. 根据权利要求2所述的方法,其特征在于,所述对所述第一梯度中的数据的绝对值进行二值化处理,得到第四梯度,包括:
    对所述第一梯度中的数据的绝对值进行归一化处理,得到第三梯度;其中,所述第三梯度中的数据为大于或等于零的连续数值;
    对所述第三梯度中的数据进行二值化处理,得到所述第四梯度。
  4. 根据权利要求3所述的方法,其特征在于,所述二值化处理的方式包括二值采样;所述对所述第三梯度中的数据进行二值化处理,得到所述第四梯度,包括:
    确定所述第三梯度中的数据为所述二值采样的采样概率;
    基于所述采样概率对所述第三梯度中的数据进行二值采样,得到所述第 四梯度。
  5. 根据权利要求4所述的方法,其特征在于,所述确定所述第三梯度中的数据为所述二值采样的采样概率中,所述采样概率为采样过程中得到二值数据中其中之一的概率。
  6. 根据权利要求1所述的方法,其特征在于,所述将所述第一样本中的样本数据与所述第二梯度中的数据结合,以生成目标对抗样本,包括:
    将所述第一样本与所述第二梯度中相同位置的数据进行累加得到第一对抗样本;
    对第一对抗样本进行限幅转换以生成所述目标对抗样本。
  7. 根据权利要求6所述的方法,其特征在于,所述对第一对抗样本进行限幅转换以生成所述目标对抗样本,包括:
    从所述第一对抗样本中确定出与所述二值数据不匹配的数据;
    将所述第一对抗样本中与所述二值数据不匹配的数据转换为二值数据,生成所述目标对抗样本。
  8. 根据权利要求6所述的方法,其特征在于,所述限幅转换中的限幅是根据第一样本中的二值数据确定的。
  9. 根据权利要求1至8中任一所述的方法,其特征在于,所述第一样本为脉冲神经网络的输入样本。
  10. 根据权利要求1至8中任一所述的方法,其特征在于,所述第一样本为以下至少一项转换得到:图像样本、语音样本、文字样本;或所述第一样本为以下至少之一所采集的数据:动态视觉传感器、脑机接口。
  11. 一种对抗样本的生成装置,其特征在于,包括:
    处理模块,用于对第一样本进行梯度下降处理,得到所述第一样本的第一梯度,其中,所述第一样本中的样本数据为二值数据,所述第一梯度中的数据为连续数值;
    转换模块,用于将所述第一梯度转换为第二梯度,其中,所述第二梯度 中的数据为三值数据;
    生成模块,用于将所述第一样本中的样本数据与所述第二梯度中的数据结合,以生成目标对抗样本;其中,所述目标对抗样本中的样本数据的为二值数据。
  12. 根据权利要求11所述的装置,其特征在于,所述转换模块包括:
    采样单元,用于对所述第一梯度中的数据的绝对值进行二值化处理,得到第四梯度,其中,所述第四梯度中的数据为二值数据;
    转换单元,用于提取所述第一梯度中目标位置的数据的目标符号,并将所述目标符号添加到所述第四梯度中与所述目标位置对应的数据上;其中,添加符号后的第四梯度为所述第二梯度。
  13. 根据权利要求12所述的装置,其特征在于,所述采样单元包括:
    归一化子单元,用于对所述第一梯度中的数据的绝对值进行归一化处理,得到第三梯度;其中,所述第三梯度中的数据为大于或等于零的连续数值;
    所述采样单元,还用于对所述第三梯度中的数据进行二值化处理,得到所述第四梯度。
  14. 根据权利要求11所述的装置,其特征在于,所述生成模块包括:
    累加单元,用于将所述第一样本与所述第二梯度中相同位置的数据进行累加得到第一对抗样本;
    生成单元,用于对第一对抗样本进行限幅转换以生成所述目标对抗样本。
  15. 一种电子设备,其特征在于,包括处理器,存储器及存储在所述存储器上并可在所述处理器上运行的程序或指令,所述程序或指令被所述处理器执行时实现包括如权利要求1-10中任一项所述的对抗样本的生成方法的步骤。
  16. 一种可读存储介质,其特征在于,所述可读存储介质上存储程序或指令,所述程序或指令被处理器执行时实现包括如权利要求1-10中任一项 所述的对抗样本的生成方法的步骤。
  17. 一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备的处理器中运行时,所述电子设备中的处理器执行用于实现权利要求1-10中的任一权利要求所述的对抗样本的生成方法。
PCT/CN2021/121736 2020-10-16 2021-09-29 对抗样本的生成方法及装置、电子设备和可读存储介质 WO2022078218A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011106873.2 2020-10-16
CN202011106873.2A CN111931932B (zh) 2020-10-16 2020-10-16 对抗样本的生成方法及装置、电子设备和可读存储介质

Publications (1)

Publication Number Publication Date
WO2022078218A1 true WO2022078218A1 (zh) 2022-04-21

Family

ID=73334488

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/121736 WO2022078218A1 (zh) 2020-10-16 2021-09-29 对抗样本的生成方法及装置、电子设备和可读存储介质

Country Status (2)

Country Link
CN (1) CN111931932B (zh)
WO (1) WO2022078218A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111931932B (zh) * 2020-10-16 2021-01-29 北京灵汐科技有限公司 对抗样本的生成方法及装置、电子设备和可读存储介质
CN117151171A (zh) * 2023-09-01 2023-12-01 软安科技有限公司 一种基于监督算法的脉冲神经网络对抗性攻击方法及系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109036389A (zh) * 2018-08-28 2018-12-18 出门问问信息科技有限公司 一种对抗样本的生成方法及装置
US20200193224A1 (en) * 2018-12-13 2020-06-18 Industrial Technology Research Institute Training method for phase image generator and training method of phase image classifier
CN111428817A (zh) * 2020-04-22 2020-07-17 浙江工业大学 一种面向无线电信号识别对抗攻击的防御方法
CN111753275A (zh) * 2020-06-04 2020-10-09 支付宝(杭州)信息技术有限公司 基于图像的用户隐私保护方法、装置、设备和存储介质
CN111931932A (zh) * 2020-10-16 2020-11-13 北京灵汐科技有限公司 对抗样本的生成方法及装置、电子设备和可读存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109036389A (zh) * 2018-08-28 2018-12-18 出门问问信息科技有限公司 一种对抗样本的生成方法及装置
US20200193224A1 (en) * 2018-12-13 2020-06-18 Industrial Technology Research Institute Training method for phase image generator and training method of phase image classifier
CN111428817A (zh) * 2020-04-22 2020-07-17 浙江工业大学 一种面向无线电信号识别对抗攻击的防御方法
CN111753275A (zh) * 2020-06-04 2020-10-09 支付宝(杭州)信息技术有限公司 基于图像的用户隐私保护方法、装置、设备和存储介质
CN111931932A (zh) * 2020-10-16 2020-11-13 北京灵汐科技有限公司 对抗样本的生成方法及装置、电子设备和可读存储介质

Also Published As

Publication number Publication date
CN111931932A (zh) 2020-11-13
CN111931932B (zh) 2021-01-29

Similar Documents

Publication Publication Date Title
US11023801B2 (en) Data processing method and apparatus
WO2022078218A1 (zh) 对抗样本的生成方法及装置、电子设备和可读存储介质
US11003896B2 (en) Entity recognition from an image
CN102880726B (zh) 一种图像过滤方法及系统
US11714921B2 (en) Image processing method with ash code on local feature vectors, image processing device and storage medium
WO2022100603A1 (zh) 二值采样的处理方法及装置、对抗样本的生成方法及装置、电子设备、可读存储介质
CN106681716B (zh) 智能终端及其应用程序的自动分类方法
CN112949767A (zh) 样本图像增量、图像检测模型训练及图像检测方法
CN114429633B (zh) 文本识别方法、模型的训练方法、装置、电子设备及介质
CN111967449B (zh) 文本检测方法、电子设备及计算机可读介质
CN112765324B (zh) 一种概念漂移检测方法及装置
CN113657596B (zh) 训练模型和图像识别的方法和装置
CN110895811B (zh) 一种图像篡改检测方法和装置
CN114153959A (zh) 键值匹配方法、装置、可读介质及电子设备
CN112419312B (zh) 相似房源信息检测方法、装置、电子设备和可读介质
CN113590857A (zh) 键值匹配方法、装置、可读介质及电子设备
CN110852250B (zh) 一种基于最大面积法的车辆排重方法、装置及存储介质
CN117609992A (zh) 一种数据泄密检测方法、装置及存储介质
CN112651399A (zh) 检测倾斜图像中同行文字的方法及其相关设备
CN111915689A (zh) 用于生成目标函数的方法、装置、电子设备和计算机可读介质
CN115082598B (zh) 文本图像生成、训练、文本图像处理方法以及电子设备
CN114724144B (zh) 文本识别方法、模型的训练方法、装置、设备及介质
CN114882334B (zh) 用于生成预训练模型的方法、模型训练方法及装置
CN114970470A (zh) 文案信息处理方法、装置、电子设备和计算机可读介质
US11880405B2 (en) Method for searching similar images in an image database using global values of a similarity measure for discarding partitions of the image database

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21879264

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21879264

Country of ref document: EP

Kind code of ref document: A1