RCNNModelWithLSTM.py 文件源码

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

项目:DeeplearningForTextClassification 作者: zldeng 项目源码 文件源码
def convertLayerWithRNN(self):
        '''
        use BI-LSTM to get contenxt
        '''
        lstm_fw_cell = rnn.BasicLSTMCell(self.context_size)
        lstm_bw_cell = rnn.BasicLSTMCell(self.context_size)

        if self.dropout_keep_prob is not None:
            lstm_fw_cell = rnn.DropoutWrapper(lstm_fw_cell,
                output_keep_prob = self.dropout_keep_prob)
            lstm_bw_cell = rnn.DropoutWrapper(lstm_bw_cell,
                output_keep_prob = self.dropout_keep_prob)

        outputs,output_states = tf.nn.bidirectional_dynamic_rnn(lstm_fw_cell,
            lstm_bw_cell,self.embedded_words,dtype = tf.float32)

        output_fw,output_bw = outputs
        result_presentation = tf.concat([output_fw,self.embedded_words,output_bw],axis = 2)

        return result_presentation
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号