PyTorch torch.msort 函数
torch.msort 是 PyTorch 中用于返回排序后的张量的函数。返回输入张量按升序排列后的副本,类似于对张量 flattened 后进行排序再reshape。
函数定义
torch.msort(input)
使用示例
实例
import torch
# 创建张量
x = torch.tensor([3, 1, 2])
# 返回排序后的张量
result = torch.msort(x)
print(result)
# 创建张量
x = torch.tensor([3, 1, 2])
# 返回排序后的张量
result = torch.msort(x)
print(result)
输出结果为:
tensor([1, 2, 3])

Pytorch torch 参考手册