#354 · Primary category: Computer Vision

Class-balanced-loss-pytorch

computer-vision cvpr2019 deep-learning loss-functions pytorch

Pytorch implementation of the paper "Class-Balanced Loss Based on Effective Number of Samples"

Project last updated:02/18/24

GitHub Stars

802

Forks

123

Contributors

1

License

MIT

Why we included this project

Class imbalance is a common headache when training classifiers, and this library tackles it at the loss level. It implements the CVPR 2019 class-balanced loss, which reweights each class by its effective number of samples instead of the raw count, so rare classes get a fairer share of the training signal. The whole thing is one self-contained PyTorch module with a small API, so you can drop it into an existing training loop without restructuring anything. That makes it a practical starting point for long-tail recognition, medical imaging, or any dataset where some classes are scarce. The author's Medium article walks through the math behind the loss, which helps before you commit to it.

Articles for this project

No articles for this project yet.

To suggest a topic or contribute an article, contact us.

Related projects in this category