torch.randn和torch.rand区别
参考链接:https://blog.csdn.net/wangwangstone/article/details/89815661
排序的结果还真不一样:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import torch
def s_sort():
loss_c = torch.rand(5, 5)
print(loss_c)
_, loss_idx = loss_c.sort(1, descending=True)
print(loss_idx)
_, idx_rank = loss_idx.sort(1)
print(idx_rank)
if __name__ == '__main__':
s_sort()
tensor([[0.6568, 0.4077, 0.9515, 0.5985, 0.7595],
[0.0324, 0.4305, 0.3135, 0.5075, 0.9878],
[0.4653, 0.8297, 0.1891, 0.9629, 0.3702],
[0.1338, 0.3348, 0.5779, 0.6260, 0.5189],
[0.9621, 0.26