捷徑

torch.numel

torch.numel(input: Tensor) int

傳回 input tensor 中的元素總數。

參數

input (Tensor) – 輸入 tensor。

範例

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

文件

取得 PyTorch 完整的開發者文件

檢視文件

教學課程

取得針對初學者和進階開發者的深入教學課程

檢視教學課程

資源

尋找開發資源並獲得您的問題解答

檢視資源