Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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/

like image 784
Garland Avatar asked Mar 16 '26 13:03

Garland


1 Answers

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)))

like image 80
Salvador Dali Avatar answered Mar 19 '26 02:03

Salvador Dali