Garland
Garland

Reputation: 65

Minimum K values of a tensor?

I am aware of an implementation to compute the inverse (i.e. tf.nn.top_k computes the K largest values along a given axis), but I can't find a in-built method to find the K smallest values.

Aside from taking the inverse or playing around with sets, is it possible to do this using the tensorflow library, or will I have to devise something myself?

Cheers/

Upvotes: 3

Views: 2509

Answers (1)

Salvador Dali
Salvador Dali

Reputation: 222521

No, there is no single function that you can use. There is no problem using tf.nn.top_k() for this purpose. Just negate the argument:

-tf.nn.top_k(-A) will do the same as tf.negative(tf.nn.top_k(tf.negative(A)))

Upvotes: 1

Related Questions