W3cubDocs

/TensorFlow Python

tf.contrib.framework.argsort

tf.contrib.framework.argsort(
    values,
    axis=-1,
    direction='ASCENDING',
    stable=False,
    name=None
)

Defined in tensorflow/contrib/framework/python/ops/sort_ops.py.

Returns the indices of a tensor that give its sorted order along an axis.

For a 1D tensor, tf.gather(values, tf.argsort(values)) is equivalent to tf.sort(values). For higher dimensions, the output has the same shape as values, but along the given axis, values represent the index of the sorted element in that slice of the tensor at the given position.

Args:

  • values: 1-D or higher numeric Tensor.
  • axis: The axis along which to sort. The default is -1, which sorts the last axis.
  • direction: The direction in which to sort the values ('ASCENDING' or 'DESCENDING').
  • stable: If True, equal elements in the original tensor will not be re-ordered in the returned order. Unstable sort is not yet implemented, but will eventually be the default for performance reasons. If you require a stable order, pass stable=True for forwards compatibility.
  • name: Optional name for the operation.

Returns:

An int32 Tensor with the same shape as values. The indices that would sort each slice of the given values along the given axis.

Raises:

  • ValueError: If axis is not a constant scalar, or the direction is invalid.

© 2018 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/contrib/framework/argsort