Class-Balanced Loss Based on Effective Number of Samples

Yin Cui, Menglin Jia, Tsung-Yi Lin, Yang Song, Serge Belongie · CVPR 2019 · 2019

In one paragraph

Inverse-frequency weights 1/n_y over-correct because the 1000th photo of a cat adds less than the first. The paper models each sample as covering a small region of the space; a new sample is “new” with probability \beta^{\,n-1} (the chance it lands outside the already-covered part). The effective number is then E_n=\sum_{j=1}^{n}\beta^{j-1}=\frac{1-\beta^n}{1-\beta}, and the class-balanced loss weights class y by 1/E_{n_y}, normalised to sum to the number of classes.

The one derivation

E_n=E_{n-1}+\beta^{n-1}, i.e. E_n=1+\beta E_{n-1} (checked in checks.py). Limits: \beta\to0 gives E_n=1 for every class (no reweighting); \beta\to1 gives E_n\to n (inverse frequency). With counts 5000/500/50 the normalised weights are (0.998,\,0.998,\,1.003) at \beta=0.9, (0.66,\,0.67,\,1.67) at 0.99, (0.13,\,0.32,\,2.56) at 0.999 and (0.03,\,0.28,\,2.69) at 0.9999. So \beta interpolates between “off” and “inverse frequency”, and a tail class is capped at roughly 1/E_\infty=1-\beta times a head class.

Questions and doubts

Takeaways