Closed whuchris closed 4 years ago
@ChrisNieo input
to forward
of MulticlassDiceLoss
should be the output of the CNN before softmax. target
should be before one-hot convertion.
Please take a look at the code: https://github.com/huangmozhilv/u2net_torch/blob/a1e43b85a2c7bc4a468f0eccc0403b87b08e9a2e/u2net_torch_src/loss/dice_loss.py#L35
Sorry to bother, i've used dice_loss function to train my 3d models, but the loss value has always been negative. i've tried many methods but it didn't work. My outputs is like [batchsize, class_nums, depth, width, height],where class_nums = 3 and I have coded the label one-hot, so the label is also like [batchsize, class_nums, depth, width, height]. I want to know how to use the loss function. Thank you very much! : ). By the way, I commented this line of code in dice_loss.py "target = one_hot(target, num_class)",because i've preprocess the label one-hot. I use pytorch 1.2.0.