StackedPhysicsLoss#
- class deepinv.loss.StackedPhysicsLoss(losses)[source]#
Bases:
Loss
Loss function for stacked physics operators.
Adapted to
deepinv.physics.StackedPhysics
physics composed of multiple physics operators.- Parameters:
losses (list[deepinv.loss.Loss]) – list of loss functions for each physics operator.
- Examples:
Gaussian and Poisson losses function for a stacked physics operator:
>>> import torch >>> import deepinv as dinv >>> # define two observations, one with Gaussian noise and one with Poisson noise >>> physics1 = dinv.physics.Denoising(dinv.physics.GaussianNoise(.1)) >>> physics2 = dinv.physics.Denoising(dinv.physics.PoissonNoise(.1)) >>> physics = dinv.physics.StackedLinearPhysics([physics1, physics2]) >>> loss1 = dinv.loss.SureGaussianLoss(.1) >>> loss2 = dinv.loss.SurePoissonLoss(.1) >>> loss = dinv.loss.StackedPhysicsLoss([loss1, loss2]) >>> x = torch.ones(1, 1, 5, 5) # image >>> y = physics(x) # noisy measurements >>> # define a denoiser model >>> model = dinv.models.ArtifactRemoval(dinv.models.MedianFilter(3)) >>> x_net = model(y, physics) >>> l = loss(x_net, x, y, physics, model)
- forward(x_net: Tensor, x: Tensor, y: TensorList, physics: StackedPhysics, model: Module, **kwargs) Tensor [source]#
Computes the loss as
\[\sum_i \mathcal{L}_i(x, y_i, \inverse{y}, \physics_i, \model),\]where \(i\) is the index of the physics operator in the stacked physics.
- Parameters:
y (deepinv.utils.TensorList) – Measurement.
x_net (torch.Tensor) – Reconstructed image \(\inverse{y}\).
Examples using StackedPhysicsLoss
:#
Remote sensing with satellite images
Remote sensing with satellite images