torch.numel
-
torch.numel(input: Tensor) → int -
Возвращает общее число элементов в тензоре
input.- Параметры:
-
input (Tensor) – входной тензор.
Пример:
>>> a = torch.randn(1, 2, 3, 4, 5) >>> torch.numel(a) 120 >>> a = torch.zeros(4,4) >>> torch.numel(a) 16
© 2026, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://docs.pytorch.org/docs/2.14/generated/torch.numel.html