Hi Rishav!



 Rishav_Sapahia:

The problem I am facing is to pass custom weight as an argument to CrossEntropyLoss, I have to pass masks as an argument like the the following method-
criterion = torch.nn.CrossEntropyLoss(make_weight_map(mask))
which I guess is not the right way. I haven’t approached such kind of problem earlier so pretty clueless right now


I’m not clear on what you are asking.
Do you want the contribution of a given prediction-target
pair to the loss to have a weight that depends (solely) on
the class of the target?
If so, I believe that the weight argument of CrossEntropyLoss
does what you want.
If this isn’t the case, could you write out a simple equation that
shows what you want the loss to be and how your “weights”
enter into it?
You make it sound like the weight argument doesn’t do what
you want, but you don’t say why.  If you could explain how
weight doesn’t work, that might help make clear what it is
you want to achieve.
Best.
K. Frank