AttributeError: 'builtin_function_or_method' object has no attribute 'cuda'

When I use features = torch.FloatTensor(1,512).zero_.cuda() in the python script, there is an error, why?

features = torch.zeros(1,512).cuda() is ok!

Hi,

.zero_ is a method not attribute. You need to call it using parentheses:

features = torch.FloatTensor(1,512).zero_().cuda()

Bests