Beispiel #1
0
 def _get_dense_feature(self, nodes, feature_ids):
     f = tf_euler.get_dense_feature(
         nodes,
         feature_ids,
         [1],
     )
     return self.session.run(f[0]).tolist()
Beispiel #2
0
 def get_graph_label(self, sample_graph):
     graph_idx = sample_graph.indices[:, 1]
     graph_mask = tf.equal(graph_idx, 0)
     graph_mask = tf.cast(graph_mask, dtype=tf.int32)
     graph_mask = tf.reshape(graph_mask, [-1])
     graph_node = tf.boolean_mask(sample_graph.values, graph_mask)
     graph_label, = tf_euler.get_dense_feature(graph_node,
                                               self.params['label'], [1])
     graph_label = tf.reshape(tf.cast(graph_label, dtype=tf.int32), [-1])
     graph_label = tf.one_hot(graph_label, self.params['num_classes'])
     return graph_label
Beispiel #3
0
    def __call__(self, inputs):
        label, = tf_euler.get_dense_feature(inputs, [self.label_idx],
                                            [self.label_dim])
        embedding = self.embed(inputs)
        logit = self.out_fc(embedding)

        metric = self.metric_class(label, tf.nn.sigmoid(logit))
        loss = tf.nn.sigmoid_cross_entropy_with_logits(labels=label,
                                                       logits=logit)
        loss = tf.reduce_mean(loss)
        #add logit output
        return (embedding, loss, self.metric_name, metric, logit)
Beispiel #4
0
 def call(self, inputs):
   samples = tf_euler.sample_fanout(inputs, self.metapath, self.fanouts)[0]
   hidden = [
       tf_euler.get_dense_feature(sample,
                                  [self.feature_idx], [self.feature_dim])[0]
       for sample in samples]
   for layer in range(self.num_layers):
     aggregator = self.aggregators[layer]
     next_hidden = []
     for hop in range(self.num_layers - layer):
       neigh_shape = [-1, self.fanouts[hop], self.dims[layer]]
       h = aggregator((hidden[hop], tf.reshape(hidden[hop + 1], neigh_shape)))
       next_hidden.append(h)
     hidden = next_hidden
   return hidden[0]
Beispiel #5
0
 def sampler(self, inputs):
     labels = tf_euler.get_dense_feature(inputs, [self.label_idx],
                                         [self.label_dim])[0]
     return inputs, labels
Beispiel #6
0
 def __call__(self, inputs):
     label, = tf_euler.get_dense_feature(inputs, [self.label_idx],
                                         [self.label_dim])
     return label
Beispiel #7
0
 def to_x(self, n_id):
     x, = tf_euler.get_dense_feature(n_id, self.feature_idx,
                                     self.feature_dim)
     return x