NoisyDataFidelity#
- class deepinv.sampling.NoisyDataFidelity[source]#
Bases:
L2
Preconditioned data fidelity term for noisy data \(\datafid{x_t}{y} = \distance{\forw{x_t}}{y}\). Here, \(x_t\) is a perturbed versions of \(x\).
This is a base class for the conditional classes for approximating \(\log p_t(y|x_t)\) used in diffusion algorithms for inverse problems, in
deepinv.sampling.PosteriorDiffusion
.It comes with a
.grad
method computing the score \(\nabla_{x_t} \log p_t(y|x_t)\)\[\begin{equation*} \nabla_{x_t} \log p_t(y|x_t) = P(\forw{x_t'}-y), \end{equation*}\]where \(P\) is a preconditioner and \(x_t'\) is an estimation of the image \(x\). By default, \(P\) is defined as \(A^\top\), \(x_t' = x_t\) and this class matches the
deepinv.optim.DataFidelity
class.- diff(x, y, physics, sigma)[source]#
Computes the difference between the forward operator applied to the current iterate and the input data.
- Parameters:
x (torch.Tensor) – Current iterate.
y (torch.Tensor) – Input data.
- Returns:
(torch.Tensor) difference between the forward operator applied to the current iterate and the input data.
- Return type:
- forward(x, y, physics, sigma, **kwargs)[source]#
Computes the data-fidelity term.
- Parameters:
x (torch.Tensor) – input image
y (torch.Tensor) – measurements
physics (deepinv.physics.Physics) – forward operator
sigma (float) – standard deviation of the noise.
- Returns:
(torch.Tensor) loss term.
- Return type:
- grad(x, y, physics, sigma)[source]#
Computes the gradient of the data-fidelity term.
- Parameters:
x (torch.Tensor) – Current iterate.
y (torch.Tensor) – Input data.
physics – physics model
sigma (float) – Standard deviation of the noise.
- Returns:
(torch.Tensor) data-fidelity term.
- Return type:
- precond(u, physics)[source]#
The preconditioner \(P = A^\top\) for the data fidelity term.
- Parameters:
u (torch.Tensor) – input tensor.
physics (deepinv.physics.Physics) – physics model.
- Returns:
(torch.FloatTensor) preconditionned tensor \(P(u)\).
- Return type:
Examples using NoisyDataFidelity
:#

Posterior Sampling for Inverse Problems with Stochastic Differential Equations modeling.