DecomposablePhysics#

class deepinv.physics.DecomposablePhysics(U=lambda x: ..., U_adjoint=lambda x: ..., V=lambda x: ..., V_adjoint=lambda x: ..., mask=1.0, **kwargs)[source]#

Bases: LinearPhysics

Parent class for linear operators with SVD decomposition.

The singular value decomposition is expressed as

\[A = U\text{diag}(s)V^{\top} \in \mathbb{R}^{m\times n}\]

where \(U\in\mathbb{C}^{n\times n}\) and \(V\in\mathbb{C}^{m\times m}\) are orthonormal linear transformations and \(s\in\mathbb{R}_{+}^{n}\) are the singular values.

Parameters:
  • U (Callable) – orthonormal transformation

  • U_adjoint (Callable) – transpose of U

  • V (Callable) – orthonormal transformation

  • V_adjoint (Callable) – transpose of V

  • params (torch.nn.parameter.Parameter, float) – Singular values of the transform


Examples:

Recreation of the Inpainting operator using the DecomposablePhysics class:

>>> from deepinv.physics import DecomposablePhysics
>>> seed = torch.manual_seed(0)  # Random seed for reproducibility
>>> tensor_size = (1, 1, 3, 3)  # Input size
>>> mask = torch.tensor([[1, 0, 1], [1, 0, 1], [1, 0, 1]])  # Binary mask
>>> U = lambda x: x  # U is the identity operation
>>> U_adjoint = lambda x: x  # U_adjoint is the identity operation
>>> V = lambda x: x  # V is the identity operation
>>> V_adjoint = lambda x: x  # V_adjoint is the identity operation
>>> mask_svd = mask.float().unsqueeze(0).unsqueeze(0)  # Convert the mask to torch.Tensor and adjust its dimensions
>>> physics = DecomposablePhysics(U=U, U_adjoint=U_adjoint, V=V, V_adjoint=V_adjoint, mask=mask_svd)

Apply the operator to a random tensor:

>>> x = torch.randn(tensor_size)
>>> with torch.no_grad():
...     physics.A(x)  # Apply the masking
tensor([[[[ 1.5410, -0.0000, -2.1788],
          [ 0.5684, -0.0000, -1.3986],
          [ 0.4033,  0.0000, -0.7193]]]])
A(x, mask=None, **kwargs)[source]#

Applies the forward operator \(y = A(x)\).

If a mask/singular values is provided, it is used to apply the forward operator, and also stored as the current mask/singular values.

Parameters:
Returns:

output tensor

Return type:

Tensor

A_A_adjoint(y, mask=None, **kwargs)[source]#

A helper function that computes \(A A^{\top}y\).

Using the SVD decomposition, we have \(A A^{\top} = U\text{diag}(s^2)U^{\top}\).

Parameters:

y (torch.Tensor) – measurement.

Returns:

(torch.Tensor) the product \(AA^{\top}y\).

A_adjoint(y, mask=None, **kwargs)[source]#

Computes the adjoint of the forward operator \(\tilde{x} = A^{\top}y\).

If a mask/singular values is provided, it is used to apply the adjoint operator, and also stored as the current mask/singular values.

Parameters:
Returns:

output tensor

Return type:

Tensor

A_adjoint_A(x, mask=None, **kwargs)[source]#

A helper function that computes \(A^{\top} A x\).

Using the SVD decomposition, we have \(A^{\top}A = V\text{diag}(s^2)V^{\top}\).

Parameters:

x (torch.Tensor) – signal/image.

Returns:

(torch.Tensor) the product \(A^{\top}Ax\).

A_dagger(y, mask=None, **kwargs)[source]#

Computes \(A^{\dagger}y = x\) in an efficient manner leveraging the singular vector decomposition.

Parameters:

y (torch.Tensor) – a measurement \(y\) to reconstruct via the pseudoinverse.

Returns:

(torch.Tensor) The reconstructed image \(x\).

