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_channels
is the number of channels in the input image.out_channels
is 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.