-
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
Cannot obtain the accuracy stated in the doc for inception_v3 pretrained on Imagenet #6066
Comments
@m-parchami I'd recommend using the torchvision training references to check the accuracy of a given model - that's what they use to report accuracies - https://github.com/pytorch/vision/tree/main/references/classification#inception-v3 Various things can affect the results. Obviously slight differences in the code, but also batch size, shuffling, some samples potentially being dropped or duplicated depending on the number of GPUs, the use of CUDA determinism, etc... |
Thanks @NicolasHug for moving it to the right place and not just closing it :) Sorry for the inconvenience. Regarding your comment, I assumed that by running I appreciate it if you or anyone else can elaborate on how the model can give different results while both the model and the loader are obtained directly from PyTorch itself. Also, the transforms were directly copied from the documents. I also noticed this inconsistency even within the Pytorch's documentation. Here, the accuracy of the model is stated as |
Good catch, thanks. In general, the torchhub docs might be trailing a bit. You'll find the latest accuracies here: https://pytorch.org/vision/main/models.html (soon to be https://pytorch.org/vision/stable/models.html).
You're right, but still different batch sizes can lead to slightly different computations (regardless of batchnorm or dropout, or anything else).
CUDA and pytorch determinism affect the model during training but also during eval. You'll find more details here https://pytorch.org/docs/stable/notes/randomness.html. This is why we recommend using our scripts with the
Another slight discrepancy is that you used |
Thank you for being so thorough. So by just fixing the Can I send a PR (to hub repo) for this to save everyone's time? I'll fix it both on the hub's webpage and the corresponding colab notebook. |
Actually, I think the documentation on TorchHub needs to change to use the new Multi-weight support API. Instead of manually preprocessing the weights and getting into problems, this should be done using the transforms attached to the weights. Here is an example on the docs. Probably we want to merge such a PR after the upcoming release though because that's a new API. |
yes this is tracked in pytorch/hub#287 |
Hi.
I'm trying to evaluate
inception_v3
pretrained model from the hub on Imagenet (ILSVRC 2012) test set. I use the following evaluation code:However, the accuracy I get is
77.216
while it should be77.45
according to this page. I figured that the model has a transform_input as preprocess in itself. So if we are doing normalization beforehand (as suggested in the example code), we should settransform_input
to false. So if I addself.model.transform_input = False
, I get77.472
, Which is closer to the expected value but not exactly the same.Assuming that the issue isn't from my code, I also found the thread on
std
,mean
values (#1439). So I tested some of the values suggested there as well, and got these results:I appreciate any input on this.
Thanks.
The text was updated successfully, but these errors were encountered: