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

.item #28

Open
LotusWhu opened this issue Jul 4, 2019 · 1 comment
Open

.item #28

LotusWhu opened this issue Jul 4, 2019 · 1 comment

Comments

@LotusWhu
Copy link

LotusWhu commented Jul 4, 2019

{'trade_off': 1.0, 'name': 'JAN'}
Traceback (most recent call last):
File "train.py", line 288, in
transfer_classification(config)
File "train.py", line 222, in transfer_classification
print image_classification_test(dset_loaders["target"], nn.Sequential(base_network, bottleneck_layer, classifier_layer), test_10crop=prep_dict["target"]["test_10crop"], gpu=use_gpu)
File "train.py", line 107, in image_classification_test
accuracy = torch.sum(torch.squeeze(predict).float() == all_label).item() / float(all_label.size()[0])
AttributeError: 'int' object has no attribute 'item'

when I remove the .item(), it works well, just wondering anyone meet the similar issue.

@sy565612345
Copy link
Collaborator

It may be an issue of different pytorch versions.
When you use lower versions, the result is an int so you should remove '.item()'.
But the same result may become a tensor in higher version, and you will need '.item()'.

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