SmoothGrad: removing noise by adding noise

Daniel SmilkovNikhil ThoratBeen KimFernanda ViégasMartin Wattenberg

article2017ICML2,724 citations

Proposes SmoothGrad, a simple method that cleans up noisy gradient-based sensitivity maps by averaging the gradients of randomly perturbed inputs, producing clearer visual explanations of deep learning predictions.

Listen

The article addresses the challenge of interpreting decisions made by deep neural networks for image classification. Gradient-based sensitivity maps, which highlight influential pixels, often appear visually noisy and fail to clearly align with human-perceived meaningful regions. This limits their usefulness for debugging models or gaining insight in high-stakes domains such as health care.

The article set out to evaluate a simple technique called SmoothGrad that reduces this noise by averaging sensitivity maps computed on multiple slightly perturbed versions of the input image. It also examined the combined effects of this approach with other gradient-based methods and with adding noise during model training.

The authors conducted qualitative experiments using an Inception v3 model trained on ImageNet and a convolutional network on MNIST. They compared SmoothGrad against vanilla gradients, Integrated Gradients, and Guided Backpropagation across hundreds of images, varying noise levels and sample sizes, and assessed visual coherence and the ability to discriminate between multiple objects in a scene.

SmoothGrad produced noticeably more coherent and less noisy maps than vanilla gradients and Integrated Gradients, with the strongest improvements on images having uniform backgrounds. It also enhanced discriminativity between competing classes. Adding noise during training further sharpened maps, and the two smoothing techniques together yielded the best results. Applying SmoothGrad on top of Guided Backpropagation or Integrated Gradients improved those methods as well.

These findings indicate that much of the apparent noise in gradient maps stems from local fluctuations in the class-score function rather than from the model's actual decision process. Smoother maps can therefore give stakeholders a more reliable view of what drives classifications, supporting better model validation and refinement without requiring new architectures.

Practitioners should consider applying SmoothGrad as a post-processing step for any gradient-based explanation method and explore training with noise when map legibility is a priority. Further work is needed to develop quantitative metrics for map quality, test generalization beyond image classification, and investigate whether explicit penalties on derivative variation during training can produce even smoother explanations.

arXiv: 1706.03825PAIR-code/saliency
Cover for SmoothGrad: removing noise by adding noise

Abstract

Explaining the output of a deep network remains a challenge. In the case of an image classifier, one type of explanation is to identify pixels that strongly influence the final decision. A starting point for this strategy is the gradient of the class score function with respect to the input image. This gradient can be interpreted as a sensitivity map, and there are several techniques that elaborate on this basic idea. This paper makes two contributions: it introduces SmoothGrad, a simple method that can help visually sharpen gradient-based sensitivity maps, and it discusses lessons in the visualization of these maps. We publish the code for our experiments and a website with our results.

Table of Contents

  • 1 Introduction
  • 2 Gradients as sensitivity maps
  • 2.1 Previous work on enhancing sensitivity maps
  • 2.2 Smoothing noisy gradients
  • 3 Experiments
  • 3.1 Visualization methods and techniques
  • 3.2 Effect of noise level and sample size
  • 3.3 Qualitative comparison to baseline methods
  • 3.4 Combining SmoothGrad with other methods
  • 3.5 Adding noise during training
  • 4 Conclusion and future work
  • References

