Fix output channel calculation in PixelShuffle2DUpBlock - #40
Open
wli51 wants to merge 4 commits into
Open
Conversation
…r spatial downsample factor. Erroenous behavior from previous refactor due to lack of caution. With pixel shuffle upsampling, the channel should reduce proportional to the combined 2D sptial expansion as opposed to remaining identical. This also fixes the problem of older (up to v0.7) model loading.
… channel perserving and unpreserving behavior for maximized backward compatibility. The default behavior for unext initialization is channel non-preserving which is the more reasonable yet lower capacity version.
…proved configuration handling and backward compatibility
…ut_h and out_w only works for a specific directional of sampling against a very specific block type.
Contributor
There was a problem hiding this comment.
Pull request overview
Corrects PixelShuffle upsampling channel sizing while adding an opt-in legacy preservation mode.
Changes:
- Reduces output channels proportionally to 2D expansion.
- Adds channel-preservation configuration.
- Updates stage calculations and tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Summary |
|---|---|
tests/models/test_up_down_blocks.py |
Tests reduced and preserved channel behavior. |
src/virtual_stain_flow/models/unext.py |
Wires and serializes channel preservation; missing-key fallback may break loading older checkpoints. |
src/virtual_stain_flow/models/stages.py |
Updates stage spatial-dimension calculations. |
src/virtual_stain_flow/models/blocks/up_down_blocks.py |
Implements proportional PixelShuffle channel reduction. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| init_cfg = config.get("init", config) | ||
| if "_pixel_shuffle_preserve_channels" not in init_cfg: | ||
| # For backward compatibility with configs that don't have this key | ||
| init_cfg["_pixel_shuffle_preserve_channels"] = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Older behavior is erroneous behavior from previous refactor due to lack of caution.
With pixel shuffle up sampling, the channel should reduce proportional to the combined 2D spatial expansion as opposed to remaining identical: