This repository contains accompanying code for the article introducing Meta-Dataset, arxiv.org/abs/1903.03096.
This code is provided here in order to give more details on the implementation of the data-providing pipeline, our back-bones and models, as well as the experimental setting.
See below for user instructions, including how to:
See this introduction notebook for a demonstration of how to sample data from the pipeline (episodes or batches).
In order to run the experiments described in the first version of the arXiv article, arxiv.org/abs/1903.03096v1, please use the instructions, code, and configuration files at version arxiv_v1 of this repository.
We are currently working on updating the instructions, code, and configuration files to reproduce the results in the second version of the article, arxiv.org/abs/1903.03096v2. You can follow the progess in branch arxiv_v2_dev of this repository.
This is not an officially supported Google product.
Meta-Dataset: A Dataset of Datasets for Learning to Learn from Few Examples
Eleni Triantafillou, Tyler Zhu, Vincent Dumoulin, Pascal Lamblin, Utku Evci, Kelvin Xu, Ross Goroshin, Carles Gelada, Kevin Swersky, Pierre-Antoine Manzagol, Hugo Larochelle
Few-shot classification refers to learning a classifier for new classes given only a few examples. While a plethora of models have emerged to tackle it, we find the procedure and datasets that are used to assess their progress lacking. To address this limitation, we propose Meta-Dataset: a new benchmark for training and evaluating models that is large-scale, consists of diverse datasets, and presents more realistic tasks. We experiment with popular baselines and meta-learners on Meta-Dataset, along with a competitive method that we propose. We analyze performance as a function of various characteristics of test tasks and examine the models' ability to leverage diverse training sources for improving their generalization. We also propose a new set of baselines for quantifying the benefit of meta-learning in Meta-Dataset. Our extensive experimentation has uncovered important research challenges and we hope to inspire work in these directions.
Meta-Dataset is now compatible with Python 2 and Python 3, please report any glitch with Python 3. The code has not been tested with TensorFlow 2 yet.
- We recommend you follow these instructions to install TensorFlow.
- A list of packages to install is available in
requirements.txt, you can install them using
- Clone the
meta-datasetrepository. Most command lines start with
python -m meta_dataset.<something>, and should be typed from within that clone (where a
meta_datasetPython module should be visible).
Downloading and converting datasets
Meta-Dataset uses several established datasets, that are available from different sources. You can find below a summary of these datasets, as well as instructions to download them and convert them into a common format.
For brevity of the command line examples, we assume the following environment variables are defined:
$DATASRC: root of where the original data is downloaded and potentially extracted from compressed files. This directory does not need to be available after the data conversion is done.
$SPLITS: directory where
*_splits.jsonfiles will be created, one per dataset. For instance,
$SPLITS/fungi_splits.jsoncontains information about which classes are part of the meta-training, meta-validation, and meta-test set. These files are only used during the dataset conversion phase, but can help troubleshooting later. To re-use the canonical splits instead of re-generating them, you can make it point to
meta_dataset/dataset_conversionin your checkout.
$RECORDS: root directory that will contain the converted datasets (one per sub-directory). This directory needs to be available during training and evaluation.
|Dataset (other names)||Number of classes (train/valid/test)||Size on disk||Conversion time|
|ilsvrc_2012 (ImageNet, ILSVRC) [instructions]||1000 (712/158/130, hierarchical)||~140 GiB||5 to 13 hours|
|omniglot [instructions]||1623 (883/81/659, by alphabet: 25/5/20)||~60 MiB||few seconds|
|aircraft (FGVC-Aircraft) [instructions]||100 (70/15/15)||~470 MiB (2.6 GiB download)||5 to 10 minutes|
|cu_birds (Birds, CUB-200-2011) [instructions]||200 (140/30/30)||~1.1 GiB||~1 minute|
|dtd (Describable Textures, DTD) [instructions]||47 (33/7/7)||~600 MiB||few seconds|
|quickdraw (Quick, Draw!) [instructions]||345 (241/52/52)||~50 GiB||3 to 4 hours|
|fungi (FGVCx Fungi) [instructions]||1394 (994/200/200)||~13 GiB||5 to 15 minutes|
|vgg_flower (VGG Flower) [instructions]||102 (71/15/16)||~330 MiB||~1 minute|
|traffic_sign (Traffic Signs, German Traffic Sign Recognition Benchmark, GTSRB) [instructions]||43 (0/0/43, test only)||~50 MiB (263 MiB download)||~1 minute|
|mscoco (Common Objects in Context, COCO) [instructions]||80 (0/40/40, validation and test only)||~5.3 GiB (18 GiB download)||4 hours|
|Total (All datasets)||4934 (3144/598/1192)||~210 GiB||12 to 24 hours|
Experiments are defined via gin configuration files, that are under
setups/contain generic setups for classes of experiment, for instance which datasets to use (
all), parameters for sampling the number of ways and shots of episodes.
models/define settings for different meta-learning algorithms (baselines, prototypical networks, MAML...)
default/contains files that each correspond to one experiment, mostly defining a setup and a model, with default values for training hyperparameters.
best/contains files with values for training hyperparameters that achieved the best performance during hyperparameter search.
There are three main architectures, also called "backbones" (or "embedding networks"):
convnet for short),
wide_resnet. These architectures can be used by all baselines and episodic models.
relationnet_embedding (similar to
four_layer_convnet but without pooling on the last layer), is only used by RelationNet (and baseline, for pre-training purposes).
See Reproducing best results for instructions to launch training experiments with the values of hyperparameters that were selected in the paper. The hyperparameters (including the backbone, whether to train from scratch or from pre-trained weights, and the number of training updates) were selected using only the validation classes of the ILSVRC 2012 dataset for all experiments. Even when training on "all" datasets, the validation classes of the other datasets were not used.
We will try our best to reproduce the original results using the public code on Google Cloud VMs, and we will include the results of the reproduced experiments in the future.
Models trained on ILSVRC-2012 only
Models trained on all datasets
TODO: Range / distribution of tried hyperparameters