Ejemplo n.º 1
0
class Gcat(NodeEdgeModel):
    """1 iteration Graph Convolution Attention Model."""
    def __init__(self, config):
        """Initializes GCAT model."""
        super(Gcat, self).__init__(config)
        self.edge_model = Gae(config)
        self.node_model = Gcn(config)

    def compute_inference(self, node_features_in, sp_adj_matrix, is_training):
        """Forward pass for GAT model."""
        adj_matrix_pred = self.edge_model.compute_inference(
            node_features_in, sp_adj_matrix, is_training)
        sp_adj_mask = tf.SparseTensor(indices=sp_adj_matrix.indices,
                                      values=tf.ones_like(
                                          sp_adj_matrix.values),
                                      dense_shape=sp_adj_matrix.dense_shape)
        sp_adj_att = sp_adj_mask * adj_matrix_pred
        sp_adj_att = tf.SparseTensor(indices=sp_adj_att.indices,
                                     values=tf.nn.leaky_relu(
                                         sp_adj_att.values),
                                     dense_shape=sp_adj_att.dense_shape)
        sp_adj_att = tf.sparse_softmax(sp_adj_att)
        logits = self.node_model.compute_inference(node_features_in,
                                                   sp_adj_att, is_training)
        return logits, adj_matrix_pred
Ejemplo n.º 2
0
class GaeGcn(NodeEdgeModel):
    """GAE for link prediction and GCN for node classification."""
    def __init__(self, config):
        """Initializes EGCNGCN model."""
        super(GaeGcn, self).__init__(config)
        self.edge_model = Gae(config)
        self.node_model = Gcn(config)

    def compute_inference(self, node_features_in, sp_adj_matrix, is_training):
        adj_matrix_pred = self.edge_model.compute_inference(
            node_features_in, sp_adj_matrix, is_training)
        self.adj_matrix_pred = adj_matrix_pred
        adj_mask = get_sp_topk(adj_matrix_pred, sp_adj_matrix, self.nb_nodes,
                               self.topk)
        sp_adj_pred = tf.contrib.layers.dense_to_sparse(
            tf.multiply(adj_mask, tf.nn.leaky_relu(adj_matrix_pred)))
        sp_adj_pred = tf.sparse_softmax(sp_adj_pred)
        logits = self.node_model.compute_inference(node_features_in,
                                                   sp_adj_pred, is_training)
        return logits, adj_matrix_pred
Ejemplo n.º 3
0
class GaeGat(NodeEdgeModel):
    """GAE for link prediction and GAT for node classification."""
    def __init__(self, config):
        """Initializes EGCNGAT model."""
        super(GaeGat, self).__init__(config)
        self.edge_model = Gae(config)
        self.node_model = Gat(config)

    def compute_inference(self, node_features_in, sp_adj_matrix, is_training):
        adj_matrix_pred = self.edge_model.compute_inference(
            node_features_in, sp_adj_matrix, is_training)
        self.adj_matrix_pred = adj_matrix_pred
        adj_mask = get_sp_topk(adj_matrix_pred, sp_adj_matrix, self.nb_nodes,
                               self.topk)
        self.adj_mask = adj_mask
        # masked_adj_matrix_pred = tf.multiply(adj_mask,
        #                                      tf.nn.sigmoid(adj_matrix_pred))
        masked_adj_matrix_pred = mask_edges(tf.nn.sigmoid(adj_matrix_pred),
                                            adj_mask)
        sp_adj_pred = tf.contrib.layers.dense_to_sparse(masked_adj_matrix_pred)
        logits = self.node_model.compute_inference(node_features_in,
                                                   sp_adj_pred, is_training)
        return logits, adj_matrix_pred
Ejemplo n.º 4
0
 def __init__(self, config):
     """Initializes EGCNGCN model."""
     super(GaeGcn, self).__init__(config)
     self.edge_model = Gae(config)
     self.node_model = Gcn(config)
Ejemplo n.º 5
0
 def __init__(self, config):
     """Initializes GCAT model."""
     super(Gcat, self).__init__(config)
     self.edge_model = Gae(config)
     self.node_model = Gcn(config)
Ejemplo n.º 6
0
 def __init__(self, config):
     """Initializes EGCN_GAT model."""
     super(GaeGatConcat, self).__init__(config)
     self.edge_model = Gae(config)
     self.node_model = Gat(config)