ptrblck:

ification (only one valid class per pixel) and use nn.CrossEntropyLoss


I got a binary segmentation problem working but am now modifying to be multi-class, labels[0,1,2…8]. I changed my loss function to crossentropyloss (previously BCEwithlogicloss), however I am now seeing error:
File “/home/user/miniconda3/envs/3dunet/lib/python3.7/site-packages/torch/nn/functional.py”, line 1848, in nll_loss
out_size, target.size()))
ValueError: Expected target size (2, 80, 160, 160), got torch.Size([2, 1, 80, 160, 160])
I am not sure where this extra dimension would be coming from, I also had to change the output of my network to 9 channels (C+1) as it was only 1 for the binary seg.
Any ideas? Thanks,
Kyle