Git Product home page Git Product logo

balancedmetasoftmax-classification's Introduction

BalancedMetaSoftmax - Classification

Code for the paper "Balanced Meta-Softmax for Long-Tailed Visual Recognition" on long-tailed visual recognition datasets.

Balanced Meta-Softmax for Long-Tailed Visual Recognition
Jiawei Ren, Cunjun Yu, Shunan Sheng, Xiao Ma, Haiyu Zhao, Shuai Yi, Hongsheng Li
NeurIPS 2020

Snapshot

def balanced_softmax_loss(labels, logits, sample_per_class, reduction):
    """Compute the Balanced Softmax Loss between `logits` and the ground truth `labels`.
    Args:
      labels: A int tensor of size [batch].
      logits: A float tensor of size [batch, no_of_classes].
      sample_per_class: A int tensor of size [no of classes].
      reduction: string. One of "none", "mean", "sum"
    Returns:
      loss: A float tensor. Balanced Softmax Loss.
    """
    spc = sample_per_class.type_as(logits)
    spc = spc.unsqueeze(0).expand(logits.shape[0], -1)
    logits = logits + spc.log()
    loss = F.cross_entropy(input=logits, target=labels, reduction=reduction)
    return loss

Requirements

Training

End-to-end Training

  • Base model (Representation Learning)
python main.py --cfg ./config/CIFAR10_LT/softmax_imba200.yaml

Alternatively, you may download a pretrained model here and put it in the corresponding log folder.

  • Balanced Softmax
python main.py --cfg ./config/CIFAR10_LT/balanced_softmax_imba200.yaml

Decoupled Training

After obataining the base model, train the classifier with the following command:

  • Balanced Softmax
python main.py --cfg ./config/CIFAR10_LT/decouple_balanced_softmax_imba200.yaml
  • BALMS
python main.py --cfg ./config/CIFAR10_LT/balms_imba200.yaml

Evaluation

Model evaluation can be done using the following command:

python main.py --cfg ./config/CIFAR10_LT/balms_imba200.yaml --test

Experiment Results

The results could be slightly different from the results reported in the paper, since we originally used an internal repository for the experiments in the paper.

Dataset Backbone Method Accuracy download
CIFAR-10 (IF 200) ResNet-32 Softmax 74.0 model | log
CIFAR-10 (IF 200) ResNet-32 Balanced Softmax (end-to-end) 79.8 model | log
CIFAR-10 (IF 200) ResNet-32 Balanced Softmax (decouple) 81.8 model | log
CIFAR-10 (IF 200) ResNet-32 BALMS 82.2 model | log
CIFAR-100 (IF 200) ResNet-32 Softmax 41.2 model | log
CIFAR-100 (IF 200) ResNet-32 Balanced Softmax (end-to-end) 46.7 model | log
CIFAR-100 (IF 200) ResNet-32 Balanced Softmax (decouple) 47.2 model | log
CIFAR-100 (IF 200) ResNet-32 BALMS 48.0 model | log
ImageNet-LT ResNet-10 Softmax 34.8 model | log
ImageNet-LT ResNet-10 BALMS 41.6 model | log
Places-LT ResNet-152 Softmax 30.2 model | log
Places-LT ResNet-152 BALMS 38.3 model | log

Cite BALMS

@inproceedings{
    Ren2020balms,
    title={Balanced Meta-Softmax for Long-Tailed Visual Recognition},
    author={Jiawei Ren and Cunjun Yu and Shunan Sheng and Xiao Ma and Haiyu Zhao and Shuai Yi and Hongsheng Li},
    booktitle={Proceedings of Neural Information Processing Systems(NeurIPS)},
    month = {Dec},
    year={2020}
}

Instance Segmentation

For BALMS on instance segmentation, please try out this repo.

Reference

balancedmetasoftmax-classification's People

Contributors

jiawei-ren 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.