Suppose I have these two tensors:
valueMatrix, shaped as(?, 3), where?is the batch sizeindexMatrix, shaped as(?, 1)
I want to retrieve values from valueMatrix at the indices contained in indexMatrix.
Example (pseudocode):
valueMatrix = [[7,15,5],[4,6,8]] -- shape=(2,3) -- type=float
indexMatrix = [[1],[0]] -- shape = (2,1) -- type=int
I want from this example to do something like:
valueMatrix[indexMatrix] --> returns --> [[15],[4]]
I prefer Tensorflow over other backends, but the answer must be compatible with a Keras model using Lambda layers or other suitable layers for the task.