libtorch 数组索引和张量操作 与pytorch比较

数组索引

  1. libtorch

    torch::Tensor idx=torch::zeros({270,360});
    torch::Tensor t=torch::zeros({255});
    //idx里的值作为t的索引
    torch::Tensor out=t.index({idx})

  2. python
    out=t[idx]

张量索引

1.python
t[i,j]
2.libtorch
t.index({i,j})

posted on 2021-09-01 09:39  逆风的泰迪man  阅读(299)  评论(0)    收藏  举报

导航