How do I index a tensor with a tensor (not quite index ...
https://discuss.pytorch.org/t/how-do-i-index-a-tensor-with-a-tensor...13.01.2022 · Let’s say I have a tensor a = torch.tensor(([0,1,2],[3,4,5])). I have another tensor, b = torch.tensor([0,1]), that I want to use to index a, such that we obtain the 0th position of the first row, 1st position of the second row (resulting tensor is [0, 3]). How can this be done? It’s not the same as index_select, which finds the 0th and 1st positions for every row. Thanks!
PyTorch中Tensor的查找和筛选_玄云飘风的博客-CSDN博客_pytorch …
https://blog.csdn.net/tfcy694/article/details/8533295329.12.2018 · 在pytorch中,我们经常需要查找tensor中某一个元素的索引,可能是在向量中查找索引,也可能是在矩阵中查找索引,下面分贝举例子: 1.在矩阵中查找某个指定元素的索引: import torch import numpy as np a = torch.tensor( [[1,2,3],[4,5,6],[5,6,7],[6,7,8]] ) a_t2n = a.numpy() index = …
torch.index_select — PyTorch 1.10.1 documentation
pytorch.org › docs › stabletorch.index_select — PyTorch 1.10.0 documentation torch.index_select torch.index_select(input, dim, index, *, out=None) → Tensor Returns a new tensor which indexes the input tensor along dimension dim using the entries in index which is a LongTensor. The returned tensor has the same number of dimensions as the original tensor ( input ).
[feature request] add `torch.find` to find the indices of ...
github.com › pytorch › pytorchJul 12, 2018 · result = torch. find ( tensor, from_) This operator outputs a long tensor of the same shape as the argument tensor, where the result [i,j,..] is the first index at vector from_ whose value is the same as tensor [i,j,..]. For example: a = torch. tensor ( [ 0, 10, 20, 30 ]) b = torch. tensor ( [ [ 0, 30, 5 ], [ 20, 1, 0 ]]) torch. find ( b, a)