
Last chance! 50% off unlimited learning
Sale ends in
Allclose
torch_allclose(self, other, rtol = 1e-05, atol = 0, equal_nan = FALSE)
(Tensor) first tensor to compare
(Tensor) second tensor to compare
(float, optional) relative tolerance. Default: 1e-05
(float, optional) absolute tolerance. Default: 1e-08
(bool, optional) if TRUE
, then two NaN
s will be compared as equal. Default: FALSE
This function checks if all input
and other
satisfy the condition:
input
and other
. The behaviour of this function is analogous to
numpy.allclose <https://docs.scipy.org/doc/numpy/reference/generated/numpy.allclose.html>
_
# NOT RUN {
if (torch_is_installed()) {
torch_allclose(torch_tensor(c(10000., 1e-07)), torch_tensor(c(10000.1, 1e-08)))
torch_allclose(torch_tensor(c(10000., 1e-08)), torch_tensor(c(10000.1, 1e-09)))
torch_allclose(torch_tensor(c(1.0, NaN)), torch_tensor(c(1.0, NaN)))
torch_allclose(torch_tensor(c(1.0, NaN)), torch_tensor(c(1.0, NaN)), equal_nan=TRUE)
}
# }
Run the code above in your browser using DataLab