Создание кодировщика rnn
с помощью lstm
;какова функция DropoutWrapper
, MultiRNNCell
, bidirectional_dynamic_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