(inputs,
               num_units,
               lengths=None,
               stack_size=1,
               use_cudnn=False,
               rnn_dropout_drop_amt=0,
               bidirectional=True)
return outputs
Create a LSTM layer using the specified backend.
Create a LSTM layer using the specified backend.
Create a LSTM layer using the specified backend .
def lstm_layer(inputs,
               num_units,
               lengths=None,
               stack_size=1,
               use_cudnn=False,
               rnn_dropout_drop_amt=0,
               bidirectional=True):
  """Create a LSTM layer using the specified backend."""
  if use_cudnn:
    tf.logging.warning('cuDNN LSTM no longer supported. Using regular LSTM.')
  if not bidirectional:
    raise ValueError('Only bidirectional LSTMs are supported.')

  assert rnn_dropout_drop_amt == 0
  cells_fw = [
      contrib_cudnn_rnn.CudnnCompatibleLSTMCell(num_units)
      for _ in range(stack_size)
  ]
  cells_bw = [
      contrib_cudnn_rnn.CudnnCompatibleLSTMCell(num_units)
      for _ in range(stack_size)
  ]
  with tf.variable_scope('cudnn_lstm'):
    (outputs, unused_state_f,
     unused_state_b) = contrib_rnn.stack_bidirectional_dynamic_rnn(
         cells_fw,
         cells_bw,
         inputs,
         dtype=tf.float32,
         sequence_length=lengths,
         parallel_iterations=1)

  return outputs
def lstm_layer ( inputs , num_units , lengths = None , stack_size = 1 , use_cudnn = False , rnn_dropout_drop_amt = 0 , bidirectional = True ) : if use_cudnn : tf . logging . warning ( 'cuDNN LSTM no longer supported. Using regular LSTM.' ) if not bidirectional : raise ValueError ( 'Only bidirectional LSTMs are supported.' ) assert rnn_dropout_drop_amt == 0 cells_fw = [ contrib_cudnn_rnn . CudnnCompatibleLSTMCell ( num_units ) for _ in range ( stack_size ) ] cells_bw = [ contrib_cudnn_rnn . CudnnCompatibleLSTMCell ( num_units ) for _ in range ( stack_size ) ] with tf . variable_scope ( 'cudnn_lstm' ) : ( outputs , unused_state_f , unused_state_b ) = contrib_rnn . stack_bidirectional_dynamic_rnn ( cells_fw , cells_bw , inputs , dtype = tf . float32 , sequence_length = lengths , parallel_iterations = 1 ) return outputs