pytorch 二分類問題,百分比
阿新 • • 發佈:2018-12-20
pytorch
out = torch.Tensor([[0,3], [2,3], [1,0], [3,4]]) cond = torch.Tensor([[1,0], [0,1], [1,0], [1,0]]) persent = torch.mean(torch.eq(torch.argmax(out, dim=1), torch.argmax(cond, dim=1)).double())
numpy
out = [[0, 3],
[2, 3],
[1, 0],
[3, 4]]
cond = [[1, 0],
[0, 1],
[1, 0],
[1, 0]]
a = np.argmax(out,axis=1)
b = np.argmax(cond, axis=1)
persent = np.mean(np.equal(a, b) + 0)
print(persent)