统计属性
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)
结果: ![在这里插入图片描述](https://img-blog.csdnimg.cn/35549c4f62944dada75b9a3f21b2e1a9.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAd2VpeGluXzQ1Nzk3OTM3,size_7,color_FFFFFF,t_70,g_se,x_16)
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)
结果: ![在这里插入图片描述](https://img-blog.csdnimg.cn/c214abf0941a490b8d372469f7e81091.png)
a=torch.arrange(8).view(2,4).float()
a.min()
a.max()
a.mean()
a.prod()
a.argmax()
a.argmin()
结果: ![在这里插入图片描述](https://img-blog.csdnimg.cn/a52d33468737412abd2efeea135f9a72.png)
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)
结果: ![在这里插入图片描述](https://img-blog.csdnimg.cn/3c662dc561694260beda5fbb4b6e95ac.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAd2VpeGluXzQ1Nzk3OTM3,size_11,color_FFFFFF,t_70,g_se,x_16) ![在这里插入图片描述](https://img-blog.csdnimg.cn/0ab0f47a102b4c8daa0ad8f55fa3d46e.png)
a.topk(3)
a.topk(3,dim=1)
a.topk(3,dim=1,largest=False)
结果: ![在这里插入图片描述](https://img-blog.csdnimg.cn/9c5522465f8044dbbb78d64143e64166.png) ![在这里插入图片描述](https://img-blog.csdnimg.cn/a3d6e33f10064bed8e95708a891bccdb.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAd2VpeGluXzQ1Nzk3OTM3,size_7,color_FFFFFF,t_70,g_se,x_16) ![在这里插入图片描述](https://img-blog.csdnimg.cn/395dbccff45549ddb955b1946c210908.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAd2VpeGluXzQ1Nzk3OTM3,size_7,color_FFFFFF,t_70,g_se,x_16)
a.kthvalue(1)
a.kthvalue(3)
a.kthvalue(3,dim=1)
结果: ![在这里插入图片描述](https://img-blog.csdnimg.cn/a8436447cb294cf68ad158838039ba11.png)
![在这里插入图片描述](https://img-blog.csdnimg.cn/cbbaac6e03ec4267b2cf92330efddcd8.png) ![在这里插入图片描述](https://img-blog.csdnimg.cn/feb18e67cdcd4c8d88873802ff3ebcd5.png)
a>0
torch.gt(a,0)
a!=0
torch.eq(a,0)
结果: ![在这里插入图片描述](https://img-blog.csdnimg.cn/47c13992d8004300ad7958506d6ea7e3.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAd2VpeGluXzQ1Nzk3OTM3,size_8,color_FFFFFF,t_70,g_se,x_16) ![在这里插入图片描述](https://img-blog.csdnimg.cn/56f0c65c937e4601b098d89744ee6bf9.png)
torch.equal(a,0)
torch.equal(a,a)
|