bearpaw/pytorch-pose

(1)raise ValueError(reduction + " is not a valid value for reduction") (2)dists[c, n] = torch.dist(preds[n,c,:], target[n,c,:])/normalize[n] RuntimeError: Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor for argument #2 'other'

Closed this issue · 7 comments

There are two bugs in the latest repo updated on Jan 8th,2019.The first one is as the title described.I think it is caused by the pytorch version 0.4.1 vs 1.0 .
I solved this problem by changing the param of the torch.nn.MSELoss() to 'size_average=True'

The second bug is :
'dists[c, n] = torch.dist(preds[n,c,:], target[n,c,:])/normalize[n]
RuntimeError: Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor for argument #2 'other''
It is caused by the type of the variable.I solved it by changing the type of variable 'target' from cuda() to cpu data.

Specifically for bug 2,in the training phase,whencomputing the accuracy,we should ensure the variables are of the same type.

Yes. I think the problem is caused by 0.4.1.

Since size_average is deprecated, we won't support this argument in the future version. We suggest you to try to upgrade to pytorch 1.0 and see how everything is going.

Yes. I think the problem is caused by 0.4.1.

Since size_average is deprecated, we won't support this argument in the future version. We suggest you to try to upgrade to pytorch 1.0 and see how everything is going.

OK,thanks.BTW,did you notice the second problem?

Can you put the whole runtime error info here?

Can you put the whole runtime error info here?

Traceback (most recent call last):
File "example/mpii.py", line 351, in
main(parser.parse_args())
File "example/mpii.py", line 108, in main
train_loss, train_acc = train(train_loader, model, criterion, optimizer, args.debug, args.flip)
File "example/mpii.py", line 158, in train
acc = accuracy(output[0], target, idx)
File "/home/zhanghan/learning/hg/pytorch-pose-new/pose/utils/evaluation.py", line 59, in accuracy
dists = calc_dists(preds, gts, norm)
File "/home/zhanghan/learning/hg/pytorch-pose-new/pose/utils/evaluation.py", line 39, in calc_dists
dists[c, n] = torch.dist(preds[n,c,:], target[n,c,:])/normalize[n]
RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for argument #2 'other'

It's weird. I cannot reproduce the error. Also, we have already sent target to GPU, as in https://github.com/bearpaw/pytorch-pose/blob/master/example/mpii.py#L150

Did you use the latest update of this code?

Close because of no further discussion.