torch.numel
-
torch.numel(input) → int
-
Returns the total number of elements in the
input
tensor.- Parameters
-
input (Tensor) – the input tensor.
Example:
>>> a = torch.randn(1, 2, 3, 4, 5) >>> torch.numel(a) 120 >>> a = torch.zeros(4,4) >>> torch.numel(a) 16
© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.numel.html