Find Number Of Non-zero Elements In A Tensor Along An Aixs
I want to find the number of non-zero elements in a tensor along a particular axis. Is there any PyTorch function which can do this? I tried to use the nonzero() method in PyTorch.
Solution 1:
Meaning of the error message - TypeError: Type Variable doesn't implement stateless method nonzero
is, we cannot use torch.nonzero()
on autograd.Variable
but only on simple tensors. Also it should be noted that, tensors are stateless while the Variables are stateful.
Post a Comment for "Find Number Of Non-zero Elements In A Tensor Along An Aixs"