for i, (data, label) in data_gen:
data = data.to(device)
label = label.to(device)
outputs = model_ft(data)
_, preds = torch.max(outputs, 1)
for t, p in zip(label.view(-1), preds.view(-1)):
print(t, p)
confusion_matrix[t.long(), p.long()] += 1
Error message is
‘torch.FloatTensor’ object has no attribute ‘to’
It would be great to test your code without using to method.
I still do not know which line causes this problem. Actually it should not bother you to convert your tensors to GPU because you are getting your items from Dataset class and they are by default on CPU. Or you have some codes somewhere which overrides these rules.
.to() was introduces in PyTorch 0.4.0 if I’m not mistaken.
If you’re using an older version, you might want to update to the latest release.
You can find the instructions here.
Yes, many things changed with 0.4.0 and 1.0.0 as well. I would create a new virtualenv, make a copy of the code (or commit everything before making changes), and just deal with the errors as they come when running your code…