Operator.py π§ΒΆ
Source: LION/operators/Operator.py
Warning
This file has not yet received a complete narrative and docstring audit. Its public source-level API is listed automatically below.
Base class for operators in LION.
- class Operator(device: torch.device | str | None = None)
Base class for operators in LION.
Operators represent mathematical operations that can be applied to data, such as forward and backward projections in imaging.
The main purpose of this class is to define a common interface for all operators in LION. The most important API for algorithms includes
forward,adjoint, anddomain_shape/range_shape.This class should be subclassed to implement specific operators.
Parameters βββ- device : torch.device | str | None, optional Device for computations. If None, computations are done on the default device.
- Operator.forward(self, x: torch.Tensor) torch.Tensor
Apply the forward operation of Operator.
Note
Prefer calling the instance of the Operator operator as
operator(x)over directly calling this method. See this PyTorch discussion.
- Operator.adjoint(self, y: torch.Tensor) torch.Tensor
Apply the adjoint (backward) operation of the operator.
Parameters βββ- y : torch.Tensor Input to which the adjoint operator is applied.
Returns ββ- torch.Tensor Result of applying the adjoint operation.
- Operator.gram(self, x: torch.Tensor) torch.Tensor
Apply the Gram operator.
For a LinearOperator \(A\), the self-adjoint Gram operator is defined as \(A^H A\).
Note
This is the inherited default implementation.
- Operator.inverse(self, y: torch.Tensor) torch.Tensor
Computes the inverse of the operator applied to input x if exists.
This method should only be implemented by subclasses that have a well-defined inverse.
Parameters βββ- y : torch.Tensor The input data to which the inverse operator is applied.
Returns ββ- torch.Tensor The result of applying the inverse operator to x.
- Operator.domain_shape(self) tuple[int, ...]
Get the shape of the image domain.
Returns ββ- Shape of the image domain.
- Operator.range_shape(self) tuple[int, ...]
Get the shape of the data (measurement) domain.
Returns ββ- Shape of the data (measurement) domain.