Pytorch Implementation for CVPR2018 Paper: Learning to Compare: Relation Network for Few-Shot Learning

Overview

LearningToCompare

Pytorch Implementation for Paper: Learning to Compare: Relation Network for Few-Shot Learning

Howto

download mini-imagenet and make it looks like:

mini-imagenet/
├── images
	├── n0210891500001298.jpg  
	├── n0287152500001298.jpg 
	...
├── test.csv
├── val.csv
└── train.csv

LearningToCompare-Pytorch/
├── compare.py
├── MiniImagenet.py
├── Readme.md
├── repnet.py
├── train.py
└── utils.py
python train.py

NOTICE

current code support multi-gpus on single machine training, to disable it and train on single machine, just set device_ids=[0] and downsize batch size according to your gpu memory capacity. make sure ckpt directory exists, otherwise mkdir ckpt.

mini-Imagenet

Model Fine Tune 5-way Acc. 20-way Acc
1-shot 5-shot 1-shot 5-shot
Matching Nets N 43.56% 55.31% 17.31% 22.69%
Meta-LSTM 43.44% 60.60% 16.70% 26.06%
MAML Y 48.7% 63.11% 16.49% 19.29%
Meta-SGD 50.49% 64.03% 17.56% 28.92%
TCML 55.71% 68.88% - -
Learning to Compare N 57.02% 71.07% - -
Ours, similarity ensemble N 55.2% 68.8%
Ours, feature ensemble N 55.2% 70.1%
Comments
  • Access the miniImageNet dataset

    Access the miniImageNet dataset

    I try to download mini-Imagenet Dataset, but I cannot find it online. Can you share the link to the miniImageNet images?Thanks. [email protected]

    opened by zhangguanghui1 9
  • type issue in accuracy

    type issue in accuracy

    for me, the accuracy was always zero because of a type issue. If you sum a boolean array like this

    correct = torch.eq(pred, query_y).sum()

    it is always either 0 or 1. I had to change it to:

    correct = torch.eq(pred, query_y).float().sum()

    Maybe it's a version difference only.

    opened by fguney 4
  • question about the accuracy

    question about the accuracy

    Hi, thanks for your source code, however when I run your source code, the accuracy is:

    1. 51.9% for the 5-way-1-shot
    2. 65.3% for the 5-way-5-shot the accuracy is far away from the what you have published (they should be 57.2% and 71.07% respectively in the form you posted ) so I am wondering if you could explain this problem, thanks a lot!
    opened by flexibility2 2
  • exact details for the tables

    exact details for the tables

    It'd be great if you could share how you set the k_query and batcsz for the tables. Also, is it possible to share MiniImagenet dataset? I cannot find it online.

    opened by fguney 2
  • What is the difference between yours and the author's code

    What is the difference between yours and the author's code

    Hi, thanks for your code! I wonder what is the difference between yours and the author's code https://github.com/floodsung/LearningToCompare_FSL

      It seems that you use the resnet as the basic network?
      Thanks a lot!
    
    opened by feynman233 1
  • ask for help

    ask for help

    As for the 5-way 1-shot experiments,in the paper,there are 19 * 5 + 1  5 = 100 images. I think 19  5 + 1 * 19 = 114 images. I can not understand it

    opened by 22wei22 1
  • multi-gpu not considered in accuracy

    multi-gpu not considered in accuracy

    in train.py, this only adds the sum of correct ones from GPU 0: total_correct += correct.data[0]

    it should be something like that in case of multiple GPUs, right?:

    for d in range(len(device_ids)): total_correct += correct.data[d]

    opened by fguney 1
  • question about the accuracy of 5-way-5-shot

    question about the accuracy of 5-way-5-shot

    Thanks for your source code, However,when I run your source code of "5-way-5-shot", the accuracy is only "63.3%" …… Could you fix this problem, thanks a lot!

    opened by flexibility2 0
  • Test phase

    Test phase

    I am trying to use this (and Prototypical nets) on a custom problem and I dont understand the test time phase. I have 5000 classes with most of them with 1 picture only... So I train the model using 5 shot and 5 query for example (getting 4 pictures with data augmentation If I have not so many pictures) and then in test I dont understand how to do to map to the 5000 classes. Should I use query of all training size and query 1 by 1?

    opened by MarioProjects 4
Owner
Jackie Loong
Make machines behave like me. [email protected]
Jackie Loong
Code for the paper "Relation of the Relations: A New Formalization of the Relation Extraction Problem"

This repo contains the code for the EMNLP 2020 paper "Relation of the Relations: A New Paradigm of the Relation Extraction Problem" (Jin et al., 2020)

YYY 27 Oct 26, 2022
Code for T-Few from "Few-Shot Parameter-Efficient Fine-Tuning is Better and Cheaper than In-Context Learning"

T-Few This repository contains the official code for the paper: "Few-Shot Parameter-Efficient Fine-Tuning is Better and Cheaper than In-Context Learni

null 220 Dec 31, 2022
Few-NERD: Not Only a Few-shot NER Dataset

