The repository contains the code for:
Adaptive Subspaces for Few-Shot Learning
CVPR 2020
Comparison with previous methods:
Robustness on toy data: subspaces VS prototypes
- PyTorch 1.0 or above
- Python 3.6
There are two backbones separated in different folders.
- Conv-4, there are two datasets using this backbone: mini-ImageNet and OpenMIC.
- ResNet-12, there are three datasets using this backbone: mini-ImageNet, tiered-ImageNet, and Cifar-FS.
- mini-ImageNet - Conv4: Google Drive (3 GB)
- mini-ImageNet - ResNet12: Google Drive ** (2 GB)
- tiered-ImageNet: Google Drive ** (13 GB)
- OpenMIC: Fill the request form and Download (0.3 GB)
- CIFAR100: CS TORONTO (0.2 GB)
** Adopted from Kwonjoon Lee
Train mini-ImageNet:
python3 train_subspace_discriminative.py --data-path 'yourdatafolder'
Evaluate mini-ImageNet:
python3 test_subspace_discriminative.py --data-path 'yourdatafolder'
Train OpenMIC:
python3 train_subspace_museum.py --data-path 'yourdatafolder'
Note: Training using ResNet-12 requires 4 GPUs with ~10GB/GPU
Set the image folders:
_IMAGENET_DATASET_DIR = './miniimagenet/' (in data/mini_imagenet.py)
_TIERED_IMAGENET_DATASET_DIR = '/tieredimagenet/' (in data/tiered_imagenet.py)
_CIFAR_FS_DATASET_DIR = './cifar/CIFAR-FS/' (in data/CIFAR_FS.py)
Train mini-ImageNet:
python3 train.py --gpu 0,1,2,3 --save-path "./experiments/miniImageNet_subspace" --train-shot 15 --\
--head Subspace --network ResNet --dataset miniImageNet --eps 0.1
Evaluate mini-ImageNet:
python3 test.py --gpu 0 --load ./experiments/miniImageNet_subspace/best_model.pth --episode 1000 \
--way 5 --shot 5 --query 15 --head Subspace --network ResNet --dataset miniImageNet
options --dataset [miniImageNet, tieredImageNet, CIFAR_FS]
@inproceedings{simon2020dsn,
author = {C. Simon}, {P. Koniusz}, {R. Nock}, and {M. Harandi}
title = {Adaptive Subspaces for Few-Shot Learning},
booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)}
year = 2020
}
Thank you for the codebases: