Utilities¶
Numerical helpers for stable fuzzy-logic operations, importable from
quivers.core. The default margin EPS is documented on the
core overview.
_util
¶
Numerical utilities for stable fuzzy-logic operations.
clamp_probs
¶
Clamp tensor values to the open interval (eps, 1 - eps).
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Input tensor with values nominally in [0, 1].
TYPE:
|
eps
|
Clamping margin.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Clamped tensor. |
Source code in src/quivers/core/_util.py
safe_log1p_neg
¶
Compute log(1 - x) in a numerically stable way.
Uses torch.log1p(-x) after clamping x away from 1.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Input tensor with values in [0, 1].
TYPE:
|
eps
|
Clamping margin.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
log(1 - x), with values in (-inf, 0]. |