I have two tensors and want to access one of them using the other one as index.
a.shape = [batch_size, num_channels, height, width]
b.shape = [batch_size, num_channels, 2]
I would now like to use the 2 as x and y coordinates of the feature maps of a, but I don’t know how to do that… Can anyone give me a hint?
The expected output would be of size [batch_size, num_channels]
I’m afraid there is not very elegant way to do this.
Another approach would be to convert your 2D indices into a 1D index into a dimension of size height * width.
Then you can use view of a and a single gather to get what you want.