(features,
                        seq_lens,
                        batch_size,
                        rnn_celltype="lstm",
                        rnn_nlayers=2,
                        rnn_nunits=128,
                        dtype=tf.float32)
return x, initial_state, final_state
Constructs an LSTM-based decoder.
Constructs an LSTM-based decoder.
Constructs an LSTM - based decoder .
def simple_lstm_decoder(features,
                        seq_lens,
                        batch_size,
                        rnn_celltype="lstm",
                        rnn_nlayers=2,
                        rnn_nunits=128,
                        dtype=tf.float32):
  """Constructs an LSTM-based decoder."""
  x = features

  with tf.variable_scope("rnn_input"):
    x = tf.layers.dense(x, rnn_nunits)

  if rnn_celltype == "lstm":
    celltype = contrib_rnn.LSTMBlockCell
  else:
    raise NotImplementedError()

  cell = rnn.MultiRNNCell(
      [celltype(rnn_nunits) for _ in range(rnn_nlayers)])

  with tf.variable_scope("rnn"):
    initial_state = cell.zero_state(batch_size, dtype)
    x, final_state = tf.nn.dynamic_rnn(
        cell=cell,
        inputs=x,
        sequence_length=seq_lens,
        initial_state=initial_state)

  return x, initial_state, final_state
def simple_lstm_decoder ( features , seq_lens , batch_size , rnn_celltype = "lstm" , rnn_nlayers = 2 , rnn_nunits = 128 , dtype = tf . float32 ) : x = features with tf . variable_scope ( "rnn_input" ) : x = tf . layers . dense ( x , rnn_nunits ) if rnn_celltype == "lstm" : celltype = contrib_rnn . LSTMBlockCell else : raise NotImplementedError ( ) cell = rnn . MultiRNNCell ( [ celltype ( rnn_nunits ) for _ in range ( rnn_nlayers ) ] ) with tf . variable_scope ( "rnn" ) : initial_state = cell . zero_state ( batch_size , dtype ) x , final_state = tf . nn . dynamic_rnn ( cell = cell , inputs = x , sequence_length = seq_lens , initial_state = initial_state ) return x , initial_state , final_state