Hi Shakeel!



 shakeel608:

weight tensor is
cl_wts = 1./torch.tensor([5., 3.]) = tensor([0.2, 0.333])


Why are you multiplying samples with label =1 by 0.333


I’m just using the weight tensor you specified.


(Doesn’t this mean we are giving it more importance , since it is already higher than other class.  Shouldn’t we multiply the samples with lower class with more weights [in our case 0.333 is more and it should be multiplied to lower class and 0.2 for higher class] )


Yes, this would be the typical approach.  Note, however, I wouldn’t
reweight a batch of size 8 with the counts of the classes in that batch.
I would typically weight my classes based on the (approximate) class
counts in my whole training set (and I wouldn’t bother reweighting
unless the classes were much more imbalanced than 5-to-3).


One more thing when i pass the weights
tensor([0.2, 0.333])

does it work like the class_0 will get weight 0.2 and class_1 will get 0.333 and so on ??


Yes, that is correct.  That is what I meant when I said that “you mixed
up your class-0 and class-1 weights.”
Best.
K. Frank