torch.cuda.floatTensor type and torch.floatTensor

i have encountered the following error:

gradient = torch.ge(inputs.grad.data,0)
File “/Users/liangshiyu/anaconda2/lib/python2.7/site-packages/torch/tensor.py”, line 331, in sub
return self.sub(other)
TypeError: sub received an invalid combination of arguments - got (torch.cuda.FloatTensor), but expected one of:

  • (float value)
    didn’t match because some of the arguments have invalid types: (torch.cuda.FloatTensor)
  • (torch.FloatTensor other)
    didn’t match because some of the arguments have invalid types: (torch.cuda.FloatTensor)
  • (float value, torch.FloatTensor other)

Could you try:

gradient = torch.ge(inputs.grad.data, 0.0)

Problem solved, thanks. Here is another problem, how do convert a torch.cuda.floatTensor type tensor to a torch.floatTensor. Thanks.

Just do tensor.cpu()

Thanks a lot!!!