How to use tf.while_loop() in tensorflow
<p>This is a generic question. I found that in the tensorflow, after we build the graph, fetch data into the graph, the output from graph is a tensor. but in many cases, we need to do some computation based on this output (which is a <code>tensor</code>), which is not allowed in tensorflow. </p>

<p>for example, I'm trying to implement a RNN, which loops times based on data self property. That is, I need use a <code>tensor</code> to judge whether I should stop (I am not using dynamic_rnn since in my design, the rnn is highly customized). I find <code>tf.while_loop(cond,body.....)</code> might be a candidate for my implementation. But the official tutorial is too simple. I don't know how to add more functionalities into the 'body'. Can anyone give me few more complex example? </p>

<p>Also, in such case that if the future computation is based on the tensor output (ex: the RNN stop based on the output criterion), which is very common case. Is there an elegant way or better way instead of dynamic graph?</p>