You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's review the theory of Class Balanced Loss:
First, the effective number of samples are calculated for all classes as:
Then the class balanced loss function is defined as:
where n_y is the number of samples in the ground-truth class y. In other words, when the number of class is N, the number of E_n is N. This means that each class has a weight. However, the weight is selected in your code.
This is your code:
This means that when the label is [1,0,0,0], loss of all categories should be multiplied by weight_1. Why not multiply by weight_1, weight_2, weight_3 and weight_4. That is, the loss of each category is multiplied by the corresponding weight.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Let's review the theory of Class Balanced Loss:
First, the effective number of samples are calculated for all classes as:
Then the class balanced loss function is defined as:
where n_y is the number of samples in the ground-truth class y. In other words, when the number of class is N, the number of E_n is N. This means that each class has a weight. However, the weight is selected in your code.
This is your code:
Suppose we have the following data and execute according to your code:
At this time, you can see the output weight:
The weight after executing your subsequent code is:
This means that when the label is
[1,0,0,0]
, loss of all categories should be multiplied by weight_1. Why not multiply by weight_1, weight_2, weight_3 and weight_4. That is, the loss of each category is multiplied by the corresponding weight.Beta Was this translation helpful? Give feedback.
All reactions