Beispiel #1
0
 def _define_variables(self):
     with tf.variable_scope('attribute' + 'embeddings'):
         self.embeds = xavier_init([self.kgs.attributes_num, self.args.dim],
                                   'attr_embed', True)
     with tf.variable_scope('nce' + 'embeddings'):
         self.nce_weights = xavier_init(
             [self.kgs.attributes_num, self.args.dim], 'nce_weights', True)
         self.nce_biases = tf.Variable(tf.zeros([self.kgs.attributes_num]))
Beispiel #2
0
    def _define_variables(self):
        with tf.variable_scope('relation_view' + 'embeddings'):
            self.rv_ent_embeds = init_embeddings([self.kgs.entities_num, self.args.dim], 'rv_ent_embeds',
                                                 self.args.init, self.args.ent_l2_norm)
            self.rel_embeds = init_embeddings([self.kgs.relations_num, self.args.dim], 'rel_embeds',
                                              self.args.init, self.args.rel_l2_norm)

        with tf.variable_scope('image_view' + 'embeddings'):
            self.iv_ent_embeds = init_embeddings([self.kgs.entities_num, self.args.dim], 'iv_ent_embeds',
                                                 self.args.init, self.args.ent_l2_norm)
            self.iv_ent_mapping = init_embeddings([self.args.vgg_dim, self.args.dim], 'iv_ent_mapping',
                                                  self.args.init, self.args.ent_l2_norm)
            self.image_embeds = tf.constant(self.img_embeds, dtype=tf.float32)

        with tf.variable_scope('attribute_view' + 'embeddings'):
            self.av_ent_embeds = xavier_init([self.kgs.entities_num, self.args.dim], 'av_ent_embeds', True)
            self.av_c = xavier_init([self.kgs.attributes_num, self.args.rbf_dim], 'av_c', True)
            self.av_delta = xavier_init([self.kgs.attributes_num, self.args.rbf_dim], 'av_delta', True)
            self.av_W = xavier_init([self.args.rbf_dim, self.args.dim], 'av_W', True)
            self.av_b = xavier_init([1, self.args.dim], 'av_b', True)
            # False important!
            self.attr_embeds = xavier_init([self.kgs.attributes_num, self.args.dim], 'attr_embeds', False)

        with tf.variable_scope('shared' + 'embeddings'):
            self.ent_embeds = init_embeddings([self.kgs.entities_num, self.args.dim], 'ent_embeds',
                                              self.args.init, self.args.ent_l2_norm)

        with tf.variable_scope('shared' + 'combination'):
            self.rv_mapping = tf.get_variable('rv_mapping', shape=[self.args.dim, self.args.dim],
                                              initializer=tf.initializers.orthogonal())
            self.iv_mapping = tf.get_variable('iv_mapping', shape=[self.args.dim, self.args.dim],
                                              initializer=tf.initializers.orthogonal())
            self.eye_mat = tf.constant(np.eye(self.args.dim), dtype=tf.float32, name='eye')
Beispiel #3
0
 def _define_variables(self):
     with tf.variable_scope('literal' + 'embeddings'):
         self.literal_embeds = tf.constant(self.data.value_vectors,
                                           dtype=tf.float32)
     with tf.variable_scope('name_view' + 'embeddings'):
         self.name_embeds = tf.constant(self.data.local_name_vectors,
                                        dtype=tf.float32)
     with tf.variable_scope('relation_view' + 'embeddings'):
         self.rv_ent_embeds = xavier_init(
             [self.kgs.entities_num, self.args.dim], 'rv_ent_embeds', True)
         self.rel_embeds = xavier_init(
             [self.kgs.relations_num, self.args.dim], 'rel_embeds', True)
     with tf.variable_scope('attribute_view' + 'embeddings'):
         self.av_ent_embeds = xavier_init(
             [self.kgs.entities_num, self.args.dim], 'av_ent_embeds', True)
         # False important!
         self.attr_embeds = xavier_init(
             [self.kgs.attributes_num, self.args.dim], 'attr_embeds', False)
     with tf.variable_scope('shared' + 'embeddings'):
         self.ent_embeds = xavier_init(
             [self.kgs.entities_num, self.args.dim], 'ent_embeds', True)
     with tf.variable_scope('shared' + 'combination'):
         self.nv_mapping = tf.get_variable(
             'nv_mapping',
             shape=[self.args.dim, self.args.dim],
             initializer=tf.initializers.orthogonal())
         self.rv_mapping = tf.get_variable(
             'rv_mapping',
             shape=[self.args.dim, self.args.dim],
             initializer=tf.initializers.orthogonal())
         self.av_mapping = tf.get_variable(
             'av_mapping',
             shape=[self.args.dim, self.args.dim],
             initializer=tf.initializers.orthogonal())
         self.eye_mat = tf.constant(np.eye(self.args.dim),
                                    dtype=tf.float32,
                                    name='eye')