Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(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' #68

Closed
unclejokerjoker opened this issue Jan 8, 2019 · 7 comments

Comments

@unclejokerjoker
Copy link

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.

@unclejokerjoker
Copy link
Author

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

@unclejokerjoker unclejokerjoker changed the title raise ValueError(reduction + " is not a valid value for reduction") 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' raise ValueError(reduction + " is not a valid value for reduction") 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' Jan 8, 2019
@unclejokerjoker unclejokerjoker changed the title raise ValueError(reduction + " is not a valid value for reduction") 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' (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' Jan 8, 2019
@bearpaw
Copy link
Owner

bearpaw commented Jan 8, 2019

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.

@unclejokerjoker
Copy link
Author

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?

@bearpaw
Copy link
Owner

bearpaw commented Jan 9, 2019

Can you put the whole runtime error info here?

@unclejokerjoker
Copy link
Author

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'

@bearpaw
Copy link
Owner

bearpaw commented Jan 15, 2019

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?

@bearpaw
Copy link
Owner

bearpaw commented Feb 28, 2019

Close because of no further discussion.

@bearpaw bearpaw closed this as completed Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants