# 积分梯度

积分梯度（Integrated Gradients）是一种归因方法，它通过沿从基线输入到实际输入的直线路径对模型输入梯度进行积分，来解释机器学习预测，并为每个特征产生重要性得分。它回答的是关于一个已训练模型的局部问题：相对于一个被认为缺少该特征的参考输入，这个特定输入的哪些部分应对这个特定输出负责。该方法无需修改网络，只需调用标准梯度算子若干次。<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup> 它是一种针对可微模型的局部、特定于模型的技术。<sup>[2](https://www.nature.com/articles/s41598-025-25839-y)</sup>

| 关键事实 | 详情 |
|---|---|
| 定义 | 从基线 \( x' \) 到输入 \( x \) 的梯度路径积分，按 \( x_i - x'_i \) 缩放<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup> |
| 完备性 | 各归因值之和等于 \( F(x) - F(x') \)，即从基线到输入的输出差<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup> |
| 典型步数 | 20 到 300 个黎曼和步可将积分近似到 5% 以内<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup>；在一项 InceptionV3 研究中，超过约 32 步后，单步得分提升已很有限<sup>[3](https://arxiv.org/html/2409.09043v1)</sup> |
| 默认基线 | 视觉任务用黑色图像，文本任务用全零嵌入；库默认使用零<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup><sup> • </sup><sup>[4](https://captum.ai/docs/extension/integrated%5Fgradients)</sup> |
| 起源 | 孙达拉拉詹（Sundararajan）、塔利（Taly）和严琪琪（Yan），《深度网络的公理化归因》，2017<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup> |
| 已知失效模式 | 饱和效应、基线盲区、可视化噪声、基线依赖<sup>[5](https://arxiv.org/pdf/2010.12697v1.pdf)</sup><sup> • </sup><sup>[6](https://openreview.net/pdf?id=Ivku4TZgEly)</sup> |
| 工具 | Captum（PyTorch）、Alibi（TensorFlow/Keras），以及一个官方 TensorFlow 仓库<sup>[4](https://captum.ai/docs/extension/integrated%5Fgradients)</sup><sup> • </sup><sup>[7](https://github.com/SeldonIO/alibi/blob/master/doc/source/methods/IntegratedGradients.ipynb)</sup><sup> • </sup><sup>[8](https://github.com/ankurtaly/Integrated-Gradients/)</sup> |

## 工作原理

对于一个表示网络的函数 \( F \)、一个基线（参考输入）\( x' \) 和一个输入 \( x \)，对特征 \( i \) 的归因是梯度沿从 \( x' \) 到 \( x \) 的直线的路径积分：<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup>

\[ \mathrm{IG}_i(x) = (x_i - x'_i) \cdot \int_{0}^{1} \frac{\partial F(x' + \alpha \cdot (x - x'))}{\partial x_i} \, d\alpha \]

路径上的每个点都是基线与输入之间的线性插值，模型输出的梯度会在沿路径的多个点上计算。<sup>[2](https://www.nature.com/articles/s41598-025-25839-y)</sup>

该方法的核心保证是完备性公理：各归因值之和等于输入处输出与基线处输出之差 \( F(x) - F(x') \)，符号表示每个特征是增加还是减少了输出。这由路径积分的微积分基本定理推出。<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup> 完备性还蕴含敏感性(a)：若输入与基线恰好只在一个特征上不同，则该差异应成为该特征的归因。积分梯度满足实现不变性，因为归因只取决于网络所表示函数的梯度，而不取决于网络内部如何实现。<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup>

原论文还借助一项归功于弗里德曼（Friedman，2004）的定理，声称路径方法具有唯一性：路径方法是唯一始终满足实现不变性、敏感性(b)、线性和完备性的归因方法。<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup> 这一唯一性主张此后受到质疑：伦德斯特伦（Lundstrom）、黄（Huang）和拉扎维扬（Razaviyayn）（2022）以及勒尔马（Lerma）和卢卡斯（Lucas）（2021）给出了反例。用不同的公理可以严格地重新建立这一唯一性结果：路径方法由线性、完备性、哑元和非递减正性刻画。<sup>[9](https://www.jmlr.org/papers/volume26/23-0671/23-0671.pdf)</sup>

## 具体做法

积分通过含 \( m \) 项的[黎曼和](https://www.edgepedia.org/zh/riemann-sum)来近似：<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup>

\[ \mathrm{IG\_approx}_i(x) = (x_i - x'_i) \cdot \sum_{k=1}^{m} \frac{\partial F(x' + \frac{k}{m} \cdot (x - x'))}{\partial x_i} \cdot \frac{1}{m} \]

在 [TensorFlow](https://www.edgepedia.org/zh/tensorflow) 中，这相当于对路径点 \( x' + \frac{k}{m} \cdot (x - x') \) 循环调用 `tf.gradients`，其中 \( k = 1, \ldots, m \)，并且这些调用可以批量化。<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup> 原论文作者发现，大约 20 到 300 步足以将积分近似到 5% 以内，并建议检查各归因值是否大致加总为得分差；若不能，则增大 \( m \)。<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup>

Captum 的 `IntegratedGradients.attribute` 默认返回输入归因；当传入 `return_convergence_delta=True` 时，还会返回根据完备性性质计算出的收敛差。它支持 `riemann_right`、`riemann_left`、`riemann_middle`、`riemann_trapezoid` 和 `gausslegendre` 近似；高斯-勒让德近似速度最快，且为默认方法，`n_steps` 控制速度与精度之间的权衡。<sup>[4](https://captum.ai/docs/extension/integrated%5Fgradients)</sup> Alibi 为 TensorFlow/Keras 模型实现了相同的近似方法，带有 `n_steps` 和 `internal_batch_size` 参数，并且可以针对内部层（例如文本模型的嵌入层）计算归因。<sup>[7](https://github.com/SeldonIO/alibi/blob/master/doc/source/methods/IntegratedGradients.ipynb)</sup>

基线表示某个特征的缺失。对于图像网络，原论文推荐使用黑色图像；对于文本网络，全零输入嵌入向量效果很好，因为训练会把不重要的词推向较小的范数。<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup> 当未提供基线时，Captum 使用零作为默认基线值。<sup>[4](https://captum.ai/docs/extension/integrated%5Fgradients)</sup> 其他常用基线包括逐分量均值、输入范围中点、均匀噪声、模糊化，以及最大距离动态基线。<sup>[6](https://openreview.net/pdf?id=Ivku4TZgEly)</sup>

基线选择对归因结果有重大影响；对表格模型和图像分类归因的综述发现，并不存在表现最好的基线。<sup>[6](https://openreview.net/pdf?id=Ivku4TZgEly)</sup> Alibi 的文档给出了一个具体警告：对于昼夜分类器，黑色图像基线会产生误导，因为所有暗像素都会得到零归因，而它们很可能对任务很重要。<sup>[7](https://github.com/SeldonIO/alibi/blob/master/doc/source/methods/IntegratedGradients.ipynb)</sup> 常量基线还会导致基线盲区：如果输入在某个特征上与基线相同，则 \( x_i - x'_i \) 项消失，即使该特征对预测至关重要，也不会被归因。<sup>[6](https://openreview.net/pdf?id=Ivku4TZgEly)</sup>

## 起源

积分梯度由穆昆德·孙达拉拉詹（Mukund Sundararajan）、安库尔·塔利（Ankur Taly）和严琪琪（Qiqi Yan）在《深度网络的公理化归因》（Axiomatic Attribution for Deep Networks）中提出，该文于 2017 年发表在 arXiv 上。<sup>[10](https://doi.org/10.48550/arxiv.1703.01365)</sup> 该方法是将奥曼-沙普利（Aumann-Shapley）成本分摊方法应用于机器学习归因场景。<sup>[9](https://www.jmlr.org/papers/volume26/23-0671/23-0671.pdf)</sup> 它针对的是作者认为在公理上存在缺陷的早期归因方法：DeepLIFT（什里库马尔（Shrikumar）、格林赛德（Greenside）和昆达杰（Kundaje），2017）、[逐层相关性传播](https://www.edgepedia.org/zh/layer-wise-relevance-propagation)、反卷积网络和引导反向传播。反卷积网络和引导反向传播违反敏感性(a)，而 DeepLIFT、LRP、DeconvNets 和引导反向传播各自至少破坏敏感性与实现不变性这两条公理中的一条。<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup><sup> • </sup><sup>[11](https://doi.org/10.48550/arxiv.1704.02685)</sup>

## 变体

若干具名变体修改了路径、被积函数或后处理：

- **分裂积分梯度**（Split Integrated Gradients，米格拉尼（Miglani）、科赫利基扬（Kokhlikyan）、阿尔萨拉赫（Alsallakh）、马丁（Martin）和雷布利茨-理查森（Reblitz-Richardson），2020）将积分分为输出显著增长的非饱和区域和饱和区域；在 ImageNet 模型上，与使用 200 个黎曼和步的标准 IG 相比，它在 ABPC 指标上表现出更好的保真度，且对小输入扰动更不敏感。<sup>[5](https://arxiv.org/pdf/2010.12697v1.pdf)</sup>
- **期望梯度**（Expected Gradients，埃里昂（Erion）、贾尼泽克（Janizek）、施图姆费尔斯（Sturmfels）、伦德伯格（Lundberg）和李（Lee），2021，《自然·机器智能》）从训练分布中抽取基线值，对 IG 取期望，使用[蒙特卡洛积分](https://www.edgepedia.org/zh/monte-carlo-integration)而非等间距插值点。<sup>[12](https://doi.org/10.1038/s42256-021-00343-w)</sup><sup> • </sup><sup>[6](https://openreview.net/pdf?id=Ivku4TZgEly)</sup>
- **模糊积分梯度**（Blur Integrated Gradients）使用去模糊路径而非直线。<sup>[9](https://www.jmlr.org/papers/volume26/23-0671/23-0671.pdf)</sup>
- **传导**（Conductance）扩展被积函数，以便归因到内部神经元而非输入。<sup>[9](https://www.jmlr.org/papers/volume26/23-0671/23-0671.pdf)</sup>
- **XRAI**（卡皮什尼科夫（Kapishnikov）、博卢克巴西（Bolukbasi）、维埃加斯（Viégas）和特里（Terry），2019）将 IG 与图像分割结合，以归因图像区域而非像素。<sup>[13](https://doi.org/10.48550/arxiv.1906.02825)</sup>
- **广义积分梯度**（Generalized Integrated Gradients，梅里尔（Merrill）、沃德（Ward）、卡姆卡尔（Kamkar）、布齐克（Budzik）和梅里尔（Merrill），2019）将 IG 扩展到某些不连续函数类，用于金融服务等领域的模型。<sup>[14](https://doi.org/10.48550/arxiv.1909.01869)</sup>
- **IDGI**（杨（Yang）、王（Wang）和比尔吉奇（Bilgic），2023）是一个框架，它通过将每个路径点沿重要方向投影到等函数值超平面上，从数学上消除积分中对归因贡献噪声的成分。<sup>[15](https://doi.org/10.48550/arxiv.2303.14242)</sup>
- **积分决策梯度**（Integrated Decision Gradients，沃克（Walker）、贾（Jha）、陈（Chen）和埃韦茨（Ewetz），2023）用输出 logit（模型在最终 softmax 之前的原始输出分数）对路径的导数来缩放每个梯度，将归因集中在 logit 快速转变的位置，并使用自适应非均匀采样来减少黎曼和误差。<sup>[16](https://doi.org/10.48550/arxiv.2305.20052)</sup><sup> • </sup><sup>[17](https://ojs.aaai.org/index.php/AAAI/article/view/28336)</sup>
- **流形积分梯度**（Manifold Integrated Gradients，扎赫尔（Zaher）、恰斯科夫斯基（Trzaskowski）、阮（Nguyen）和鲁斯塔（Roosta），2024）利用深度生成模型，使归因路径与黎曼数据流形的测地线对齐，以解决可视化噪声和对对抗性归因攻击的脆弱性。<sup>[18](https://doi.org/10.48550/arxiv.2405.09800)</sup>

## 应用

原论文将 IG 应用于图像模型（ImageNet 上的 GoogleNet）、一个使用 100 到 1000 步的基于 LSTM 的神经机器翻译系统，以及一个化学模型。<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup> 随后在 ACL 2018 上发表的一篇论文《模型理解问题了吗？》（Did the model understand the questions?），由穆德拉卡尔塔（Mudrakarta）、塔利、孙达拉拉詹和达姆德雷（Dhamdhere）撰写，将该方法应用于问答网络。<sup>[8](https://github.com/ankurtaly/Integrated-Gradients/)</sup> 一位作者的演讲报告称，该方法在 Google 被 20 多个产品团队和 3 个机器学习框架使用。<sup>[19](http://theory.stanford.edu/~ataly/Talks/berkeley_ig_talk_feb_2019.pdf)</sup>

## 局限与替代方法

**饱和**是一种有文献记录的失效模式。路径中模型输出变化极小的饱和区域内的梯度，可能主导计算出的归因；对于 Inception-v3 ImageNet 模型，目标类 logit 仅在 \( \alpha \in [0, 0.33] \) 时显著上升，此后几乎保持不变。在 softmax 输出上计算 IG 时，当输出接近 1 会削弱饱和区域梯度，而当输出接近较小值时则会放大这些梯度，因此建议用户可视化沿路径的输出和梯度。<sup>[5](https://arxiv.org/pdf/2010.12697v1.pdf)</sup> 其他局限包括：需要精心选择有意义的基线；模型必须可微；计算成本高于简单梯度方法；归因在视觉上存在噪声。<sup>[20](https://alan-turing-institute.github.io/tea-techniques/techniques/integrated-gradients/)</sup>

在公理符合性方面，[SmoothGrad](https://www.edgepedia.org/zh/smoothgrad)（斯米尔科夫（Smilkov）、托拉特（Thorat）、金（Kim）、维埃加斯（Viégas）和瓦滕伯格（Wattenberg），2017）和 SHAP（伦德伯格（Lundberg）和李（Lee），2017）满足实现不变性，而 DeepLIFT 和 LRP 不满足。<sup>[9](https://www.jmlr.org/papers/volume26/23-0671/23-0671.pdf)</sup><sup> • </sup><sup>[21](https://doi.org/10.48550/arxiv.1706.03825)</sup> 在成本方面，IG 需要 20 到 300 次梯度调用，而对于 100 × 100 的图像（\( n = 10000 \) 个特征），基于沙普利的归因将需要 \( n! \) 条路径，每条采样路径需要 \( n \) 次调用。<sup>[1](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)</sup>

## References

1. [Axiomatic Attribution for Deep Networks (Sundararajan, Taly, Yan; ICML 2017, PMLR v70; arXiv:1703.01365)](https://proceedings.mlr.press/v70/sundararajan17a/sundararajan17a.pdf)
2. [A comparative evaluation of explainability techniques for image data | Scientific Reports (2025)](https://www.nature.com/articles/s41598-025-25839-y)
3. [Strengthening Interpretability: An Investigative Study of Integrated Gradient Methods (arXiv, 2024)](https://arxiv.org/html/2409.09043v1)
4. [Integrated Gradients · Captum documentation](https://captum.ai/docs/extension/integrated%5Fgradients)
5. [Investigating Saturation Effects in Integrated Gradients (Miglani et al., ICML WHI 2020 workshop)](https://arxiv.org/pdf/2010.12697v1.pdf)
6. [Exploring Unfairness in Integrated Gradients Based Attribution Methods (OpenReview)](https://openreview.net/pdf?id=Ivku4TZgEly)
7. [Alibi documentation: IntegratedGradients](https://github.com/SeldonIO/alibi/blob/master/doc/source/methods/IntegratedGradients.ipynb)
8. [ankurtaly/Integrated-Gradients (official code repository by author Ankur Taly)](https://github.com/ankurtaly/Integrated-Gradients/)
9. [Four Axiomatic Characterizations of the Integrated Gradients Attribution Method (JMLR vol. 26)](https://www.jmlr.org/papers/volume26/23-0671/23-0671.pdf)
10. [Sundararajan, Mukund, Taly, Ankur, Yan, Qiqi (2017). Axiomatic Attribution for Deep Networks. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1703.01365)
11. [Shrikumar, Avanti, Greenside, Peyton, Kundaje, Anshul (2017). Learning Important Features Through Propagating Activation Differences. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1704.02685)
12. [Gabriel Erion and colleagues (2021). Improving performance of deep learning models with axiomatic attribution priors and expected gradients. Nature Machine Intelligence.](https://doi.org/10.1038/s42256-021-00343-w)
13. [Kapishnikov, Andrei and colleagues (2019). XRAI: Better Attributions Through Regions. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1906.02825)
14. [Merrill, John and colleagues (2019). Generalized Integrated Gradients: A practical method for explaining diverse ensembles. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1909.01869)
15. [Yang, Ruo, Wang, Binghui, Bilgic, Mustafa (2023). IDGI: A Framework to Eliminate Explanation Noise from Integrated Gradients. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2303.14242)
16. [Walker, Chase and colleagues (2023). Integrated Decision Gradients: Compute Your Attributions Where the Model Makes Its Decision. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2305.20052)
17. [Integrated Decision Gradients: Compute Your Attributions Where the Model Makes Its Decision (AAAI 2024)](https://ojs.aaai.org/index.php/AAAI/article/view/28336)
18. [Zaher, Eslam and colleagues (2024). Manifold Integrated Gradients: Riemannian Geometry for Feature Attribution. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2405.09800)
19. [Analyzing Deep Neural Networks (Berkeley talk by Ankur Taly, Feb 2019)](http://theory.stanford.edu/~ataly/Talks/berkeley_ig_talk_feb_2019.pdf)
20. [Integrated Gradients - TEA Techniques (Alan Turing Institute)](https://alan-turing-institute.github.io/tea-techniques/techniques/integrated-gradients/)
21. [Smilkov, Daniel and colleagues (2017). SmoothGrad: removing noise by adding noise. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1706.03825)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › 机器学习与神经计算 › 神经网络与深度学习 › 标题：I至Z

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/integrated-gradients

English original: https://www.edgepedia.org/integrated-gradients
