TorchGaussianDistribution

class probly.representation.distribution.torch_gaussian.TorchGaussianDistribution(mean: Tensor, var: Tensor)[source]

Bases: TorchAxisProtected[TorchGaussianDistribution, TorchGaussianDistribution | torch.Tensor | float, TorchGaussianDistribution, Never, TorchGaussianDistribution, Tensor, TorchGaussianDistribution], GaussianDistribution[Tensor]

Gaussian distribution with torch tensor parameters.

Addition and subtraction combine independent Gaussian variances. Constant shifts and sign changes preserve variance. Arithmetic requires alpha=1 and does not support out; use the returned distribution instead.

property T: ShapeResultT

Inverts the order of the dimensions of the underlying array.

clone(*, memory_format: torch.memory_format = torch.preserve_format) → OwnerT[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.

detach() → Self[source]

Return a detached version of the array.

property device: device

Device of the array.

property dtype: dtype

Data type of the array.

entropy() → ArrayLike[source]

Compute entropy.

gather(dim: int, index: torch.Tensor) → ShapeResultT[source]

Return a copy with gathered protected values along a batch dimension.

property mH: ShapeResultT

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

property mT: ShapeResultT

The transposed version of the underlying array.

mean: torch.Tensor
property ndim: int

Number of dimensions.

numpy(*, force: bool = False) → ndarray[source]

Convert to a numpy array.

permitted_functions: ClassVar[set[Callable]] = {<built-in method add of type object>, <built-in method eq of type object>, <built-in method ne of type object>, <built-in method neg of type object>, <built-in method positive of type object>, <built-in method sub of type object>}
permute(*dims: torch.Size | int | tuple[int] | list[int]) → ShapeResultT[source]

Return a permuted version of the array.

primary_protected_name = 'mean'
protected_axes = {'mean': 0, 'var': 0}
property protected_shape: tuple[int, ...]

Protected trailing shape of the primary field.

protected_value() → TorchProtectedValue[source]

Return the primary protected value.

protected_values(func: Callable | None = None) → dict[str, V] | None[source]

Read effective values as-is, optionally checking function permissions.

quantile(q: float | list[float] | Tensor) → Tensor[source]

Calculate the quantile function at the given points.

reshape(*shape: int | tuple[int, ...]) → ShapeResultT[source]

Return a copy with reshaped protected values.

resolve_conj() → OpResultT[source]

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

resolve_neg() → OpResultT[source]

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

sample(num_samples: int = 1, rng: Generator | None = None) → TorchSample[Tensor][source]

Draw samples and wrap them in a TorchSample (sample_dim=0).

property shape: tuple[int, ...]

Read the logical shape without collecting fields unless all broadcast.

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

Return the size of the array along the given dimension.

property std: Tensor

Get the standard deviation.

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

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

to_device(device: device | str | None = None, /, *, stream: int | Any | None = None) → Self[source]

Move the array to the given device.

Parameters:
  • device – Target device, or None to retain the current device.

  • stream – Unsupported; must be None.

Returns:

The moved array representation.

Raises:

NotImplementedError – If a stream is provided.

transpose(dim0: int, dim1: int) → ShapeResultT[source]

Return a transposed version of the array.

type: ClassVar[Literal['gaussian']] = 'gaussian'
validate() → None[source]

Raise if effective fields have insufficient rank or incompatible batches.

Call explicitly, or from __post_init__ to check dataclass construction. Fields owned by initialization (init=False) are excluded.

var: torch.Tensor
with_protected_values(values: dict[str, TorchProtectedValue], func: Callable | None = None) → OwnerT | OpResultT | ShapeResultT | CompResultT | SetResultT[source]

Return a copy with updated protected field values.