Hi Ben!



 benkolber:

Given that I have much more background pixels than classes, I would initialize cross entropy loss as:
criterion = nn.CrossEntropyLoss(weight = tensor([0.3, 1, 1, 1])  to reduce the weight value of the background?


This could be reasonable.  You are weighting each of the foreground
pixels equally, and weighting the background pixels about one third as
much as any one foreground class.
So this would make sense if each of your three foreground classes
appeared about equally often, and each of your foreground classes
individually appeared about one third as often as your background
class.
The typical advice is to weight your classes in about inverse proportion
to their frequency of occurrence.
Having said that, a three-to-one difference in frequency of occurrence
doesn’t strike me as being highly unbalanced.  In such a case I might
expect using class weights to help at the margins, but I doubt doing so
would be a game changer.
Best.
K. Frank