How can I slice a PyTorch tensor with another tensor? - py4u
https://www.py4u.net › discussI have: inp = torch.randn(4, 1040, 161). and I have another tensor called indices with values: tensor([[124, 583, 158, 529], [172, 631, 206, 577]], ...
Tensor indexing with another tensor - PyTorch Forums
https://discuss.pytorch.org/t/tensor-indexing-with-another-tensor/11448511.03.2021 · Hi, I usually index tensors with lists of indices, like x = torch.as_tensor([[1,2,3,4,5], [6,7,8,9,0]]) index = [[0, 1, 1], [1, 1, 2]] # tensor([2, 7, 8]) x[index] Now I need index to be a tensor object, but doing this, I get an error: x = torch.as_tensor([[1,2,3,4,5], [6,7,8,9,0]]) index = torch.as_tensor( [[0, 1, 1], [1, 1, 2]]) # IndexError: index 2 is out of bounds for dimension 0 with ...