fyu/drn

NLLLoss cant work

cmdjzs opened this issue · 0 comments

hi,I meet some trouble while training on myself dataset which only have 3 classes.
environment is: Ubuntu 18.04; conda, cuda etc all is satisfied.
Please help,any advice is appreciate!thanks a lot.

Traceback (most recent call last):
File "segment1.py", line 734, in
main()
File "segment1.py", line 728, in main
train_seg(args)
File "segment1.py", line 418, in train_seg
validate(val_loader, model, criterion, eval_score=accuracy)
File "segment1.py", line 223, in validate
loss = criterion(output, target_var)
File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 726, in _call_impl
result = self.forward(*input, **kwargs)
File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/loss.py", line 212, in forward
return F.nll_loss(input, target, weight=self.weight, ignore_index=self.ignore_index, reduction=self.reduction)
File "/opt/conda/lib/python3.6/site-packages/torch/nn/functional.py", line 2243, in nll_loss
ret = torch._C._nn.nll_loss2d(input, target, weight, _Reduction.get_enum(reduction), ignore_index)
RuntimeError: 1only batches of spatial targets supported (3D tensors) but got targets of size: : [1, 3, 840, 840]