Hi Entropy!



 Entropy:

on average ~5587 pixels belonged to the primary background class, ~802 pixels belonged to the secondary background class, and ~11 pixels belonged to the third class (which again, can be any one of the nine special classes).
Obviously, this is a very unbalanced dataset, so I was thinking about using weighted cross-entropy loss as my criterion. How should I go about choosing these weights?


The conventional wisdom suggests that you should weight each
class inversely to the number of samples (pixels) in that class.
Now your “third class” is actually nine “special classes.”  Let’s
assume (since you don’t give the numbers) that those “special
classes” all appear about equally often in your data.
Then I would weight your eleven actual classes as follows:
primary background: 6400 / 5587
secondary background:  6400 / 802
third class - 1:  9 * 6400 / 11
third class - 2:  9 * 6400 / 11
…
third class - 9:  9 * 6400 / 11
(Of course, if your nine “special classes” don’t occur about equally
often, you would not want to weight them all the same, but rather in
inverse proportion to how frequently they occur.)
Lastly, the exact values of these weights shouldn’t really matter.  You
just need them to be approximately right to smooth out the significant
imbalance among classes in your dataset.
Best.
K. Frank