allclose¶
- tripy.allclose(a: Tensor, b: Tensor, rtol: float = 1e-05, atol: float = 1e-08) bool [source]¶
Returns true if the following equation is true for every element in
a
andb
:\(|a_i - b_i| <= (\text{atol} + \text{rtol} * |b_i|)\)
- Parameters:
- Returns:
True
if the tensors were within the specified tolerances andFalse
otherwise.- Return type:
Example: Within Tolerance
1out = tp.allclose(tp.Tensor([1e-7]), tp.Tensor([1.1e-7]))
>>> out True
Example: Outside Tolerance
1out = tp.allclose(tp.Tensor([1e-7]), tp.Tensor([1.2e-7]))
>>> out False