def biLSTM_layer(self,inputs,lengths):
with tf.variable_scope('bi_lstm'):
lstm_cell = {}
for direction in ['forward','backward']:
with tf.variable_scope(direction):
lstm_cell[direction] = rnn.LSTMCell(self.num_hidden,use_peepholes=True,initializer=self.initializer)
outputs,_ = tf.nn.bidirectional_dynamic_rnn(lstm_cell['forward'],lstm_cell['backward'],
inputs,dtype=tf.float32,sequence_length=lengths)
return tf.concat(outputs,axis=2)
评论列表
文章目录