U(x)[source]#

Applies the \(U\) operator of the SVD decomposition.

Note

This method should be overwritten by the user to define its custom DecomposablePhysics operator.

Parameters:

x (torch.Tensor) – input tensor

U_adjoint(x)[source]#

Applies the \(U^{\top}\) operator of the SVD decomposition.

Note

This method should be overwritten by the user to define its custom DecomposablePhysics operator.

Parameters:

x (torch.Tensor) – input tensor

V(x)[source]#

Applies the \(V\) operator of the SVD decomposition.

Note

This method should be overwritten by the user to define its custom DecomposablePhysics operator.

Parameters:

x (torch.Tensor) – input tensor

V_adjoint(x)[source]#

Applies the \(V^{\top}\) operator of the SVD decomposition.

Note

This method should be overwritten by the user to define its custom DecomposablePhysics operator.

Parameters:

x (torch.Tensor) – input tensor

prox_l2(z, y, gamma, **kwargs)[source]#

Computes proximal operator of \(f(x)=\frac{\gamma}{2}\|Ax-y\|^2\) in an efficient manner leveraging the singular vector decomposition.

Parameters:
Returns:

(torch.Tensor) estimated signal tensor

update_parameters(**kwargs)[source]#

Updates the singular values of the operator.

Examples using DecomposablePhysics:#

A tour of blur operators

A tour of blur operators

Image deblurring with custom deep explicit prior.

Image deblurring with custom deep explicit prior.

Creating your own dataset

Creating your own dataset

Reconstructing an image using the deep image prior.

Reconstructing an image using the deep image prior.

Saving and loading models

Saving and loading models

Creating a forward operator.

Creating a forward operator.

A tour of forward sensing operators

A tour of forward sensing operators

Tour of MRI functionality in DeepInverse

Tour of MRI functionality in DeepInverse

Training a reconstruction network.

Training a reconstruction network.

Image deblurring with Total-Variation (TV) prior

Image deblurring with Total-Variation (TV) prior

Image inpainting with wavelet prior

Image inpainting with wavelet prior

Expected Patch Log Likelihood (EPLL) for Denoising and Inpainting

Expected Patch Log Likelihood (EPLL) for Denoising and Inpainting

Patch priors for limited-angle computed tomography

Patch priors for limited-angle computed tomography

DPIR method for PnP image deblurring.

DPIR method for PnP image deblurring.

PnP with custom optimization algorithm (Condat-Vu Primal-Dual)

PnP with custom optimization algorithm (Condat-Vu Primal-Dual)

Plug-and-Play algorithm with Mirror Descent for Poisson noise inverse problems.

Plug-and-Play algorithm with Mirror Descent for Poisson noise inverse problems.

Building your custom sampling algorithm.

Building your custom sampling algorithm.

Image reconstruction with a diffusion model

Image reconstruction with a diffusion model

Implementing DiffPIR

Implementing DiffPIR

Implementing DPS

Implementing DPS

Uncertainty quantification with PnP-ULA.

Uncertainty quantification with PnP-ULA.

Self-supervised MRI reconstruction with Artifact2Artifact

Self-supervised MRI reconstruction with Artifact2Artifact

Image transformations for Equivariant Imaging

Image transformations for Equivariant Imaging

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.

Self-supervised denoising with the Neighbor2Neighbor loss.

Self-supervised denoising with the Neighbor2Neighbor loss.

Self-supervised denoising with the Generalized R2R loss.

Self-supervised denoising with the Generalized R2R loss.

Self-supervised denoising with the SURE loss.

Self-supervised denoising with the SURE loss.

Self-supervised denoising with the UNSURE loss.

Self-supervised denoising with the UNSURE loss.

Deep Equilibrium (DEQ) algorithms for image deblurring

Deep Equilibrium (DEQ) algorithms for image deblurring

Unfolded Chambolle-Pock for constrained image inpainting

Unfolded Chambolle-Pock for constrained image inpainting