learnables / learn2learn

A PyTorch Library for Meta-learning Research
http://learn2learn.net
MIT License
2.66k stars 353 forks source link

Why are we restricting to num_tasks = 20000 in the maml demo for omniglot, but not for the miniImageNet demo? #315

Closed patricks-lab closed 2 years ago

patricks-lab commented 2 years ago

Not much of a bug as much of a clarification/beginner question - but why do we restrict num_tasks = 20000 in the maml_omniglot.py demo:

https://github.com/learnables/learn2learn/blob/691f573ce6deada2021c586a9d762bda4c769406/examples/vision/maml_omniglot.py#L68-L75

but we don't specify num_tasks in the maml_miniimagenet.py demo:

https://github.com/learnables/learn2learn/blob/691f573ce6deada2021c586a9d762bda4c769406/examples/vision/maml_miniimagenet.py#L75-L81

And since we don't specify num_tasks, its value is taken to be -1, which means we continuously sample new tasks rather than recomputing them: https://github.com/learnables/learn2learn/blob/691f573ce6deada2021c586a9d762bda4c769406/learn2learn/data/task_dataset.pyx#L64-L65

I presume this is because of the number of classes in each of the datasets - in omniglot we have 1623 different classes, yet in miniimagenet we only have 100 classes, and as such we want to restrict the total number of possible tasks in omniglot (previously there would be ((1623 classes) choose (5 ways per task)) = 9e13 possible tasks to something more reasonable? Or is something else going on?

Thanks so much for the clarifications!

seba-1511 commented 2 years ago

For Omniglot, it replicates the original MAML experiments. For mini-ImageNet, the convention is to not store tasks.

brando90 commented 1 year ago

key comment for me:

If `num_tasks` is -1, the TaskDataset will not cache task descriptions and instead continuously resample 
     new ones.