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, **kwargs)[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, x, y, physics, model, **kwargs)[source]#

Computes the loss.

Parameters:
Returns:

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

Return type:

torch.Tensor

Examples using Loss:#

Image transforms for equivariance & augmentations

Image transforms for equivariance & augmentations

Remote sensing with satellite images

Remote sensing with satellite images

Training a reconstruction network.

Training a reconstruction network.

Tour of MRI functionality in DeepInverse

Tour of MRI functionality in DeepInverse

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

Image transformations for Equivariant Imaging

Image transformations for Equivariant Imaging

Self-supervised learning with measurement splitting

Self-supervised learning with measurement splitting

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 denoising with the Generalized R2R loss.

Self-supervised denoising with the Generalized R2R loss.

Self-supervised learning from incomplete measurements of multiple operators.

Self-supervised learning from incomplete measurements of multiple operators.

Self-supervised MRI reconstruction with Artifact2Artifact

Self-supervised MRI reconstruction with Artifact2Artifact

Imaging inverse problems with adversarial networks

Imaging inverse problems with adversarial networks