Closed WandernForte closed 1 year ago
i've solve it by self.
class TargetedMisclassificationML(Criterion):
"""Considers those perturbed inputs adversarial whose predicted class
matches the target classes. Multi-Label
Args:
target_classes: Tensor with target classes ``(batch,)``.
"""
def __init__(self, target_classes: Any):
super().__init__()
self.target_classes: ep.Tensor = ep.astensor(target_classes)
_, self.restore_type = ep.astensor_(target_classes)
def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.target_classes!r})"
def __call__(self, perturbed: T, outputs: T) -> T:
outputs_, restore_type = ep.astensor_(outputs)
del perturbed, outputs
classes = torch.tensor(torch.round(torch.sigmoid(self.restore_type(outputs_).to(device))).detach().numpy().tolist()).to(device)
classes = ep.astensor(classes)
assert classes.shape == self.target_classes.shape
is_adv = classes == self.target_classes
return restore_type(is_adv)
i'm trying to modify foolbox like following,
will u support sigmoid function in the future? and how to implement sigmoid with eagerpy now?