Method to get k smallest elements from a tensor #43977
Labels
comp:ops
OPs related issues
stat:awaiting tensorflower
Status - Awaiting response from tensorflower
type:feature
Feature requests
tf.math.top_k
only returnsk
largest elements from the inputtensor
along a specifiedaxis
. However, there is no direct way to obtaink
smallest elements from atensor
. The equivalent methodtopk
inpytorch
has anbool
flaglargest
to toggle the output fromk
largest elements tok
smallest elements and vice versa. It would be useful to have similar option (or an alternative method likebottom_k
) for this purpose so that hacky solution like the following can be avoided.Finding
k
minimum values can be potentially very useful in many cases especially for writing customops
. This does not seem to be too hard to implement or drastically change the API.System information
Related discussion in Stackoverflow.
The text was updated successfully, but these errors were encountered: