It's not allowed to fetch the values of tensors created inside a conditional or while loop in tensorflow. I've tried tf.shape(t)
Session.run()
and Tensor.eval()
, but all of them occur errors.
Is it possible to get the shape of tensor, which is determined after graph execution?
For example, here is a while_loop:
inputs = tf.placeholder(tf.float32,shape=(None,32,32))
i = tf.placeholder(dtype='int32')
def loop_body(i,inputs):
x = tf.add(i, 1, name = 'add1')
y = tf.add(inputs,1)
return x,y
output = tf.while_loop(lambda i,inputs: tf.less(i, 10), loop_body, [i,inputs])
How can I get the shape of tensor while/add1:0
after input placeholder is feed?