View source: R/gen-namespace.R
torch_count_nonzero | R Documentation |
Count_nonzero
torch_count_nonzero(self, dim = NULL)
self |
(Tensor) the input tensor. |
dim |
(int or tuple of ints, optional) Dim or tuple of dims along which to count non-zeros. |
Counts the number of non-zero values in the tensor input
along the given dim
.
If no dim is specified then all non-zeros in the tensor are counted.
if (torch_is_installed()) {
x <- torch_zeros(3,3)
x[torch_randn(3,3) > 0.5] = 1
x
torch_count_nonzero(x)
torch_count_nonzero(x, dim=1)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.