Conv2dReLU¶

class Conv2dReLU(in_channels, out_channels, kernel_size=3, padding=1)[source]¶

Conv2d + BatchNorm + ReLU block.

This class implements a common convolutional block used in UNet decoder. It consists of a 2D convolution followed by batch normalization and a ReLU activation function.

conv¶

Convolutional layer for feature extraction.

Type:

nn.Conv2d

norm¶

Batch normalization layer for stabilizing training.

Type:

nn.BatchNorm2d

activation¶

ReLU activation function applied after normalization.

Type:

nn.ReLU

Example

>>> block = Conv2dReLU(in_channels=32, out_channels=64)
>>> x = torch.randn(1, 32, 128, 128)
>>> output = block(x)
>>> output.shape
... torch.Size([1, 64, 128, 128])

Initialize Conv2dReLU block.

Creates a convolutional layer followed by batch normalization and a ReLU activation function.

Parameters:
  • in_channels (int) – Number of input channels.

  • out_channels (int) – Number of output channels.

  • kernel_size (int) – Size of the convolution kernel. Defaults to 3.

  • padding (int) – Padding applied to the input. Defaults to 1.

Methods

Attributes

training