CWAttack<T, TInput, TOutput>

Models & Types · AiDotNet.AdversarialRobustness.Attacks

Implements the Carlini and Wagner (C and W) attack.

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

For Beginners

C and W is one of the most sophisticated attacks. Instead of following gradients, it treats creating adversarial examples as a carefully crafted optimization problem. It’s slower than FGSM or PGD but often finds adversarial examples that are more subtle and harder to defend against.

How It Works

C and W is an optimization-based attack that formulates adversarial example generation as an optimization problem, typically producing stronger attacks than gradient-based methods.

Original paper: “Towards Evaluating the Robustness of Neural Networks” by Carlini and Wagner (2017)

Constructors

Constructor Summary
CWAttack(AdversarialAttackOptions<T> options) Initializes a new instance of the C and W attack.

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 C and W L2 attack.