Given list of index, obtain the corresponding element from a tensor

Rewrapping a tensor in torch.Tensor will detach it from the computation graph, so you might want to use torch.cat or torch.stack instead.

1 Like