title: Does LSTM in Keras support dynamic sentence length or not?
body: <p>Since I see people arguing on some platform that the <code>LSTM</code> in Keras does not support dynamic sentence length, I wrote the following code.</p>
  
  <pre><code>embedding_size = 100
  model = Sequential()
  model.add(LSTM(32, return_sequences=True, input_shape=(None, embedding_size)))
  </code></pre>
  
  <p>And it works perfectly given two input <code>val1</code> and <code>val2</code> I fed (those input are in shape <code>batch_size * sentence length * embedding size</code>),</p>
  
  <pre><code>val1 = np.random.random((5,20,embedding_size))
  val2 = np.random.random((5,10,embedding_size))
  input = model.input
  output = model.output
  
  with tf.Session() as sess:
      sess.run(tf.global_variables_initializer())
      k1 = sess.run(output, feed_dict={input:val1})
      k2 = sess.run(output, feed_dict={input:val2})
      print k1.shape
      print k2.shape
  </code></pre>
  
  <p>And I have the following output, which meets my expectation that the <code>LSTM</code> in Keras is dynamic in input length if we set the <code>input_shape</code> to be <code>(None, embedding_size)</code>, am I understanding right?</p>
  
  <blockquote>
    <p>(5, 20, 32)</p>
    
    <p>(5, 10, 32)</p>
  </blockquote>