I have a index matrix and a matrix filled by zero .
For example :
index = Tensor([[ 0, 1],
[ 1, 2],
[ 4, 1]])
a = Tensor([[ 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0.]])
Therefore, I would like to fill 1 to the zero matrix based on the index matrix .
Like this :
a = Tensor([[ 1, 1, 0, 0., 0., 0.],
[ 0., 1, 1, 0., 0., 0.],
[ 0., 1, 0., 0., 1, 0.]])
Is there any easy way ?