// else 100 * compute_success(self.classifier, x, y, adv_x_best, self.targeted, batch_size=self.batch_size),
// )
return adv_x.cpu().detach().numpy()
def _compute_perturbation(self, batch, batch_labels):
// Pick a small scalar to avoid division by 0
tol = 10e-8
After Change
mask = kwargs.get("mask")
if mask is not None:
// Ensure the mask is broadcastable
if len(mask.shape) > len(x.shape) or mask.shape != x.shape[-len(mask.shape):]:
raise ValueError("Mask shape must be broadcastable to input shape.")
adv_x_best = None