pylops_gpu.TorchOperator

class pylops_gpu.TorchOperator(Op, batch=False, pylops=False, device='cpu')[source]

Wrap a PyLops operator into a Torch function.

This class can be used to wrap a pylops (or pylops-gpu) 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 adjont operator for its backward (gradient) pass.

Parameters:
Op : pylops_gpu.LinearOperator or pylops.LinearOperator

PyLops operator

batch : bool, optional

Input has single sample (False) or batch of samples (True). If batch==False the input must be a 1-d Torch tensor, if batch==False` the input must be a 2-d Torch tensor with batches along the first dimension

pylops : bool, optional

Op is a pylops operator (True) or a pylops-gpu operator (False)

device : str, optional

Device to be used for output vectors when Op is a pylops operator

Returns:
y : torch.Tensor

Output array resulting from the application of the operator to x.

Methods

__init__(Op[, batch, pylops, device]) Initialize self.
apply(x) Apply forward pass to input vector
apply(x)[source]

Apply forward pass to input vector

Parameters:
x : torch.Tensor

Input array

Returns:
y : torch.Tensor

Output array resulting from the application of the operator to x.

Examples using pylops_gpu.TorchOperator