model.py 文件源码

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

项目:HAN-text-classification-tf 作者: lc222 项目源码 文件源码
def BidirectionalGRUEncoder(self, inputs, name):
        #??inputs?shape?[batch_size, max_time, voc_size]
        with tf.variable_scope(name):
            GRU_cell_fw = rnn.GRUCell(self.hidden_size)
            GRU_cell_bw = rnn.GRUCell(self.hidden_size)
            #fw_outputs?bw_outputs?size??[batch_size, max_time, hidden_size]
            ((fw_outputs, bw_outputs), (_, _)) = tf.nn.bidirectional_dynamic_rnn(cell_fw=GRU_cell_fw,
                                                                                 cell_bw=GRU_cell_bw,
                                                                                 inputs=inputs,
                                                                                 sequence_length=length(inputs),
                                                                                 dtype=tf.float32)
            #outputs?size?[batch_size, max_time, hidden_size*2]
            outputs = tf.concat((fw_outputs, bw_outputs), 2)
            return outputs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号