I would like select the values from 3rd dimension based on indexes and copy the values along fourth dimension of output. Given X as input as 3d tensor i.e. N,C,H and output should be N,C,H,M.
Below example is has N=1, C=1 and H=9. x is input tensor with indexes of size (9,4) i.e. for first row select values from indexes 1 and 3 (ignoring negative values).
x = [ [1, 2, 3, 4, 5, 6, 7, 8, 9]]
indexes =[ [1, 3, -1, -1],
[ 0, 2, 4, -1],
[ 1, 5, -1, -1],
[ 0, 4, 6, -1],
[ 1, 3, 5, 7],
[ 2, 4, 8, -1],
[ 3, 7, -1, -1],
[ 4, 6, 8, -1],
[ 5, 7, -1, -1]]
Out = [[ 2, 4, 0, 0],
[ 1, 3, 5, 0],
[ 2, 6, 0, 0],
[ 1, 5, 7, 0],
[ 2, 4, 6, 8],
[ 3, 5, 9, 0],
[ 4, 8, 0, 0],
[ 5, 7, 9, 0],
[ 6, 8 , 0, 0]]
Thanks
Anil