Document Inception3 transform_input override for pretrained weights#9494
Document Inception3 transform_input override for pretrained weights#9494adityasingh2400 wants to merge 1 commit into
Conversation
…weights Inception3 lacked a class docstring entirely. The constructor exposes transform_input with default False, but when weights are loaded via inception_v3(weights=...) the factory calls _ovewrite_named_param to force transform_input=True regardless of caller intent (the pretrained weights expect ImageNet-normalised inputs). Document the full Args block and add a Note explaining the override so users do not silently get a different behaviour from what their constructor call suggested. Fixes pytorch#1709
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9494
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Hi @adityasingh2400! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary
Fixes #1709.
Inception3had no class docstring. The constructor exposestransform_inputwith defaultFalse, butinception_v3(weights=...)silently calls_ovewrite_named_param(kwargs, "transform_input", True)and forces it toTruewhenever pretrained weights are loaded (the weights expect ImageNet-normalised inputs). Users reading the source seetransform_input: bool = Falseand reasonably assume the constructor default holds, when in practice it does not.This is a pure docs change. No behaviour is modified.
Changes
Inception3documenting all constructor arguments (num_classes,aux_logits,transform_input,inception_blocks,init_weights,dropout) in the torchvision style... note::to the class docstring describing thetransform_inputoverride applied by the factory when pretrained weights are loaded, and pointing readers toinception_v3... note::to theinception_v3factory docstring, explaining the override and showing the escape hatch (model.transform_input = Falseafter construction) for users who need it.Test plan
python3 -c "import ast; ast.parse(open('torchvision/models/inception.py').read())"succeeds (no syntax regressions)._ovewrite_named_paramcall are untouched.