tf.sort  |  TensorFlow v2.0.0 (original) (raw)

tf.sort

Stay organized with collections Save and categorize content based on your preferences.

Sorts a tensor.

View aliases

Compat aliases for migration

SeeMigration guide for more details.

tf.compat.v1.sort

tf.sort(
    values, axis=-1, direction='ASCENDING', name=None
)

Usage:

import tensorflow as tf
a = [1, 10, 26.9, 2.8, 166.32, 62.3]
b = tf.sort(a,axis=-1,direction='ASCENDING',name=None)
c = tf.keras.backend.eval(b)
# Here, c = [  1.     2.8   10.    26.9   62.3  166.32]
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').
name Optional name for the operation.
Returns
A Tensor with the same dtype and shape as values, with the elements sorted along the given axis.
Raises
ValueError If axis is not a constant scalar, or the direction is invalid.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2020-10-01 UTC.