Few-NERD: Not Only a Few-shot NER Dataset This is the source code of the ACL-IJCNLP 2021 paper: Few-NERD: A Few-shot Named Entity Recognition Dataset.

THUNLP 319 Dec 30, 2022
Pytorch implementation of the paper "Optimization as a Model for Few-Shot Learning"

Optimization as a Model for Few-Shot Learning This repo provides a Pytorch implementation for the Optimization as a Model for Few-Shot Learning paper.

Albert Berenguel Centeno 238 Jan 4, 2023
A lightweight library to compare different PyTorch implementations of the same network architecture.

TorchBug is a lightweight library designed to compare two PyTorch implementations of the same network architecture. It allows you to count, and compar

Arjun Krishnakumar 5 Jan 2, 2023
PyTorch implementation of ARM-Net: Adaptive Relation Modeling Network for Structured Data.

A ready-to-use framework of latest models for structured (tabular) data learning with PyTorch. Applications include recommendation, CRT prediction, healthcare analytics, and etc.

null 48 Nov 30, 2022
Implementation of the paper "Self-Promoted Prototype Refinement for Few-Shot Class-Incremental Learning"

Self-Promoted Prototype Refinement for Few-Shot Class-Incremental Learning This is the implementation of the paper "Self-Promoted Prototype Refinement

Kai Zhu 78 Dec 2, 2022
Task-related Saliency Network For Few-shot learning

Task-related Saliency Network For Few-shot learning This is an official implementation in Tensorflow of TRSN. Abstract An essential cue of human wisdo

null 1 Nov 18, 2021
The implementation of PEMP in paper "Prior-Enhanced Few-Shot Segmentation with Meta-Prototypes"

Prior-Enhanced network with Meta-Prototypes (PEMP) This is the PyTorch implementation of PEMP. Overview of PEMP Meta-Prototypes & Adaptive Prototypes

Jianwei ZHANG 8 Oct 14, 2021
The official implementation of the CVPR 2021 paper FAPIS: a Few-shot Anchor-free Part-based Instance Segmenter

FAPIS The official implementation of the CVPR 2021 paper FAPIS: a Few-shot Anchor-free Part-based Instance Segmenter Introduction This repo is primari

Khoi Nguyen 8 Dec 11, 2022
Official PyTorch implementation of MX-Font (Multiple Heads are Better than One: Few-shot Font Generation with Multiple Localized Experts)

Introduction Pytorch implementation of Multiple Heads are Better than One: Few-shot Font Generation with Multiple Localized Expert. | paper Song Park1

Clova AI Research 97 Dec 23, 2022
Official PyTorch Implementation of Hypercorrelation Squeeze for Few-Shot Segmentation, arXiv 2021

Hypercorrelation Squeeze for Few-Shot Segmentation This is the implementation of the paper "Hypercorrelation Squeeze for Few-Shot Segmentation" by Juh

Juhong Min 165 Dec 28, 2022
Implementation of Cross Transformer for spatially-aware few-shot transfer, in Pytorch

Cross Transformers - Pytorch (wip) Implementation of Cross Transformer for spatially-aware few-shot transfer, in Pytorch Install $ pip install cross-t

Phil Wang 40 Dec 22, 2022
Pytorch implementation of few-shot semantic image synthesis

Few-shot Semantic Image Synthesis Using StyleGAN Prior Our method can synthesize photorealistic images from dense or sparse semantic annotations using

null 40 Sep 26, 2022
(ICCV'21) Official PyTorch implementation of Relational Embedding for Few-Shot Classification

Relational Embedding for Few-Shot Classification (ICCV 2021) Dahyun Kang, Heeseung Kwon, Juhong Min, Minsu Cho [paper], [project hompage] We propose t

Dahyun Kang 82 Dec 24, 2022
PyTorch implementation of D2C: Diffuison-Decoding Models for Few-shot Conditional Generation.

D2C: Diffuison-Decoding Models for Few-shot Conditional Generation Project | Paper PyTorch implementation of D2C: Diffuison-Decoding Models for Few-sh

Jiaming Song 90 Dec 27, 2022
Implementation of 🦩 Flamingo, state-of-the-art few-shot visual question answering attention net out of Deepmind, in Pytorch

?? Flamingo - Pytorch Implementation of Flamingo, state-of-the-art few-shot visual question answering attention net, in Pytorch. It will include the p

Phil Wang 630 Dec 28, 2022
A pytorch-version implementation codes of paper: "BSN++: Complementary Boundary Regressor with Scale-Balanced Relation Modeling for Temporal Action Proposal Generation"

BSN++: Complementary Boundary Regressor with Scale-Balanced Relation Modeling for Temporal Action Proposal Generation A pytorch-version implementation

null 11 Oct 8, 2022
PFENet: Prior Guided Feature Enrichment Network for Few-shot Segmentation (TPAMI).

PFENet This is the implementation of our paper PFENet: Prior Guided Feature Enrichment Network for Few-shot Segmentation that has been accepted to IEE

DV Lab 230 Dec 31, 2022