Giter Site home page Giter Site logo

dl-alva / inc-few-shot-attractor-public Goto Github PK

View Code? Open in Web Editor NEW

This project forked from renmengye/inc-few-shot-attractor-public

0.0 1.0 0.0 5.44 MB

Code for Paper "Incremental Few-Shot Learning with Attention Attractor Networks"

License: MIT License

Makefile 0.04% Python 99.87% Shell 0.09%

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

Watchers

 avatar

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.