Neighbor2Neighbor

class deepinv.loss.Neighbor2Neighbor(metric: Metric | Module = MSELoss(), gamma=2.0)[source]

Bases: Loss

Neighbor2Neighbor loss.

Splits the noisy measurements using two masks \(A_1\) and \(A_2\), each choosing a different neighboring map (see details in “Neighbor2Neighbor: Self-Supervised Denoising from Single Noisy Images”).

The self-supervised loss is computed as:

\[\| A_2 y - R(A_1 y)\|^2 + \gamma \| A_2 y - R(A_1 y) - (A_2 R(y) - A_1 R(y))\|^2\]

where \(R\) is the trainable denoiser network, \(\gamma>0\) is a regularization parameter and no gradient is propagated when computing \(R(y)\).

By default, the error is computed using the MSE metric, however any other metric (e.g., \(\ell_1\)) can be used as well.

The code has been adapted from the repository https://github.com/TaoHuang2018/Neighbor2Neighbor.

Parameters:
  • metric (Metric, torch.nn.Module) – metric used for computing data consistency, which is set as the mean squared error by default.

  • gamma (float) – regularization parameter \(\gamma\).

forward(y, physics, model, **kwargs)[source]

Computes the neighbor2neighbor loss.

Parameters:
Returns:

(torch.Tensor) loss.

Examples using Neighbor2Neighbor:

Self-supervised denoising with the Neighbor2Neighbor loss.

Self-supervised denoising with the Neighbor2Neighbor loss.