Skip to content

amazon-science/uniform-episodic-sampling

Uniform Sampling over Episode Difficulty

This repository contains the code for the paper:

Sébastien M. R. Arnold*, Guneet S. Dhillon*, Avinash Ravichandran, Stefano Soatto
Uniform Sampling over Episode Difficulty (pdf)

* Equal contributions

Abstract

Episodic training is a core ingredient of few-shot learning to train models on tasks with limited labelled data. Despite its success, episodic training remains largely understudied, prompting us to ask the question: what is the best way to sample episodes? In this paper, we first propose a method to approximate episode sampling distributions based on their difficulty. Building on this method, we perform an extensive analysis and find that sampling uniformly over episode difficulty outperforms other sampling schemes, including curriculum and easy-/hard-mining. As the proposed sampling method is algorithm agnostic, we can leverage these insights to improve few-shot learning accuracies across many episodic training algorithms. We demonstrate the efficacy of our method across popular few-shot learning datasets, algorithms, network architectures, and protocols.

Citation

If you use this code for your research, please cite our paper:

@inproceedings{arnold2021uniform,
    author = {Arnold, S\'{e}bastien M R and Dhillon, Guneet S and Ravichandran, Avinash and Soatto, Stefano},
    booktitle = {Advances in Neural Information Processing Systems},
    editor = {M. Ranzato and A. Beygelzimer and Y. Dauphin and P.S. Liang and J. Wortman Vaughan},
    pages = {1481--1493},
    publisher = {Curran Associates, Inc.},
    title = {Uniform Sampling over Episode Difficulty},
    url = {https://proceedings.neurips.cc/paper/2021/file/0b3f44d9054402de39441e165a4bdfe0-Paper.pdf},
    volume = {34},
    year = {2021}
}

Usage

The training script takes the following arguments:

  • dataset : the dataset
    • options - 'mini-imagenet', 'tiered-imagenet'
  • model : the network architecture
    • options - 'cnn4', 'resnet12'
  • algorithm : the few-shot algorithm
    • options - 'proto', 'cosine_proto', 'maml', 'anil'
  • sampler : the episodic sampler
    • options - 'regular', 'offline_easy', 'offline_hard', 'offline_curriculum', 'offline_uniform', 'online_uniform'
  • ways : the number of ways (few-shot classes)
    • default - 5
  • support shots : the number of support shots (labeled train examples per class)
  • query shots : the number of query shots (unlabeled test examples per class)
    • default - 15
  • params path : the path to the parameter file (used only for offline episodic samplers)

Examples:

  • To train a conv(64)4 Protoypical Network on Mini-ImageNet, with a way of 5, support shot of 1 and query shot of 15, using online uniform sampling, run
python train.py --dataset 'mini-imagenet' --model 'cnn4' --algorithm 'proto' --sampler 'online_uniform' --ways 5 --support_shots 1 --query_shots 15

License

This project is licensed under the Apache-2.0 License.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages