torch max函数

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jacke121/article/details/83036546

这个能返回索引,但是是索引序号,原来的数据结构会破坏

torch.max(anch_ious, 1, keepdim=True)[1]

二维数组 max获取索引的正确方法:

import torch
anch_ious=torch.Tensor([[1,2,3],[4,5,6],[7,8,9]])

b=torch.max(anch_ious, 1, keepdim=True)
print(b[0])
print(b[1])

b=b[1].squeeze(1)
print(b)
print(anch_ious[list(range(anch_ious.size(0))),b])

猜你喜欢

转载自blog.csdn.net/jacke121/article/details/83036546