TorchMixtureDistribution¶
- class probly.representation.distribution.torch_mixture.TorchMixtureDistribution(components: D, mixture_weights: torch.Tensor)[source]¶
Bases:
TorchAxisProtected[OwnerT,OwnerT,OwnerT,Never,OwnerT,Tensor,OwnerT],MixtureDistribution,GenericMixture distribution with torch tensor mixture weights.
The final batch axis of
componentsandmixture_weightsis the protected component axis. The exposed shape is the shared batch shape before that component axis.- 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.
- component_type[source]¶
alias of
Distribution
- components: D¶
- 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.
- 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.
- property mean: T¶
Compute the mean of the mixture distribution.
- mixture_weights: torch.Tensor¶
- property normalized_mixture_weights: Tensor¶
Return mixture weights normalized along the component axis.
- permitted_functions = {}¶
- permute(*dims: torch.Size | int | tuple[int] | list[int]) ShapeResultT[source]¶
Return a permuted version of the array.
- primary_protected_name = 'components'¶
- protected_values(func: Callable | None = None) dict[str, V] | None[source]¶
Read effective values as-is, optionally checking function permissions.
- 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: torch.Generator | None = None) TorchSample[T][source]¶
Draw samples from the mixture distribution.
- Parameters:
num_samples – Number of samples to draw.
rng – Optional torch random generator used for component selection and forwarded to components that accept an
rngargument.
- Returns:
Samples drawn from the selected mixture components.
- 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.
- 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.
- type: ClassVar[Literal['mixture']] = 'mixture'¶