项目作者: Reza-esfandiarpoor

项目描述 :
Pseudo Shots: Few-Shot Learning with Auxiliary Data
高级语言: Python
项目地址: git://github.com/Reza-esfandiarpoor/pseudo-shots.git
创建时间: 2021-01-14T15:49:31Z
项目社区:https://github.com/Reza-esfandiarpoor/pseudo-shots

开源协议:

下载


This repository is no longer maintained. You can find the updated version of the paper as well as its code here: BatsResearch/efsl.

—-

Pseudo Shots: Few-Shot Learning with Auxiliary Data

Code for Pseudo Shots: Few-Shot Learning with Auxiliary Data.

Requirements

  • python 3.8.6
  • pytorch 1.5.1
  • torchvision
  • tensorboardX

The code is tested on ubuntu 18.04.

Setup

Run the follwowing in the project root to create the required directory structure.

  1. mkdir ../data_root
  2. mkdir ../data_root/mini-imagenet
  3. mkdir ../data_root/tiered-imagenet
  4. mkdir ../data_root/cifarfs
  5. 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.

meta-data

Evaluation

To evaluate a model run the following command.

  1. python test_few_shot.py --dir DIR --nshot NSHOT
  • DIR is the directory where the model is saved.
  • You should specificy NSHOT when evaluating the basic model.

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

Pre-trained Variables

Training

Feature Embedding. To train the feature embedding parameters from scratch run the following command.

  1. python train_classifier.py --config CONFIG
  2. --aux-level AUX-LEVEL
  3. [--topk {TOPK}]
  4. [--name {NAME}]
  5. [--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.

  1. python train_fsl.py --config CONFIG
  2. --embedding EMBEDDING
  3. --aux-level AUX-LEVEL
  4. --nshot NSHOT
  5. --helper
  6. [--topk {TOPK}]
  7. [--name {NAME}]
  8. [--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.

Citation

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.

  1. @article{esfandiarpoor:arxiv20,
  2. Author = {Esfandiarpoor, R. and Hajabdollahi, M. and Bach, S. H.},
  3. Title = {Pseudo Shots: {F}ew-Shot Learning with Auxiliary Data},
  4. Volume = {arXiv:2012.07176 [cs.LG]},
  5. Year = {2020}}

Acknowledgement

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