ALDDataFidelity#

class deepinv.sampling.ALDDataFidelity(gamma=None, weight=1.0, *args, **kwargs)[source]#

Bases: NoisyDataFidelity

Score-based annealed Langevin dynamics (Score-ALD) data-fidelity term.

This corresponds to the \(p(y|x_t)\) approximation proposed in [64], and reviewed in [35], given by

\[p_t(y|x_t) \approx \mathcal{N} \left( y; A x_t, \left(\sigma_y^2 + \gamma_t^2\right)\mathrm{Id} \right).\]

The resulting negative log-likelihood gradient is

\[-\nabla_{x_t} \log p_t(y|x_t) \approx \lambda \frac{A^\top \left(A x_t - y\right)}{\sigma_y^2 + \gamma_t^2},\]

where \(\sigma_y\) is the measurement noise level and \(\lambda\), exposed as weight, controls the scale of the data-fidelity term.

Note

\(\gamma_t\) should decrease along the diffusion, so that the guidance strengthens as \(x_t\) gets closer to the data manifold. The default gamma=None follows [64] and uses the current diffusion noise level, \(\gamma_t=\sigma_t\).

Parameters:
  • gamma (Callable, float) – annealing parameter \(\gamma_t\). If None (default), \(\gamma_t = \sigma_t\), the current diffusion noise level. A float uses a constant value, and a Callable is evaluated as \(\gamma_t = \text{gamma}(\sigma_t)\).

  • weight (float) – Weighting factor \(\lambda\). Default: 1.0.

forward(x, y, physics, sigma, *args, **kwargs)[source]#

Returns the loss term \(\lambda \| A x_t - y \|^2 / \left(2(\sigma_y^2 + \gamma_t^2)\right)\), whose gradient is given by grad().

Parameters:
Returns:

(torch.Tensor) loss term, of size B the batch size.

Return type:

Tensor

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

Compute the Score-ALD data-fidelity gradient.

\[-\nabla_{x_t} \log p_t(y|x_t) \approx \lambda \frac{A^\top \left(A x_t - y\right)}{\sigma_y^2 + \gamma_t^2}.\]

The measurement noise level \(\sigma_y\) is read from physics.noise_model.sigma when the noise is Gaussian, and is taken to be zero otherwise.

Parameters:
Returns:

Score-ALD gradient, with the same shape as x.

Return type:

Tensor

Examples using ALDDataFidelity:#

Noisy data-fidelity terms for diffusion posterior sampling

Noisy data-fidelity terms for diffusion posterior sampling