pytorch-semseg
pytorch-semseg copied to clipboard
RuntimeError: Expected object of type torch.FloatTensor but found type torch.LongTensor for argument #2 'exponent'
I want to train ade20k on pspnet i use your train_cnn, but it appears like this one
File "/home/victor/catkin_ws/src/semantic_slam/semantic_cloud/include/ptsemseg/loss.py", line 74, in multi_scale_cross_entropy2d scale_weight = torch.pow(scale * torch.ones(n_inp), torch.arange(n_inp)) RuntimeError: Expected object of type torch.FloatTensor but found type torch.LongTensor for argument #2 'exponent'
can anybody help me?
Hi, @victor123499 . Change 'exponent' tensor type to float:
scale_weight = torch.pow(scale * torch.ones(n_inp), torch.arange(n_inp).float())
and it still have the problem like this
RuntimeError: cuda runtime error (59) : device-side assert triggered at /pytorch/aten/src/THC/generated/../THCReduceAll.cuh:317
like this
File "train.py", line 173, in train loss = multi_scale_cross_entropy2d(input=outputs, target=labels, device = device) File "/home/victor/catkin_ws/src/semantic_slam/semantic_cloud/include/ptsemseg/loss.py", line 75, in multi_scale_cross_entropy2d loss = loss + scale_weight[i] * cross_entropy2d(input=inp, target=target, weight=weight, size_average=size_average) File "/home/victor/catkin_ws/src/semantic_slam/semantic_cloud/include/ptsemseg/loss.py", line 30, in cross_entropy2d weight=weight, size_average=False) File "/usr/local/lib/python2.7/dist-packages/torch/nn/functional.py", line 1332, in nll_loss return torch._C._nn.nll_loss(input, target, weight, size_average, ignore_index, reduce) RuntimeError: cuda runtime error (59) : device-side assert triggered at /pytorch/aten/src/THCUNN/generic/ClassNLLCriterion.cu:116
Maybe you can check whether your target labels are in the range [0, n_classes-1].
@adam9500370 i figure out this problem. Is my labels problem. Thank you.