Skip to content

Extended Few-Shot Learning: Exploiting Existing Resources for Novel Tasks

Notifications You must be signed in to change notification settings

BatsResearch/efsl

Repository files navigation

Extended Few-Shot Learning: Exploiting Existing Resources for Novel Tasks

Code for Extended Few-Shot Learning: Exploiting Existing Resources for Novel Tasks.

Setup

Run the following 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.

Download and extract the compressed meta-data file to ../data_root directory.

You can download our pre-trained variables for each model here:

  • Nearest Centroid Classifier (NCC) - link
  • Relation Module (RM) - link
  • Embedding Adaptation (EA) - link

Requirements

Install the following packages in your environment.

python=3.8.3
torch=1.5.1
cuda=10.1
torchvision=0.6.1
scipy=1.5.0
scikit-learn=0.23.1
pandas=1.1.1
opencv-contrib-python=4.5.2.54
flatten_dict=0.4.0
filelock=3.0.12
tqdm=4.61.1
tensorboardx=2.4
pyyaml=5.4.1
h5py=2.10.0

Evaluation

To evaluate a model run the following command. Use the following command to evaluate the 1-shot NNC model with basic embeddings on mini-imagenet dataset with level0 auxiliary data.

python test_efsl.py --encoder-conifg configs/resnet12.yaml 
                    --model-checkpoint path/to/saved/parameters
                    --data-dir path/to/dataset/files

Run python test_efsl.py --help for the list of possible command line options and their description.

Training

Feature Embedding. Use the following to train the feature embedding parameters on mini-imagenet dataset with level0 auxiliary data.

python train_classifier.py --config configs/classifier.yaml 
                           --data-dir path/to/dataset/files

Run python train_classifier.py --help for the list of possible command line options and their description.

Masking Module. Use the following to train the masking module parameters for 1-shot task on mini-imagenet dataset with level0 auxiliary data.

python train_efsl.py --encoder-config configs/resnet12-mask.yaml
                     --encoder-checkpoint path/to/resnet/parameters
                     --data-dir path/to/dataset/files

Run python train_efsl.py --help for the list of possible command line options and their description.

Citation

If you use this repo, please cite the corresponding paper.

Esfandiarpoor, R., Pu, A., Hajabdollahi, M. and Bach, S.H., 2020.

@article{esfandiarpoor:arxiv20,
  Author = {Esfandiarpoor, R. and Pu, A. and Hajabdollahi, M. and Bach, S. H.},
  Title = {Extended Few-Shot Learning: Exploiting Existing Resources for Novel Tasks},
  Volume = {arXiv:2012.07176 [cs.LG]},
  Year = {2020}}

Acknowledgement

The code in this repo is based on the following repositories:

Releases

No releases published

Packages

No packages published

Languages