spyrit.core.nnet.Unet.expans

Unet.expans(in_channels: int, mid_channel: int, out_channels: int, kernel_size=3, padding=1) Sequential[source]

Defines an upsampling block.

It is composed of two convolutional layers followed by a ReLU activation function and a batch normalization layer. The block finally contains an upsampling layer. The upsampling layer can be either a transposed convolution or an upsampling followed by a convolution, depending on the value of the upsample attribute defined at initialization.

Args:

in_channels (int): Number of channels in the input tensor.

mid_channel (int): Number of channels in the intermediate tensor (i.e.) the tensor after the first convolutional layer.

out_channels (int): Number of channels in the output tensor.

kernel_size (int or tuple, optional): Size of the two convolution kernels. If the upsampling layer is a upsampling followed by a convolution, this kernel size is also used in that convolution. This argument is directly passed to torch.nn.Conv2d. Defaults to 3.

padding (int or tuple or string, optional): Input padding. It is directly passed to torch.nn.Conv2d, see its documentation for valid options. Defaults to 1.

Returns:

torch.nn.Sequential: A sequential block with two convolutional layers, ReLU activation function, batch normalization layer, and an upsampling layer.