Pseudo Shots: Few-Shot Learning with Auxiliary Data
This repository is no longer maintained. You can find the updated version of the paper as well as its code here: BatsResearch/efsl.
Code for Pseudo Shots: Few-Shot Learning with Auxiliary Data.
The code is tested on ubuntu 18.04.
Run the follwowing in the project root to create the required directory structure.
mkdir ../data_root
mkdir ../data_root/mini-imagenet
mkdir ../data_root/tiered-imagenet
mkdir ../data_root/cifarfs
mkdir ../data_root/fc100
Download and extract the compressed file for each dataset to the corresponding directory.
mini-ImageNet \
tiered-ImageNet \
cifarfs \
fc100
Download and extract the compressed meta-data file to ../data_root
directory.
To evaluate a model run the following command.
python test_few_shot.py --dir DIR --nshot NSHOT
DIR
is the directory where the model is saved.NSHOT
when evaluating the basic model.You can download our pre-trained variables for the masking model here:
Feature Embedding. To train the feature embedding parameters from scratch run the following command.
python train_classifier.py --config CONFIG
--aux-level AUX-LEVEL
[--topk {TOPK}]
[--name {NAME}]
[--tag {TAG}]
CONFIG
is the path to the desired YAML config file.AUX-LEVEL
is the level of semantic pruning for auxiliary data.TOPK
(int) specifies the K most similar classes to use for auxiliary data.NAME
overrides the default model name.TAG
is an optional name tag.Masking Model. To train the masking model parameters run the follwoing command.
python train_fsl.py --config CONFIG
--embedding EMBEDDING
--aux-level AUX-LEVEL
--nshot NSHOT
--helper
[--topk {TOPK}]
[--name {NAME}]
[--tag {TAG}]
CONFIG
is the path to the desired YAML config file.EMBEDDING
is the path to where you saved the embedding model parameters.AUX-LEVEL
is the level of semantic pruning for auxiliary data.NSHOT
is the number of shots in a K-shot N-way episode.helper
determines whether to use the helper dataset or not.TOPK
(int) specifies the K most similar classes to use as auxiliary data.NAME
overrides the default model name.TAG
is an optional name tag.If you use this repo, please cite the corresponding paper.
Esfandiarpoor, R., Hajabdollahi, M. and Bach, S.H., 2020. Pseudo Shots: Few-Shot Learning with Auxiliary Data. arXiv preprint arXiv:2012.07176.
@article{esfandiarpoor:arxiv20,
Author = {Esfandiarpoor, R. and Hajabdollahi, M. and Bach, S. H.},
Title = {Pseudo Shots: {F}ew-Shot Learning with Auxiliary Data},
Volume = {arXiv:2012.07176 [cs.LG]},
Year = {2020}}
The code in this repo is based on the following repositories: