spyrit.core.nnet.Unet.contract

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

Defines a convolutional block.

It is composed of two convolutional layers followed by a ReLU activation function and a batch normalization layer.

Args:

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

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

kernel_size (int or tuple, optional): Size of the kernel in the convolution layers. It is 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, and batch normalization layer.