mr2.nn.ResBlock

class mr2.nn.ResBlock[source]

Bases: CondMixin, Module

Residual convolution block with two convolutions.

__init__(n_dim: int, n_channels_in: int, n_channels_out: int, cond_dim: int) → None[source]

Initialize the ResBlock.

Parameters:
  • n_dim (int) – The number of dimensions, i.e. 1, 2 or 3.

  • n_channels_in (int) – The number of channels in the input tensor.

  • n_channels_out (int) – The number of channels in the output tensor.

  • cond_dim (int) – The number of features in the conditioning tensor used in a FiLM. If set to 0 no FiLM is used.

__call__(x: Tensor, *, cond: Tensor | None = None) → Tensor[source]

Apply the ResBlock.

Parameters:
  • x (Tensor) – The input tensor.

  • cond (Tensor | None, default: None) – A conditioning tensor to be used for FiLM.

Returns:

The output tensor.

forward(x: Tensor, *, cond: Tensor | None = None) → Tensor[source]

Apply the ResBlock.