Skip to content

Conversation

@bnb32
Copy link
Collaborator

@bnb32 bnb32 commented Feb 4, 2025

This generalizes the padding fix implemented in #247

bnb32 added 2 commits January 17, 2025 19:11
…ate models with increased receptive field and larger padding values.
…adding`` layers in the generator model. Generalized current min padding to use these values.
@bnb32 bnb32 requested a review from grantbuster February 4, 2025 19:55
if 2 * self.spatial_pad + (lr_slice_stop - lr_slice_start) < 4:
if (
2 * padding + (lr_slice_stop - lr_slice_start)
<= self.min_width[dim]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, i find it really helpful to define some of these weird conditionals, both for readability and also to reduce this crazy one-liner. What are these? Just guessing but i'd do:

slice_width = lr_slice_stop - lr_slice_start
padded_width = 2 * padding + slice_width
too_small = padded_width <= self.min_width[dim]
if too_small:
    ...

And also wait i would think that if we're padded_width == min_width we should be okay based on the docstring for "min_width"? Surprised that it's <=

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good suggestions. It's <= because the method in strategy returns the .paddings attribute, and the min padding needs to be 1 more than this. But we can just do < and make it an arg.

check_boundary
and win_stop == max_steps
and (2 * max_pad + win_stop - win_start) < 4
and (2 * max_pad + win_stop - win_start) <= min_width
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment here, i'd recommend breaking this into semantic variables thats easier for future us to read.

pad_width = [
np.max((new_pw[i], pad_width[i])) for i in range(3)
]
return pad_width
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it could be a bit specific to our current model design. What if we migrate to a different padding layer or change the attr in FlexiblePadding? Seems like a pretty rigid tight coupling. Could we just have min_width be an optional user arg that defaults to (1,1,1)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that was roughly the thinking with the implicit (1,1,1) default here but removing this method and making it a user kwarg is fine. I'd prefer the default to be (4,4,4) though, since we mostly use paddings = [3,3,3].

@bnb32 bnb32 merged commit a77323d into main Feb 20, 2025
12 checks passed
@bnb32 bnb32 deleted the bnb/min_padding_general branch February 20, 2025 21:57
github-actions bot pushed a commit that referenced this pull request Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants