I'm trying to slice the tensor into small ones as long as there's still some columns using tf.while_loop.
Note : I'm using this way because I cannot loop over a value in a placeholder at the graph construction time ( without session ) considered as a tensor and not integer.
[ 5 7 8 ]
[ 7 4 1 ] =>
[5 7 ] [ 7 8 ]
[7 4 ] [ 4 1 ]
This is my code:
i = tf.constant(0)
result = tf.subtract(tf.shape(f)[1],1)
c = lambda result : tf.greater(result, 0)
b = lambda i: [i+1, tf.slice(x, [0,i],[2, 3])]
o= tf.while_loop(c, b,[i])
with tf.Session() as sess:
print (sess.run(o))
However, I get this error :
ValueError: The two structures don't have the same nested structure.
First structure: type=list str=[<tf.Tensor 'while_2/Identity:0' shape=() dtype=int32>]
Second structure: type=list str=[<tf.Tensor 'while_2/add:0' shape=() dtype=int32>, <tf.Tensor 'while_2/Slice:0' shape=(2, 3) dtype=int32>]
I would like to return the sub tensor everytime