pub struct SaliencyMap { /* private fields */ }Expand description
Saliency Maps for neural network visualization.
Computes gradients of the output with respect to input features, showing which parts of the input most affect the prediction.
§Method
Uses numerical gradient estimation via finite differences:
saliency_i = ∂f/∂x_i ≈ (f(x + ε*e_i) - f(x - ε*e_i)) / (2ε)§Reference
- Simonyan, K., et al. (2014). Deep Inside Convolutional Networks: Visualising Image Classification Models and Saliency Maps.
Implementations§
Source§impl SaliencyMap
impl SaliencyMap
Sourcepub fn with_epsilon(epsilon: f32) -> Self
pub fn with_epsilon(epsilon: f32) -> Self
Create with custom epsilon.
Sourcepub fn compute_absolute<F>(
&self,
model_fn: F,
sample: &Vector<f32>,
) -> Vector<f32>
pub fn compute_absolute<F>( &self, model_fn: F, sample: &Vector<f32>, ) -> Vector<f32>
Compute absolute saliency (magnitude of gradient).
Useful for visualizing which features matter, regardless of direction.
Sourcepub fn smooth_grad<F>(
&self,
model_fn: F,
sample: &Vector<f32>,
n_samples: usize,
noise_level: f32,
) -> Vector<f32>
pub fn smooth_grad<F>( &self, model_fn: F, sample: &Vector<f32>, n_samples: usize, noise_level: f32, ) -> Vector<f32>
Compute smooth gradient by averaging over noisy samples.
SmoothGrad reduces noise in saliency maps by averaging gradients
over multiple noisy versions of the input.
§Reference
- Smilkov, D., et al. (2017).
SmoothGrad: removing noise by adding noise.
Trait Implementations§
Source§impl Clone for SaliencyMap
impl Clone for SaliencyMap
Source§fn clone(&self) -> SaliencyMap
fn clone(&self) -> SaliencyMap
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 moreSource§impl Debug for SaliencyMap
impl Debug for SaliencyMap
Auto Trait Implementations§
impl Freeze for SaliencyMap
impl RefUnwindSafe for SaliencyMap
impl Send for SaliencyMap
impl Sync for SaliencyMap
impl Unpin for SaliencyMap
impl UnwindSafe for SaliencyMap
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