Skip to main content
QUICK REVIEW

[Paper Review] Efficient Per-Example Gradient Computations

Ian Goodfellow|arXiv (Cornell University)|Oct 7, 2015
Stochastic Gradient Optimization TechniquesComputer Science1 references32 citations
TL;DR

This paper proposes an efficient method to compute the L² norm of the per-example gradient for each sample in a minibatch during neural network training. By reusing standard backpropagation computations and applying a matrix-based formula involving squared activations and gradients, the method reduces computational cost from doubling to negligible overhead, enabling practical importance sampling and gradient-based analysis.

ABSTRACT

This technical report describes an efficient technique for computing the norm of the gradient of the loss function for a neural network with respect to its parameters. This gradient norm can be computed efficiently for every example.

Motivation & Objective

  • To enable efficient computation of the L² norm of the gradient with respect to model parameters for each individual example in a minibatch.
  • To address the inefficiency of naively running backpropagation m times for m examples in a minibatch.
  • To support applications such as importance sampling, where examples with higher gradient norms are prioritized during training.
  • To minimize additional computational cost beyond standard backpropagation, especially for large models and minibatches.

Proposed method

  • Reuses the standard backpropagation computation of ∇Z C, where Z represents the pre-activation values across layers.
  • Introduces a formula: s_j^(i) = (Σ_k (Z̄_j,k^(i))²) × (Σ_k (H_j,k^(i-1))²), where Z̄ is the gradient of the total loss with respect to Z, and H^(i-1) is the activation from the previous layer.
  • Computes the per-example gradient norm as √(Σ_i s_j^(i)), enabling efficient gradient magnitude analysis per example.
  • Applies the method in a single forward and backward pass over the full minibatch, avoiding repeated backpropagation runs.
  • Extends the method to allow gradient norm constraints by modifying Z̄ values and re-running the final backpropagation step.
  • Uses matrix representations H^(i) and Z^(i) to efficiently compute per-example norms across all examples simultaneously.

Experimental results

Research questions

  • RQ1Can the L² norm of the per-example gradient be computed efficiently without running backpropagation m times for m examples in a minibatch?
  • RQ2What is the computational overhead of computing per-example gradient norms compared to standard backpropagation?
  • RQ3How can gradient norms be used to improve training efficiency through importance sampling?
  • RQ4Can gradient norm constraints be applied per example while maintaining computational efficiency?
  • RQ5What is the impact of minibatch parallelism on the performance of per-example gradient computation?

Key findings

  • The proposed method computes per-example gradient norms using only O(mnp) additional operations beyond standard backpropagation, which is asymptotically negligible.
  • The method reuses the backpropagation computation of ∇Z C, avoiding the need to recompute gradients for each example separately.
  • The naive approach of running backpropagation m times with minibatch size 1 incurs roughly double the computational cost, making it impractical for large-scale training.
  • Due to the inefficiency of small-batch backpropagation, the performance gap between the naive and proposed methods is significantly larger in practice than asymptotic analysis suggests.
  • The method enables practical implementation of importance sampling by efficiently identifying examples with high gradient norms.
  • The framework supports post-processing modifications to gradient norms, such as normalization, by updating Z̄ and re-running the final backpropagation step.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.