def process_leafs(self,emb):
with tf.variable_scope("Composition",reuse=True):
cU = tf.get_variable("cU",[self.emb_dim,2*self.hidden_dim])
cb = tf.get_variable("cb",[4*self.hidden_dim])
b = tf.slice(cb,[0],[2*self.hidden_dim])
def _recurseleaf(x):
concat_uo = tf.matmul(tf.expand_dims(x,0),cU) + b
u,o = tf.split(1,2,concat_uo)
o=tf.nn.sigmoid(o)
u=tf.nn.tanh(u)
c = u#tf.squeeze(u)
h = o * tf.nn.tanh(c)
hc = tf.concat(1,[h,c])
hc=tf.squeeze(hc)
return hc
hc = tf.map_fn(_recurseleaf,emb)
return hc
评论列表
文章目录