title: Outputs and State of MultiRNNCell in Tensorflow
body: <p>I have a stacked MultiRNNCell defined as below :</p>
  
  <pre><code>batch_size = 256
  rnn_size = 512
  keep_prob = 0.5
  
  lstm_1 = tf.nn.rnn_cell.LSTMCell(rnn_size)
  lstm_dropout_1 = tf.nn.rnn_cell.DropoutWrapper(lstm_1, output_keep_prob = keep_prob)
  
  lstm_2 = tf.nn.rnn_cell.LSTMCell(rnn_size)
  lstm_dropout_2 = tf.nn.rnn_cell.DropoutWrapper(lstm_2, output_keep_prob = keep_prob)
  
  stacked_lstm = tf.nn.rnn_cell.MultiRNNCell([lstm_dropout_1, lstm_dropout_2])
  
  rnn_inputs = tf.nn.embedding_lookup(embedding_matrix, ques_placeholder)
  
  init_state = stacked_lstm.zero_state(batch_size, tf.float32)
  rnn_outputs, final_state = tf.nn.dynamic_rnn(stacked_lstm, rnn_inputs, initial_state=init_state)
  </code></pre>
  
  <p>In this code, there are two RNN layers. I just want to process the final state of this dynamic RNN. I expected the state to be a 2D tensor of shape <code>[batch_size, rnn_size*2]</code>.</p>
  
  <p>The shape of the final_state is 4D - <code>[2,2,256,512]</code> </p>
  
  <p>Can someone please explain why am I getting this shape ? Also, how can I process this tensor so that I can pass it through a fully_connected layer ?</p>