TensorList

class deepinv.utils.TensorList(x)[source]

Bases: object

Represents a list of torch.Tensor with different shapes. It allows to sum, flatten, append, etc. lists of tensors seamlessly, in a similar fashion to torch.Tensor.

Parameters:

x – a list of torch.Tensor, a single torch.Tensor or a TensorList.

__add__(other)[source]

Adds two TensorLists. The sizes of the tensor lists must match.

__mul__(other)[source]

Multiply two TensorLists. The sizes of the tensor lists must match.

__neg__()[source]

Negate a TensorList.

__sub__(other)[source]

Substract two TensorLists. The sizes of the tensor lists must match.

__truediv__(other)[source]

Divide two TensorLists. The sizes of the tensor lists must match.

append(other)[source]

Appends a torch.Tensor or a list of torch.Tensor to the list.

conj()[source]

Computes the conjugate of the elements of the TensorList.

flatten()[source]

Returns a torch.Tensor with a flattened version of the list of tensors.

reshape(shape)[source]

Reshape each tensor of the TensorList into the given list of shapes.

sum(dim, keepdim=False)[source]

Computes the sum of each elements of the TensorList along the given dimension(s).

Examples using TensorList:

Stacking and concatenating forward operators.

Stacking and concatenating forward operators.