MSDN icon indicating copy to clipboard operation
MSDN copied to clipboard

RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.cuda.LongTensor for argument #2 'other'

Open TP0609 opened this issue 5 years ago • 0 comments

Hello, yikang-li! when I runing: CUDA_VISIBLE_DEVICES=0 python train_rpn.py,I get this error:

/home/tp/MSDN-master/faster_rcnn/RPN.py:140: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument. rpn_cls_prob = F.softmax(rpn_cls_score_reshape) /home/tp/.local/lib/python2.7/site-packages/torch/nn/functional.py:52: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead. warnings.warn(warning.format(ret)) Traceback (most recent call last): File "train_rpn.py", line 194, in main() File "train_rpn.py", line 73, in main train(train_loader, net, optimizer, epoch) File "train_rpn.py", line 117, in train target_net(im_data, im_info.numpy(), gt_objects.numpy()[0], gt_regions.numpy()[0]) File "/home/tp/.local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, **kwargs) File "/home/tp/MSDN-master/faster_rcnn/RPN.py", line 182, in forward self.build_loss(rpn_cls_score_reshape, rpn_bbox_pred, rpn_data) File "/home/tp/MSDN-master/faster_rcnn/RPN.py", line 240, in build_loss rpn_loss_box = F.smooth_l1_loss(rpn_bbox_pred, rpn_bbox_targets, size_average=False) /(fg_cnt + 1e-4) RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.cuda.LongTensor for argument #2 'other'

How do I resolve this error? I use python2.7, cuda9.0 ,pytorch0.4.1

TP0609 avatar Dec 02 '19 12:12 TP0609