/IDEAL

Code for "From Instance to Metric Calibration: A Unified Framework for Open-World Few-Shot Learning" in TPAMI 2023.

Primary LanguagePython

Code for IDEAL

Code for "From Instance to Metric Calibration: A Unified Framework for Open-world Few-shot Learning" in IEEE Transactions on Pattern Analysis and Machine Intelligence.

If you use the code in this repo for your work, please cite the following bib entries:

@ARTICLE{10041935,
  author={An, Yuexuan and Xue, Hui and Zhao, Xingyu and Wang, Jing},
  journal={IEEE Transactions on Pattern Analysis and Machine Intelligence}, 
  title={From Instance to Metric Calibration: A Unified Framework for Open-World Few-Shot Learning}, 
  year={2023},
  volume={45},
  number={8},
  pages={9757-9773},
  doi={10.1109/TPAMI.2023.3244023}
}

Requirements

  • Python >= 3.6
  • PyTorch (GPU version) >= 1.5
  • NumPy >= 1.13.3
  • Scikit-learn >= 0.20

Getting started

CIFAR-FS

  • Change directory to ./filelists/cifar
  • Download CIFAR-FS
  • run python make.py in the terminal

FC100

  • Change directory to ./filelists/fc100
  • Download FC100
  • run python make.py in the terminal

miniImagenet

  • Change directory to ./filelists/miniImagenet
  • Download miniImagenet
  • run python make.py in the terminal

tieredImagenet

  • Change directory to ./filelists/tieredImagenet
  • Download tieredImagenet
  • run python make.py in the terminal

Running the scripts

To pre-train the contrastive network in the terminal, use:

$ python run_IDEAL_pre_train.py --dataset cifar --model_name Conv4 --train_n_way 5 --test_n_way 5 --n_shot 5 --device cuda:0

To train and test the IDEAL model in the terminal, use:

$ python run_IDEAL.py --dataset cifar --noises 1 --noise_type IT --model_name Conv4 --train_n_way 5 --test_n_way 5 --n_shot 5 --device cuda:0 --meta_algorithm IDEAL --attention_method bilstm --eta 0.1 --gamma 0.1

Acknowledgment

Our project references the codes and datasets in the following repo and papers.

CloserLookFewShot

Luca Bertinetto, João F. Henriques, Philip H. S. Torr, Andrea Vedaldi. Meta-learning with differentiable closed-form solvers. ICLR 2019.

Boris N. Oreshkin, Pau Rodríguez López, Alexandre Lacoste. TADAM: Task dependent adaptive metric for improved few-shot learning. NeurIPS 2018: 719-729.

Oriol Vinyals, Charles Blundell, Tim Lillicrap, Koray Kavukcuoglu, Daan Wierstra. Matching Networks for One Shot Learning. NIPS 2016: 3630-3638.

Mengye Ren, Eleni Triantafillou, Sachin Ravi, Jake Snell, Kevin Swersky, Joshua B. Tenenbaum, Hugo Larochelle, Richard S. Zemel. Meta-Learning for Semi-Supervised Few-Shot Classification. ICLR 2018.