Hi Talha!



 talhaanwarch:

Shouldnot it be 60 class encoding in all batches?


Yes, you should encode all 60 classes for all of your batches even
if some batches don’t happen to have all 60 classes in them.
To expand on this a little:  Your network architecture will have the
60 classes built into it (at least in standard approaches).  Let’s say
that we label your 60 classes with the integers 0, …, 59.  Now let’s
say that a particular batch happens to have only three classes in it,
specifically 3, 27, and 45.  If you were to label this batch with, say, 0,
1, and 2, so that you gave class-27 the label 1, your network wouldn’t
know what that meant.
As an aside, whether you use one-hot encoding or something else
to label your classes is irrelevant to this question – you need all 60
either way.  Having said that, you shouldn’t be using one-hot encoding.
Semantic segmentation is a classification problem (You classify
individual pixels.), so you would most typically use some version
of a cross-entropy-like loss function.  Pytorch’s  cross-entropy loss
functions use integer categorical class labels (like I alluded to, above),
and don’t work with one-hot encoding.
(You should also be aware that people sometimes – mistakenly – use
the term “one hot” to refer class labels of any sort, even if they are
not actually one-hot encoded.  This, of course, can be confusing.)
Best.
K. Frank