L2#

class deepinv.optim.L2(sigma=1.0)[source]#

Bases: DataFidelity

Implementation of the data-fidelity as the normalized \(\ell_2\) norm

\[f(x) = \frac{1}{2\sigma^2}\|\forw{x}-y\|^2\]

It can be used to define a log-likelihood function associated with additive Gaussian noise by setting an appropriate noise level \(\sigma\).

Parameters:

sigma (float) – Standard deviation of the noise to be used as a normalisation factor.

>>> import torch
>>> import deepinv as dinv
>>> # define a loss function
>>> fidelity = dinv.optim.data_fidelity.L2()
>>>
>>> x = torch.ones(1, 1, 3, 3)
>>> mask = torch.ones_like(x)
>>> mask[0, 0, 1, 1] = 0
>>> physics = dinv.physics.Inpainting(tensor_size=(1, 3, 3), mask=mask)
>>> y = physics(x)
>>>
>>> # Compute the data fidelity f(Ax, y)
>>> fidelity(x, y, physics)
tensor([0.])
>>> # Compute the gradient of f
>>> fidelity.grad(x, y, physics)
tensor([[[[0., 0., 0.],
          [0., 0., 0.],
          [0., 0., 0.]]]])
>>> # Compute the proximity operator of f
>>> fidelity.prox(x, y, physics, gamma=1.0)
tensor([[[[1., 1., 1.],
          [1., 1., 1.],
          [1., 1., 1.]]]])
prox(x, y, physics, *args, gamma=1.0, **kwargs)[source]#

Proximal operator of \(\gamma \datafid{Ax}{y} = \frac{\gamma}{2\sigma^2}\|Ax-y\|^2\).

Computes \(\operatorname{prox}_{\gamma \datafidname}\), i.e.

\[\operatorname{prox}_{\gamma \datafidname} = \underset{u}{\text{argmin}} \frac{\gamma}{2\sigma^2}\|Au-y\|_2^2+\frac{1}{2}\|u-x\|_2^2\]
Parameters:
Returns:

(torch.Tensor) proximity operator \(\operatorname{prox}_{\gamma \datafidname}(x)\).

Examples using L2:#

Image deblurring with custom deep explicit prior.

Image deblurring with custom deep explicit prior.

Random phase retrieval and reconstruction methods.

Random phase retrieval and reconstruction methods.

Image deblurring with Total-Variation (TV) prior

Image deblurring with Total-Variation (TV) prior

Image inpainting with wavelet prior

Image inpainting with wavelet prior

Vanilla PnP for computed tomography (CT).

Vanilla PnP for computed tomography (CT).

DPIR method for PnP image deblurring.

DPIR method for PnP image deblurring.

Regularization by Denoising (RED) for Super-Resolution.

Regularization by Denoising (RED) for Super-Resolution.

PnP with custom optimization algorithm (Condat-Vu Primal-Dual)

PnP with custom optimization algorithm (Condat-Vu Primal-Dual)

Uncertainty quantification with PnP-ULA.

Uncertainty quantification with PnP-ULA.

Building your custom sampling algorithm.

Building your custom sampling algorithm.

Implementing DPS

Implementing DPS

Implementing DiffPIR

Implementing DiffPIR

Learned Iterative Soft-Thresholding Algorithm (LISTA) for compressed sensing

Learned Iterative Soft-Thresholding Algorithm (LISTA) for compressed sensing

Vanilla Unfolded algorithm for super-resolution

Vanilla Unfolded algorithm for super-resolution

Learned iterative custom prior

Learned iterative custom prior

Deep Equilibrium (DEQ) algorithms for image deblurring

Deep Equilibrium (DEQ) algorithms for image deblurring

Radio interferometric imaging with deepinverse

Radio interferometric imaging with deepinverse