pub struct AttackConfig {
pub epsilon: f64,
pub norm: PerturbNorm,
pub n_steps: usize,
pub step_size: f64,
pub random_start: bool,
pub clip_min: f64,
pub clip_max: f64,
}Expand description
Configuration for an adversarial attack.
Fields§
§epsilon: f64Maximum allowed perturbation magnitude (ε > 0).
norm: PerturbNormNorm used to constrain the perturbation.
n_steps: usizeNumber of iterative steps (used by PGD; FGSM uses 1).
step_size: f64Per-step size α. Defaults to epsilon / 4.0.
random_start: boolIf true (PGD), initialise with a random perturbation inside the ε-ball.
clip_min: f64Minimum allowed value for the perturbed input.
clip_max: f64Maximum allowed value for the perturbed input.
Implementations§
Source§impl AttackConfig
impl AttackConfig
Sourcepub fn new(epsilon: f64) -> Result<Self, AdversarialError>
pub fn new(epsilon: f64) -> Result<Self, AdversarialError>
Create a new config with epsilon as the perturbation budget.
Defaults: L∞ norm, 40 PGD steps, step_size = ε/4, no random start, no input clipping.
Sourcepub fn with_norm(self, norm: PerturbNorm) -> Self
pub fn with_norm(self, norm: PerturbNorm) -> Self
Override the perturbation norm.
Sourcepub fn with_steps(self, n: usize) -> Result<Self, AdversarialError>
pub fn with_steps(self, n: usize) -> Result<Self, AdversarialError>
Override the number of PGD steps. Must be ≥ 1.
Sourcepub fn with_step_size(self, s: f64) -> Result<Self, AdversarialError>
pub fn with_step_size(self, s: f64) -> Result<Self, AdversarialError>
Override the per-step size. Must be strictly positive.
Sourcepub fn with_random_start(self, b: bool) -> Self
pub fn with_random_start(self, b: bool) -> Self
Enable or disable random initialisation of the perturbation.
Trait Implementations§
Source§impl Clone for AttackConfig
impl Clone for AttackConfig
Source§fn clone(&self) -> AttackConfig
fn clone(&self) -> AttackConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AttackConfig
impl RefUnwindSafe for AttackConfig
impl Send for AttackConfig
impl Sync for AttackConfig
impl Unpin for AttackConfig
impl UnsafeUnpin for AttackConfig
impl UnwindSafe for AttackConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more