This NeurIPS 2021 paper explores a fundamental but often ignored question in few-shot learning: does the way we pick training tasks (episodes) matter? The authors find that it matters significantly, and the best strategy is surprisingly simple: sampling tasks uniformly across the difficulty spectrum.
The Problem with Random Sampling
Few-shot learning (FSL) aims to train models capable of learning new concepts from just a handful of examples. The standard approach is episodic training, where a model is trained on thousands of mini-tasks (episodes) sampled from a large base dataset.
In traditional deep learning, data sampling strategies like "hard negative mining" or "curriculum learning" are common. However, in FSL, researchers almost always sample episodes uniformly at random. This paper asks whether the difficulty of a task affects how well a model learns to generalize, and if there is a better way to sample these episodes.
Defining and Reshaping Episode Difficulty
The authors first define episode difficulty as the negative log-likelihood (the loss) incurred on a specific task. They make a key empirical discovery: when tasks are sampled randomly, their difficulty naturally follows a Normal distribution. Most tasks are of average difficulty, while very easy or very hard tasks are rare.
To test different sampling strategies, the researchers use Importance Sampling (IS). This technique allows them to "reshape" the natural normal distribution into a target distribution by re-weighting the loss of each episode. They compared four distinct strategies:
- HARD: Focus only on the most difficult tasks.
- EASY: Focus only on the easiest tasks.
- CURRICULUM: Start with easy tasks and gradually increase difficulty.
- UNIFORM: Ensure the model sees an equal number of easy, medium, and hard tasks.
Crucially, they developed an "Online" version of this method. Instead of requiring a pre-trained model to judge difficulty, the system estimates the mean and variance of task difficulty on-the-fly using an exponential moving average. This makes the method a "plug-and-play" addition for almost any FSL algorithm.
Key Insights: Universality and the Power of Uniformity
One of the most striking findings is that difficulty is universal. Episode difficulty is largely independent of the specific algorithm (e.g., ProtoNet vs. MAML) or the model architecture. If a task is hard for one model, it is highly likely to be hard for all of them.
In many machine learning domains, "hard mining" (focusing on what the model gets wrong) is the gold standard. However, the authors found that Uniform sampling performed best for few-shot learning. They argue that Uniform sampling acts as a powerful regularizer. By forcing the model to perform well across the entire difficulty spectrum, it prevents the model from over-optimizing for "average" cases, leading to much better performance on unseen test tasks.
Empirical Results
The researchers evaluated their method on standard few-shot benchmarks (Mini-ImageNet, Tiered-ImageNet) and cross-domain datasets (CUB-200, DTD, FGVC Aircrafts, VGG Flowers). The results were highly compelling:
- Consistent Gains: UNIFORM sampling outperformed or matched the baseline in 19 out of 24 tested scenarios.
- Accuracy Boost: Compared to standard random sampling, UNIFORM sampling boosted accuracy by as much as 8.74%, with an average improvement of 3.86%.
- Cross-Domain Success: The method was particularly effective when generalizing to completely different types of images, winning in 49 out of 64 cross-domain scenarios.
- Algorithm Agnostic: The method improved performance for a wide range of popular algorithms, including ProtoNet, MAML, ANIL, and FEAT.
Limitations and Future Work
While the empirical results are strong, the study focused exclusively on image classification. It remains to be seen if uniform difficulty sampling provides similar benefits in few-shot regression or reinforcement learning. Furthermore, while Uniform acts as a great "uninformative prior," knowing the specific distribution of the test tasks might allow for an even more specialized sampling distribution. Finally, a more formal theoretical proof explaining why Uniform outperforms Hard-mining in the context of meta-learning remains a valuable next step for the community.
Summary updated