pytorch-semantic-segmentation icon indicating copy to clipboard operation
pytorch-semantic-segmentation copied to clipboard

Loss Layer

Open herleeyandi opened this issue 7 years ago • 3 comments
trafficstars

Hello I still confuse here, for example what is our model output size and mask size. Suppose :

size = [batch, channel, height, width]
batch = 8
height = 96
width = 160
number of class = 2
model output = [8, 2, 96, 160] -> channel = 2 because class = 2
mask = [8, 1, 96, 160] -> channel = 1, which consist of 0 and 1 pixel value

How did you do this with CrossEntrophy2D?

herleeyandi avatar Dec 16 '17 17:12 herleeyandi

Turn the mask into a 2-channel one (one channel for foreground class and another channel for background class). Or just use sigmod + BCELoss2D.

zijundeng avatar Dec 17 '17 03:12 zijundeng

So you means the mask is in one hot encoding form?, then how to do BCELoss2D?, I just see your code in CrossEntrophy2D you use nn.nllloss2D, if I am using BCELoss2D, should I use log_softmax after the BCELoss?, and for your CrossEntrophy2D why it not use sigmoid before nn.nllloss2D?

herleeyandi avatar Dec 17 '17 08:12 herleeyandi

Yes, one hot encoding form. BCELoss can be used for any shape of data, which means you do not need to write an extra one.

zijundeng avatar Dec 27 '17 02:12 zijundeng