fn
isclose
→Tensorisclose(input: Tensor, other: Tensor, rtol: float = ..., atol: float = ..., equal_nan: bool = ...)Element-wise approximate equality with absolute and relative tolerance.
Returns a boolean tensor that is True where the two operands are equal up
to a combined absolute / relative tolerance. Useful for comparing
floating-point results where bit-exact equality is too strict.
Parameters
inputTensorLeft operand.
otherTensorRight operand. Broadcasts against
input.rtolfloat= ...Relative tolerance.
atolfloat= ...Absolute tolerance.
equal_nanbool= ...If
True, two NaN entries compare equal.Returns
TensorBoolean tensor (dtype bool) with shape broadcast(input.shape, other.shape).
Notes
Mathematical definition:
When equal_nan is True positions where both operands are NaN are
additionally marked True. Not differentiable.
Examples
>>> import lucid
>>> a = lucid.tensor([1.0, 2.0])
>>> b = lucid.tensor([1.0 + 1e-9, 2.5])
>>> lucid.isclose(a, b, rtol=1e-5, atol=1e-8)
Tensor([True, False])