擷取tensor中一共包含多少個元素
import torch
x = torch.randn(3,3)
print("number elements of x is ",x.numel())
y = torch.randn(3,10,5)
print("number elements of y is ",y.numel())
輸出:
number elements of x is 9
number elements of y is 150
27和150分别位x和y中各有多少個元素或變量