- class pylops.TorchOperator(Op, batch=False, flatten=True, device='cpu', devicetorch='cpu')#
Wrap a PyLops operator into a Torch function.
This class can be used to wrap a pylops operator into a torch function. Doing so, users can mix native torch functions (e.g. basic linear algebra operations, neural networks, etc.) and pylops operators.
Since all operators in PyLops are linear operators, a Torch function is simply implemented by using the forward operator for its forward pass and the adjoint operator for its backward (gradient) pass.
Input has single sample (
False) or batch of samples (
batch==Falsethe input must be a 1-d Torch tensor or a tensor of size equal to
batch==Truethe input must be a 2-d Torch tensor with batches along the first dimension or a tensor of size equal to
nbatchis the size of the batch
Input is flattened along
True) or not (
Device to be used when applying operator (
Device to be assigned the output of the operator to (any Torch-compatible device)
__init__(Op[, batch, flatten, device, ...])
Apply forward pass to input vector