spd_learn.functional.get_epsilon_tensor#
- spd_learn.functional.get_epsilon_tensor(dtype: dtype, name: Literal['eigval_clamp', 'eigval_log', 'eigval_sqrt', 'eigval_inv_sqrt', 'eigval_power', 'loewner_equal', 'batchnorm_var', 'dropout', 'trace_norm', 'stiefel_init', 'division_safe'] = 'eigval_clamp', *, device: str | device | None = None, config: NumericalConfig | None = None) Tensor[source]#
Get a dtype-aware epsilon value as a tensor.
Similar to
get_epsilon(), but returns a tensor on the specified device. This is useful when the epsilon needs to be used in tensor operations that require matching devices.- Parameters:
dtype (torch.dtype) – The PyTorch dtype to compute epsilon for.
name (ThresholdName, default="eigval_clamp") – The type of threshold to compute.
device (str or torch.device, optional) – The device to place the tensor on. If None, uses CPU.
config (NumericalConfig, optional) – Configuration to use. If None, uses the global
numerical_config.
- Returns:
A scalar tensor containing the epsilon value.
- Return type:
Examples
>>> import torch >>> from spd_learn.functional.numerical import get_epsilon_tensor >>> eps = get_epsilon_tensor(torch.float32, "eigval_clamp", device="cpu") >>> print(eps) tensor(0.0012)