mr2.nn.ComplexAsChannel

class mr2.nn.ComplexAsChannel[source]

Bases: CondMixin, Module

Wrap module to treat complex numbers as a channel dimension.

__init__(module: Module, convert_back: bool = True)[source]

Initialize the ComplexAsChannel module.

Wraps a module to treat complex numbers as a channel dimension. For each complex tensor in the input, real and imaginary parts are concatenated along the channel dimension before being passed to the wrapped module.

Parameters:
  • module (Module) – The module to wrap. Should output a single real tensor.

  • convert_back (bool, default: True) – If True, the output is converted back to a complex tensor. The output should have a number of channels that is a multiple of 2.

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

Apply the module.

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

  • cond (Tensor | None, default: None) – The conditioning tensor (if used by the wrapped module)

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

Apply the module.