Papers › Class-Balanced Loss Based on Effective Number of Samples

Class-Balanced Loss Based on Effective Number of Samples

16 Jan 2019CVPR 2019 6arXiv:1901.05555archive 2025-07-28

Yin Cui, Menglin Jia, Tsung-Yi Lin, Yang song, Serge Belongie

With the rapid increase of large-scale, real-world datasets, it becomes critical to address the problem of long-tailed data distribution (i.e., a few classes account for most of the data, while most classes are under-represented). Existing solutions typically adopt class re-balancing strategies such as re-sampling and re-weighting based on the number of observations for each class. In this work, we argue that as the number of samples increases, the additional benefit of a newly added data point will diminish. We introduce a novel theoretical framework to measure data overlap by associating with each sample a small neighboring region rather than a single point. The effective number of samples is defined as the volume of samples and can be calculated by a simple formula (1-βⁿ)/(1-β), where n is the number of samples and β∈[0,1) is a hyperparameter. We design a re-weighting scheme that uses the effective number of samples for each class to re-balance the loss, thereby yielding a class-balanced loss. Comprehensive experiments are conducted on artificially induced long-tailed CIFAR datasets and large-scale datasets including ImageNet and iNaturalist. Our results show that when trained with the proposed class-balanced loss, the network is able to achieve significant performance gains on long-tailed datasets.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="1901.05555")

Code

Syntology Ran 7 of 27 code samples harvested from 6 repositories linked to this paper; 20 have no recorded run. Of those that ran: 2 ran · our draft was wrong; 5 ran with no contract checked.

By repository: official repository: 19 samples from 1 repository, 0 ran; community (archive-listed): 8 samples from 5 repositories, 7 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

richardaecn/class-balanced-loss officialmentioned in papermentioned on GitHubtfMIT report
bazinga699/ncl mentioned on GitHubpytorch report
feidfoe/AdjustBnd4Imbalance mentioned on GitHubpytorch report
frgfm/Holocron mentioned on GitHubpytorch report
lijian16/fcc mentioned on GitHubpytorchMIT report
statsu1990/yoto_class_balanced_loss mentioned on GitHubpytorch report
tiagoCuervo/JapaNet mentioned on GitHubtf report
vandit15/Class-balanced-loss-pytorch mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

27 samples harvested; 7 ran; 0 honoured the contract we drafted; 20 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran · our draft was wrong
5ran
20unverified

Licence: 0 of the 27 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 6 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

