Inferensys

Glossary

Saliency Maps

A foundational visualization technique that ranks input features by computing the absolute value of the partial derivative of the model's output with respect to each input dimension.
Data engineer managing feature store on laptop, feature definitions visible, casual data engineering session.
VANILLA GRADIENT VISUALIZATION

What is Saliency Maps?

A foundational feature attribution technique that ranks input features by computing the absolute value of the partial derivative of the model's output with respect to each input dimension.

A saliency map is a visualization technique that computes the importance of each input feature by taking the absolute value of the gradient of the target class score with respect to the input pixels. This first-order Taylor expansion approximation answers: which input dimensions, if changed infinitesimally, would cause the largest change in the model's prediction?

The resulting heatmap highlights regions of maximal sensitivity but often suffers from visual noise due to shattered gradients in deep ReLU networks. While computationally efficient—requiring only a single backward pass—vanilla saliency maps violate the completeness axiom and can produce misleading attributions when gradients saturate in flat regions of the prediction function.

SALIENCY MAPS

Frequently Asked Questions

Clear, technically precise answers to the most common questions about saliency maps, gradient-based feature attribution, and their role in decoding neural network predictions.

A saliency map is a visualization technique that ranks input features by computing the absolute value of the partial derivative of the model's output with respect to each input dimension. In the context of image classification, it produces a heatmap where the intensity of each pixel corresponds to how much a small change in that pixel would affect the prediction score for the target class.

  • Mechanism: Given a trained neural network and an input x, the saliency map is computed as |∂S_c(x) / ∂x|, where S_c is the score for class c before the softmax.
  • First-order approximation: The magnitude of the gradient indicates which pixels the model is most sensitive to locally.
  • Interpretation: High-intensity regions are those where a tiny perturbation would most significantly alter the output, suggesting the model relies on those pixels for its decision.

This method, introduced by Simonyan et al. (2013), is foundational to the field of feature attribution and remains widely used due to its simplicity and computational efficiency.

GRADIENT-BASED VISUALIZATION

Key Characteristics of Saliency Maps

Saliency maps are foundational interpretability tools that compute the absolute value of the partial derivative of a model's output with respect to each input dimension, producing a heatmap that ranks pixel-level or feature-level importance for a specific prediction.

01

Vanilla Gradient Computation

The simplest form of saliency map computes the gradient of the target class score S_c with respect to the input image I using a single backward pass. For an input with dimensions W × H × C, the saliency map M is defined as:

M = |∂S_c / ∂I|

  • The absolute value ensures both positive and negative influences are visualized
  • For RGB images, the maximum absolute gradient across color channels is typically taken
  • This method satisfies the sensitivity axiom: a feature receiving a zero attribution must not affect the prediction
  • Computationally efficient, requiring only one forward and one backward pass
1 backward pass
Computational Cost
02

Noise and Visual Coherence Limitations

Raw saliency maps often appear noisy and visually fragmented due to shattered gradients—rapid local fluctuations in the gradient signal caused by the piecewise-linear nature of ReLU networks. Key issues include:

  • Gradient saturation: When the prediction score is near 1.0, gradients in saturated regions approach zero, falsely indicating low importance
  • High-frequency noise: Small adversarial perturbations in the input can dramatically alter the gradient landscape without changing the prediction
  • Lack of spatial coherence: Individual pixel gradients do not capture the importance of contiguous regions or higher-level features

These limitations motivated the development of refined methods like SmoothGrad and Integrated Gradients.

03

Class Discriminative Property

Saliency maps are inherently class-discriminative: they highlight only the input features that contribute to the specific predicted class, not all salient objects in the image. This distinguishes them from class-agnostic methods.

  • For an image containing both a cat and a dog, the saliency map for class "cat" highlights feline features while suppressing canine regions
  • This property is critical for debugging misclassifications: the map reveals which spurious features the model latched onto
  • Contrast with activation-based methods like CAM, which may highlight all discriminative regions regardless of the target class
  • The gradient is computed with respect to the logit (pre-softmax) score, not the probability, to avoid gradient saturation from the softmax function
04

Implementation Invariance Failure

A critical theoretical limitation: vanilla saliency maps violate the implementation invariance axiom. Two functionally identical networks with different parameterizations can produce different attribution maps for the same input.

  • A network f(x) and a reparameterized version f'(x) that compute identical outputs for all inputs may yield different gradients at specific points
  • This occurs because the gradient operator is sensitive to the specific computational path, even when the function is mathematically equivalent
  • Integrated Gradients was explicitly designed to satisfy implementation invariance by accumulating gradients along a path
  • This failure mode is particularly problematic when comparing attributions across different model architectures or training runs
05

Relationship to Deconvolution and Guided Backpropagation

Saliency maps are closely related to but distinct from DeconvNet and Guided Backpropagation visualizations. The key difference lies in how gradients are handled at ReLU nonlinearities during the backward pass:

  • Vanilla Saliency: Standard backpropagation through ReLU, passing gradients only where the forward activation was positive
  • DeconvNet: Uses a deconvolutional network that applies ReLU to the gradient signal itself, zeroing out negative gradients regardless of forward activations
  • Guided Backpropagation: Combines both conditions—only backpropagates positive gradients at locations where the forward activation was also positive

Guided Backpropagation produces sharper visualizations but is not class-discriminative and can reconstruct patterns even from randomly initialized networks.

06

Evaluation via Perturbation Sanity Checks

The faithfulness of saliency maps is evaluated using perturbation-based metrics that measure how model predictions change when important pixels are modified:

  • Deletion Metric: Remove pixels in descending order of importance and measure the area under the probability curve—a steep drop indicates a faithful map
  • Insertion Metric: Incrementally reveal pixels from most to least important into a blurred baseline—a rapid rise indicates quality
  • Randomization Sanity Check: Randomizing model weights should produce entirely different saliency maps; if the map remains similar, the method is independent of model parameters and invalid
  • Cascade Randomization: Randomizing weights layer by layer from top to bottom should cause progressive degradation of the saliency map quality
ATTRIBUTION METHOD COMPARISON

Saliency Maps vs. Other Attribution Methods

A technical comparison of foundational feature attribution techniques based on their computational mechanism, axiomatic properties, and output characteristics.

FeatureSaliency MapsIntegrated GradientsLIME

Core Mechanism

Absolute value of output gradient w.r.t. input

Path integral of gradients from baseline to input

Local surrogate model trained on perturbed samples

Satisfies Completeness

Satisfies Sensitivity

Satisfies Implementation Invariance

Requires Baseline Input

Computational Cost

Single backward pass

50-300 backward passes

N perturbed forward passes

Visual Noise Level

High (raw gradient noise)

Low (smoothed accumulation)

Medium (segmentation-dependent)

Model Agnostic

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.