I am trying to build a classifier which should be trained with the cross entropy loss. The training data is highly class-imbalanced. To tackle this, I've gone through the advice of the tensorflow docs
and now I am using a weighted cross entropy loss where the weights are calculated as
weight_for_class_a = (1 / samples_for_class_a) * total_number_of_samples/number_of_classes
following the mentioned tutorial.
It works perfectly, but why is there this factor total_number_of_samples/number_of_classes
?
The mentioned tutorial says this
[...] helps keep the loss to a similar magnitude.
But I don not understand why. Can someone clarify?