Im trying to run U-Net. My data set has 3 classes (2 classes + background) so I made the mask which contains class indices for each pixel like [[0,1,2,1,2,0,...,1],[0,1,1,0,0,...,1]...[0,1,1,0,1,...,2]]. The mask shape is (512,512), and class indices are 0, 1, 2 (0 for background). But I wonder how the model works! My model(U-Net)s input channel is 1 (gray image), and output is 3 channels.
I have no idea which loss function do i need to use? why?
And if the answer is CrossEntropyLoss, how does it work despite output channel is 3, mask channel is 1.
Please god help me.
(Or did i do something wrong?)