提交 cfd8a73e 编写于 作者: lyz_sea's avatar lyz_sea

modify the method that judege zero mask

上级 1a62ee33
......@@ -57,7 +57,7 @@ class SaliencyMapAttack(Attack):
return adversary
# stop if mask is all zero
if self._is_zero_mask(mask):
if not any(mask):
return adversary
# get pixel location with highest influence on class
......@@ -82,21 +82,6 @@ class SaliencyMapAttack(Attack):
return adversary
def _is_zero_mask(self, mask):
"""
The elements in mask are all zero or not.
Args:
mask(list): Each modified pixel with border value is set to zero in mask.
Return: bool
"""
is_all_zero = True
for item in mask:
if item != 0:
is_all_zero = False
break
return is_all_zero
def _saliency_map(self, image, target, labels, mask, fast=False):
"""
Get pixel location with highest influence on class.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册