def get_candidate_answer_final_representations(self, candidate_answer_hidden_list):
inputs=tf.expand_dims(candidate_answer_hidden_list,axis=0)
sequence_length=tf.gather(tf.shape(inputs),1)
sequence_length=tf.expand_dims(sequence_length, 0)
#with tf.variable_scope('candidate_answer_generation_forward',reuse=True):
# fwcell=rnn.BasicLSTMCell(self.config.hidden_dim, activation=tf.nn.tanh)
#with tf.variable_scope('candidate_answer_generation_backward',reuse=True):
# bwcell=rnn.BasicLSTMCell(self.config.hidden_dim, activation=tf.nn.tanh)
chain_outputs, chain_state=tf.nn.bidirectional_dynamic_rnn(self.fwcell, self.bwcell, inputs,
sequence_length, initial_state_fw=self._fw_initial_state, initial_state_bw=self._bw_initial_state,scope='candidate_answer_{}'.format(self.scope_index))
self.scope_index+=1
chain_outputs=tf.concat(chain_outputs, 2)
chain_outputs=tf.gather(chain_outputs, 0)
output=tf.gather(chain_outputs, tf.subtract(tf.gather(tf.shape(chain_outputs),0),1))
return output #[2*hidden_dim]
ccrc_model.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录