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:
Returns:

(torch.Tensor) difference between the forward operator applied to the current iterate and the input data.

Return type:

Tensor

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

Computes the data-fidelity term.

Parameters:
Returns:

(torch.Tensor) loss term.

Return type:

Tensor

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:

Tensor

precond(u, physics)[source]#

The preconditioner \(P = A^\top\) for the data fidelity term.

Parameters:
Returns:

(torch.FloatTensor) preconditionned tensor \(P(u)\).

Return type:

Tensor

Examples using NoisyDataFidelity:#

Posterior Sampling for Inverse Problems with Stochastic Differential Equations modeling.

Posterior Sampling for Inverse Problems with Stochastic Differential Equations modeling.