iamsile / meta-transfer-learning-tensorflow

The TensorFlow implementation of "Meta-Transfer Learning for Few-Shot Learning"

Home Page:https://mtl.yaoyao-liu.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Meta-Transfer Learning Tensorflow

LICENSE

This repo is the TensorFlow implementation of CVPR 2019 Paper Meta-Transfer Learning for Few-Shot Learning by Qianru Sun, Yaoyao Liu, Tat-Seng Chua and Bernt Schiele.

Summary:

Introduction

Meta-learning has been proposed as a framework to address the challenging few-shot learning setting. The key idea is to leverage a large number of similar few-shot tasks in order to learn how to adapt a base-learner to a new task for which only a few labeled samples are available. As deep neural networks (DNNs) tend to overfit using a few samples only, meta-learning typically uses shallow neural networks (SNNs), thus limiting its effectiveness. In this paper we propose a novel few-shot learning method called meta-transfer learning (MTL) which learns to adapt a deep NN for few shot learning tasks. Specifically, meta refers to training multiple tasks, and transfer is achieved by learning scaling and shifting functions of DNN weights for each task. In addition, we introduce the hard task (HT) meta-batch scheme as an effective learning curriculum for MTL. We conduct experiments using (5-class, 1-shot) and (5-class, 5-shot) recognition tasks on two challenging few-shot learning benchmarks: miniImageNet and Fewshot-CIFAR100. Extensive comparisons to related works validate that our meta-transfer learning approach trained with the proposed HT meta-batch scheme achieves top performance. An ablation study also shows that both components contribute to fast convergence and high accuracy.

Installation

In order to run this repo, we advise you to install python 2.7 and TensorFlow 1.3.0 with Anaconda.

You may download Anaconda and read the installation instrucation on their offical website: https://www.anaconda.com/download/

Create a new environment and install tensorflow on it:

conda create --name tensorflow_1.3.0_gpu python=2.7
source activate tensorflow_1.3.0_gpu
pip install --ignore-installed --upgrade https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp27-none-linux_x86_64.whl

Clone the repo:

git clone https://github.com/y2l/meta-transfer-learning-tensorflow.git 
cd meta-transfer-learning-tensorflow-master

Install the requirements:

pip install scipy
pip install tqdm
pip install opencv-python

Dataset

miniImageNet

Mini-ImageNet dataset was proposed by Vinyals et al. for few-shot learning evaluation. Its complexity is high due to the use of ImageNet images but requires fewer resources and infrastructure than running on the full ImageNet dataset. In total, there are 100 classes with 600 samples of 84×84 color images per class. These 100 classes are divided into 64, 16, and 20 classes respectively for sampling tasks for meta-training, meta-validation, and meta-test.

To generate this dataset, your may use the repo miniImageNet Tools.

FC100

For Few-shot CIFAR100 dataset, we will release the code to generate this dataset soon. You may also generate it yourself with the splits provided by TADAM.

Uasge

To run the experiment:

python run_experiment.py

You may edit the run_experiment.py file to change the hyperparameters and default settings.

Citation

Please cite our paper if it is helpful to your work:

@inproceedings{Sun2019MTL,
  title={Meta-Transfer Learning for Few-Shot Learning},
  author={Sun, Qianru and Liu, Yaoyao and Chua, Tat-Seng and Schiele, Bernt},
  booktitle={CVPR},
  year={2019}
}

Acknowledgements

This repo use the source code from the following repos:

MAML

Optimization as a Model for Few-Shot Learning

About

The TensorFlow implementation of "Meta-Transfer Learning for Few-Shot Learning"

https://mtl.yaoyao-liu.com

License:MIT License


Languages

Language:Python 100.0%