3-14pytorch与统计学方法

在这里插入图片描述
在这里插入图片描述
颜色直方图
在这里插入图片描述
特征(lbp gabor sift hog/纹理)

import torch

a = torch.rand(2,2)

print(a)
print(torch.mean(a))
print(torch.sum(a))
print(torch.prod(a))#连乘
tensor([[0.8627, 0.2681],
        [0.0640, 0.9844]])
tensor(0.5448)
tensor(2.1793)
tensor(0.0146)
print(a)
print(torch.mean(a,dim=0))
print(torch.sum(a,dim=0))
print(torch.prod(a,dim=0))#连乘
print(torch.argmax(a,dim=0))
print(torch.argmin(a,dim=0))
tensor([[0.8627, 0.2681],
        [0.0640, 0.9844]])
tensor([0.4634, 0.6263])
tensor([0.9267, 1.2526])
tensor([0.0552, 0.2640])
tensor([0, 1])
tensor([1, 0])
print(torch.std(a))
print(torch.var(a))#方差

print(torch.median(a))
print(torch.mode(a))
tensor(0.4480)
tensor(0.2007)
tensor(0.2681)
torch.return_types.mode(
values=tensor([0.2681, 0.0640]),
indices=tensor([1, 0]))
a = torch.rand(2,2)*10
print(a)
print(torch.histc(a,6,0,0))
tensor([[5.3550, 9.0492],
        [8.6544, 5.3874]])
tensor([2., 0., 0., 0., 0., 2.])
a = torch.randint(0,10,[10])#只能1维[10,2]报错
print(a)
print(torch.bincount(a))

#统计某一类别样本的个数
tensor([7, 2, 6, 0, 7, 9, 7, 7, 7, 2])
tensor([1, 0, 2, 0, 0, 0, 1, 5, 0, 1])
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值