Modify the rows of a tensor at specific indices given by a list (Pytorch)
I have a tensor X with shape (N,M) and a list of indices idx_list.
I would like to modify X but only at the rows given by idx_list.
So I'd like to do something like this:
X[idx_list, :] = Y

Y is a tensor with shape (len(idx_list), M)

The solution is mentioned in your question. The usual slicing notation that's used in numpy arrays works well with PyTorch tensors as well.
X[idx_list, :] = Y

Here's a screenshot from Jupyter notebook illustrating it:

Your approach posted as answer would work too
X[(torch.tensor(idx_list),)] = Y

However, you do not need to complicate it like this by converting the idx_list into a tensor. Slicing is preferably done using standard Python lists.
