torch.allclose¶
- torch.allclose(input, other, rtol=1e-05, atol=1e-08, equal_nan=False) bool ¶
This function checks if
input
andother
satisfy the condition:elementwise, for all elements of
input
andother
. The behaviour of this function is analogous to numpy.allclose- Parameters:
Example:
>>> torch.allclose(torch.tensor([10000., 1e-07]), torch.tensor([10000.1, 1e-08])) False >>> torch.allclose(torch.tensor([10000., 1e-08]), torch.tensor([10000.1, 1e-09])) True >>> torch.allclose(torch.tensor([1.0, float('nan')]), torch.tensor([1.0, float('nan')])) False >>> torch.allclose(torch.tensor([1.0, float('nan')]), torch.tensor([1.0, float('nan')]), equal_nan=True) True