blstm_crf.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:deeplearning 作者: fanfanfeng 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号