henry_Kang:

Because I read some article and they said I have to use one hot encoding for cross entropy loss.
[…]
Do you think I should change the my mask as 5 channel with 0 and 1? Or should my model output is the 5 channels, because 0 is background.


Nom you shouldn’t use one-hot encoded target tensors for nn.CrossEntropyLoss, as it expects a model output in the shape [batch_size, nb_classes, height, width] and a target tensor in the shape of [batch_size, height, width] containing the class indices in the range [0, nb_classes-1] for a multi-class segmentation use case.



 henry_Kang:

Or should my model output is the 5 channels, because 0 is background.


For 4 valid classes + a background class, the number of classes should be 5.



 henry_Kang:

Also I am not sure that what is class mapping?


A class mapping might be a method which maps the different discrete color codes from the target image to a class index, e.g. red -> class0, green -> class1, blue -> class2, pink -> class3, …