def soft_attn(self, top_recur):
""""""
reuse = (self.moving_params is not None) or None
input_size = top_recur.get_shape().as_list()[-1]
with tf.variable_scope('MLP', reuse=reuse):
head_mlp, dep_mlp = self.MLP(top_recur, self.info_mlp_size,
func=self.info_func,
keep_prob=self.info_keep_prob,
n_splits=2)
with tf.variable_scope('Arcs', reuse=reuse):
arc_logits = self.bilinear_classifier(dep_mlp, head_mlp, keep_prob=self.info_keep_prob)
arc_prob = self.softmax(arc_logits)
head_lin = tf.batch_matmul(arc_prob, top_recur)
top_recur = tf.concat(2, [top_recur, head_lin])
top_recur.set_shape([tf.Dimension(None), tf.Dimension(None), tf.Dimension(4*self.recur_size)])
return top_recur
#=============================================================
评论列表
文章目录