Skip to content

Instantly share code, notes, and snippets.

@HarshSingh16
Created February 5, 2019 04:33
Show Gist options
  • Save HarshSingh16/c0a5be85e5116367982324019dc983fd to your computer and use it in GitHub Desktop.
Save HarshSingh16/c0a5be85e5116367982324019dc983fd to your computer and use it in GitHub Desktop.
Defining the Encoder_RNN
def encoder_rnn(rnn_inputs, rnn_size, num_layers, keep_prob, sequence_length):
lstm = tf.contrib.rnn.BasicLSTMCell(rnn_size)
lstm_dropout = tf.contrib.rnn.DropoutWrapper(lstm, input_keep_prob = keep_prob)
encoder_cell = tf.contrib.rnn.MultiRNNCell([lstm_dropout] * num_layers)
encoder_output, encoder_state = tf.nn.bidirectional_dynamic_rnn(cell_fw = encoder_cell,
cell_bw = encoder_cell,
sequence_length = sequence_length,
inputs = rnn_inputs,
dtype = tf.float32)
return encoder_state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment