# perceptron.utils.criteria¶

Provides class to wrap all adversarial criterions so that attacks has uniform API access.

 Misclassification Defines adversarials as images for which the predicted class is not the original class. ConfidentMisclassification Defines adversarials as images for which the probability of any class other than the original is above a given threshold. TopKMisclassification Defines adversarials as images for which the original class is not one of the top k predicted classes. TargetClass Defines adversarials as images for which the predicted class is the given target class. OriginalClassProbability Defines adversarials as images for which the probability of original class is below a given threshold. TargetClassProbability Defines adversarials as images for which the probability of a given target class is above a given threshold. MisclassificationAntiPorn Defines adversarials as image for which the probability of being normal is larger than the probability of being porn. MisclassificationSafeSearch Defines adversarials as image for which the probability of being unsafe is lower than a threshold. TargetClassMiss Defines adversarials as images for which the target class is not in the detection result. TargetClassMissGoogle Defines adversarials as images for which the target class is not in the Google object detection result. WeightedAP Defines adversarials as weighted AP value larger than given threshold.

## Detailed description¶

class perceptron.utils.criteria.Criterion[source]

Base class for criteria that define what is adversarial.

The Criterion class represents a criterion used to determine if predictions for an image are adversarial given a reference label. It shoud be subclassed when implementing new criteria. Subclasses must implement is_adversarial.

is_adversarial(self, predictions, ground_truth)[source]

Decides if predictions for an image are adversarial given a reference ground truth.

name(self)[source]

class perceptron.utils.criteria.CombinedCriteria(*criteria)[source]

Meta criterion that combines several criteria into a new one.

Parameters: *criteria : variable length list of Criterion instances List of sub-criteria that will be combined.

Notes

This class uses lazy evaluation of the criteria in the order they are passed to the constructor.

is_adversarial(self, predictions, ground_truth)[source]

Decides if predictions for an image are adversarial given a reference ground truth.

name(self)[source]

Concatenates the names of the given criteria in alphabetical order.