zoukankan      html  css  js  c++  java
  • torch:torch.sort

    import torch
    import torchvision
    import torch.nn as nn
    import torch.nn.functional as F
    
    x = torch.randn(3, 4)
    print(x)
    print()
    sorted, indices = torch.sort(x)
    print(sorted)
    print(indices)
    
    sorted, indices = torch.sort(x, 0)
    print(sorted)
    print(indices)
    D:ProgramDataMiniconda3python.exe E:/新脚本主文件夹/训练测试项目/test_torch/sort.py
    tensor([[ 1.0198,  0.6535, -0.5993, -1.2033],
            [-1.2741, -0.1615, -1.4329, -2.1151],
            [-1.8084, -0.3558,  0.6515, -0.2942]])
    
    tensor([[-1.2033, -0.5993,  0.6535,  1.0198],
            [-2.1151, -1.4329, -1.2741, -0.1615],
            [-1.8084, -0.3558, -0.2942,  0.6515]])
    tensor([[3, 2, 1, 0],
            [3, 2, 0, 1],
            [0, 1, 3, 2]])
    tensor([[-1.8084, -0.3558, -1.4329, -2.1151],
            [-1.2741, -0.1615, -0.5993, -1.2033],
            [ 1.0198,  0.6535,  0.6515, -0.2942]])
    tensor([[2, 2, 1, 1],
            [1, 1, 0, 0],
            [0, 0, 2, 2]])
    
    Process finished with exit code 0
  • 相关阅读:
    准备重启blog。。。
    愿我成功省一。
    [LUOGU]P5502 [JSOI2015]最大公约数
    [LUOGU]P3400 仓鼠窝
    [LUOGU]P5149 会议座位
    OI退役记
    新开博客园~~
    1108 模拟赛
    牛客1102
    题解 CF21B 【Intersection】
  • 原文地址:https://www.cnblogs.com/DDBD/p/14096802.html
Copyright © 2011-2022 走看看