L2Distance#
- class deepinv.optim.L2Distance[source]#
Bases:
Distance
Implementation of \(\distancename\) as the normalized \(\ell_2\) norm
\[f(x) = \frac{1}{2\sigma^2}\|x-y\|^2\]- fn(x, y, *args, **kwargs)[source]#
Computes the distance \(\distance{x}{y}\) i.e.
\[\distance{x}{y} = \frac{1}{2}\|x-y\|^2\]- Parameters:
u (torch.Tensor) – Variable \(x\) at which the data fidelity is computed.
y (torch.Tensor) – Data \(y\).
- Returns:
(torch.Tensor) data fidelity \(\datafid{u}{y}\) of size B with B the size of the batch.
- grad(x, y, *args, **kwargs)[source]#
Computes the gradient of \(\distancename\), that is \(\nabla_{x}\distance{x}{y}\), i.e.
\[\nabla_{x}\distance{x}{y} = x-y\]- Parameters:
x (torch.Tensor) – Variable \(x\) at which the gradient is computed.
y (torch.Tensor) – Observation \(y\).
- Returns:
(torch.Tensor) gradient of the distance function \(\nabla_{x}\distance{x}{y}\).
- prox(x, y, *args, gamma=1.0, **kwargs)[source]#
Proximal operator of \(\gamma \distance{x}{y} = \frac{1}{2} \|x-y\|^2\).
Computes \(\operatorname{prox}_{\gamma \distancename}\), i.e.
\[\operatorname{prox}_{\gamma \distancename} = \underset{u}{\text{argmin}} \frac{\gamma}{2}\|u-y\|_2^2+\frac{1}{2}\|u-x\|_2^2\]- Parameters:
x (torch.Tensor) – Variable \(x\) at which the proximity operator is computed.
y (torch.Tensor) – Data \(y\).
gamma (float) – thresholding parameter.
- Returns:
(torch.Tensor) proximity operator \(\operatorname{prox}_{\gamma \distancename}(x)\).