Tensorflow: How to convert scalar tensor to scalar variable in python?
<p>In Tensorflow, I'd like to convert a scalar tensor to an integer. Is it possible to do? </p>

<p>I need to create a loop and the index of the loop is a scalar tensor, and inside the loop body, I want to use the index to access an entry in a tensor array. </p>

<p>For example:</p>

<pre><code>idx = tf.constant(0)
c = lambda i : tf.less(i, 10)
def body(idx) :
  i = # convert idx to int 
  b = weights[i]  # access an entry in a tensor array, tensor cannot be used directly
  ....
  return idx+1
tf.while_loop(c, body, [idx])
</code></pre>