torch.numel torch.numel(input) → 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