Knowls

  1. Knowl 1 — SmoothGrad Algorithm

    algorithm

    SmoothGrad computes an enhanced sensitivity map by stochastically approximating the Gaussian smoothing of a gradient-based sensitivity function in the neighborhood of an input image. Given an input image xRdx \in \mathbb{R}^d and a class score function Sc(x)S_c(x) for class cc, a base sensitivity map Mc(x)M_c(x) is typically defined as the gradient Sc(x)/x\partial S_c(x) / \partial x (or another gradient-based attribution method). SmoothGrad estimates the locally smoothed sensitivity map M^c(x)\hat{M}_c(x) via Monte Carlo sampling:

    M^c(x)=1ni=1nMc(x+N(0,σ2I))\hat{M}_c(x) = \frac{1}{n} \sum_{i=1}^n M_c\left(x + \mathcal{N}(0, \sigma^2 I)\right)

    where nn is the number of samples and σ\sigma is the noise standard deviation, typically chosen relative to the image dynamic range as a fraction σ/(xmaxxmin)\sigma / (x_{\max} - x_{\min}).

    Input: Input image xx, base sensitivity function McM_c, noise level σ\sigma, sample count nn
    Output: Smoothed sensitivity map M^c(x)\hat{M}_c(x)
    Initialize accumulator map A0A \leftarrow 0
    for i1i \leftarrow 1 to nn do
        Sample noise vector ϵN(0,σ2I)\epsilon \sim \mathcal{N}(0, \sigma^2 I) of the same dimension as xx
        Compute perturbed image x~x+ϵ\tilde{x} \leftarrow x + \epsilon
        Compute base sensitivity map MMc(x~)M \leftarrow M_c(\tilde{x})
        AA+MA \leftarrow A + M
    end for
    return M^c(x)1nA\hat{M}_c(x) \leftarrow \frac{1}{n} A
  2. Knowl 2 — Local Gradient Fluctuations as the Cause of Saliency Noise

    empirical result

    In deep neural networks with piecewise linear activation functions (such as ReLU), the class score function Sc(x)S_c(x) is not continuously differentiable, and its gradient Sc(x)/x\partial S_c(x) / \partial x fluctuates sharply at small spatial scales. When moving along a short trajectory x+tϵx + t\epsilon parameterized by t[0,1]t \in [0, 1], where ϵN(0,0.012I)\epsilon \sim \mathcal{N}(0, 0.01^2 I) is a imperceptible Gaussian noise vector such that classification remains unchanged and x+ϵx + \epsilon is indistinguishable from xx to a human, the partial derivatives Sc(x+tϵ)/xi\partial S_c(x + t\epsilon) / \partial x_i for individual pixel channels fluctuate by significant fractions of the maximum gradient entry maxiSc/xi\max_i \partial S_c / \partial x_i. Consequently, raw gradients are noisy local point samples, and a local average over a Gaussian neighborhood provides a more meaningful attribution map.

  3. Knowl 3 — Hyperparameter Calibration for Noise Scale and Sample Count in SmoothGrad

    empirical result

    SmoothGrad depends on two hyperparameters: the noise ratio σ/(xmaxxmin)\sigma / (x_{\max} - x_{\min}) (the standard deviation of Gaussian perturbations divided by the dynamic range of the input) and the sample count nn.

    • Noise level σ\sigma: Setting σ/(xmaxxmin)\sigma / (x_{\max} - x_{\min}) between 10%10\% and 20%20\% balances the removal of background noise against preserving the structural features of the underlying object on deep vision models such as Inception v3 on ImageNet. Setting noise too low retains high-frequency noise, while setting it too high degrades object contours.
    • Sample count nn: Increasing nn yields progressively smoother sensitivity maps, but visual improvements exhibit diminishing returns beyond n=50n = 50 samples.
  4. Knowl 4 — Combining SmoothGrad with Other Attribution Methods

    model/method

    SmoothGrad operates as a meta-method that can wrap any gradient-based attribution technique. When applied to Integrated Gradients or Guided Backpropagation, SmoothGrad substitutes the base attribution calculation Mc(x)M_c(x) with an ensemble average of that attribution method applied across nn noise-perturbed inputs x+N(0,σ2I)x + \mathcal{N}(0, \sigma^2 I). In both cases, this smoothing substantially reduces visual noise and sharpens object boundaries compared to using Integrated Gradients or Guided Backpropagation alone.

  5. Knowl 5 — Additive Denoising Effect of Training with Noise and SmoothGrad Inference

    empirical result

    Regularizing deep neural networks during training by adding Gaussian noise to training samples induces smoother class score functions, which inherently reduces noise in post-hoc sensitivity maps. Furthermore, training with input noise and applying inference-time smoothing via SmoothGrad have an additive effect: models trained with noise and evaluated using SmoothGrad produce the sharpest and most visually coherent sensitivity maps compared to applying either technique alone or applying neither.

  6. Knowl 6 — Class Discriminativity in Saliency Maps

    empirical result

    For images containing multiple objects belonging to distinct classes c1c_1 and c2c_2, the class discriminativity of a sensitivity map method can be evaluated by normalizing the two class maps to [0,1][0, 1] and computing their difference:

    ΔM(x)=scale(Mc1(x))scale(Mc2(x))\Delta M(x) = \text{scale}(M_{c_1}(x)) - \text{scale}(M_{c_2}(x))

    visualized on a diverging color scale [1,1][blue,gray,red][-1, 1] \mapsto [\text{blue}, \text{gray}, \text{red}]. SmoothGrad produces high visual discriminativity, assigning distinctly positive values to the regions corresponding to class c1c_1 and negative values to regions corresponding to class c2c_2. In contrast, methods such as Guided Backpropagation exhibit weak discriminativity despite producing sharp visual features.

  7. Knowl 7 — Gradient Outlier Capping in Sensitivity Heatmap Visualization

    model/method

    Raw gradient maps typically contain a small number of outlier pixels with partial derivatives significantly higher in magnitude than the mean gradient. If heatmap color scales are linearly mapped from the minimum to maximum gradient value, these extreme outliers cause the visualization to render almost entirely black. Capping gradient magnitudes at a high percentile threshold (e.g., the 99th percentile) before normalising to [0,1][0, 1] prevents scale compression and yields visually interpretable heatmaps.

  8. Knowl 8 — Dataset-Dependent Selection of Signed vs Absolute Gradient Visualizations

    model/method

    The choice between visualizing signed gradients Sc(x)/x\partial S_c(x) / \partial x or absolute gradients Sc(x)/x|\partial S_c(x) / \partial x| depends on the contrast properties of the dataset:

    • In datasets with fixed contrast polarity across classes (e.g., MNIST, where digits are uniformly white on a black background), positive gradients specifically denote supportive evidence for the target class, making signed visualizations appropriate.
    • In natural image datasets (e.g., ImageNet), visual classification is invariant to illumination and background contrast changes (e.g., a dark object on a bright background yields negative gradients, whereas a bright object on a dark background yields positive gradients). Taking the absolute value of the gradient eliminates polarity artifacts and produces clearer object attribution.
  9. Knowl 9 — Trade-offs of Gradient Multiplied by Input Visualization

    model/method

    Multiplying gradient sensitivity maps point-wise by the input image values (xMc(x)x \odot M_c(x)) produces visually sharper maps by incorporating input structure, analogous to computing feature contributions xiwix_i w_i in linear models y=Wxy = Wx. However, this multiplication has structural limitations: pixels with a value of zero are strictly mapped to zero attribution regardless of their gradient magnitude (preventing the identification of dark objects on light backgrounds), and high-contrast edges in the input image can introduce sharp visual contours into the attribution map even when the underlying sensitivity function contains no edge information.

