probly.representation.distribution.torch_gaussian.TorchGaussianDistributionSample

class probly.representation.distribution.torch_gaussian.TorchGaussianDistributionSample(tensor: D, sample_dim: int, weights: torch.Tensor | None = None)[source]

Bases: GaussianDistributionSample[TorchGaussianDistribution], TorchSample[TorchGaussianDistribution]

Sample type for empirical second-order Gaussian distributions.

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.

concat(other: Sample[D]) Self[source]

Append another sample to this sample.

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.

detach() Self[source]

Return a detached copy of the sample tensor wrapper.

property device: Any

The device of the underlying array.

property dtype: dtype

The data type of the underlying array.

classmethod from_iterable(samples: Iterable[ArrayLike[D]], weights: Iterable[float] | None = None, sample_dim: SampleAxis | None = None, sample_axis: SampleAxis | None = 'auto', dtype: torch.dtype | None = None) Self[source]

Create an TorchSample from a sequence of samples.

Parameters:
  • samples – The predictions to create the sample from.

  • weights – Optional weights for the samples.

  • sample_dim – The dimension along which samples are organized.

  • sample_axis – Alias for sample_dim for compatibility.

  • dtype – Desired data type of the array.

Returns:

The created TorchSample.

classmethod from_sample(sample: Sample[T], **kwargs: Unpack[SampleParams]) Self[source]

Create a new Sample from an existing Sample.

Parameters:
  • sample – The sample to create the new sample from.

  • kwargs – Parameters for sample creation.

Returns:

The created Sample.

property is_weighted: bool

Return whether the samples are weighted.

property mH: Self

The adjoint view over the last two dimensions.

property mT: Self

The transposed view over the last two dimensions.

move_sample_axis(new_sample_axis: int) TorchSample[source]

Alias for TorchSample.move_sample_dim().

move_sample_dim(new_sample_dim: int) TorchSample[source]

Return a new TorchSample with the sample dimension moved to new_sample_dim.

Parameters:

new_sample_dim – The new sample dimension.

Returns:

A new TorchSample with the sample dimension moved.

property ndim: int

The number of dimensions of the underlying array.

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 sample_axis: int

The axis along which samples are organized.

sample_dim: int
sample_mean() D[source]

Compute the mean of the sample.

property sample_size: int

Return the number of samples.

sample_space[source]

alias of TorchGaussianDistribution

sample_std(ddof: int = 0) D[source]

Compute the standard deviation of the sample.

sample_var(ddof: int = 0) D[source]

Compute the variance of the sample.

property samples: D

Return an iterator over the samples.

property shape: tuple[int, ...]

The shape of the underlying array.

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

The total number of elements in the underlying array.

tensor: D
to(*args: Any, **kwargs: Any) Self[source]

Moves and/or casts the underlying tensor. See torch.Tensor.to for details.

Parameters:
  • *args – Positional arguments to pass to torch.Tensor.to.

  • **kwargs – Keyword arguments to pass to torch.Tensor.to.

Returns:

A copy of the TorchSample.

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.

weights: Tensor | None