Find pivots in tensor that maximize sum of values

Viewed 63

Let's suppose I have a matrix like this:

[[15,10,8],
[11,5,8],
[9,14,4]]

I need to write a function that, for each row, returns the indices of the maximum value, without repeating the same column index.

Given the previous matrix, the best solution would be the following:

[[0,0],
[1,2],
[2,1]]

That's because the sum of the values given by those indices is (15+8+14 = 37) and the summed elements' index don't get repeated in the output tensor.

This is needed in a loss function so I need it written only in tensorflow.

Thanks

1 Answers
Related