Skip to main content

AttackModel

Trait AttackModel 

Source
pub trait AttackModel: Send + Sync {
    // Required method
    fn forward(&self, input: &[f64]) -> Vec<f64>;

    // Provided method
    fn input_gradient(&self, input: &[f64], output_grad: &[f64]) -> Vec<f64> { ... }
}
Expand description

A model that can be attacked.

Implementors provide a forward pass; input_gradient has a default finite- difference implementation that can be overridden for efficiency.

Required Methods§

Source

fn forward(&self, input: &[f64]) -> Vec<f64>

Forward pass: given an input slice, return predictions (logits or probs).

Provided Methods§

Source

fn input_gradient(&self, input: &[f64], output_grad: &[f64]) -> Vec<f64>

Gradient of the scalar output_grad · forward(input) w.r.t. input, via reverse-mode chain rule if available, otherwise via finite differences.

output_grad has the same length as forward(input).

Implementors§