Sparsity

class colibri.recovery.terms.prior.Sparsity(basis=None)[source]

Bases: Module

Sparsity prior

\[g(\mathbf{x}) = \| \transform \textbf{x}\|_1\]

where \(\transform\) is the sparsity basis and \(\textbf{x}\) is the input tensor.

Parameters:

basis (str) – Basis function. ‘dct’, ‘None’. Default is None.

forward(x)[source]

Compute sparsity term.

Parameters:

x (torch.Tensor) – Input tensor.

Returns:

Sparsity term.

Return type:

torch.Tensor

prox(x, _lambda, type='soft')[source]

Compute proximal operator of the sparsity term.

Parameters:
  • x (torch.Tensor) – Input tensor.

  • _lambda (float) – Regularization parameter.

  • type (str) – String, it can be “soft” or “hard”.

Returns:

Proximal operator of the sparsity term.

Return type:

torch.Tensor

Examples using Sparsity:

Demo FISTA.

Demo FISTA.

Demo PnP.

Demo PnP.