-
Notifications
You must be signed in to change notification settings - Fork 7
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
Input shape verification for convolutional models #10
Conversation
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.
Hi !
Very good job and very nice first contribution.
I have only 2 minor comments concerning the unit test of the padding.
Léa
Hi again @MicheleCattaneo , Sorry for the late reply we went thru a lot of changes before being able to integrate/discuss new features. We discussed with the team and we have some suggestions to make for the autopad you propose:
We propose that a model able to autopad should expose it thru extra settings, here is an example with HalfUnet: @dataclass_json
@dataclass(slots=True)
class HalfUNetSettings:
num_filters: int = 64
dilation: int = 1
bias: bool = False
use_ghost: bool = False
last_activation: str = "Identity"
absolute_pos_embed: bool = False
autopad: bool = False Now the model can handle this in its forward method (this code could be factored in a common class or Mixin): def forward(self, x):
if self.settings.autopad:
x = self.pad(x)
y=self._forward(x)
return self.unpad(y)
else:
return self._forward(x) Note : i omitted the shape tracking on purpose for the brevity of this. This way the autopad doesn't "pollute" the Segmentation/Regression lightning, we don't have to check if autopad is supported using dedicated code outside the model and we can also use it transparently in pure PyTorch loops. |
…utopad via the settings
Hi @colon3ltocard, |
@MicheleCattaneo A few minor comments + some CI fails and then we can merge 👍 |
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.
One last comment: directly reference the self._settings for the autopad_enabled bool
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.
Done 👍
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.
Hi ! Very good contribution, thank you Michele ! :)
What does this PR do?
It introduces utilities to handle invalid input shapes for convolutional models.
Current progress
UNet
,HalfUNet
andCustomUNet
+ tests.Related Issue
closes #9
This draft PR will be updated as the work progresses. Please share any feedback on the overall structure.