附代码:
x_new = torch.zero(x.size())
x_new[x==0] = 1e9
x_new += x
_, min_index = torch.min(x_new, dim=1, keepdim=True)
min_value = x.gather(1, min_index) # 按照索引位置对原始数据进行索引值
文章出处登录后可见!
已经登录?立即刷新
x_new = torch.zero(x.size())
x_new[x==0] = 1e9
x_new += x
_, min_index = torch.min(x_new, dim=1, keepdim=True)
min_value = x.gather(1, min_index) # 按照索引位置对原始数据进行索引值
文章出处登录后可见!