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