TorchDirichletLevelSetCredalSet

class probly.representation.credal_set.torch.TorchDirichletLevelSetCredalSet(alphas: Tensor, threshold: Tensor)[source]

Bases: TorchAxisProtected[Any], TorchCategoricalCredalSet, DirichletLevelSetCredalSet

Dirichlet density level set credal set.

Contains all distributions whose Dirichlet likelihood is at least threshold times the peak density.

property T: Self

Inverts the order of the dimensions of the underlying array.

alphas: torch.Tensor
property barycenter: TorchCategoricalDistribution

Return the Dirichlet mean as the barycenter.

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.

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.

classmethod from_sample(sample: Sample[TorchCategoricalDistribution]) Self[source]

Create a credal set from a finite sample.

Parameters:

sample – The sample to create the credal set from.

Returns:

The created credal set.

classmethod from_torch_sample(sample: TorchSample[TorchCategoricalDistribution]) Self[source]

Create from a torch sample (not supported).

Raises:

NotImplementedError – Always, as this credal set type cannot be created from samples.

gather(dim: int, index: Tensor) Self[source]

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

lower() Tensor[source]

Compute per-class lower bounds via Monte Carlo sampling.

Returns:

Lower probability bounds, shape (…, K).

property mH: Self

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

property mT: Self

The transposed version of the underlying array.

property ndim: int

Number of dimensions.

property num_classes: int

Return the number of classes.

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

Convert to a numpy array.

permitted_functions = {}
permute(*dims: Size | int | tuple[int] | list[int]) Self[source]

Return a permuted version of the array.

classmethod primary_protected_name() str[source]

Return the first protected field (dict order).

protected_axes: ClassVar[dict[str, int]] = {'alphas': 1, 'threshold': 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, 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.

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

Return a copy with reshaped protected values.

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 shape: tuple[int, ...]

Shape of the array.

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

Return the size of the array along the given dimension.

threshold: torch.Tensor
to(*args: Any, **kwargs: Any) Self[source]

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

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.

type = 'categorical'
upper() Tensor[source]

Compute per-class upper bounds via Monte Carlo sampling.

Returns:

Upper probability bounds, shape (…, K).

with_protected_values(values: dict[str, TorchProtectedValue], func: Callable | None = None) TorchAxisProtected[T][source]

Return a copy with updated protected field values.