ccrc_model.py 文件源码

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

项目:Constituent-Centric-Neural-Architecture-for-Reading-Comprehension 作者: shrshore 项目源码 文件源码
def __init__(self, config):
        self.q_encoding=question_encoding(config)
        self.c_encoding=context_encoding(config)
        self.config=config
        self.sentence_num=self.c_encoding.sentence_num
        ##to do list
        self.att_layer=attentioned_layer(config, self.q_encoding, self.c_encoding)
        self.scope_index=0
        #every constituency has a representation [ 4* hidden_dim]
        with tf.variable_scope('candidate_answer_generation_forward'):
            self.fwcell=rnn.BasicLSTMCell(self.config.hidden_dim, activation=tf.nn.tanh)
        with tf.variable_scope('candidate_answer_generation_backword'):
            self.bwcell=rnn.BasicLSTMCell(self.config.hidden_dim, activation=tf.nn.tanh)
        self._fw_initial_state=self.fwcell.zero_state(1,dtype=tf.float32)
        self._bw_initial_state=self.bwcell.zero_state(1,dtype=tf.float32)
        self.add_placeholders()
        self.candidate_answer_representations=self.get_candidate_answer_representations()
        assert tf.gather(tf.shape(self.candidate_answer_representations),0)==self.candidate_answer_overall_number
        self.loss=self.get_loss(self.candidate_answer_representations,self.correct_answer_idx)
        self.train_op=self.add_training_op()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号