ScoreSDEDataFidelity#
- class deepinv.sampling.ScoreSDEDataFidelity(gamma=None, weight=1.0, rng=None, *args, **kwargs)[source]#
Bases:
ALDDataFidelityScore-SDE data-fidelity term.
This corresponds to the \(p(y|x_t)\) approximation proposed in [138], and reviewed in [35]. The difference with
deepinv.sampling.ALDDataFidelityis that the measurements are noised to the current diffusion noise level before the mismatch is computed,\[y_t = y + \sigma_t\epsilon, \qquad \epsilon\sim\mathcal{N}(0,\mathrm{Id}),\]so that \(y_t\) and \(A x_t\) live at the same noise level. 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_t\right)}{\sigma_y^2 + \gamma_t^2},\]where \(\lambda\), exposed as
weight, controls the scale of the data-fidelity term.Note
[35] writes this approximation without a guidance strength, noting that it then differs from
deepinv.sampling.ALDDataFidelityonly by the noising of the measurements. We keep the annealed guidance strength \(\sigma_y^2 + \gamma_t^2\) here, so that the term stays balanced against the unconditional score across noise levels.- Parameters:
gamma (Callable, float) – annealing parameter \(\gamma_t\). If
None(default), \(\gamma_t = \sigma_t\), the current diffusion noise level.weight (float) – Weighting factor \(\lambda\). Default:
1.0.rng (torch.Generator) – Random number generator used to noise the measurements, for reproducibility. Default:
None.
- forward(*args, **kwargs)[source]#
Not implemented: the measurements are re-noised at every call, so this term has no deterministic value, see
grad().
- grad(x, y, physics, sigma, *args, **kwargs)[source]#
Compute the Score-SDE data-fidelity gradient \(\lambda A^\top \left(A x_t - y_t\right) / (\sigma_y^2 + \gamma_t^2)\).
- Parameters:
x (torch.Tensor) – Current noisy iterate.
y (torch.Tensor) – Measurements.
physics (deepinv.physics.Physics) – physics model.
sigma (torch.Tensor, float) – Diffusion noise standard deviation.
- Returns:
Score-SDE gradient, with the same shape as
x.- Return type:
Examples using ScoreSDEDataFidelity:#
Noisy data-fidelity terms for diffusion posterior sampling