評價此頁

torch.msort#

torch.msort(input: Tensor, *, out: Optional[Tensor]) Tensor#

按值對 input 張量沿其第一個維度進行升序排序。

注意

torch.msort(t) 等同於 torch.sort(t, dim=0)[0]。另請參閱 torch.sort()

引數

input (Tensor) – 輸入張量。

關鍵字引數

out (Tensor, optional) – 輸出張量。

示例

>>> t = torch.randn(3, 4)
>>> t
tensor([[-0.1321,  0.4370, -1.2631, -1.1289],
        [-2.0527, -1.1250,  0.2275,  0.3077],
        [-0.0881, -0.1259, -0.5495,  1.0284]])
>>> torch.msort(t)
tensor([[-2.0527, -1.1250, -1.2631, -1.1289],
        [-0.1321, -0.1259, -0.5495,  0.3077],
        [-0.0881,  0.4370,  0.2275,  1.0284]])