AmplitudeLossDistance#

class deepinv.optim.AmplitudeLossDistance[source]#

Bases: Distance

Amplitude loss for deepinv.physics.PhaseRetrieval() reconstrunction, defined as

\[f(x) = \sum_{i=1}^{m}{(\sqrt{|y_i - x|^2}-\sqrt{y_i})^2},\]

where \(y_i\) is the i-th entry of the measurements, and \(m\) is the number of measurements.

fn(u, y, *args, **kwargs)[source]#

Computes the amplitude loss.

Parameters:
Returns:

(torch.Tensor) the amplitude loss of shape B where B is the batch size.

grad(u, y, *args, epsilon=1e-12, **kwargs)[source]#

Computes the gradient of the amplitude loss \(\distance{u}{y}\), i.e.,

\[\nabla_{u}\distance{u}{y} = \frac{\sqrt{u}-\sqrt{y}}{\sqrt{u}}\]
Parameters:
  • u (torch.Tensor) – Variable \(u\) at which the gradient is computed.

  • y (torch.Tensor) – Data \(y\).

  • epsilon (float) – small value to avoid division by zero.

Returns:

(torch.Tensor) gradient of the amplitude loss function.