Skip to content

Document Inception3 transform_input override for pretrained weights#9494

Open
adityasingh2400 wants to merge 1 commit into
pytorch:mainfrom
adityasingh2400:doc-inception3-transform-input-1709
Open

Document Inception3 transform_input override for pretrained weights#9494
adityasingh2400 wants to merge 1 commit into
pytorch:mainfrom
adityasingh2400:doc-inception3-transform-input-1709

Conversation

@adityasingh2400
Copy link
Copy Markdown

Summary

Fixes #1709.

Inception3 had no class docstring. The constructor exposes transform_input with default False, but inception_v3(weights=...) silently calls _ovewrite_named_param(kwargs, "transform_input", True) and forces it to True whenever pretrained weights are loaded (the weights expect ImageNet-normalised inputs). Users reading the source see transform_input: bool = False and reasonably assume the constructor default holds, when in practice it does not.

This is a pure docs change. No behaviour is modified.

Changes

  • Add a class docstring to Inception3 documenting all constructor arguments (num_classes, aux_logits, transform_input, inception_blocks, init_weights, dropout) in the torchvision style.
  • Add a .. note:: to the class docstring describing the transform_input override applied by the factory when pretrained weights are loaded, and pointing readers to inception_v3.
  • Add a matching .. note:: to the inception_v3 factory docstring, explaining the override and showing the escape hatch (model.transform_input = False after construction) for users who need it.

Test plan

  • python3 -c "import ast; ast.parse(open('torchvision/models/inception.py').read())" succeeds (no syntax regressions).
  • No behaviour change: only docstrings were added; the constructor signature, defaults, factory logic, and _ovewrite_named_param call are untouched.
  • Sphinx render of the updated docstrings looks clean (CI on this PR exercises the docs build).

…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
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 21, 2026

🔗 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.

@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented May 21, 2026

Hi @adityasingh2400!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the cla signed label May 22, 2026
@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented May 22, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistency in inception_v3 'transform_input' default value

1 participant