(self, sess, batch)
return enc_states, dec_in_state
For beam search decoding. Run the encoder on the batch and return the encoder states and decoder initial state.

    Args:
      sess: Tensorflow session.
      batch: Batch object that is the same example repeated across the batch (for beam search)

    Returns:
      enc_states: The encoder states. A tensor of shape [batch_size, <=max_enc_steps, 2*hidden_dim].
      dec_in_state: A LSTMStateTuple of shape ([1,hidden_dim],[1,hidden_dim])
For beam search decoding. Run the encoder on the batch and return the encoder states and decoder initial state.
For beam search decoding . Run the encoder on the batch and return the encoder states and decoder initial state .
def run_encoder(self, sess, batch):
    """For beam search decoding. Run the encoder on the batch and return the encoder states and decoder initial state.

    Args:
      sess: Tensorflow session.
      batch: Batch object that is the same example repeated across the batch (for beam search)

    Returns:
      enc_states: The encoder states. A tensor of shape [batch_size, <=max_enc_steps, 2*hidden_dim].
      dec_in_state: A LSTMStateTuple of shape ([1,hidden_dim],[1,hidden_dim])
    """
    feed_dict = self._make_feed_dict(batch, just_enc=True) # feed the batch into the placeholders
    (enc_states, dec_in_state, global_step) = sess.run([self._enc_states, self._dec_in_state, self.global_step], feed_dict) # run the encoder

    # dec_in_state is LSTMStateTuple shape ([batch_size,hidden_dim],[batch_size,hidden_dim])
    # Given that the batch is a single example repeated, dec_in_state is identical across the batch so we just take the top row.
    dec_in_state = tf.contrib.rnn.LSTMStateTuple(dec_in_state.c[0], dec_in_state.h[0])
    return enc_states, dec_in_state
def run_encoder ( self , sess , batch ) : feed_dict = self . _make_feed_dict ( batch , just_enc = True ) # feed the batch into the placeholders ( enc_states , dec_in_state , global_step ) = sess . run ( [ self . _enc_states , self . _dec_in_state , self . global_step ] , feed_dict ) # run the encoder # dec_in_state is LSTMStateTuple shape ([batch_size,hidden_dim],[batch_size,hidden_dim]) # Given that the batch is a single example repeated, dec_in_state is identical across the batch so we just take the top row. dec_in_state = tf . contrib . rnn . LSTMStateTuple ( dec_in_state . c [ 0 ] , dec_in_state . h [ 0 ] ) return enc_states , dec_in_state