Fill in a tensor according to another tensor

I’m looking for a pytorch function that takes as input 3 index-coresponding tensors: X, Y, Z and returns a 2D matrix M with the values of Z accordingly. (M(y1, x1) = z1).

a function that operates similarly to what torch.scatter(…) does.


M.view(-1).scatter_(0, Y * M.size(1) + X, Z)?

edit: index_scatter_ to scatter_

1 Like

I can’t find documentation for the function index_scatter_ online.

Sorry, it should be just scatter_

1 Like

uh it should also be M.size(1). I updated above. Sorry!

1 Like