Riemann Sum Optimization for Accurate Integrated Gradients Computation
Swadesh Swain, Shree Singhi
TL;DR
RiemannOpt tackles noise and computational cost in gradient-based attributions by precomputing model-specific optimal sampling points for Riemann-sum integration along attribution paths. By deriving a 1D upper bound on left-Riemann-sum error $|R-I| \lesssim \tfrac{1}{2} \sum_i |g'(\alpha_i)|(\alpha_{i+1}-\alpha_i)^2$ and generalizing to multi-dimensional line integrals, it selects a small set of optimal sampling positions $\{\alpha_i\}$ using a subset of images and Powell's method, then applies these points across the full dataset. The method enhances IG, BlurIG, and Guided IG attributions, achieving up to a $20\%$ improvement in Insertion Scores and up to a $4\times$ reduction in computation, with particularly strong gains for BlurIG. It also demonstrates that the optimal sampling points generalize across images, enabling practical deployment in real-time or resource-constrained settings. Future work includes extending the approach to additional adaptive-path attribution methods and exploring augmentation-driven shifts in optimal sampling.
Abstract
Integrated Gradients (IG) is a widely used algorithm for attributing the outputs of a deep neural network to its input features. Due to the absence of closed-form integrals for deep learning models, inaccurate Riemann Sum approximations are used to calculate IG. This often introduces undesirable errors in the form of high levels of noise, leading to false insights in the model's decision-making process. We introduce a framework, RiemannOpt, that minimizes these errors by optimizing the sample point selection for the Riemann Sum. Our algorithm is highly versatile and applicable to IG as well as its derivatives like Blur IG and Guided IG. RiemannOpt achieves up to 20% improvement in Insertion Scores. Additionally, it enables its users to curtail computational costs by up to four folds, thereby making it highly functional for constrained environments.
