Giter VIP home page Giter VIP logo

inc-few-shot-attractor-public's Introduction

inc-few-shot-attractor-public

This repository contains code for the following paper: Incremental Few-Shot Learning with Attention Attractor Networks. Mengye Ren, Renjie Liao, Ethan Fetaya, Richard S. Zemel. NeurIPS 2019. [arxiv]

Dependencies

  • cv2
  • numpy
  • pandas
  • python 2.7 / 3.5+
  • tensorflow 1.11
  • tqdm

Our code is tested on Ubuntu 14.04 and 16.04.

Setup

First, designate a folder to be your data root:

export DATA_ROOT={DATA_ROOT}

Then, set up the datasets following the instructions in the subsections.

miniImageNet

[Google Drive] (5GB)

# Download and place "mini-imagenet.tar.gz" in "$DATA_ROOT/mini-imagenet".
mkdir -p $DATA_ROOT/mini-imagenet
cd $DATA_ROOT/mini-imagenet
mv ~/Downloads/mini-imagenet.tar .
tar -xvf mini-imagenet.tar
rm -f mini-imagenet.tar

tieredImageNet

[Google Drive] (15GB)

# Download and place "tiered-imagenet.tar" in "$DATA_ROOT/tiered-imagenet".
mkdir -p $DATA_ROOT/tiered-imagenet
cd $DATA_ROOT/tiered-imagenet
mv ~/Downloads/tiered-imagenet.tar .
tar -xvf tiered-imagenet.tar
rm -f tiered-imagenet.tar

Note: Please make sure that the following hardware requirements are met before running tieredImageNet experiments.

  • Disk: 30 GB
  • RAM: 32 GB

Config files

Run make to make protobuf files.

git clone https://github.com/renmengye/inc-few-shot-attractor.git
cd inc-few-shot-attractor
make

Core Experiments

Pretraining

./run.sh {GPUID} python run_exp.py --config {CONFIG_FILE}     \
                  --dataset {DATASET}                         \
                  --data_folder {DATASET_FOLDER}              \
                  --results {SAVE_FOLDER}                     \
                  --tag {EXPERIMENT_NAME}
  • Possible DATASET options are mini-imagenet, tiered-imagenet.
  • Possible CONFIG options are any prototxt file in the ./configs/pretrain folder.

Meta-learning

./run.sh {GPUID} python run_exp.py --config {CONFIG_FILE}     \
                  --dataset {DATASET}                         \
                  --data_folder {DATASET_FOLDER}              \
                  --pretrain {PRETRAIN_CKPT_FOLDER}           \
                  --nshot {NUMBER_OF_SHOTS}                   \
                  --nclasses_b {NUMBER_OF_FEWSHOT_WAYS}       \
                  --results {SAVE_FOLDER}                     \
                  --tag {EXPERIMENT_NAME}                     \
                  [--eval]                                    \
                  [--retest]
  • Possible DATASET options are mini-imagenet, tiered-imagenet.
  • Possible CONFIG options are any prototxt file in the ./configs/attractors folder, e.g. \*-{mlp|lr}-attn-s{1|5}.prototxt means 1/5-shot model using MLP or LR as fast weights model.
  • You need to pass in PRETRAIN_CKPT_FOLDER option with the pretrained model.
  • Add --retest flag for restoring a fully trained model and re-run eval.

Baselines

  • Baseline configs are in ./configs/lwof and ./configs/imprint.
  • For ProtoNet baseline please run run_proto_exp.py with the same flags from the previous section.
  • Configs for ablation studies can be found in ./configs/ablation.

Citation

If you use our code, please consider cite the following:

  • Mengye Ren, Renjie Liao, Ethan Fetaya and Richard S. Zemel. Incremental Few-Shot Learning with Attention Attractor Networks. In Advances in Neural Information Processing Systems (NeurIPS), 2019.
@inproceedings{ren19incfewshot,
  author   = {Mengye Ren and
              Renjie Liao and
              Ethan Fetaya and
              Richard S. Zemel},
  title    = {Incremental Few-Shot Learning with Attention Attractor Networks,
  booktitle= {Advances in Neural Information Processing Systems (NeurIPS)},
  year     = {2019},
}

inc-few-shot-attractor-public's People

Contributors

renmengye avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

inc-few-shot-attractor-public's Issues

Question about tiered_imagenet_split csv files name

Hello,

I just got confused about naming rules of these csv files.

Here are some questions:

1)what is the difference between train_a_phase_train and train_phase_train? Does it refer to task a and b?

  1. train_aa and train_a?

3)trainval and val?

  1. train and rest of the train_ files?

Thank you and have a great day!

KeyError: 'catname2label'

Thanks for sharing the data and code. But when I download your code and run it on my own computer, there is an error occurs:
File "/inc-few-shot-attractor-public-master/fewshot/data/mini_imagenet.py", line 153, in _read_cache
dic = datafile['catname2label']
KeyError: 'catname2label'
I find that the pkl file, such as mini-imagenet-cache-train.pkl, only contains 2 keys: 'image_data' and 'class_dict' without the key 'catname2label' after loading it. Did I miss something?

Some questions about ResNet.

It is a really nice job! We tried to use resnet as a backbone just like what you did in our own experiment. However, it didn't improve performance as we expected and even performed worse than 4-conv. I wonder if there are some tricks when you trained your model with a resnet. Thank you very much.

Questions about the mini-Imagenet experiment

When I run the pretrain experiment on mini-Imagenet, I found that there is a KeyError in the 97th line of the "/fewshot/data/mini_imagenet.py" file, where the CSV_FILE doesn't have a key named 'train_phase_train'. Is it a mistake of your code or my operation?

Details about results in the paper

Hi, thanks for your good job. It's a very interesting work.
I want to know more details about Table 2 in your paper. What does the Acc in the table mean? Top-1 acc or Top-5 acc?
In addition, I'm also very curious about the Train-A-Val top-1 accuracy of your resnet-18 model pretrained on the Train-A-Train part.

Thanks in advance.

Query regarding implementation

Hi, Thank you for this inspiring work.
I would like to know exactly how to get the results for the baseline experiments. Can you please provide the command to be used. Also please do clarify what exactly is the accuracy used in Table 2 of the paper. What do New, New2, Old and Old2 stand for, and also how to calculate the accuracy from these values so as to get the accuracy value equivalent to that found in the Table2 of the paper.

Thank you in advance.

makefile error

I try to run make to make protobuf files, but got error
protoc fewshot/configs/*.proto --python_out . /bin/sh: 1: protoc: not found Makefile:3: recipe for target 'proto' failed make: *** [proto] Error 127

Process of pretrain

Hi, thanks for providing such an awesome project!

For the part of pretraing, you mentioned in your paper that it is a regular supervised classification task and it learns parameters of backbone which fixed afterwards.

But in the pretrain process, you still use the whole network for training and you fix the parameters of backbone or you only take the backbone for training?

Thanks in advance for your response!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.