Thanks for your reply.
What I wanted is something like this:
zero_tensor = torch.zeros([3,4])
index_tensor = tensor([[1, 2, 0], [0, 0, 1], [0,2,2]])
result = tensor([[1., 1., 1., 0.],
[1., 1., 0., 0.],
[1., 0., 1., 0.]])
replace values of zero_tensor from 0 to 1, where the indices are given by the index_tensor. And this operation has to be performed row-wise.
“scatter_” solves this problem. Now I don’t need to use put_along_axis from numpy. Thanks once again.