AmplitudeLoss
- class deepinv.optim.AmplitudeLoss[source]
Bases:
DataFidelity
Amplitude loss as the data fidelity term for
deepinv.physics.PhaseRetrieval()
reconstrunction.In this case, the data fidelity term is defined as
\[f(x) = \sum_{i=1}^{m}{(\sqrt{|b_i x|^2}-\sqrt{y_i})^2},\]where \(b_i\) is the i-th row of the linear operator \(B\) of the phase retrieval class and \(y_i\) is the i-th entry of the measurements, and \(m\) is the number of measurements.
- d(u, y)[source]
Computes the amplitude loss.
- Parameters:
u (torch.Tensor) – estimated measurements.
y (torch.Tensor) – true measurements.
- Returns:
(torch.Tensor) the amplitude loss of shape B where B is the batch size.
- grad_d(u, y, epsilon=1e-12)[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.