Coverage note — None was omitted; all key contributions, algorithms, visualization lessons, empirical findings, and hypotheses from the paper are represented.

References

  1. 1.Bach, Sebastian, Binder, Alexander, Montavon, Grégoire, Klauschen, Frederick, Müller, Klaus-Robert, and Samek, Wojciech. On pixel-wise explanations for non-linear classifier decisions by layer-wise relevance propagation. PloS one, 10(7):e0130140, 2015.
  2. 2.Baehrens, David, Schroeter, Timon, Harmeling, Stefan, Kawanabe, Motoaki, Hansen, Katja, and MÞller, Klaus-Robert. How to explain individual classification decisions. Journal of Machine Learning Research, 11 (Jun):1803–1831, 2010.
  3. 3.Bishop, Chris M. Training with noise is equivalent to tikhonov regularization. Neural computation, 7(1):108–116, 1995.
  4. 4.Doshi-Velez, Finale; Kim, Been. Towards a rigorous science of interpretable machine learning. In eprint arXiv:1702.08608, 2017.
  5. 5.Doshi-Velez, Finale, Ge, Yaorong, and Kohane, Isaac. Comorbidity clusters in autism spectrum disorders: an electronic health record time-series analysis. Pediatrics, 133 (1):e54–e63, 2014.
  6. 6.Erhan, Dumitru, Bengio, Yoshua, Courville, Aaron, and Vincent, Pascal. Visualizing higher-layer features of a deep network. University of Montreal, 1341:3, 2009.
  7. 7.Freitas, Alex. Comprehensible classification models: a position paper. ACM SIGKDD Explorations, 2014.
  8. 8.Hughes, Michael C, Elibol, Huseyin Melih, McCoy, Thomas, Perlis, Roy, and Doshi-Velez, Finale. Supervised topic models for clinical interpretability. arXiv preprint arXiv:1612.01678, 2016.
  9. 9.Kim, Been, Glassman, Elena, Johnson, Brittney, and Shah, Julie. ibcm: Interactive bayesian case model empowering humans via intuitive interaction. Technical report, Massachusetts Institute of Technology, 2015.
  10. 10.LeCun, Yann, Bottou, Léon, Bengio, Yoshua, and Haffner, Patrick. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278–2324, 1998.
  11. 11.LeCun, Yann, Cortes, Corinna, and Burges, Christopher JC. Mnist handwritten digit database. AT&T Labs [Online]. Available: http://yann.lecun.com/exdb/mnist, 2, 2010.
  12. 12.Lou, Yin, Caruana, Rich, and Gehrke, Johannes. Intelligible models for classification and regression. In ACM SIGKDD international conference on Knowledge discovery and data mining. ACM, 2012.
  13. 13.Oh, Seong Joon, Benenson, Rodrigo, Khoreva, Anna, Akata, Zeynep, Fritz, Mario, and Schiele, Bernt. Exploiting saliency for object segmentation from image level labels. arXiv preprint arXiv:1701.08261, 2017.
  14. 14.Russakovsky, Olga, Deng, Jia, Su, Hao, Krause, Jonathan, Satheesh, Sanjeev, Ma, Sean, Huang, Zhiheng, Karpathy, Andrej, Khosla, Aditya, Bernstein, Michael, et al. Imagenet large scale visual recognition challenge. International Journal of Computer Vision, 115(3):211–252, 2015.
  15. 15.Selvaraju, Ramprasaath R, Das, Abhishek, Vedantam, Ramakrishna, Cogswell, Michael, Parikh, Devi, and Batra, Dhruv. Grad-cam: Why did you say that? arXiv preprint arXiv:1611.07450, 2016.
  16. 16.Shrikumar, Avanti, Greenside, Peyton, and Kundaje, Anshul. Learning important features through propagating activation differences. arXiv preprint arXiv:1704.02685, 2017.
  17. 17.Simonyan, Karen, Vedaldi, Andrea, and Zisserman, Andrew. Deep inside convolutional networks: Visualising image classification models and saliency maps. arXiv preprint arXiv:1312.6034, 2013.
  18. 18.Springenberg, Jost Tobias, Dosovitskiy, Alexey, Brox, Thomas, and Riedmiller, Martin. Striving for simplicity: The all convolutional net. arXiv preprint arXiv:1412.6806, 2014.
  19. 19.Sundararajan, Mukund, Taly, Ankur, and Yan, Qiqi. Axiomatic attribution for deep networks. arXiv preprint arXiv:1703.01365, 2017.
  20. 20.Szegedy, Christian, Zaremba, Wojciech, Sutskever, Ilya, Bruna, Joan, Erhan, Dumitru, Goodfellow, Ian, and Fergus, Rob. Intriguing properties of neural networks. arXiv preprint arXiv:1312.6199, 2013.
  21. 21.Szegedy, Christian, Vanhoucke, Vincent, Ioffe, Sergey, Shlens, Jon, and Wojna, Zbigniew. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2818–2826, 2016.
  22. 22.TensorFlow. MNIST TensorFlow tutorial. https://www.tensorflow.org/get_started/mnist/pros, 2017. [Online; accessed 9-May-2017].
  23. 23.Zeiler, Matthew D and Fergus, Rob. Visualizing and understanding convolutional networks. In European conference on computer vision, pp. 818–833. Springer, 2014.
  24. 24.Zhou, Bolei, Khosla, Aditya, Lapedriza, Agata, Oliva, Aude, and Torralba, Antonio. Learning deep features for discriminative localization. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2921–2929, 2016.
  25. 25.Zintgraf, Luisa M., Cohen, Taco S., and Welling, Max. A new method to visualize deep neural networks. CoRR, abs/1603.02518, 2016. URL http://arxiv.org/abs/1603.02518.

