I made those changes, but I found a new error.
Lets say 66 is the class number and feature maps where 8x8 = 64
after modifying the predictions and GTs I have:
input and target.
print(input.type())
print(target.type())
print(input.size())
print(target.size())
torch.cuda.FloatTensor
torch.FloatTensor
torch.Size([64, 66])
torch.Size([64, 66])
So I read a couple of other posts and realized that I should convert it to LongTensor.
target =target.type(torch.LongTensor).cuda()
print(input.type())
print(target.type())
print(input.size())
print(target.size())
torch.cuda.FloatTensor
torch.cuda.LongTensor
torch.Size([64, 66])
torch.Size([64, 66])
but still when i want to compute the loss i face this:
loss = F.cross_entropy(input, target)
RuntimeError Traceback (most recent call last)
in ()
24 print(input.size())
25 print(target.size())
—> 26 loss = F.cross_entropy(input, target)
27
~/anaconda3/lib/python3.6/site-packages/torch/nn/functional.py in cross_entropy(input, target, weight, size_average, ignore_index, reduce)
1440 >>> loss.backward()
1441 “”"
→ 1442 return nll_loss(log_softmax(input, 1), target, weight, size_average, ignore_index, reduce)
1443
1444
~/anaconda3/lib/python3.6/site-packages/torch/nn/functional.py in nll_loss(input, target, weight, size_average, ignore_index, reduce)
1330 .format(input.size(0), target.size(0)))
1331 if dim == 2:
→ 1332 return torch._C._nn.nll_loss(input, target, weight, size_average, ignore_index, reduce)
1333 elif dim == 4:
1334 return torch._C._nn.nll_loss2d(input, target, weight, size_average, ignore_index, reduce)
RuntimeError: multi-target not supported at /opt/conda/conda-bld/pytorch_1524586445097/work/aten/src/THCUNN/generic/ClassNLLCriterion.cu:16
Can you please let me know if you have any suggestion in this regard…