how to set a tensor’s value by index?
For example, we have a tensor a=[[0,0,0], [0,0,0], [0,0,0]],
and index=[[0,0], [1,1], [2,2]], values=[1,2,-1], how can a change a to [[1,0,0], [0,2,0], [0,0,-1]]?
I tied scatter but failed, could you also explain when we need scatter?
Because values has shape [3] you will want the two index tensors that
you use to index into a to also have shape [3]. Then you can assign values to the view into a obtained by indexing into a. Specifically: