learn2learn.vision.models

Description

A set of commonly used models for meta-learning vision tasks.

OmniglotFC

OmniglotFC(input_size, output_size, sizes=None)

[Source]

Description

The fully-connected network used for Omniglot experiments, as described in Santoro et al, 2016.

References

  1. Santoro et al. 2016. “Meta-Learning with Memory-Augmented Neural Networks.” ICML.

Arguments

Example

net = OmniglotFC(input_size=28**2,
                 output_size=10,
                 sizes=[64, 64, 64])

OmniglotCNN

OmniglotCNN(output_size=5, hidden_size=64, layers=4)

Source

Description

The convolutional network commonly used for Omniglot, as described by Finn et al, 2017.

This network assumes inputs of shapes (1, 28, 28).

References

  1. Finn et al. 2017. “Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networks.” ICML.

Arguments

Example

model = OmniglotCNN(output_size=20, hidden_size=128, layers=3)

MiniImagenetCNN

MiniImagenetCNN(output_size, hidden_size=32, layers=4)

[Source]

Description

The convolutional network commonly used for MiniImagenet, as described by Ravi et Larochelle, 2017.

This network assumes inputs of shapes (3, 84, 84).

References

  1. Ravi and Larochelle. 2017. “Optimization as a Model for Few-Shot Learning.” ICLR.

Arguments

Example

model = MiniImagenetCNN(output_size=20, hidden_size=128, layers=3)

learn2learn.vision.datasets

Description

Some datasets commonly used in meta-learning vision tasks.

FullOmniglot

FullOmniglot(root, transform=None, target_transform=None, download=False)

[Source]

Description

This class provides an interface to the Omniglot dataset.

The Omniglot dataset was introduced by Lake et al., 2015. Omniglot consists of 1623 character classes from 50 different alphabets, each containing 20 samples. While the original dataset is separated in background and evaluation sets, this class concatenates both sets and leaves to the user the choice of classes splitting as was done in Ravi and Larochelle, 2017. The background and evaluation splits are available in the torchvision package.

References

  1. Lake et al. 2015. “Human-Level Concept Learning through Probabilistic Program Induction.” Science.
  2. Ravi and Larochelle. 2017. “Optimization as a Model for Few-Shot Learning.” ICLR.

Arguments

Example

omniglot = l2l.vision.datasets.FullOmniglot(root='./data',
                                            transform=transforms.Compose([
                                                transforms.Resize(28, interpolation=LANCZOS),
                                                transforms.ToTensor(),
                                                lambda x: 1.0 - x,
                                            ]),
                                            download=True)
omniglot = l2l.data.MetaDataset(omniglot)

MiniImagenet

MiniImagenet(root, mode='train', transform=None, target_transform=None)

[Source]

Description

The mini-ImageNet dataset was originally introduced by Vinyals et al., 2016.

It consists of 60'000 colour images of sizes 84x84 pixels. The dataset is divided in 3 splits of 64 training, 16 validation, and 20 testing classes each containing 600 examples. The classes are sampled from the ImageNet dataset, and we use the splits from Ravi & Larochelle, 2017.

References

  1. Vinyals et al. 2016. “Matching Networks for One Shot Learning.” NeurIPS.
  2. Ravi and Larochelle. 2017. “Optimization as a Model for Few-Shot Learning.” ICLR.

Arguments

Example

train_dataset = l2l.vision.datasets.MiniImagenet(root='./data', mode='train')
train_dataset = l2l.data.MetaDataset(train_dataset)
train_generator = l2l.data.TaskGenerator(dataset=train_dataset, ways=ways)

TieredImagenet

TieredImagenet(root,
               mode='train',
               transform=None,
               target_transform=None,
               download=False)

[Source]

Description

The tiered-ImageNet dataset was originally introduced by Ren et al, 2018 and we download the data directly from the link provided in their repository.

Like mini-ImageNet, tiered-ImageNet builds on top of ILSVRC-12, but consists of 608 classes (779,165 images) instead of 100. The train-validation-test split is made such that classes from similar categories are in the same splits. There are 34 categories each containing between 10 and 30 classes. Of these categories, 20 (351 classes; 448,695 images) are used for training, 6 (97 classes; 124,261 images) for validation, and 8 (160 class; 206,209 images) for testing.

References

  1. Ren et al, 2018. "Meta-Learning for Semi-Supervised Few-Shot Classification." ICLR '18.
  2. Ren Mengye. 2018. "few-shot-ssl-public". https://github.com/renmengye/few-shot-ssl-public

Arguments

Example

train_dataset = l2l.vision.datasets.TieredImagenet(root='./data', mode='train', download=True)
train_dataset = l2l.data.MetaDataset(train_dataset)
train_generator = l2l.data.TaskDataset(dataset=train_dataset, num_tasks=1000)

FC100

FC100(root, mode='train', transform=None, target_transform=None)

[Source]

Description

The FC100 dataset was originally introduced by Oreshkin et al., 2018.

It is based on CIFAR100, but unlike CIFAR-FS training, validation, and testing classes are split so as to minimize the information overlap between splits. The 100 classes are grouped into 20 superclasses of which 12 (60 classes) are used for training, 4 (20 classes) for validation, and 4 (20 classes) for testing. Each class contains 600 images. The specific splits are provided in the Supplementary Material of the paper. Our data is downloaded from the link provided by [2].

References

  1. Oreshkin et al. 2018. "TADAM: Task Dependent Adaptive Metric for Improved Few-Shot Learning." NeurIPS.
  2. Kwoonjoon Lee. 2019. "MetaOptNet." https://github.com/kjunelee/MetaOptNet

Arguments

Example

train_dataset = l2l.vision.datasets.FC100(root='./data', mode='train')
train_dataset = l2l.data.MetaDataset(train_dataset)
train_generator = l2l.data.TaskDataset(dataset=train_dataset, num_tasks=1000)

CIFARFS

CIFARFS(root, mode='train', transform=None, target_transform=None)

[Source]

Description

The CIFAR Few-Shot dataset as originally introduced by Bertinetto et al., 2019.

It consists of 60'000 colour images of sizes 32x32 pixels. The dataset is divided in 3 splits of 64 training, 16 validation, and 20 testing classes each containing 600 examples. The classes are sampled from the CIFAR-100 dataset, and we use the splits from Bertinetto et al., 2019.

References

  1. Bertinetto et al. 2019. "Meta-learning with differentiable closed-form solvers". ICLR.

Arguments

Example

train_dataset = l2l.vision.datasets.CIFARFS(root='./data', mode='train')
train_dataset = l2l.data.MetaDataset(train_dataset)
train_generator = l2l.data.TaskGenerator(dataset=train_dataset, ways=ways)

VGGFlower102

VGGFlower102(root,
             mode='all',
             transform=None,
             target_transform=None,
             download=False)

[Source]

Description

The VGG Flowers dataset was originally introduced by Maji et al., 2013 and then re-purposed for few-shot learning in Triantafillou et al., 2020.

The dataset consists of 102 classes of flowers, with each class consisting of 40 to 258 images. We provide the raw (unprocessed) images, and follow the train-validation-test splits of Triantafillou et al.

References

  1. Nilsback, M. and A. Zisserman. 2006. "A Visual Vocabulary for Flower Classification." CVPR '06.
  2. Triantafillou et al. 2019. "Meta-Dataset: A Dataset of Datasets for Learning to Learn from Few Examples." ICLR '20.
  3. https://www.robots.ox.ac.uk/~vgg/data/flowers/

Arguments

Example

train_dataset = l2l.vision.datasets.VGGFlower102(root='./data', mode='train')
train_dataset = l2l.data.MetaDataset(train_dataset)
train_generator = l2l.data.TaskDataset(dataset=train_dataset, num_tasks=1000)

FGVCAircraft

FGVCAircraft(root,
             mode='all',
             transform=None,
             target_transform=None,
             download=False)

[Source]

Description

The FGVC Aircraft dataset was originally introduced by Maji et al., 2013 and then re-purposed for few-shot learning in Triantafillou et al., 2020.

The dataset consists of 10,200 images of aircraft (102 classes, each 100 images). We provided the raw (un-processed) images and follow the train-validation-test splits of Triantafillou et al.

References

  1. Maji et al. 2013. "Fine-Grained Visual Classification of Aircraft." arXiv [cs.CV].
  2. Triantafillou et al. 2019. "Meta-Dataset: A Dataset of Datasets for Learning to Learn from Few Examples." ICLR '20.
  3. http://www.robots.ox.ac.uk/~vgg/data/fgvc-aircraft/

Arguments

Example

train_dataset = l2l.vision.datasets.FGVCAircraft(root='./data', mode='train', download=True)
train_dataset = l2l.data.MetaDataset(train_dataset)
train_generator = l2l.data.TaskDataset(dataset=train_dataset, num_tasks=1000)

learn2learn.vision.transforms

Description

A set of transformations commonly used in meta-learning vision tasks.

RandomClassRotation

RandomClassRotation(dataset, degrees)

[Source]

Description

Samples rotations from a given list uniformly at random, and applies it to all images from a given class.

Arguments

Example

transform = RandomClassRotation([0, 90, 180, 270])