-
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
Fix warnings in unit-tests tests #6159
base: main
Are you sure you want to change the base?
Conversation
Fix warnings in the tests
@puhuk ci failures are related. I think a fix could be something like: diff --git a/torchvision/models/quantization/googlenet.py b/torchvision/models/quantization/googlenet.py
index 644df8ae4..682ba1833 100644
--- a/torchvision/models/quantization/googlenet.py
+++ b/torchvision/models/quantization/googlenet.py
@@ -74,6 +74,8 @@ class QuantizableInceptionAux(InceptionAux):
class QuantizableGoogLeNet(GoogLeNet):
# TODO https://github.com/pytorch/vision/pull/4232#pullrequestreview-730461659
def __init__(self, *args: Any, **kwargs: Any) -> None:
+ if "init_weights" not in kwargs:
+ kwargs["init_weights"] = True
super().__init__( # type: ignore[misc]
blocks=[QuantizableBasicConv2d, QuantizableInception, QuantizableInceptionAux], *args, **kwargs
)
diff --git a/torchvision/models/quantization/inception.py b/torchvision/models/quantization/inception.py
index ba4b21d41..647c00472 100644
--- a/torchvision/models/quantization/inception.py
+++ b/torchvision/models/quantization/inception.py
@@ -142,6 +142,7 @@ class QuantizableInception3(inception_module.Inception3):
QuantizableInceptionE,
QuantizableInceptionAux,
],
+ init_weights=True,
)
self.quant = torch.ao.quantization.QuantStub()
self.dequant = torch.ao.quantization.DeQuantStub() |
To fix CI error
Remove unrelevant init_weights from mobilenet2, shufflenet2
Hmm, why it raises typo error in |
@puhuk it is unrelated as main branch is broken : https://app.circleci.com/pipelines/github/pytorch/vision/18344/workflows/d0222980-4837-4c46-a9bf-d9cc4be80051/jobs/1484167 |
@vfdev-5 Thank you for the feedback! |
@puhuk there are few similar warnings:
Can you try to fix them as well ? Thanks |
To resolve warnings in models/googlenet, models/inception
torchvision/models/googlenet.py
Outdated
@@ -34,7 +34,7 @@ def __init__( | |||
num_classes: int = 1000, | |||
aux_logits: bool = True, | |||
transform_input: bool = False, | |||
init_weights: Optional[bool] = None, | |||
init_weights: bool = True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not good. Check #2170 why they switched from True to None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I don't have good idea. Is there better method than I did here.
https://github.com/pytorch/vision/pull/6159/commits/16ddd6c0f23fe56e8029f336c5e3f3c69e9c534f
To resolve warnings in models/googlenet, models/inception
@@ -74,6 +74,8 @@ def forward(self, x: Tensor) -> Tensor: | |||
class QuantizableGoogLeNet(GoogLeNet): | |||
# TODO https://github.com/pytorch/vision/pull/4232#pullrequestreview-730461659 | |||
def __init__(self, *args: Any, **kwargs: Any) -> None: | |||
if "init_weights" not in kwargs: | |||
kwargs["init_weights"] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why in order to fix the warning on unit-tests we modify the models themselves. My expectations without having all the details in my mind, is that the tests are the ones that need to be updated. What am I missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first I was thinking that QuantizableGoogLeNet does not properly set up its base class GoogLeNet
. Thinking more about that, I think you are right, we have to try again to fix that from tests side
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let me check and send PR again.
Update _model_params to prevent future warning
I think the approach taken now should work. Our CI is toasted so we won't be able to test this thoroughly, so I recommend waiting for tomorrow until the breakage is fixed. Edit: The failing linter is related. You need to add a space at |
To correct format
@datumbox |
Fixes #6155