Estimating Example Difficulty using Variance of Gradients

Chirag Agarwal, Sara Hooker

Abstract

In machine learning, a question of great interest is understanding what examples are challenging for a model to classify. Identifying atypical examples ensures the safe deployment of models, isolates samples that require further human inspection, and provides interpretability into model behavior. In this work, we propose Variance of Gradients (VoG) as a valuable and efficient metric to rank data by difficulty and to surface a tractable subset of the most challenging examples for human-in-the-loop auditing. We show that data points with high VoG scores are far more difficult for the model to learn and over-index on corrupted or memorized examples. Further, restricting the evaluation to the test set instances with the lowest VoG improves the model's generalization performance. Finally, we show that VoG is a valuable and efficient ranking for out-of-distribution detection.

Introduction

Deep learning models are often viewed as "black boxes," making it difficult to discern why they succeed on certain inputs while failing on others. As datasets scale to millions of samples, manual auditing by human experts to identify edge cases or labeling errors becomes computationally and logistically prohibitive. Existing methods for ranking "example difficulty" often require training thousands of model replications or rely on static saliency maps that offer only a snapshot of a trained model's focus. There is a pressing need for a scalable, unsupervised metric that can surface the most challenging or atypical samples—those that might require memorization rather than general learning—to help practitioners prioritize auditing efforts.

Methodology: Variance of Gradients (VoG)

The core premise of Variance of Gradients (VoG) is that "hard" examples cause a model's internal representation to fluctuate significantly during the learning process, whereas "easy" examples are learned quickly and remain stable. The calculation of VoG is straightforward and model-agnostic:

  1. Compute Gradients: For a given input, calculate the gradient of the pre-softmax activation with respect to the input pixels.
  2. Utilize Checkpoints: Compute these gradients across several checkpoints saved during training (e.g., every 10 epochs).
  3. Calculate Variance: For each pixel, compute the variance of its gradient values across these checkpoints.
  4. Aggregate and Normalize: Average the pixel-wise variances to produce a single scalar score, then normalize by the class mean and standard deviation to account for inherent differences in class difficulty.

Visualization on toy datasets confirms that samples closer to the decision boundary exhibit higher VoG scores, linking geometric proximity to the metric. This method is highly efficient, requiring only vanilla gradients from a small number of existing training checkpoints.

Semantic Interpretability and Training Dynamics

VoG scores provide significant semantic insight into data difficulty. Images with low VoG scores tend to be "prototypical"—objects are centered, backgrounds are clean, and the vantage point is standard. Conversely, high VoG scores often highlight images with heavy clutter, atypical angles, or partial occlusions.

Semantic visualization of VoG scores across training stages for CIFAR-10 and CIFAR-100.

The interpretation of VoG changes depending on the training stage. In early training, high VoG indicates "easy" samples that the model is actively learning. In late training, high VoG indicates "hard" samples that the model is struggling to fit or is being forced to memorize. This makes VoG a powerful tool for identifying samples that require memorization, such as those with corrupted labels.

Experimental Results

The researchers validated VoG across standard benchmarks including CIFAR-10, CIFAR-100, and ImageNet.

Generalization and Error Analysis

A key finding is that a model’s generalization performance improves when evaluation is restricted to the lowest VoG (easiest) test instances. This confirms that VoG successfully captures the "noise" or "difficulty" that leads to misclassification. Quantitative analysis shows that the top-1 test set error increases significantly as the VoG percentile range increases across different datasets.

Test set error increases with higher VoG percentile ranges across CIFAR-10, CIFAR-100, and ImageNet.

Out-of-Distribution Detection

VoG serves as a valuable ranking for out-of-distribution (OoD) detection, outperforming established methods like PCA and KDE. On the MNIST-C benchmark, VoG achieved an AUROC of 85.42. Furthermore, the ranking is remarkably stable; across five independently trained ResNet-18 networks, the distribution of error by VoG percentile remained consistent with minimal deviation.

Efficiency

While some difficulty metrics require tens of thousands of model runs, VoG rankings remain robust using as few as three checkpoints from a single training run, making it a highly practical tool for large-scale applications.

Discussion and Future Work

While VoG is more efficient than ensemble-based methods, it still incurs computational overhead due to the need for multiple checkpoints and backpropagation for every image. Future work could explore expanding VoG to other domains such as Natural Language Processing (NLP) or Reinforcement Learning. Additionally, VoG presents a promising selection criterion for active learning, identifying which unlabeled samples would be most beneficial for human labeling to improve model robustness.

Summary updated

BibTeX
@inproceedings{agarwal2020estimating,
  author = {Chirag Agarwal and Sara Hooker},
  title = {{Estimating Example Difficulty using Variance of Gradients}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2020},
  url = {https://openreview.net/forum?id=TdMY1hwdYf},
}
Figure