You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have implemented a generic, customizable U-Net that comes with options for:
Number of input and output channels in_channels is the number of channels in the input image. out_channels is the number of channels in the output image.
Upsampling
bilinear = False: Transposed convolution with a 2x2 kernel applied with stride 2. This is followed by a ReLU.
bilinear = True: Factor 2 bilinear upsampling followed by convolution with a 1x1 kernel applied with stride 1.
Padding
pad = True: The input size is retained in the output by zero-padding convolutions and, if necessary, the results of the upsampling operations.
pad = False: The output is smaller than the input as in the original implementation. In this case, every 3x3 convolution layer reduces the height and width by 2 pixels each. Consequently, the right side of the U-Net has a smaller spatial size than the left size. Therefore, before concatenating, the central slice of the left tensor is cropped along the spatial dimensions to match those of the right tensor.
Normalization following the ReLU which follows each convolution and transposed convolution.
normalization = "ln": Applies layer normalization. A permutation of dimensions is performed before the layer to ensure normalization is applied over the channel dimension. Afterward, the dimensions are permuted back to their original order.
I have implemented a generic, customizable U-Net that comes with options for:
Number of input and output channels in_channels is the number of channels in the input image. out_channels is the number of channels in the output image.
Upsampling
bilinear = False: Transposed convolution with a 2x2 kernel applied with stride 2. This is followed by a ReLU.
bilinear = True: Factor 2 bilinear upsampling followed by convolution with a 1x1 kernel applied with stride 1.
Padding
pad = True: The input size is retained in the output by zero-padding convolutions and, if necessary, the results of the upsampling operations.
pad = False: The output is smaller than the input as in the original implementation. In this case, every 3x3 convolution layer reduces the height and width by 2 pixels each. Consequently, the right side of the U-Net has a smaller spatial size than the left size. Therefore, before concatenating, the central slice of the left tensor is cropped along the spatial dimensions to match those of the right tensor.
Normalization following the ReLU which follows each convolution and transposed convolution.
normalization = "ln": Applies layer normalization. A permutation of dimensions is performed before the layer to ensure normalization is applied over the channel dimension. Afterward, the dimensions are permuted back to their original order.
I have now also added an option for controlling the depth of the U-Net:
5. Depth depth is the The depth of the U-Net.
This is the number of steps in the encoder and decoder paths.
This is one less than the number of downsampling and upsampling blocks.
The number of intermediate channels is 64*2**depth, i.e. [64, 128, 256, 512, 1024] for depth = 5.
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
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.
I have implemented a generic, customizable U-Net that comes with options for:
in_channelsis the number of channels in the input image.out_channelsis the number of channels in the output image.bilinear = False: Transposed convolution with a 2x2 kernel applied with stride 2. This is followed by a ReLU.bilinear = True: Factor 2 bilinear upsampling followed by convolution with a 1x1 kernel applied with stride 1.pad = True: The input size is retained in the output by zero-padding convolutions and, if necessary, the results of the upsampling operations.pad = False: The output is smaller than the input as in the original implementation. In this case, every 3x3 convolution layer reduces the height and width by 2 pixels each. Consequently, the right side of the U-Net has a smaller spatial size than the left size. Therefore, before concatenating, the central slice of the left tensor is cropped along the spatial dimensions to match those of the right tensor.normalization = None: Applies no normalization.normalization = "bn": Applies batch normalization.normalization = "ln": Applies layer normalization. A permutation of dimensions is performed before the layer to ensure normalization is applied over the channel dimension. Afterward, the dimensions are permuted back to their original order.