-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Description
I met this error:
File "./train.py", line 162, in rcnn_build_loss
cross_entropy = F.cross_entropy(score, label)
File "/home/acgtyrant/Projects/faster_rcnn_pytorch/.env/lib/python3.5/site-packages/torch/nn/functional.py", line 533, in cross_entropy
return nll_loss(log_softmax(input), target, weight, size_average)
File "/home/acgtyrant/Projects/faster_rcnn_pytorch/.env/lib/python3.5/site-packages/torch/nn/functional.py", line 501, in nll_loss
return f(input, target)
File "/home/acgtyrant/Projects/faster_rcnn_pytorch/.env/lib/python3.5/site-packages/torch/nn/_functions/thnn/auto.py", line 41, in forward
output, *self.additional_args)
TypeError: CudaClassNLLCriterion_updateOutput received an invalid combination of arguments - got (int, torch.cuda.FloatTensor, torch.cuda.IntTensor, torch.cuda.FloatTensor, bool, NoneType, torch.cuda.FloatTensor),
but expected (int state, torch.cuda.FloatTensor input, torch.cuda.LongTensor target, torch.cuda.FloatTensor output, bool sizeAverage, [torch.cuda.FloatTensor weights or None], torch.cuda.FloatTensor total_weight)
It note that the cross_entropy function only accept a LongTensor variable. By the way, torch.max(input, dim, keepdim=True, max=None, max_indices=None) returns (Tensor, LongTensor) too, so my prediction is LongTensor which produced in my program. I can not compare it with the labels which is IntTensor type. In other words, labels = IntTensor(1); prediction = score.data.max(1); prediction.eq(labels) reports errors.
It is not coordinating with the dynamic Python. I do not know if this is a drawback, in other words, is there any plan to improve these functions so dynamic/flexible?
Metadata
Metadata
Assignees
Labels
No labels