In Tensorflow, I'd like to convert a scalar tensor to an integer. Is it possible to do?
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.
For example:
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])