获取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中各有多少个元素或变量
本文链接:https://my.lmcjl.com/post/3161.html
展开阅读全文
4 评论