pub struct AdversarialAttack { /* private fields */ }Expand description
Adversarial attack generator
Implementations§
Source§impl AdversarialAttack
impl AdversarialAttack
Sourcepub fn new(config: AttackConfig) -> Self
pub fn new(config: AttackConfig) -> Self
Create new adversarial attack
Sourcepub fn fgsm(&self, input: &Tensor, gradient: &Tensor) -> Result<Tensor, String>
pub fn fgsm(&self, input: &Tensor, gradient: &Tensor) -> Result<Tensor, String>
Generate adversarial example using FGSM
Sourcepub fn pgd(
&self,
input: &Tensor,
compute_gradient: impl Fn(&Tensor) -> Result<Tensor, String>,
) -> Result<Tensor, String>
pub fn pgd( &self, input: &Tensor, compute_gradient: impl Fn(&Tensor) -> Result<Tensor, String>, ) -> Result<Tensor, String>
Generate adversarial example using PGD
Auto Trait Implementations§
impl Freeze for AdversarialAttack
impl RefUnwindSafe for AdversarialAttack
impl Send for AdversarialAttack
impl Sync for AdversarialAttack
impl Unpin for AdversarialAttack
impl UnwindSafe for AdversarialAttack
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> 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