L1Distance#

class deepinv.optim.L1Distance[source]#

Bases: Distance

\(\ell_1\) distance

\[f(x) = \|x-y\|_1.\]
fn(x, y, *args, **kwargs)[source]#

Computes the distance \(\distance{x}{y}\).

Parameters:
Returns:

(torch.Tensor) distance \(\distance{x}{y}\) of size B with B the size of the batch.

grad(x, y, *args, **kwargs)[source]#

Gradient of the gradient of the \(\ell_1\) norm, i.e.

\[\partial \datafid(x) = \operatorname{sign}(x-y)\]

Note

The gradient is not defined at \(x=y\).

Parameters:
  • x (torch.Tensor) – Variable \(x\) at which the gradient is computed.

  • y (torch.Tensor) – Data \(y\) of the same dimension as \(x\).

Returns:

(torch.Tensor) gradient of the \(\ell_1\) norm at x.

prox(u, y, *args, gamma=1.0, **kwargs)[source]#

Proximal operator of the \(\ell_1\) norm, i.e.

\[\operatorname{prox}_{\gamma \ell_1}(x) = \underset{z}{\text{argmin}} \,\, \gamma \|z-y\|_1+\frac{1}{2}\|z-x\|_2^2\]

also known as the soft-thresholding operator.

Parameters:
  • u (torch.Tensor) – Variable \(u\) at which the proximity operator is computed.

  • y (torch.Tensor) – Data \(y\) of the same dimension as \(x\).

  • gamma (float) – stepsize (or soft-thresholding parameter).

Returns:

(torch.Tensor) soft-thresholding of u with parameter gamma.