Skip to content
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

Feature: Add independent channel option in UNet – Conv group implementation #118

Merged
merged 16 commits into from
May 20, 2024

Conversation

melisande-c
Copy link
Member

Feature

Option to conveniently train independent UNets for each channel in parallel. This is useful for noise2void, most cases will have channel independent noise.

Implementation

PyTorch has the option to pass the parameter groups to Conv2d & Conv3d. groups=n creates n parallel convolutions with no shared connections; in this case we have groups==in_channels and out_channels==K*in_channels – which is also known as a "depthwise convolution". Using depthwise convolutions throughout the network creates essentially n=in_channels parallel networks.

When concatenating the skip connections in the decoder we have to interleave the input and the encoder features to ensure no connections between the parallel networks.

No change has to be made to batch normalisation because it is channel-wise.

Change details

  • add independent_channels option to UNet class and UNetModel
  • add groups parameter to UnetEncoder and UnetDecoder; which will be passed to each of their ConvBlock layers.
  • if independent_channels=True set groups==in_channels in the encoder and decoder. set groups=1 otherwise.
  • add _interleave static method in decoder for interleaving input and skip connections.
  • update tests to cover independent channels at different depths
  • add test to validate channels are indeed independent throughout network
  • !possible breaking change! independent_channels default is set to True

@melisande-c melisande-c requested a review from jdeschamps May 17, 2024 11:10
Copy link
Member

@jdeschamps jdeschamps left a comment

Choose a reason for hiding this comment

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

Looks good on my side!

@melisande-c melisande-c merged commit 2d90c7a into main May 20, 2024
14 of 15 checks passed
@melisande-c melisande-c deleted the mc/feat/UNet_channel_group_conv branch May 20, 2024 11:52
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