Hi,

Sorry if this question has been asked already. I couldn’t find a solution anywhere.

I want to assign a value to a tensor at particular column indices.

For instance, given a tensor t1 = [[0.3,0.4,0.5], [0.1,0.2, 0.8]] , indices = [1,2] and value = 1. I want to compute t2 such that t2 = [[0.3,1, 0.5], [0.1, 0.2, 1]].

Basically, I would like to do below with pytorch tensor indexing

for i in range(t1.size(0)):

t2[i][indices[i]] = value

Thanks!

P.S. I tried scatter and index_select but couldn’t figure out how to use them for above problem.