Citation

MLA
Smilkov, D., et al. “SmoothGrad: Removing Noise by Adding Noise”. arXiv, 2017, https://doi.org/10.48550/arxiv.1706.03825.
APA
Smilkov, D., Thorat, N., Kim, B., Viégas, F., & Wattenberg, M. (2017). SmoothGrad: removing noise by adding noise. arXiv. https://doi.org/10.48550/arxiv.1706.03825
Chicago
Smilkov, D., N. Thorat, B. Kim, F. Viégas, and M. Wattenberg. 2017. “SmoothGrad: Removing Noise by Adding Noise”. Preprint, ArXiv. https://doi.org/10.48550/arxiv.1706.03825.
Harvard
Smilkov, D. et al. (2017) “SmoothGrad: removing noise by adding noise”. arXiv. Available at: https://doi.org/10.48550/arxiv.1706.03825.
Vancouver
1. Smilkov D, Thorat N, Kim B, Viégas F, Wattenberg M (2017) SmoothGrad: removing noise by adding noise. https://doi.org/10.48550/arxiv.1706.03825

BibTeX

@misc{https://doi.org/10.48550/arxiv.1706.03825,
  doi = {10.48550/ARXIV.1706.03825},
  url = {https://arxiv.org/abs/1706.03825},
  author = {Smilkov, Daniel and Thorat, Nikhil and Kim, Been and Viégas, Fernanda and Wattenberg, Martin},
  keywords = {Machine Learning (cs.LG), Computer Vision and Pattern Recognition (cs.CV), Machine Learning (stat.ML), FOS: Computer and information sciences, FOS: Computer and information sciences},
  title = {SmoothGrad: removing noise by adding noise},
  publisher = {arXiv},
  year = {2017},
  copyright = {arXiv.org perpetual, non-exclusive license}
}
Metadata:DOI registry

Source Code

This paper has an official code repository available. Click below to access the source code.

View Repository

Access the Paper

This paper is available from its original source. Click below to access the PDF.

Open PDF

License: Published with permission