How can I slice a PyTorch tensor with another tensor? Ask Question Asked 1 year, 8 months ago. Active 1 year, 8 months ago. Viewed 4k times 5 I have: inp = torch.randn(4, 1040, 161) and I have another tensor called indices with values: tensor([[124, 583, 158 ...
index = tensor([[124, 583, 158, 529], [172, 631, 206, 577]], device='cuda:0') #create a concatenated list of ranges of indices you desire to slice indexer ...
Slices the self tensor along the selected dimension at the given index. This function returns a view of the original tensor with the given dimension removed.
15.09.2017 · If I have a tensor like x = torch.rand((3,4,8)) and I would like to slice ‘x’ in order to fit into y = torch.rand((2,3,4,4)). I am able to do slicing in 2D using torch.narrow or torch.select. But, I am really confused in the 3D. I really need to know this because I want to split up a bunch of patches. Thank you in advance.
18.07.2021 · In this article, we will discuss how to Slice a 3D Tensor in Pytorch. Let’s create a 3D Tensor for demonstration. We can create a vector by using torch.tensor() function