Skip to main content

pgd

Function pgd 

Source
pub fn pgd(
    model: &dyn AttackModel,
    loss: &dyn AttackLoss,
    input: &[f64],
    labels: &[f64],
    config: &AttackConfig,
    seed: u64,
) -> Result<AdversarialExample, AdversarialError>
Expand description

Projected Gradient Descent (Madry et al., 2017).

Iterative attack with optional random initialisation:

x₀ = x + Uniform(−ε, ε)  [if random_start]
xₜ₊₁ = Proj_{Bε(x)}( clip( xₜ + α · step_direction ) )

Step direction:

  • L∞: sign(∇_x L)
  • L2: ∇_x L / ‖∇_x L‖₂
  • L1: argmax-coordinate (greedy Frank-Wolfe step)

seed is used only when config.random_start = true.