title: Extract Hidden Layer Vector from RNN Tensoflow
body: <p>I'm very unfamiliar with TensorFlow, but I'm trying to get a project working.</p>
  
  <p>I've trained an LSTM using the following code: <a href="https://github.com/sherjilozair/char-rnn-tensorflow" rel="nofollow">https://github.com/sherjilozair/char-rnn-tensorflow</a></p>
  
  <p>This is great, and using sample.py I get great output data. However, I'm not very interested in generating output data. What I want to do is extract the hidden layer vector from the last step of the LSTM.</p>
  
  <p>Basically, I would like to return an array of the hidden values which would normally be passed to the next time step in the LSTM (128-dimensional vector for this particular model, which is specified in train.py) immediately after the following segment of model.py is run:</p>
  
  <pre><code>def sample(self, sess, chars, vocab, num=200, prime='The ', sampling_type=1):
          state = self.cell.zero_state(1, tf.float32).eval()
          for char in prime[:-1]:
              x = np.zeros((1, 1))
              x[0, 0] = vocab[char]
              feed = {self.input_data: x, self.initial_state:state}
              [state] = sess.run([self.final_state], feed)
  </code></pre>
  
  <p>I'm not sure how to do this in Tensorflow, any help would be great, thanks.</p>