Table of Contents

Class AdversarialDefenseOptions<T>

Namespace
AiDotNet.Models.Options
Assembly
AiDotNet.dll

Configuration options for adversarial defense mechanisms.

public class AdversarialDefenseOptions<T>

Type Parameters

T

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

Inheritance
AdversarialDefenseOptions<T>
Inherited Members

Remarks

These options control how models are defended against adversarial attacks through training procedures, preprocessing, and ensemble methods.

For Beginners: These settings control how your "armor" protects the AI model. You can adjust how the defense is applied, how strong it should be, and what techniques to use.

Properties

AdversarialRatio

Gets or sets the ratio of adversarial examples to include in training.

public double AdversarialRatio { get; set; }

Property Value

double

The adversarial ratio, defaulting to 0.5.

Remarks

For Beginners: When training, this controls what percentage of examples should be adversarial. 0.5 means 50% clean and 50% adversarial, providing a balance between robustness and normal accuracy.

AttackMethod

Gets or sets the attack method to use during adversarial training.

public string AttackMethod { get; set; }

Property Value

string

The attack method name, defaulting to "PGD".

Remarks

For Beginners: This determines what type of attacks to train against. PGD is a strong iterative attack that provides good robustness when used for training.

EnsembleSize

Gets or sets the number of models in the ensemble.

public int EnsembleSize { get; set; }

Property Value

int

The ensemble size, defaulting to 3.

Epsilon

Gets or sets the perturbation budget for adversarial training.

public double Epsilon { get; set; }

Property Value

double

The epsilon value, defaulting to 0.1.

Remarks

For Beginners: This is how strong the adversarial examples during training are. Training on stronger attacks makes the model more robust but might reduce clean accuracy.

PreprocessingMethod

Gets or sets the preprocessing method to use.

public string PreprocessingMethod { get; set; }

Property Value

string

The preprocessing method name, defaulting to "JPEG".

Remarks

For Beginners: Different preprocessing methods work better for different types of data. JPEG compression, for example, can remove small adversarial changes from images.

TrainingEpochs

Gets or sets the number of training epochs.

public int TrainingEpochs { get; set; }

Property Value

int

The number of epochs, defaulting to 100.

Remarks

For Beginners: An epoch is one complete pass through all training data. More epochs allow the model to learn better defenses but take longer.

UseEnsemble

Gets or sets whether to use ensemble defenses.

public bool UseEnsemble { get; set; }

Property Value

bool

True to use ensembles, false otherwise (default: false).

Remarks

For Beginners: Ensemble defenses use multiple models to make predictions. It's harder to fool all models at once, making the system more robust.

UsePreprocessing

Gets or sets whether to use input preprocessing for defense.

public bool UsePreprocessing { get; set; }

Property Value

bool

True to use preprocessing, false otherwise (default: true).

Remarks

For Beginners: Preprocessing cleans up inputs before they reach the model, potentially removing adversarial perturbations.