Skip to content

Conversation

sm00thix
Copy link

I have implemented a generic, customizable U-Net that comes with options for:

  1. 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.
  2. Upsampling
    1. bilinear = False: Transposed convolution with a 2x2 kernel applied with stride 2. This is followed by a ReLU.
    2. bilinear = True: Factor 2 bilinear upsampling followed by convolution with a 1x1 kernel applied with stride 1.
  3. Padding
    1. pad = True: The input size is retained in the output by zero-padding convolutions and, if necessary, the results of the upsampling operations.
    2. 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.
  4. Normalization following the ReLU which follows each convolution and transposed convolution.
    1. normalization = None: Applies no normalization.
    2. normalization = "bn": Applies batch normalization.
    3. 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.

@meta-cla meta-cla bot added the cla signed label Aug 20, 2025
Copy link

netlify bot commented Aug 20, 2025

Deploy Preview for pytorch-hub-preview ready!

Name Link
🔨 Latest commit 45b4bcd
🔍 Latest deploy log https://app.netlify.com/projects/pytorch-hub-preview/deploys/68a5b9c94efa3e00080e6c12
😎 Deploy Preview https://deploy-preview-359--pytorch-hub-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant