def is_adversarial(self, predictions, label): """Decides if predictions for an image are adversarial.""" top1 = np.argmax(predictions) probabilities = softmax(predictions) return (np.max(probabilities) >= self.threshold) and (top1 != label)
def is_adversarial(self, predictions, label): """Decides if predictions for an image are adversarial.""" probabilities = softmax(predictions) return probabilities[self.target_class()] > self.p