FORGrad¶
_{ } View colab tutorial  _{ } View source  ðŸ“° Paper
ForGrad is an enhancement for any attribution method by effectively filtering out highfrequency noise in gradientbased attribution maps, resulting in improved explainability scores and promoting the adoption of more computationally efficient techniques for model interpretability.
Quote
The application of an optimal lowpass filter to attribution maps improves gradientbased attribution methods significantly, resulting in higher explainability scores across multiple models and elevating gradientbased methods to a top ranking among stateoftheart techniques, sparking renewed interest in simpler and more computationally efficient explainability approaches.
 Gradient strikes back: How filtering out high frequencies improves explanations (2023)^{1}
In a more precise manner, to obtain an attribution map \(\varphi_\sigma(x)\), we apply a filter \(w_\sigma\) with a cutoff value \(\sigma\) to remove high frequencies, as shown in the equation:
The parameter \(\sigma\) controls the amount of frequencies retained and ranges between \((0, W]\), where \(W\) represents the dimension of the squared image. A value of \(0\) eliminates all frequencies, while \(W\) retains all frequencies. The paper presents a method to estimate the optimal cutoff, and for ImageNet images, the recommended default value for the optimal sigma is typically around 15.
Example¶
from xplique.attributions import Saliency
from xplique.common import forgrad
# load images, labels and model
# ...
method = Saliency(model)
explanations = method.explain(images, labels)
explanations_filtered = forgrad(explanations, sigma=15)
Notebooks¶
forgrad(explanations: tf.Tensor,
sigma: int = 15) > tf.Tensor
¶
sigma: int = 15) > tf.Tensor
ForGRAD is a method that enhances any attributions explanations (particularly useful on
gradients based attribution method) by eliminating high frequencies in the explanations.
Parameters

explanations : tf.Tensor
List of explanations to filter. Explanation should be at least 3D (batch, height, width) and should have the same height and width.

sigma : int = 15
Bandwith of the low pass filter. The higher the sigma, the more frequencies are kept.
Sigma should be positive and less than image size.
Default to paper recommendation, 15 for image size 224.
Return

filtered_explanations : tf.Tensor
Explanations lowpass filtered.