提交 4c90f3d5 编写于 作者: B baidu

modify code style

上级 66e0f528
...@@ -12,6 +12,7 @@ class IteratorGradientSignAttack(Attack): ...@@ -12,6 +12,7 @@ class IteratorGradientSignAttack(Attack):
This attack was originally implemented by Alexey Kurakin(Google Brain). This attack was originally implemented by Alexey Kurakin(Google Brain).
Paper link: https://arxiv.org/pdf/1607.02533.pdf Paper link: https://arxiv.org/pdf/1607.02533.pdf
""" """
def _apply(self, image_label, epsilons=100, steps=10): def _apply(self, image_label, epsilons=100, steps=10):
""" """
Apply the iterative gradient sign attack. Apply the iterative gradient sign attack.
...@@ -22,7 +23,6 @@ class IteratorGradientSignAttack(Attack): ...@@ -22,7 +23,6 @@ class IteratorGradientSignAttack(Attack):
Return: Return:
numpy.ndarray: The adversarail sample generated by the algorithm. numpy.ndarray: The adversarail sample generated by the algorithm.
""" """
assert len(image_label) == 1 assert len(image_label) == 1
pre_label = np.argmax(self.model.predict(image_label)) pre_label = np.argmax(self.model.predict(image_label))
gradient = self.model.gradient(image_label) gradient = self.model.gradient(image_label)
...@@ -41,4 +41,3 @@ class IteratorGradientSignAttack(Attack): ...@@ -41,4 +41,3 @@ class IteratorGradientSignAttack(Attack):
adv_label = np.argmax(self.model.predict([(adv_img, 0)])) adv_label = np.argmax(self.model.predict([(adv_img, 0)]))
if pre_label != adv_label: if pre_label != adv_label:
return adv_img return adv_img
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册