提交 9542bab2 编写于 作者: wgzqz's avatar wgzqz

Bug fix:

1. target_label.setter
2. Adversary(data) should be Adversary(data[0][0], data[0][1])
上级 ca131878
...@@ -121,11 +121,11 @@ class Adversary(object): ...@@ -121,11 +121,11 @@ class Adversary(object):
return self.__target_label return self.__target_label
@target_label.setter @target_label.setter
def target_label(self): def target_label(self, label):
""" """
:property: target_label :property: target_label
""" """
return self.__target_label self.__target_label = label
@property @property
def target(self): def target(self):
......
...@@ -5,9 +5,9 @@ import matplotlib.pyplot as plt ...@@ -5,9 +5,9 @@ import matplotlib.pyplot as plt
import paddle.v2 as paddle import paddle.v2 as paddle
import paddle.v2.fluid as fluid import paddle.v2.fluid as fluid
from .advbox import Adversary from advbox import Adversary
from .advbox.attacks.gradientsign import GradientSignAttack from advbox.attacks.gradientsign import GradientSignAttack
from .advbox.models.paddle import PaddleModel from advbox.models.paddle import PaddleModel
def cnn_model(img): def cnn_model(img):
...@@ -76,7 +76,7 @@ def main(): ...@@ -76,7 +76,7 @@ def main():
att = GradientSignAttack(m) att = GradientSignAttack(m)
for data in train_reader(): for data in train_reader():
# fgsm attack # fgsm attack
adversary = att(Adversary(data)) adversary = att(Adversary(data[0][0], data[0][1]))
if adversary.is_successful(): if adversary.is_successful():
plt.imshow(adversary.target, cmap='Greys_r') plt.imshow(adversary.target, cmap='Greys_r')
plt.show() plt.show()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册