convert_array_to_image richardaecn/class-balanced-loss/tpu/models/experimental/dcgan/cifar_input.py official repository unverified MIT (permissive) · 44a9936773ea082c · report
dir2version richardaecn/class-balanced-loss/src/cifar_main.py official repository unverified MIT (permissive) · 90a8002ad4ce5c44 · report
discriminator richardaecn/class-balanced-loss/tpu/models/experimental/dcgan/cifar_model.py official repository unverified MIT (permissive) · 59ec4e09ac2ce079 · report
generate_input_fn richardaecn/class-balanced-loss/tpu/models/experimental/dcgan/dcgan_main.py official repository unverified MIT (permissive) · 787ada018be76773 · report
generator richardaecn/class-balanced-loss/tpu/models/experimental/dcgan/cifar_model.py official repository unverified MIT (permissive) · 6bfcb692805e9db9 · report
get_imbalanced_data richardaecn/class-balanced-loss/src/generate_cifar_tfrecords_im.py official repository unverified MIT (permissive) · ea12a62c609bc291 · report
get_traindata_list richardaecn/class-balanced-loss/src/generate_cifar_tfrecords_im.py official repository unverified MIT (permissive) · 306ffaa84f8da0c6 · report
img_num richardaecn/class-balanced-loss/src/data_utils.py official repository unverified MIT (permissive) · 4f59b56fcbea8270 · report
input_fn richardaecn/class-balanced-loss/tpu/models/experimental/cifar_keras/cifar_keras.py official repository unverified MIT (permissive) · 57184f395fe4ff8f · report
learning_rate_schedule richardaecn/class-balanced-loss/src/cifar_main.py official repository unverified MIT (permissive) · 10fc348fea580bf2 · report
local_device_setter richardaecn/class-balanced-loss/src/cifar_utils.py official repository unverified MIT (permissive) · 667cea6bb6608b7b · report
model_fn richardaecn/class-balanced-loss/tpu/models/experimental/cifar_keras/cifar_keras.py official repository unverified MIT (permissive) · a8d0a5e19105636a · report
model_fn richardaecn/class-balanced-loss/tpu/models/experimental/dcgan/dcgan_main.py official repository unverified MIT (permissive) · 7634c2c31837e3f5 · report
noise_input_fn richardaecn/class-balanced-loss/tpu/models/experimental/dcgan/dcgan_main.py official repository unverified MIT (permissive) · f3d3946d06874d2a · report
parser richardaecn/class-balanced-loss/tpu/models/experimental/dcgan/cifar_input.py official repository unverified MIT (permissive) · 1863a653dad9ca35 · report
read_json richardaecn/class-balanced-loss/src/data_utils.py official repository unverified MIT (permissive) · 35ae8c0dce858108 · report
read_pickle_from_file richardaecn/class-balanced-loss/src/data_utils.py official repository unverified MIT (permissive) · 162b6ba3306530cc · report
read_pickle_from_file richardaecn/class-balanced-loss/src/generate_cifar_tfrecords.py official repository unverified MIT (permissive) · 7137e8ae47a966ce · report
sort_input richardaecn/class-balanced-loss/src/generate_cifar_tfrecords_im.py official repository unverified MIT (permissive) · c20afab5ec1e1d08 · report
CB_loss vandit15/Class-balanced-loss-pytorch/class_balanced_loss.py community (archive-listed) ran · our draft was wrong MIT (permissive) · 213dab5ee3c9a730 · report
ClassBalanceCE lijian16/fcc/lib/loss/loss_impl/class_balanced_loss.py community (archive-listed) ran fingerprinted MIT (permissive) · 749ae093d1002dc8 · report
ClassBalancedWrapper frgfm/Holocron/holocron/nn/modules/loss.py community (archive-listed) ran · metamorphic tier: invariant Apache-2.0 (permissive) · fa48de5142876479 · report
ClassBalanced_CELoss statsu1990/yoto_class_balanced_loss/src/model/cb_loss.py community (archive-listed) ran MIT (permissive) · 68d1f62eac95f880 · report
CrossEntropy lijian16/fcc/lib/loss/loss_impl/class_balanced_loss.py community (archive-listed) ran MIT (permissive) · 03ec3d933bc9e286 · report
NBOD bazinga699/ncl/lib/loss/loss.py community (archive-listed) ran · our draft was wrong BSD-2-Clause (permissive) · e4d180e212ea7092 · report
NIL_NBOD bazinga699/ncl/lib/loss/loss.py community (archive-listed) ran BSD-2-Clause (permissive) · 49b09b16b775ec58 · report
focal_loss vandit15/Class-balanced-loss-pytorch/class_balanced_loss.py community (archive-listed) unverified MIT (permissive) · c32ccdb4e101c470 · report

Tasks

Image ClassificationLong-tail Learning

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Image Classification iNaturalist 2018 ResNet-152 Top-1 Accuracy 69.05% #41 of 60 Archive leaderboard report
Image Classification iNaturalist 2018 ResNet-101 Top-1 Accuracy 67.98% #44 of 60 Archive leaderboard report
Image Classification iNaturalist 2018 ResNet-50 Top-1 Accuracy 64.16% #52 of 60 Archive leaderboard report
Long-tail Learning CIFAR-10-LT (ρ=10) Class-balanced Focal Loss Error Rate 12.90 #45 of 50 Archive leaderboard report
Long-tail Learning CIFAR-10-LT (ρ=10) Class-balanced Reweighting Error Rate 13.46 #48 of 50 Archive leaderboard report
Long-tail Learning CIFAR-100-LT (ρ=100) Cross-Entropy (CE) Error Rate 61.68 #65 of 66 Archive leaderboard report
Long-tail Learning COCO-MLT CB Loss(ResNet-50) Average mAP 49.06 #9 of 13 Archive leaderboard report
Long-tail Learning EGTEA CB Loss Average Precision 63.39 #2 of 3 Archive leaderboard report
Long-tail Learning EGTEA CB Loss Average Recall 63.26 #2 of 3 Archive leaderboard report
Long-tail Learning VOC-MLT CB Focal(ResNet-50) Average mAP 75.24 #9 of 13 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections