All Projects → bl0 → Negative Margin.few Shot

bl0 / Negative Margin.few Shot

Licence: other
PyTorch implementation of “Negative Margin Matters: Understanding Margin in Few-shot Classification”

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Negative Margin.few Shot

Rkd
Official pytorch Implementation of Relational Knowledge Distillation, CVPR 2019
Stars: ✭ 257 (+154.46%)
Mutual labels:  metric-learning
Amsoftmax
A simple yet effective loss function for face verification.
Stars: ✭ 443 (+338.61%)
Mutual labels:  metric-learning
Metric Learn
Metric learning algorithms in Python
Stars: ✭ 1,125 (+1013.86%)
Mutual labels:  metric-learning
Pytorch Metric Learning
The easiest way to use deep metric learning in your application. Modular, flexible, and extensible. Written in PyTorch.
Stars: ✭ 3,936 (+3797.03%)
Mutual labels:  metric-learning
Survey of deep metric learning
A comprehensive survey of deep metric learning and related works
Stars: ✭ 406 (+301.98%)
Mutual labels:  metric-learning
Humpback Whale Identification 1st
https://www.kaggle.com/c/humpback-whale-identification
Stars: ✭ 591 (+485.15%)
Mutual labels:  metric-learning
disent
🧶 Modular VAE disentanglement framework for python built with PyTorch Lightning ▸ Including metrics and datasets ▸ With strongly supervised, weakly supervised and unsupervised methods ▸ Easily configured and run with Hydra config ▸ Inspired by disentanglement_lib
Stars: ✭ 41 (-59.41%)
Mutual labels:  metric-learning
Pointglr
Global-Local Bidirectional Reasoning for Unsupervised Representation Learning of 3D Point Clouds (CVPR 2020)
Stars: ✭ 86 (-14.85%)
Mutual labels:  metric-learning
Deep Metric Learning Baselines
PyTorch Implementation for Deep Metric Learning Pipelines
Stars: ✭ 442 (+337.62%)
Mutual labels:  metric-learning
Open Ucn
The first fully convolutional metric learning for geometric/semantic image correspondences.
Stars: ✭ 60 (-40.59%)
Mutual labels:  metric-learning
Batch Dropblock Network
Official source code of "Batch DropBlock Network for Person Re-identification and Beyond" (ICCV 2019)
Stars: ✭ 304 (+200.99%)
Mutual labels:  metric-learning
Hardnet
Hardnet descriptor model - "Working hard to know your neighbor's margins: Local descriptor learning loss"
Stars: ✭ 350 (+246.53%)
Mutual labels:  metric-learning
Prototypical Networks
Code for the NeurIPS 2017 Paper "Prototypical Networks for Few-shot Learning"
Stars: ✭ 705 (+598.02%)
Mutual labels:  metric-learning
Powerful Benchmarker
A PyTorch library for benchmarking deep metric learning. It's powerful.
Stars: ✭ 272 (+169.31%)
Mutual labels:  metric-learning
Open Reid
Open source person re-identification library in python
Stars: ✭ 1,144 (+1032.67%)
Mutual labels:  metric-learning
symmetrical-synthesis
Official Tensorflow implementation of "Symmetrical Synthesis for Deep Metric Learning" (AAAI 2020)
Stars: ✭ 67 (-33.66%)
Mutual labels:  metric-learning
Additive Margin Softmax
This is the implementation of paper <Additive Margin Softmax for Face Verification>
Stars: ✭ 464 (+359.41%)
Mutual labels:  metric-learning
Pvse
Polysemous Visual-Semantic Embedding for Cross-Modal Retrieval (CVPR 2019)
Stars: ✭ 93 (-7.92%)
Mutual labels:  metric-learning
Mvgcn
Multi-View Graph Convolutional Network and Its Applications on Neuroimage Analysis for Parkinson's Disease (AMIA 2018)
Stars: ✭ 81 (-19.8%)
Mutual labels:  metric-learning
Hcn Prototypeloss Pytorch
Hierarchical Co-occurrence Network with Prototype Loss for Few-shot Learning (PyTorch)
Stars: ✭ 17 (-83.17%)
Mutual labels:  metric-learning

Negative Margin Matters: Understanding Margin in Few-shot Classification

By Bin Liu, Yue Cao, Yutong Lin, Qi Li, Zheng Zhang, Mingsheng Long, Han Hu.

This repo is an official implementation of "Negative Margin Matters: Understanding Margin in Few-shot Classification" on PyTorch.

Update on 2020/07/01

Our paper was accepted by ECCV 2020 as spotlight!

Introduction

This paper is initially described in arxiv, which introduces a negative margin loss to metric learning based few-shot learning methods. The negative margin loss significantly outperforms regular softmax loss, and achieves state-of-the-art accuracy on three standard few-shot classification benchmarks with few bells and whistles. These results are contrary to the common practice in the metric learning field, that the margin is zero or positive. To understand why the negative margin loss performs well for the few-shot classification, the authors analyze the discriminability of learned features w.r.t different margins for training and novel classes, both empirically and theoretically. They find that although negative margin reduces the feature discriminability for training classes, it may also avoid falsely mapping samples of the same novel class to multiple peaks or clusters, and thus benefit the discrimination of novel classes.

Citation

@article{liu2020negative,
  title={Negative Margin Matters: Understanding Margin in Few-shot Classification},
  author={Liu, Bin and Cao, Yue and Lin, Yutong and Li, Qi and Zhang, Zheng and Long, Mingsheng and Hu, Han},
  journal={arXiv preprint arXiv:2003.12060},
  year={2020}
}

Main Results

The few-shot classification accuracy on the novel classes with ResNet-18 as the backbone is listed bellowing:.

Method Mini-ImageNet
1 - shot
Mini-ImageNet
5 - shot
CUB
1 - shot
CUB
5 - shot
Mini-ImageNet -> CUB
5-shot
Softmax 51.75+-0.80 74.27+-0.63 65.51+-0.87 82.85+-0.55 65.57+-0.70
Cosine 51.87+-0.77 75.68+-0.63 67.02+-0.90 83.58+-0.54 62.04+-0.76
Neg-Sofmax 59.02+-0.81 78.80+-0.61 71.48+-0.83 87.30+-0.48 69.30+-0.73
Neg-Cosine 62.33+-0.82 80.94+-0.59 72.66+-0.85 89.40+-0.43 67.03+-0.76

You can download the pre-trained model checkpoints of resnet-18 from OneDrive.

Getting started

Environment

  • Anaconda with python >= 3.6
  • pytorch=1.2.0, torchvison, cuda=9.2
  • others: pip install yacs

Datasets

CUB

  • Change directory to ./data/CUB
  • run bash ./download_CUB.sh

mini-ImageNet

  • Change directory to ./data/miniImagenet
  • run bash ./download_miniImagenet.sh

(WARNING: This would download the 155G ImageNet dataset. You can comment out correponded line 5-6 in download_miniImagenet.sh if you already have one.)

mini-ImageNet->CUB

  • Finish preparation for CUB and mini-ImageNet and you are done!

Train and eval

Run the following commands to train and evaluate:

python main.py --config [CONFIGFILENAME] \
    --supp [SUPPLEMENTSTRING] \
    method.backbone [BACKBONE] \
    method.image_size [IMAGESIZE] \
    method.metric_params.margin [MARGIN] \
    [OPTIONARG]

For additional options, please refer to ./lib/config.py.

We have also provided some scripts to reproduce the results in the paper. Pleas check ./script for details.

References

Our testbed builds upon several existing publicly available code. Specifically, we have modified and integrated the following code into this project:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].