Target label images categorical single channel or one hot encoded multichannel

Working on a segmentation problem, converting single channel categorial coded image label to one hot encoded form in the data loader is taking considerable runtime,

does it make sense to create a one hot encoded label dataset?

→ How to save single channel label image as png with multichannel one hot encoded form?

Hi Srinath!

In general, I don’t think using one-hot encoding with pytorch makes

I’ve never been able to think of a non-contrived use case (other than
if you’re working with preexisting one-hot encoded data that you don’t
want to bother transforming or with preexisting code that uses one-hot
encoding that you don’t want to modify) where one-hot encoding would
be preferred.

Pytorch’s workhorse loss criterion for classification problems,
CrossEntropyLoss, expects categorical integer class labels as its
target, so that’s the straightforward choice when using pytorch.


K. Frank

1 Like