AutoAttack<T, TInput, TOutput>

Models & Types · AiDotNet.AdversarialRobustness.Attacks

Implements AutoAttack, the parameter-free attack ensemble of Croce and Hein (2020).

Inheritance: AdversarialAttackBase<T, TInput, TOutput> → AutoAttack<T, TInput, TOutput>

For Beginners

AutoAttack is like having multiple expert attackers work together. Each attacker tries in turn; as soon as one of them fools the model, that adversarial example is returned. If your model resists all of them, it is genuinely robust.

How It Works

The standard version runs APGD-CE (auto-PGD on the cross-entropy loss), APGD-T (targeted auto-PGD on the DLR loss, over the top 9 target classes), FAB-T (targeted fast adaptive boundary attack) and the Square attack (5000 queries). The plus version runs APGD-CE and APGD-DLR with 5 restarts, FAB with 5 restarts, Square, APGD-T and FAB-T. The attacks run in that order, and each one only attacks an input that every earlier attack failed on: an input is robust only if every attack fails (worst case over attacks), as in the reference implementation (fra31/auto-attack).

AutoAttack is an untargeted evaluation: its targeted members only use target classes to search for any misclassification, and inputs the model already misclassifies are returned unchanged. With IsTargeted set, it runs its targeted members (APGD-T, then FAB-T) against TargetClass only, an attack succeeds when the model predicts that class, and inputs already predicted as it are returned unchanged. UseRandomStart chooses whether APGD starts from a random point of the ball (the reference default) or from the clean input. The step size is APGD’s own (2 epsilon, halved adaptively), so StepSize is not used. For inputs without spatial layout (vectors), the Square attack uses intervals covering the same fraction of the input instead of squares.

Constructors

Constructor Summary
AutoAttack(AdversarialAttackOptions<T> options) Initializes a new instance of AutoAttack.

Methods

Method Summary
TInput CalculatePerturbation(TInput original, TInput adversarial)
TInput GenerateAdversarialExample(TInput input, TOutput trueLabel, IFullModel<T, TInput, TOutput> targetModel) Generates an adversarial example using the AutoAttack ensemble.