probly.representation.torch_like.TorchLikeImplementation

class probly.representation.torch_like.TorchLikeImplementation(*args, **kwargs)[source]

Bases: ArrayLike, ABC, Generic

ABC implementation for array-like objects that behave like torch tensors.

property T: Self

Inverts the order of the dimensions of the underlying array.

clone(*, memory_format: memory_format = torch.preserve_format) Self[source]

Return a copy of the array.

cpu(memory_format: memory_format = torch.preserve_format) Self[source]

Move the array to the CPU.

cuda(device: device | str | None = None, non_blocking: bool = False, memory_format: memory_format = torch.preserve_format) Self[source]

Move the array to the GPU.

abstractmethod detach() Self[source]

Return a detached version of the array.

property device: Any

Device of the array.

property dtype: Any

Data type of the array.

abstract property mH: Self

The adjoint (conjugate) transposed version of the underlying array.

abstract property mT: Self

The transposed version of the underlying array.

property ndim: int

Number of dimensions.

abstractmethod numpy(*, force: bool = False) NDArray[Any][source]

Convert to a numpy array.

permute(*dims: Size | int | tuple[int] | list[int]) Self[source]

Return a permuted version of the array.

resolve_conj() Self[source]

Return a version of the array with any conjugate operations resolved.

resolve_neg() Self[source]

Return a version of the array with any negation operations resolved.

property shape: tuple[int, ...]

Shape of the array.

abstractmethod size(dim: int) int[source]
abstractmethod size(dim: None = None) Size

Return the size of the array along the given dimension.

abstractmethod to(dtype: dtype, non_blocking: bool = False, copy: bool = False, *, memory_format: memory_format = torch.preserve_format) Self[source]
abstractmethod to(device: device | str | None = None, dtype: dtype | None = None, non_blocking: bool = False, copy: bool = False, *, memory_format: memory_format = torch.preserve_format) Self
abstractmethod to(other: Tensor, non_blocking: bool = False, copy: bool = False) Self

Move and/or cast the tensor, mirroring torch.Tensor.to.

to_device(device: Literal['cpu'], /, *, stream: int | Any | None = None) Self[source]

Move the array to a device.

transpose(dim0: int, dim1: int) Self[source]

Return a transposed version of the array.

Examples using probly.representation.torch_like.TorchLikeImplementation

MC-Dropout uncertainty on a 2-D stream

MC-Dropout uncertainty on a 2-D stream