-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Small discrepancy in accuracy & Some results of pretrained classifiers are missing in doc #3152
Comments
@yoshitomo-matsubara Thanks a lot for reporting! Given that the discrepancies are very small, it's unclear whether this is the result of changes in the code or differences on our setup (GPU count, ImageNet copy etc) between our infra and yours. I'll leave the ticket open, so that we can reproduce the numbers on our side and confirm. |
Sure. Just FYI, I used only one GPU and ILSVRC 2012 (validation dataset) to get the above numbers. |
Hi, I also suffer this problem recently.
import torch
import torch.cuda
import torch.utils.data
import torchvision
import torchvision.transforms
root='./data/' # Need to modify
transform = torchvision.transforms.Compose([
torchvision.transforms.Resize(256),
torchvision.transforms.CenterCrop(224),
torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
dataset = torchvision.datasets.ImageNet(root=root, split='val', transform=transform)
dataloader = torch.utils.data.DataLoader(dataset, batch_size=128, pin_memory=True, num_workers=8)
model = torchvision.models.resnet.resnet18(pretrained=True)
model.cuda()
model.eval()
correct = 0
total = 0
for _input, _target in dataloader:
_input = _input.to(device='cuda', non_blocking=True)
_target = _target.to(device='cuda', non_blocking=True)
_output = model(_input)
correct += int((_output.argmax(1) == _target).int().sum())
total += int(_target.size(0))
print(correct / total)
|
Hi @ain-soph , My best guess from your sample code is that the small accuracy difference between yours and mine is caused by ‘Resize(256, 256)‘ as long as you're using ILSVRC 2012 dataset. ‘Resize(256)‘ in example code should not be equal to ‘Resize(256, 256)‘ in your sample code according to https://pytorch.org/docs/stable/torchvision/transforms.html#torchvision.transforms.Resize |
You are certainly correct! I just validate that. Thanks a lot and happy new year! I think the docs may be already out-of-date? Even though I don't know what things have changed. I've tested multiple settings, including multiple GPUs with |
Hi @datumbox
|
@yoshitomo-matsubara Sorry I did not have time to check this. I'll try to run the too missing models ShuffleNet V2 (x0.5) and MNASNet 0.5 soon. Could you let me know which of the other models that seem incorrect has the biggest discrepancy? |
@datumbox Thank you for the response!
|
@yoshitomo-matsubara Thanks for flagging. I confirmed that there are some discrepancies of the numbers. Especially for DenseNet the reason was that the model was trained with Torch-Lua and later ported to PyTorch (see #116). I've rerun the inference for all the models and you can see the numbers at #3360. Let me know if you see any other issues. |
Thank you @datumbox for reruning inference for all the models and updating the doc! |
📚 Documentation
With torch==1.7.0 and torchvision==0.8.1, I found
Environment
I used
pipenv run python train.py --test-only --pretrained --model ${model} --data-path /home/yoshitom/dataset/ilsvrc2012/ -b 32
to get accuracy of pretrained models.For Inception v3, the following change is made on train.py as specified in README.md. as part of
commit aa753263b8e7b3180225e3ad1e6e5434a5f42882
The text was updated successfully, but these errors were encountered: