Integrated Gradients
A single gradient snapshot at the input can be misleadingly flat even for features that clearly matter; integrated gradients instead accumulates sensitivity all along the path from a neutral baseline to the actual input.
Prerequisites: Saliency Maps and Raw Gradient Attribution, Choosing the Baseline in Feature Attribution
Explaining a network's prediction by looking at the gradient at the actual input point can be badly misleading whenever the network has saturated — the gradient at a specific point tells you how the output would change with an infinitesimal nudge right there, but a feature that saturated a neuron long before reaching its current value can show a near-zero gradient even though changing that feature substantially would clearly change the output. Integrated gradients fixes this by not trusting a single snapshot at all — it walks a straight path from a neutral baseline input to the actual input, and accumulates sensitivity all along the way.
The analogy: crediting the whole climb, not just the last step
Imagine measuring how much a hiker's satisfaction improved during a climb by only checking their rate of enjoyment gain at the exact summit — if they had already plateaued in mood just before reaching the top (the last few steps added almost nothing new), that final measurement would suggest the whole climb barely mattered, even though the climb from the trailhead clearly did. A fairer measure adds up how much satisfaction changed at every single step of the climb, from the trailhead (a neutral starting point) all the way to the summit (the actual endpoint). Integrated gradients does exactly this for a feature: instead of reading the gradient only at the actual input, it sums the gradient along the entire straight-line path from a baseline (often all zeros, or an average input) to the input in question.
The formula, piece by piece
Here is the baseline value of feature (the neutral starting point), and is the total distance travelled for that feature. The integral walks a parameter from 0 (at the baseline) to 1 (at the actual input), evaluating the gradient of the model's output with respect to feature at every intermediate point along that straight line, and averaging those gradients. In plain English: rather than trusting the gradient's value only right at the destination, integrated gradients checks the gradient at many points along the entire journey there and adds up the contribution earned at each step — so a feature whose gradient was large early in the journey but flattened out near the end still gets proper credit.
Worked example 1: verifying completeness on
Take , baseline , input . The exact integral: . Approximating with 4 discrete steps at : gradients are , , , ; averaging gives , times gives — already in the right neighborhood with only 4 steps, converging to the exact value 9 as more steps are used. Crucially, exactly — this "completeness" property (attributions sum to the actual output difference) is guaranteed by construction, never approximately true by luck.
Worked example 2: catching a saturated feature saliency misses
A sigmoid-based network is deeply saturated at the actual input, giving a raw gradient there of essentially — plain saliency would report this feature as nearly irrelevant. Walking the path from baseline to in 4 steps at , the gradients (of a logistic function ) are roughly — large near the start of the path, where the sigmoid was still in its steep region, and small only near the end. Averaging these four gradients, , times the path length , gives an integrated gradient of about — a meaningfully nonzero attribution that the single end-point gradient completely missed.
Drag the input here and watch the slope flatten near the extremes — a raw gradient taken only at a saturated point looks tiny, but integrated gradients credits the steep slope the path passed through earlier.
Integrated gradients attributes a prediction to each feature by accumulating the gradient along the straight-line path from a neutral baseline to the actual input, not just at the input itself. This avoids the blind spot of plain gradient attribution at saturated points, and guarantees attributions sum exactly to the difference between the model's output at the input and at the baseline.
What this means in practice
Integrated gradients is the standard choice for explaining deep networks with smooth, differentiable architectures — image classifiers, embedding-based ranking models, deep trading signal networks — anywhere plain saliency risks reporting "no importance" for features the model actually relies on heavily but happens to be locally saturated with respect to.
The common mistake is treating the baseline as an arbitrary implementation detail rather than a modeling choice that changes the answer. Attributions are always relative to the chosen baseline — a black-image baseline versus a blurred-image baseline for the same input can produce meaningfully different feature attributions, because "how much credit feature gets" is inherently a comparison to "what if this feature were at the baseline instead," and different baselines represent different counterfactual questions.
Related concepts
Practice in interviews
Further reading
- Sundararajan, Taly & Yan, Axiomatic Attribution for Deep Networks (2017)