Loss

class deepinv.loss.Loss[source]

Bases: Module

Base class for all loss functions.

Sets a template for the loss functions, whose forward method must follow the input parameters in deepinv.loss.Loss.forward().

adapt_model(model: Module, **kwargs) Module[source]

Some loss functions require the model forward call to be adapted before the forward pass.

Parameters:

model (torch.nn.Module) – reconstruction model

forward(x_net: Tensor, x: Tensor, y: Tensor, physics: Physics, model: Module, **kwargs) Tensor[source]

Computes the loss.

Parameters:
Returns:

(torch.Tensor) loss, the tensor size might be (1,) or (batch size,).

Examples using Loss:

Imaging inverse problems with adversarial networks

Imaging inverse problems with adversarial networks

Image transforms for equivariance & augmentations

Image transforms for equivariance & augmentations

Training a reconstruction network.

Training a reconstruction network.

Self-supervised learning with measurement splitting

Self-supervised learning with measurement splitting

Image transformations for Equivariant Imaging

Image transformations for Equivariant Imaging

Self-supervised MRI reconstruction with Artifact2Artifact

Self-supervised MRI reconstruction with Artifact2Artifact

Self-supervised denoising with the UNSURE loss.

Self-supervised denoising with the UNSURE loss.

Self-supervised denoising with the SURE loss.

Self-supervised denoising with the SURE loss.

Self-supervised denoising with the Neighbor2Neighbor loss.

Self-supervised denoising with the Neighbor2Neighbor loss.

Self-supervised learning with Equivariant Imaging for MRI.

Self-supervised learning with Equivariant Imaging for MRI.

Self-supervised learning from incomplete measurements of multiple operators.

Self-supervised learning from incomplete measurements of multiple operators.

Learned Iterative Soft-Thresholding Algorithm (LISTA) for compressed sensing

Learned Iterative Soft-Thresholding Algorithm (LISTA) for compressed sensing

Vanilla Unfolded algorithm for super-resolution

Vanilla Unfolded algorithm for super-resolution

Learned iterative custom prior

Learned iterative custom prior

Deep Equilibrium (DEQ) algorithms for image deblurring

Deep Equilibrium (DEQ) algorithms for image deblurring

Learned Primal-Dual algorithm for CT scan.

Learned Primal-Dual algorithm for CT scan.

Unfolded Chambolle-Pock for constrained image inpainting

Unfolded Chambolle-Pock for constrained image inpainting