Shortcuts

torch.numel

torch.numel(input) int

返回input张量中元素的总数。

Parameters

输入 (张量) – 输入张量。

示例:

>>> a = torch.randn(1, 2, 3, 4, 5)
>>> torch.numel(a)
120
>>> a = torch.zeros(4,4)
>>> torch.numel(a)
16
优云智算