mrpro.operators.functionals.MSE

class mrpro.operators.functionals.MSE(target: Tensor | None | complex = None, weight: Tensor | complex = 1.0, dim: int | Sequence[int] | None = None, divide_by_n: bool = True, keepdim: bool = False)[source]

Bases: L2NormSquared

Functional class for the mean squared error.

__init__(target: Tensor | None | complex = None, weight: Tensor | complex = 1.0, dim: int | Sequence[int] | None = None, divide_by_n: bool = True, keepdim: bool = False) None[source]

Initialize MSE Functional.

The MSE functional is given by \(f: C^N -> [0, \infty), x -> 1/N \| W (x-b)\|_2^2\), where \(W\) is either a scalar or tensor that corresponds to a (block-) diagonal operator that is applied to the input. The division by N can be disabled by setting divide_by_n=False For more details also see mrpro.operators.functionals.L2NormSquared

Parameters:
  • target – target element - often data tensor (see above)

  • weight – weight parameter (see above)

  • dim – dimension(s) over which functional is reduced. All other dimensions of weight ( x - target) will be treated as batch dimensions.

  • divide_by_n – if true, the result is scaled by the number of elements of the dimensions index by dim in the tensor weight ( x - target). If true, the functional is thus calculated as the mean, else the sum.

  • keepdim – if true, the dimension(s) of the input indexed by dim are maintained and collapsed to singeltons, else they are removed from the result.

forward(x: Tensor) tuple[Tensor]

Forward method.

Compute the squared L2-norm of the input.

Parameters:

x – input tensor

Return type:

squared l2 norm of the input tensor

prox(x: Tensor, sigma: Tensor | float = 1.0) tuple[Tensor]

Proximal Mapping of the squared L2 Norm.

Apply the proximal mapping of the squared L2-norm.

Parameters:
  • x – input tensor

  • sigma – scaling factor

Return type:

Proximal mapping applied to the input tensor

prox_convex_conj(x: Tensor, sigma: Tensor | float = 1.0) tuple[Tensor]

Convex conjugate of squared L2 Norm.

Apply the proximal mapping of the convex conjugate of the squared L2-norm.

Parameters:
  • x – data tensor

  • sigma – scaling factor

Return type:

Proximal of convex conjugate applied to the input tensor