Loss

This package contains popular training losses for supervised and self-supervised learning, which are especially designed for inverse problems.

Introduction

All losses inherit from the base class deepinv.loss.Loss(), which is a meth:torch.nn.Module.

deepinv.loss.Loss

Base class for all loss/metric functions.

>>> import torch
>>> import deepinv as dinv
>>> loss = dinv.loss.SureGaussianLoss(.1)
>>> physics = dinv.physics.Denoising()
>>> x = torch.ones(1, 3, 16, 16)
>>> y = physics(x)
>>> model = dinv.models.DnCNN()
>>> x_net = model(y)
>>> l = loss(x_net=x_net, y=y, physics=physics, model=model) # self-supervised loss, doesn't require ground truth x

Supervised Learning

Use a dataset of pairs of signals and measurements (and possibly information about the forward operator), i.e., they can be written as \(\mathcal{L}(x,\inverse{y})\).

deepinv.loss.SupLoss

Standard supervised loss

Self-Supervised Learning

Use a dataset of measurement data alone (and possibly information about the forward operator), i.e., they can be written as \(\mathcal{L}(y,\inverse{y})\) and take into account information about the forward measurement process.

deepinv.loss.MCLoss

Measurement consistency loss

deepinv.loss.EILoss

Equivariant imaging self-supervised loss.

deepinv.loss.MOILoss

Multi-operator imaging loss

deepinv.loss.Neighbor2Neighbor

Neighbor2Neighbor loss.

deepinv.loss.SplittingLoss

Measurement splitting loss.

deepinv.loss.SureGaussianLoss

SURE loss for Gaussian noise

deepinv.loss.SurePoissonLoss

SURE loss for Poisson noise

deepinv.loss.SurePGLoss

SURE loss for Poisson-Gaussian noise

deepinv.loss.TVLoss

Total variation loss (\(\ell_2\) norm).

deepinv.loss.R2RLoss

Recorrupted-to-Recorrupted (R2R) Loss

Metrics

Metrics are generally used to evaluate the performance of a model. Some of them can be used as training losses as well.

deepinv.loss.PSNR

Peak Signal-to-Noise Ratio (PSNR) metric.

deepinv.loss.SSIM

Structural Similarity Index (SSIM) metric.

deepinv.loss.LPIPS

Learned Perceptual Image Patch Similarity (LPIPS) metric.

deepinv.loss.NIQE

Natural Image Quality Evaluator (NIQE) metric.

Transforms

This submodule contains different transforms which can be used for data augmentation or together with the equivariant losses.

deepinv.transform.Rotate

2D Rotations.

deepinv.transform.Shift

Fast integer 2D translations.

deepinv.transform.Scale

2D Scaling.

Network Regularization

These losses can be used to regularize the learned function, e.g., controlling its Lipschitz constant.

deepinv.loss.JacobianSpectralNorm

Computes the spectral norm of the Jacobian.

deepinv.loss.FNEJacobianSpectralNorm

Computes the Firm-Nonexpansiveness Jacobian spectral norm.

Utils

A set of popular distances that can be used by the supervised and self-supervised losses.

deepinv.loss.LpNorm

\(\ell_p\) metric for \(p>0\).