• 文档 >
  • torch >
  • torch.numel
快捷键

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

© 版权所有 PyTorch 贡献者。

使用 Sphinx 构建,并使用 Read the Docs 提供的主题。

文档

PyTorch 的全面开发者文档

查看文档

教程

深入了解初学者和高级开发者的教程

查看教程

资源

查找开发资源并获得您的疑问解答

查看资源