FGSMAttack<T, TInput, TOutput>

Models & Types · AiDotNet.AdversarialRobustness.Attacks

Implements the Fast Gradient Sign Method (FGSM) attack.

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

For Beginners

FGSM is like finding the steepest hill and taking one big step in that direction. It’s fast but might not be as powerful as multi-step attacks like PGD. Think of it as the “quick and dirty” attack - it’s not the strongest, but it’s very efficient.

How It Works

FGSM is a simple yet effective white-box adversarial attack that uses the gradient of the loss function to create adversarial examples in a single step.

Original paper: “Explaining and Harnessing Adversarial Examples” by Goodfellow et al. (2014)

Constructors

Constructor Summary
FGSMAttack(AdversarialAttackOptions<T> options) Initializes a new instance of the FGSM 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 FGSM attack.