DPS#

class deepinv.sampling.DPS(denoiser, schedule='vp', alpha=1.0, num_steps=1000, weight=1.0, verbose=False, device='cpu', dtype=torch.float64, rng=None, **kwargs)[source]#

Bases: PosteriorDiffusion

Diffusion Posterior Sampling (DPS).

This class implements the Diffusion Posterior Sampling algorithm (DPS) described in Chung et al.[1].

DPS is an approximation of a gradient-based posterior sampling algorithm, which has minimal assumptions on the forward model. The only restriction is that the measurement model has to be differentiable, which is generally the case.

The algorithm solves the reverse-time SDE specified by the schedule argument, using the Euler solver, and approximating the conditional score by the DPS data fidelity term, which is defined as follows:

\[\nabla_{x_t} \log p_t(y|x_t) \approx \nabla_{x_t} \frac{\lambda}{2 \sqrt{m}} \|y - A D_{\sigma_t}(x_t)\|\]

where \(\denoiser{\cdot}{\sigma}\) is a denoising network for noise level \(\sigma\), and \(\lambda\) is a hyperparameter that controls the weight of the data fidelity term in the approximation of the likelihood gradient.

Note

This method is a particular instance of the general posterior sampling framework described in deepinv.sampling.PosteriorDiffusion, by specifying the data fidelity term as the DPS data fidelity, a SDE and the Euler solver. The user can thus easily modify the algorithm by changing the SDE or the solver, for instance to use a different noise schedule or a different sampling scheme. Please refer to the example Building your diffusion posterior sampling method using SDEs for a full demonstration of how to modify the algorithm.

Parameters:
  • denoiser (deepinv.models.Denoiser) – a denoiser network that can handle different noise levels

  • schedule (str) – the noise schedule to use, either "vp" (default, which matches the original implementation) for the variance preserving noise schedule, or "ve" for the variance exploding noise schedule.

  • num_steps (int) – the number of diffusion iterations to run the algorithm (default: 1000)

  • alpha (float) – DDIM hyperparameter which controls the stochasticity. Default to 1.0, which corresponds to the original DDPM sampling scheme. Setting it to 0 corresponds to the deterministic DDIM sampling scheme.

  • weight (float) – the weight of the data fidelity term in the approximation of the likelihood gradient. Default to 1.0.

  • verbose (bool) – if True, print the progress of the algorithm

  • device (str) – the device to use for the computations


References:

Examples using DPS:#

DPS – Posterior Sampling with Diffusion Models

DPS -- Posterior Sampling with Diffusion Models