if (torch_is_installed()) {
a <- torch_tensor(c(1., 2., NaN, 4.))
torch_nansum(a)
torch_nansum(torch_tensor(c(1., NaN)))
a <- torch_tensor(rbind(c(1, 2), c(3., NaN)))
torch_nansum(a)
torch_nansum(a, dim=1)
torch_nansum(a, dim=2)
}
Run the code above in your browser using DataLab