统计属性
import torch
a = torch.full([8],1)
a
b=a.view(2,4)
b
c=a.view(2,2,2)
c
a.norm(1)
此时修改:a = torch.full([8],1.0)就可以了
b.norm(1)
c.norm(1)
结果: 
a.norm(2)求L2范数(所有元素的平方和再开根号)
b.norm(2)
c.norm(2)
b.norm(1,dim=1)
b.norm(2,dim=1)
c.norm(1,dim=0)
c.norm(2,dim=0)
结果: 
a=torch.arrange(8).view(2,4).float()
a.min()
a.max()
a.mean()
a.prod()
a.argmax()
a.argmin()
结果: 
a=torch.rand(2,3,4)
a.argmax()
a.argmax(dim=1)
看https://www.cnblogs.com/findlj/p/15040829.html讲解
a.max()
a.max(dim=1)
a.max(dim=1,keepdim=True)
a.argmax(dim=1,keepdim=True)
结果:  
a.topk(3)
a.topk(3,dim=1)
a.topk(3,dim=1,largest=False)
结果:   
a.kthvalue(1)
a.kthvalue(3)
a.kthvalue(3,dim=1)
结果: 
 
a>0
torch.gt(a,0)
a!=0
torch.eq(a,0)
结果:  
torch.equal(a,0)
torch.equal(a,a)
|