AdversarialTraining<T, TInput, TOutput>

Models & Types · AiDotNet.AdversarialRobustness.Defenses

Implements adversarial training as a defense mechanism.

Implements: IAdversarialDefense<T, TInput, TOutput>

For Beginners

Adversarial training is like vaccinating your model. Just as vaccines expose your immune system to weakened pathogens so it learns to fight them, adversarial training exposes your model to adversarial examples during training so it learns to resist them. This is one of the most effective defenses against adversarial attacks.

How It Works

Adversarial training augments the training data with adversarial examples, teaching the model to correctly classify both clean and adversarial inputs.

Constructors

Constructor Summary
AdversarialTraining(AdversarialDefenseOptions<T> options) Initializes a new instance of adversarial training that generates its training examples with AttackMethod.
AdversarialTraining(AdversarialDefenseOptions<T> options, IAdversarialAttack<T, TInput, TOutput> trainingAttack) Initializes a new instance of adversarial training that generates its training examples with a custom attack.

Methods

Method Summary
AdversarialDefenseOptions<T> GetOptions()
IFullModel<T, TInput, TOutput> ApplyDefense(TInput[] trainingData, TOutput[] labels, IFullModel<T, TInput, TOutput> model) Adversarially trains model (or an ensemble of copies of it) and wraps the result with the configured preprocessing defense.
RobustnessMetrics<T> EvaluateRobustness(IFullModel<T, TInput, TOutput> model, TInput[] testData, TOutput[] labels, IAdversarialAttack<T, TInput, TOutput> attack)
TInput PreprocessInput(TInput input)
byte[] Serialize()
void Deserialize(byte[] data)
void LoadModel(string filePath)
void Reset()
void SaveModel(string filePath)