Hi everyone,
I have a problem that I try to solve, and I have real problems coming up with a solution so far. In tensorflow, one could use tf.gather_nd for it:
Let’s image I have a batch tensor img_feat of size (16, 256, 16, 16).  In addition, I have an x and y tensor, each of size (16, 150), so that I have 150 points, each with an x and a y coordinate.
What I want to do is to extract for each batch (16), each of the features (256) for each point (150) which has a x and y coordinate in the 16x16 images of img_feats More precise, this is exactly what I want to have:
feats = torch.stack([torch.stack([img_feat[i,:,x[i,j].long(), y[i,j].long()] for j in range(x.shape[1])]) for i in range(batch_size)])
My problem is, that I want to implement it with torch functions (e.g. gather, select_index, etc.) so that it can be parallelised when using GPUs.
Does anyone can come up with a solution? It would be so awesome!
Thanks a lot in advance!