title: confusion about sequence length in dynamic rnn version of tensor flow
body: <p>i am training a RNN to classify a sequence of input (13 values at each time step) as a particular class.<br>
  Here is relevant part of my code (line numbers prefixed)<br></p>
  
  <pre><code> 50 data = tf.placeholder(tf.float32, [None, 40,13]) #Number of examples, number of input, dimension of each input
   51 target = tf.placeholder(tf.float32, [None, 3])
   52 num_hidden = 24
   53 cell = tf.nn.rnn_cell.LSTMCell(num_hidden,state_is_tuple=True)
   54 val, _ = tf.nn.dynamic_rnn(cell, data, dtype=tf.float32) 
  </code></pre>
  
  <p>Here my I have padded (prefixed and value zero) to each input sequence of a batch to make it 40x13.(padding operation not shown in above code)<br>
  So RNN will consider the past 40 steps for each example and then one hot vector of target will tell it to which class the example belongs.<br>
  Also, I made sure that output class of each example is 1 or2 (never zero).<br></p>
  
  <p>I saw <a href="https://www.tensorflow.org/api_docs/python/tf/nn/dynamic_rnn" rel="nofollow noreferrer">https://www.tensorflow.org/api_docs/python/tf/nn/dynamic_rnn</a> which mentions sequence_length parameter.<br></p>
  
  <p>Que 1) Can it be used for each example in a batch or across a batch ?<br>
  Que 2) Also, can you suggest me way to vary this value for each batch or across batch (whichever is relevant) assuming that I have a integer array seq_len which stores the desired value for each batch or each example (whichever is relevant) ?<br></p>
  
  <p>[quote]sequence_length: (optional) An int32/int64 vector sized [batch_size]. Used to copy-through state and zero-out outputs when past a batch element's sequence length. So it's more for correctness than performance.[/quote]</p>
  
  <p>Que 3) Suppose I set it to 14 - does that mean RNN will consider first 14 timestep and carry the output state(call it O<sub>14</sub>) after 14th step and ignore the input at 15th to 40th step (consider it all zeroes) and then associate O<sub>14</sub> with the target vector. So then I won't have to prefixed zero padding ?
  <br>
  Thanks.<br>
  Do you need more code to understand this situation ?<br></p>
  
  <p>PS: My setup<br></p>
  
  <pre><code>$ python
  Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
  [GCC 5.4.0 20160609] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import tensorflow as tf
  &gt;&gt;&gt; tf.__version__
  '1.8.0'
  </code></pre>