TensorFlow is open-source python library designed by Google to develop Machine Learning models and deep learning neural networks. Tensorflow have a method argsort() which is used to find the indices of a Tensor in sorted order.
Syntax: tf.argsort(values, axis, direction, stable, name)
- values: It is a numeric Tensor of any dimension.
- axis: It defines the axis along which shorting need to be done. If no value is given, default is -1 and sorting is done based on last axis.
- direction: Either ASCENDING or DESCENDING.
- stable: Either True or False. If it’s true then in case of equality original order is maintained.
- name: It’s an optional argument which define the name for the operation.
Return: It returns a Tensor of type int32 having same shape as values.This tensor contains the indices that will give the sorted order of given values.
If axis or direction is invalid it will raise ValueError.
Indices: tf.Tensor([0 2 1 4 5 3], shape=(6,), dtype=int32) Sorted Values 1 2.5 5 7 8.5 10
Example 2: In this example wrong value is passes to direction. This will raise ValueError.
ValueError: ASC should be one of ASCENDING, DESCENDING
- class method vs static method in Python
- Difference between Method Overloading and Method Overriding in Python
- Get() method for dictionaries in Python
- Real-Time Edge Detection using OpenCV in Python | Canny edge detection method
- Python Program to detect the edges of an image using OpenCV | Sobel edge detection method
- Line detection in python with OpenCV | Houghline method
- Python | os._exit() method
- Python | os.WEXITSTATUS() method
- Python | os.abort() method
- Python | os.renames() method
- Python | os.lseek() method
- Python calendar module | formatmonth() method
- Python | PyTorch sin() method
- Python | Sympy Line.is_parallel() method
- Python PIL | GaussianBlur() method
- Python | range() method
- Python | Numpy np.hermefit() method
- Python | Numpy np.hermevander() method
- Python String Title method
- Python groupby method to remove all consecutive duplicates
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.