Table of Contents

Class AdversarialAttackOptions<T>

Namespace
AiDotNet.Models.Options
Assembly
AiDotNet.dll

Configuration options for adversarial attack algorithms.

public class AdversarialAttackOptions<T>

Type Parameters

T

The numeric data type used for calculations (e.g., float, double).

Inheritance
AdversarialAttackOptions<T>
Inherited Members

Remarks

These options control how adversarial examples are generated, including the strength of perturbations, attack iterations, and norm constraints.

For Beginners: These settings control how the "stress test" for your AI works. You can adjust how strong the attacks are, how many attempts they make to fool your model, and what type of changes they're allowed to make to inputs.

Properties

Epsilon

Gets or sets the maximum perturbation budget (epsilon).

public double Epsilon { get; set; }

Property Value

double

The epsilon value, defaulting to 0.1.

Remarks

For Beginners: Epsilon controls how much the attack can change the input. For images, 0.1 means changing pixel values by up to 10%. Smaller values make attacks harder to detect but less powerful, while larger values make attacks more effective but easier to notice.

IsTargeted

Gets or sets whether to use targeted or untargeted attacks.

public bool IsTargeted { get; set; }

Property Value

bool

True for targeted attacks, false for untargeted (default).

Remarks

For Beginners: - Untargeted: Just try to make the model wrong (easier) - Targeted: Try to make the model predict a specific wrong class (harder)

Iterations

Gets or sets the number of iterations for iterative attacks.

public int Iterations { get; set; }

Property Value

int

The number of iterations, defaulting to 40.

Remarks

For Beginners: This is how many attempts the attack makes to fool the model. More iterations generally create stronger attacks but take longer to compute.

NormType

Gets or sets the norm type for perturbation constraints.

public string NormType { get; set; }

Property Value

string

The norm type, defaulting to "L-infinity".

Remarks

For Beginners: This defines what "small change" means: - L-infinity: No single value changes by more than epsilon - L2: The total change size is limited by epsilon - L1: The sum of all changes is limited by epsilon

RandomSeed

Gets or sets the random seed for reproducibility.

public int RandomSeed { get; set; }

Property Value

int

The random seed, defaulting to 42.

StepSize

Gets or sets the step size for iterative attacks.

public double StepSize { get; set; }

Property Value

double

The step size, defaulting to 0.01.

Remarks

For Beginners: For iterative attacks (like PGD), this controls how big each step is when searching for adversarial examples. Smaller steps are more precise but take more iterations, while larger steps are faster but might miss good attacks.

TargetClass

Gets or sets the target class for targeted attacks.

public int TargetClass { get; set; }

Property Value

int

The target class index, defaulting to 0.

Remarks

For Beginners: If using targeted attacks, this is the class you want to trick the model into predicting.

UseRandomStart

Gets or sets whether to use random initialization.

public bool UseRandomStart { get; set; }

Property Value

bool

True to use random initialization (default), false otherwise.

Remarks

For Beginners: Starting from a random point within the allowed budget can make attacks stronger by exploring different starting positions.