Ejemplo n.º 1
0
 def _define_mapping_graph_new(self):
     with tf.name_scope('seed_links_placeholder_new'):
         self.seed_entities1_new = tf.placeholder(tf.int32, shape=[None])
         self.seed_entities2_new = tf.placeholder(tf.int32, shape=[None])
     with tf.name_scope('seed_links_lookup_new'):
         tes1 = tf.nn.embedding_lookup(self.ent_embeds, self.seed_entities1_new)
         tes2 = tf.nn.embedding_lookup(self.ent_embeds, self.seed_entities2_new)
     with tf.name_scope('mapping_loss_new'):
         self.mapping_loss_new = self.args.new_param * mapping_loss(tes1, tes2, self.mapping_mat, self.eye_mat)
         self.mapping_optimizer_new = generate_optimizer(self.mapping_loss_new, self.args.learning_rate,
                                                         opt=self.args.optimizer)
Ejemplo n.º 2
0
def add_mapping_module(model):
    with tf.name_scope('seed_links_placeholder'):
        model.seed_entities1 = tf.placeholder(tf.int32, shape=[None])
        model.seed_entities2 = tf.placeholder(tf.int32, shape=[None])
    with tf.name_scope('seed_links_lookup'):
        tes1 = tf.nn.embedding_lookup(model.ent_embeds, model.seed_entities1)
        tes2 = tf.nn.embedding_lookup(model.ent_embeds, model.seed_entities2)
    with tf.name_scope('mapping_loss'):
        model.mapping_loss = model.args.alpha * mapping_loss(
            tes1, tes2, model.mapping_mat, model.eye_mat)
        model.mapping_optimizer = generate_optimizer(model.mapping_loss,
                                                     model.args.learning_rate,
                                                     opt=model.args.optimizer)