mrpro.operators.ElementaryFunctional
- class mrpro.operators.ElementaryFunctional[source]
Bases:
Operator[Tensor,tuple[Tensor]],ABCElementary functional base class.
Here, an ‘elementary’ functional is a functional that can be written as \(f(x) = \phi ( \mathrm{weight} ( x - \mathrm{target}))\), returning a real value. It does not require another functional for initialization.
- __init__(target: Tensor | None | complex = None, weight: Tensor | complex = 1.0, dim: int | Sequence[int] | None = None, divide_by_n: bool = False, keepdim: bool = False) None[source]
Initialize a Functional.
We assume that functionals are given in the form \(f(x) = \phi ( \mathrm{weight} ( x - \mathrm{target}))\) for some functional \(\phi\).
- Parameters:
target (
Tensor|None|complex, default:None) – target element - often data tensor (see above)weight (
Tensor|complex, default:1.0) – weight parameter (see above)dim (
int|Sequence[int] |None, default:None) – dimension(s) over which functional is reduced. All other dimensions ofweight ( x - target)will be treated as batch dimensions.divide_by_n (
bool, default:False) – if true, the result is scaled by the number of elements of the dimensions index bydimin the tensorweight ( x - target). If true, the functional is thus calculated as the mean, else the sum.keepdim (
bool, default:False) – if true, the dimension(s) of the input indexed bydimare maintained and collapsed to singletons, else they are removed from the result.
- __add__(other: Operator[Unpack[Tin], Tout]) Operator[Unpack[Tin], Tout][source]
- __add__(other: Tensor | complex) Operator[Unpack[Tin], tuple[Unpack[Tin]]]
Operator addition.
Returns
lambda x: self(x) + other(x)if other is a operator,lambda x: self(x) + other*xif other is a tensor
- __matmul__(other: Operator[Unpack[Tin2], tuple[Unpack[Tin]]] | Operator[Unpack[Tin2], tuple[Tensor, ...]]) Operator[Unpack[Tin2], Tout][source]
Operator composition.
Returns
lambda x: self(other(x))
- __mul__(other: Tensor | complex) Operator[Unpack[Tin], Tout][source]
Operator multiplication with tensor.
Returns
lambda x: self(x*other)