Helper Functions¶
General utility functions for Logical Neural Networks.
- jlnn.utils.helpers.is_precise(interval: Array, epsilon: float = 1e-05) bool[source]¶
Checks if a truth interval has collapsed into a single point (L ≈ U).
- Parameters:
interval – Truth interval tensor [L, U].
epsilon – Maximum allowed difference between bounds.
- Returns:
True if the uncertainty is within epsilon, False otherwise.
- jlnn.utils.helpers.scalar_to_interval(x: Array) Array[source]¶
Converts standard [0, 1] probability scalars into precise [L, U] intervals.
This is used to ground the JLNN model with data from classical datasets where truth values are known exactly (L = U = x).
- Parameters:
x (jnp.ndarray) – Tensor of scalar truth values.
- Returns:
Tensor of intervals with shape
(*x.shape, 2).- Return type:
jnp.ndarray
Helper functions for transforming data between standard formats and the JLNN interval representation.
scalar_to_interval: Converts classical probabilities in the range \([0, 1]\) to precise intervals \([x, x]\). This is crucial when initializing facts from fixed datasets.
is_precise: Checks whether the interval has already “collapsed” into a single point (zero uncertainty).