NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

A Theoretical Analysis of the Number of Shots in Few-Shot Learning

Tianshi Cao, Marc Law, Sanja Fidler

TL;DR

This paper provides a theoretical foundation for why few-shot learning models, specifically Prototypical Networks, suffer when the number of training "shots" (examples per class) doesn't match the number used at test time. The authors introduce Embedding Space Transformation (EST), a simple yet effective linear transformation that makes a single trained model robust to varying shot numbers during deployment.

What Problem Does This Paper Address?

In few-shot classification, a model is trained to recognize new categories using only a handful of labeled examples ($k$ shots). Current state-of-the-art methods use "episodic training," where the model practices on many small tasks. However, there is a catch: a model trained on 5-shot tasks often performs poorly when asked to do 1-shot classification, and vice versa. This "meta-overfitting" to the shot number is a major hurdle for real-world deployment, where the number of available examples for a new task is often unpredictable.

The authors set out to answer two questions:

  1. Why does this performance degradation happen?
  2. How can we build a model that works well across different shot numbers without training multiple versions?

Methods

The authors approach the problem through both theoretical analysis and a practical algorithmic solution:

  1. Theoretical Analysis: Using Chebyshev’s inequality and VC-dimension theory, they derive a lower bound for the expected accuracy of Prototypical Networks (ProtoNets). They show that the number of shots ($k$) acts as a scaling factor for intra-class variance (noise).
  2. Embedding Space Transformation (EST): Based on their theory, they propose a post-training step. Instead of just using the raw embeddings from a deep network, they apply a linear transformation $V^*$ calculated from the entire training set. This transformation is designed to maximize the ratio of inter-class variance (the "signal" that separates classes) to intra-class variance (the "noise" within a class). While similar to Linear Discriminant Analysis (LDA), EST is specifically tailored to improve the performance bounds identified in their theoretical work and is more stable in few-shot scenarios.

Datasets

The researchers evaluated their approach on three standard few-shot learning benchmarks:

  • Omniglot: A dataset of handwritten characters from 50 different alphabets.
  • miniImageNet: A subset of the larger ImageNet dataset, commonly used to benchmark few-shot algorithms on natural images.
  • tieredImageNet: A larger, more challenging subset of ImageNet that groups classes into broader categories to ensure a larger domain gap between training and testing.

Key Insights and Ideas

  • The Signal-to-Noise Trade-off: The paper reveals that training with a small $k$ (e.g., 1-shot) forces the model to be extremely good at minimizing intra-class variance (noise reduction). Conversely, training with a large $k$ allows the model to focus more on maximizing the distance between class means (signal maximization).
  • Intrinsic Dimension Matters: The authors found that the "intrinsic dimension" of the learned embedding space—the actual number of coordinates needed to represent the data effectively—increases as the number of training shots increases.
  • Variance ratios decrease as training shots increase, showing the model's changing sensitivity to noise vs signal.
  • The intrinsic dimension of the embedding space grows with the number of training shots.
  • Mismatched Shots as a Scaling Issue: When you train on 10-shot but test on 1-shot, the high intra-class variance the model "tolerated" during training is suddenly amplified by the small $k$ at test time, leading to a performance crash.
Variance ratios decrease as training shots increase, showing the model's changing sensitivity to noise vs signal.
The intrinsic dimension of the embedding space grows with the number of training shots.

Key Results

The proposed EST method significantly mitigates the "shot mismatch" problem.

  • Robustness: On miniImageNet, a vanilla ProtoNet trained on 5-shot tasks drops significantly in accuracy when tested on 1-shot tasks. The EST-enhanced version maintains much higher performance, often outperforming models specifically trained for that shot number.
  • Versatility: A single EST-ProtoNet model trained at $k=5$ provides near-optimal performance across the entire range of 1 to 10 shots, eliminating the need to store multiple models for different deployment scenarios.
  • Theoretical Validation: The authors' derived lower bound for accuracy closely tracks actual empirical performance, suggesting their mathematical model of ProtoNets is highly accurate.
  • Comparison showing the theoretical lower bound (left) closely matches empirical accuracy (right).
Comparison showing the theoretical lower bound (left) closely matches empirical accuracy (right).

Limitations and Future Work

  • Linearity: EST is a linear transformation. While effective, the authors note that non-linear transformations might offer even better alignment, though they would be more complex to compute.
  • Dependence on Training Statistics: EST requires calculating means and covariances over the entire training set after the main training phase is complete.
  • Future Directions: The authors suggest that this approach could be combined with other few-shot extensions (like task-conditioned embeddings) to further push the boundaries of robust meta-learning.

Summary updated

BibTeX
@inproceedings{cao2020theoretical,
  author = {Tianshi Cao and Marc Law and Sanja Fidler},
  title = {{A Theoretical Analysis of the Number of Shots in Few-Shot Learning}},
  booktitle = {International Conference on Learning Representations},
  year = {2020},
}
Figure