TorchBernoulliDistribution¶
- class probly.representation.distribution.torch_bernoulli.TorchBernoulliDistribution(*args, **kwargs)[source]¶
Bases:
BernoulliDistribution,TorchCategoricalDistribution,ABCA Bernoulli distribution represented as a categorical distribution with 2 classes.
- 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.
- gather(dim: int, index: Tensor) Self[source]¶
Return a copy with gathered protected values along a batch dimension.
- permitted_functions = {}¶
- permute(*dims: Size | int | tuple[int] | list[int]) Self[source]¶
Return a permuted version of the array.
- protected_axes = {}¶
- 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: Generator | None = None) TorchSample[Tensor][source]¶
Sample from the categorical distribution (torch backend).
- size(dim: int | None = None) int | Size[source]¶
Return the size of the array along the given dimension.
- abstract property tensor: Tensor¶
Get the underlying tensor representing the categorical distribution.
- abstractmethod to_categorical() CategoricalDistribution[source]¶
Convert to a two-class categorical distribution.
- to_device(device: Literal['cpu'], /, *, stream: int | Any | None = None) Self[source]¶
Move the array to a device.
- type: Literal['bernoulli'] = 'bernoulli'¶