← Explainer Library

Interactive Explainer

Saliency, Side by Side

Which pixels does your classifier actually use? Four attribution methods (vanilla gradient, SmoothGrad, Integrated Gradients, Grad-CAM) computed live on the same image. Where they agree, where they disagree, and the known reasons each one can lie.

Prelude

The 'why' question

A classifier outputs "tumor present, p = 0.92" on a scan. The right next question is why. Saliency methods produce a per-pixel "importance" map answering "which pixels of the input most influenced this prediction?". They are useful, sometimes deeply misleading, and almost always worth running before publishing a model or deploying it.

The catch. Saliency does not equal evidence. The same prediction can be supported by very different maps. Saliency-shapley experiments (Adebayo et al., 2018) show some methods pass their sanity tests on randomised models — meaning the map looked like the original even when the classifier was random. Use saliency to generate hypotheses, not to confirm them.
Step 1

The four methods

For Integrated Gradients, $x^\prime$ is the baseline (often a black image). The integral guarantees completeness: $\sum_i \mathrm{IG}_i = f_c(x) - f_c(x^\prime)$ — every unit of the prediction is attributed to some pixel. No gradient method without an integration path has this property.

Step 1½

Axioms — why we should care about them

Sundararajan, Taly, Yan (2017) introduced an axiomatic frame for evaluating attribution methods. The four key axioms:

The axioms uniquely pick out the path-integrated gradient when you also require Shapley-style symmetry. That's why Integrated Gradients (and its Shapley relatives, like Expected Gradients) are the academically-correct choice when you can afford them.

Step 2

Live, on a synthetic image

Below: a hand-crafted small CNN (just 1 conv + global mean + linear head, with manually-chosen weights) classifies a synthetic "thermal" image. Toggle the image and watch the four saliency maps respond. The hot regions in the image are the ground-truth signal; a faithful method should focus its attribution there.

input + class score
vanilla gradient
SmoothGrad (n=20, σ=0.15)
Integrated Gradients (steps=30)
Grad-CAM
ground truth
Step 3

The traps

Final takeaway. Always show a saliency map next to the prediction in paper figures. Use IG with a domain-meaningful baseline + Grad-CAM together — they fail in different ways and their disagreement is informative.
Step 4

Beyond gradient-based: perturbation methods

Gradient methods answer "if I changed this pixel infinitesimally, how would the prediction change?". A perturbation method asks the stronger, causal question: "if I removed this pixel entirely, how would the prediction change?". Three families:

Step 5

Sanity checks you should always run

Step 6

Saliency for vision transformers

ViTs don't have convolutional feature maps, so Grad-CAM doesn't apply directly. Three replacements:

Step 7

Reading list