-
Notifications
You must be signed in to change notification settings - Fork 7.1k
[RFC] Use pretrained=True
to load the best available pre-trained weights
#5015
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
Comments
I like option 2 and is inline with common user experience. As long as we inform the user that we have upgraded the weights to reflect the latest ones and document how they could use the old weights if needed, this is the preferred approach. |
I lean towards option 1. The reason being that paper implementations don't generally get updated once they are released to the public. Reproducing research is fundamental, and option 2 provides a silent breakage in BC that can make reproducing the results of the paper not possible, without any warnings to the user of why (and raising warnings all the time is very annoying). In the same way, if a downstream user is on an older version of torchvision (say 0.11), and is pulling a repository which used torchvision 0.13 (with |
This is a complex problem, because both options have pros and cons: Option 1:
Option 2:
Honestly, I don't think it is the role of a toolkit to fix the lack of reproducibility or robustness of current research papers. Because there is no clear view of the time at which the option will be removed, I would vote for a hybrid solution with a warning associated to the option |
Since the |
I lean towards option 1 for similar reasons as @fmassa. I would maybe propose the following two additions:
Thank you all for working on PyTorch, it is overall one of the best libraries I know, often because the user interface is carefully designed. |
I have quite often needed to precompute features using the torchvision resnets (such as for indexing with FAISS) and relied on being able to get a comparable feature for new images by just creating a new |
I'd suggest using the legacy weights. Reproducibility/Fairness and BC is crucial for research. Imagine a 2021 paper said it used the torchvision ImageNet pre-trained weights and a 2022 paper that use better weights also say the same thing, how can we compare what's what? Of course the new weights are also important for people to move forward, so maybe just keep the legacy weights as default and throw a warning for the existence of much better weights. This way people can find out usage of better weights by looking at the code instead of the dependency versions. |
🚀 RFC
Background Info
To access pre-trained models in TorchVision, one needs to pass
pretrained=True
on the model builders. Example:Unfortunately the above API does not allow us to support multiple pre-trained weights. This feature is necessary when we want to provide improved weights on the same dataset (for example better Acc@1 on ImageNet) or additional weights trained on a different dataset (for example in Object Detection use VOC instead of COCO). With the completion of the Multi-weight support prototype the TorchVision model builders can now support more than 1 set of weights:
The above prototype API is now available on nightly builds where users can test it and gather feedback. Once the feedback is gathered and acted upon, we will consider releasing the new API on the main area.
What should be the behaviour of
pretrained=True
?Upon release, the legacy
pretrained=True
parameter will be deprecated and it will be removed on a future version of TorchVision (TBD when). The question of this RFC is what the behaviour of thepretrained=True
should be until its removal. There are currently two obvious candidates:Option 1: Using the Legacy weights
Using
pretrained=True
the new API should return the same legacy weights as the one used by the current API.This is how the prototype is currently implemented. The following calls are all equivalent:
Why to select this option:
Option 2: Using the Best available weights
Using
pretrained=True
the new API should return the best available weights.The following calls will be made equivalent:
Why to select this option:
pretrained=True
always meant "give me the current best weights".To address some of the cons of adopting this option we will:
Feedback
We would love to hear your thoughts on the matter. You can vote on this topic on Twitter or explain your position in the comments.
The text was updated successfully, but these errors were encountered: