(self, encoder_inputs, seq_len)
return encoder_outputs, fw_st, bw_st
Add a single-layer bidirectional LSTM encoder to the graph.

    Args:
      encoder_inputs: A tensor of shape [batch_size, <=max_enc_steps, emb_size].
      seq_len: Lengths of encoder_inputs (before padding). A tensor of shape [batch_size].

    Returns:
      encoder_outputs:
        A tensor of shape [batch_size, <=max_enc_steps, 2*hidden_dim]. It's 2*hidden_dim because it's the concatenation of the forwards and backwards states.
      fw_state, bw_state:
        Each are LSTMStateTuples of shape ([batch_size,hidden_dim],[batch_size,hidden_dim])
Add a single-layer bidirectional LSTM encoder to the graph.
Add a single - layer bidirectional LSTM encoder to the graph .
def _add_encoder(self, encoder_inputs, seq_len):
    """Add a single-layer bidirectional LSTM encoder to the graph.

    Args:
      encoder_inputs: A tensor of shape [batch_size, <=max_enc_steps, emb_size].
      seq_len: Lengths of encoder_inputs (before padding). A tensor of shape [batch_size].

    Returns:
      encoder_outputs:
        A tensor of shape [batch_size, <=max_enc_steps, 2*hidden_dim]. It's 2*hidden_dim because it's the concatenation of the forwards and backwards states.
      fw_state, bw_state:
        Each are LSTMStateTuples of shape ([batch_size,hidden_dim],[batch_size,hidden_dim])
    """
    with tf.variable_scope('encoder'):
      cell_fw = tf.contrib.rnn.LSTMCell(self._hps.hidden_dim, initializer=self.rand_unif_init, state_is_tuple=True)
      cell_bw = tf.contrib.rnn.LSTMCell(self._hps.hidden_dim, initializer=self.rand_unif_init, state_is_tuple=True)
      (encoder_outputs, (fw_st, bw_st)) = tf.nn.bidirectional_dynamic_rnn(cell_fw, cell_bw, encoder_inputs, dtype=tf.float32, sequence_length=seq_len, swap_memory=True)
      encoder_outputs = tf.concat(axis=2, values=encoder_outputs) # concatenate the forwards and backwards states
    return encoder_outputs, fw_st, bw_st
def _add_encoder ( self , encoder_inputs , seq_len ) : with tf . variable_scope ( 'encoder' ) : cell_fw = tf . contrib . rnn . LSTMCell ( self . _hps . hidden_dim , initializer = self . rand_unif_init , state_is_tuple = True ) cell_bw = tf . contrib . rnn . LSTMCell ( self . _hps . hidden_dim , initializer = self . rand_unif_init , state_is_tuple = True ) ( encoder_outputs , ( fw_st , bw_st ) ) = tf . nn . bidirectional_dynamic_rnn ( cell_fw , cell_bw , encoder_inputs , dtype = tf . float32 , sequence_length = seq_len , swap_memory = True ) encoder_outputs = tf . concat ( axis = 2 , values = encoder_outputs ) # concatenate the forwards and backwards states return encoder_outputs , fw_st , bw_st