颜色直方图
特征(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])