numel Namely "number of elements" Abbreviation .numel() Can return directly int The number of elements of type
import torch
a = torch.randn(1, 2, 3, 4)
b = a.numel()
print(type(b)) # int
print(b) # 24
adopt numel() function , We can quickly see how many elements a tensor has .