numel就是"number of elements"的簡寫。numel()能夠直接返回int類型的元素個數python
import torch a = torch.randn(1, 2, 3, 4) b = a.numel() print(type(b)) # int print(b) # 24
經過numel()函數,咱們能夠迅速查看一個張量到底又多少元素。函數
numel就是"number of elements"的簡寫。numel()能夠直接返回int類型的元素個數python
import torch a = torch.randn(1, 2, 3, 4) b = a.numel() print(type(b)) # int print(b) # 24
經過numel()函數,咱們能夠迅速查看一個張量到底又多少元素。函數