For example, I have a tensor t = torch.rand(10,1)
. And I want to select the tensor subset of at the rows of {1,3,7,9}
and concatenate them as new tensor. Is there any elegant way? Thank you.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
There's :index
method:
tens = torch.rand(10,1)
ind = torch.LongTensor{1,3,7,9}
subset = tens:index(1, ind)