How to rank a 2-d tensor along an axis in tensorflow?
<p>I am trying to get the ranks of a 2-d tensor in Tensorflow. I can do that in numpy using something like:</p>

<pre><code>import numpy as np
from scipy.stats import rankdata

a = np.array([[0,3,2], [6,5,4]])
ranks = np.apply_along_axis(rankdata, 1, a)
</code></pre>

<p>And <code>ranks</code> is:</p>

<pre><code>array([[ 1.,  3.,  2.],
       [ 3.,  2.,  1.]])
</code></pre>

<p>My question is how can I do this in tensorflow?</p>

<pre><code>import tensorflow as tf
a = tf.constant([[0,3,2], [6,5,4]])
sess = tf.InteractiveSession()
ranks = magic_function(a)
ranks.eval()
</code></pre>