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
  • 相关阅读:
    10-12
    8-10
    5.2-5.3
    四则运算 测试与封装
    第5-7章
    汉堡包
    1-5章
    实验二
    实验一
    Controller方法是如何与请求匹配上的及参数如何填充的
  • 原文地址:https://www.cnblogs.com/DDBD/p/14096802.html
Copyright © 2011-2022 走看看