mr2.operators.functionals.NuclearNorm

class mr2.operators.functionals.NuclearNorm[source]

Bases: ElementaryProximableFunctional

Weighted nuclear norm on the last two input axes.

For each matrix in an input of shape (..., m, n), compute \(f(X) = |w| \sum_i s_i(X-b) / N\), where \(s_i\) are singular values, \(b\) is target, and \(N=mn\) if divide_by_n=True (otherwise \(N=1\)). Batch axes are retained without reduction. Use RearrangeOp to arrange other matrix axes externally.

Weights and proximal steps must broadcast to (..., 1, 1) without expanding the input batch shape. For input (B, m, n), use (B, 1, 1) for per-matrix parameters. Entrywise weights or steps are unsupported. Complex and negative weights use their magnitude, as in L1Norm.

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

Initialize the nuclear norm.

Parameters:
  • target (Tensor | complex | None, default: None) – Translation, broadcastable to the input without expanding its shape.

  • weight (Tensor | complex, default: 1.0) – Scalar or per-matrix weight. Its magnitude multiplies the norm.

  • divide_by_n (bool, default: False) – Divide by the number of matrix entries, m*n, in all methods.

  • keepdim (bool, default: False) – Retain both matrix axes with size one in the forward result.

__call__(x: Tensor) → tuple[Tensor][source]

Return one weighted sum of singular values per matrix.

Parameters:

x (Tensor) – Real or complex input of shape (..., m, n).

Returns:

Batch of norms, with two trailing singleton axes if keepdim=True.

forward(x: Tensor) → tuple[Tensor][source]

Apply forward of NuclearNorm.

Note

Prefer calling the instance of the NuclearNorm as operator(x) over directly calling this method. See this PyTorch discussion.

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

Apply singular-value soft thresholding about target.

Parameters:
  • x (Tensor) – Real or complex input of shape (..., m, n).

  • sigma (Tensor | float, default: 1.0) – Nonnegative real scalar or per-matrix step, with trailing singleton matrix axes. Zero steps return the corresponding input matrices.

Returns:

Proximal mapping with the same shape as the input.

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

Project x - sigma * target onto the spectral-norm ball.

The ball radius is \(|w|/N\). Zero steps return the input, including outside the conjugate domain, as in L21Norm.

Parameters:
  • x (Tensor) – Real or complex input of shape (..., m, n).

  • sigma (Tensor | float, default: 1.0) – Nonnegative real scalar or per-matrix step, with trailing singleton matrix axes.

Returns:

Proximal mapping of the convex conjugate, with the input shape.

__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*x if 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)

__or__(other: ProximableFunctional) → ProximableFunctionalSeparableSum[Tensor, Tensor][source]

Create a ProximableFunctionalSeparableSum from two proximable functionals.

f | g is a separable sum with (f|g)(x,y) == f(x) + g(y).

Parameters:

other (ProximableFunctional) – second functional to be summed

Returns:

ProximableFunctionalSeparableSum object

__radd__(other: Tensor | complex) → Operator[Unpack[Tin], tuple[Unpack[Tin]]][source]

Operator right addition.

Returns lambda x: other*x + self(x)

__rmul__(scalar: Tensor | complex) → ProximableFunctional[source]

Multiply functional with scalar.