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.

clone()[source]#

Returns a copy of the TensorList.

conj()[source]#

Computes the conjugate of the elements of the TensorList.

cpu()[source]#

Moves the TensorList to the cpu.

cuda(*args, **kwargs)[source]#

Moves the TensorList to the cuda device.

detach()[source]#

Returns a copy of the TensorList with detached gradients.

flatten()[source]#

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

numpy()[source]#

Returns a list of numpy arrays.

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).

to(*args, **kwargs)[source]#

Moves the TensorList to the given device and dtype.

type(dtype)[source]#

Returns the TensorList with the given dtype.

Examples using TensorList:#

Remote sensing with satellite images

Remote sensing with satellite images