(self, x)
return outputs
LSTM layers.
LSTM layers.
LSTM layers .
def lstm_layer(self, x):
    ''' LSTM layers. '''
    if self.netconf['use_lstm_layer']:
      with tf.variable_scope('lstm'):
        cell_fw = tf.nn.rnn_cell.BasicLSTMCell(
            self.netconf['cell_num'], forget_bias=1.0)
        if self.netconf['use_dropout']:
          cell_fw = tf.nn.RNNCellDropoutWrapper(
              cell=cell_fw,
              output_keep_prob=1 -
              self.netconf['dropout_rate'] if self.train else 1.0)

        cell_bw = tf.nn.rnn_cell.BasicLSTMCell(
            self.netconf['cell_num'], forget_bias=1.0)
        if self.netconf['use_dropout']:
          cell_bw = tf.nn.RNNCellDropoutWrapper(
              cell=cell_bw,
              output_keep_prob=1 -
              self.netconf['dropout_rate'] if self.train else 1.0)

        # Now we feed `linear` into the LSTM BRNN cell and obtain the LSTM BRNN output.
        outputs, _ = tf.nn.bidirectional_dynamic_rnn(
            cell_fw=cell_fw,
            cell_bw=cell_bw,
            inputs=x,
            dtype=tf.float32,
            time_major=False,
            scope='LSTM1')
    else:
      outputs = x
    return outputs
def lstm_layer ( self , x ) : if self . netconf [ 'use_lstm_layer' ] : with tf . variable_scope ( 'lstm' ) : cell_fw = tf . nn . rnn_cell . BasicLSTMCell ( self . netconf [ 'cell_num' ] , forget_bias = 1.0 ) if self . netconf [ 'use_dropout' ] : cell_fw = tf . nn . RNNCellDropoutWrapper ( cell = cell_fw , output_keep_prob = 1 - self . netconf [ 'dropout_rate' ] if self . train else 1.0 ) cell_bw = tf . nn . rnn_cell . BasicLSTMCell ( self . netconf [ 'cell_num' ] , forget_bias = 1.0 ) if self . netconf [ 'use_dropout' ] : cell_bw = tf . nn . RNNCellDropoutWrapper ( cell = cell_bw , output_keep_prob = 1 - self . netconf [ 'dropout_rate' ] if self . train else 1.0 ) # Now we feed `linear` into the LSTM BRNN cell and obtain the LSTM BRNN output. outputs , _ = tf . nn . bidirectional_dynamic_rnn ( cell_fw = cell_fw , cell_bw = cell_bw , inputs = x , dtype = tf . float32 , time_major = False , scope = 'LSTM1' ) else : outputs = x return outputs