Is_nonzero
Source:R/gen-namespace-docs.R
, R/gen-namespace-examples.R
, R/gen-namespace.R
torch_is_nonzero.Rd
Is_nonzero
is_nonzero(input) -> (bool)
Returns TRUE if the input
is a single element tensor which is not equal to zero
after type conversions.
i.e. not equal to torch_tensor(c(0))
or torch_tensor(c(0))
or
torch_tensor(c(FALSE))
.
Throws a RuntimeError
if torch_numel() != 1
(even in case
of sparse tensors).
Examples
if (torch_is_installed()) {
torch_is_nonzero(torch_tensor(c(0.)))
torch_is_nonzero(torch_tensor(c(1.5)))
torch_is_nonzero(torch_tensor(c(FALSE)))
torch_is_nonzero(torch_tensor(c(3)))
if (FALSE) {
torch_is_nonzero(torch_tensor(c(1, 3, 5)))
torch_is_nonzero(torch_tensor(c()))
}
}