TorchDirichletMixtureDistribution¶
- class probly.representation.distribution.torch_mixture.TorchDirichletMixtureDistribution(components: D = <property object>, mixture_weights: torch.Tensor = <property object>, type: Literal['mixture'] = 'mixture')[source]¶
Bases:
TorchMixtureDistribution[TorchDirichletDistribution,TorchCategoricalDistribution],MixtureDistribution[TorchDirichletDistribution,TorchCategoricalDistribution]Mixture distribution with Dirichlet components and torch tensor mixture weights.
- clone(*, memory_format: memory_format = torch.preserve_format) Self[source]¶
Return a copy of the array.
- component_type[source]¶
alias of
TorchDirichletDistribution
- components: TorchDirichletDistribution¶
- 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: Tensor) Self[source]¶
Return a copy with gathered protected values along a batch dimension.
- 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: Size | int | tuple[int] | list[int]) Self[source]¶
Return a permuted version of the array.
- protected_axes = {'components': 1, 'mixture_weights': 1}¶
- protected_values(func: Callable | None = None) dict[str, TorchProtectedValue] | None[source]¶
Return all protected field values as-is.
Optionally takes the torch function that triggered the call for context. This can be used to conditionally modify the returned values or prevent them from being accessed.
- 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.
- size(dim: int | None = None) int | Size[source]¶
Return the size of the array along the given dimension.
- to_device(device: Literal['cpu'], /, *, stream: int | Any | None = None) Self[source]¶
Move the array to a device.
- type¶