예제 #1
0
파일: GCN.py 프로젝트: youngjt/fennlp
 def call(self, node_embeddings, adjacency_lists, training=True):
     adjacency_loop = [add_self_loop(adjacency_lists, len(node_embeddings))]
     x = self.gc1(GNNInput(node_embeddings, adjacency_loop), training)
     x = tf.nn.relu(x)
     x = self.dropout(x, training=training)
     x = self.gc2(GNNInput(x, adjacency_loop), training)
     return tf.math.softmax(x, 1)
예제 #2
0
 def call(self, node_embeddings, adjacency_lists, training=True):
     node_embeddings = self.dropout1(node_embeddings, training=training)
     x = self.gc1(GNNInput(node_embeddings, adjacency_lists), training)
     x = tf.nn.elu(x)
     x = self.dropout2(x, training=training)
     x = self.gc2(GNNInput(x, adjacency_lists), training)
     return tf.math.softmax(x, -1)
예제 #3
0
 def call(self, inputs, training):
     adjacency_lists = inputs.adjacency_lists
     node_embeddings = inputs.node_embeddings
     part1 = (1 + self.eps) * node_embeddings
     part2 = self.propagate(GNNInput(node_embeddings, adjacency_lists),
                            training)
     out = self.nn(part1 + part2, training=training)
     return out
예제 #4
0
 def call(self, inputs, training):
     adjacency_lists = inputs.adjacency_lists
     adjacency_lists = [remove_self_loop(adjacency_lists[0])]
     node_embeddings = inputs.node_embeddings
     part1 = (1 + self.eps) * node_embeddings
     part2 = self.propagate(GNNInput(node_embeddings, adjacency_lists),
                            training)
     out = self.nn(part1 + part2)
     return out
예제 #5
0
 def call(self, inputs):
     adjacency_lists = inputs.adjacency_lists
     node_embeddings = inputs.node_embeddings
     if self.use_bias:
         node_embeddings = tf.linalg.matmul(node_embeddings,
                                            self.weight) + self.bias
     else:
         node_embeddings = tf.linalg.matmul(node_embeddings, self.weight)
     aggr_out = self.propagate(GNNInput(node_embeddings, adjacency_lists))
     return aggr_out
예제 #6
0
    def call(self, inputs, training):
        adjacency_lists = inputs.adjacency_lists
        node_embeddings = inputs.node_embeddings
        node_embeddings = tf.linalg.matmul(node_embeddings, self.weight)
        aggr_out = self.propagate(GNNInput(node_embeddings, adjacency_lists),
                                  training)
        if self.concat is True:
            aggr_out = tf.reshape(aggr_out,
                                  [-1, self.heads * self.out_features])
        else:
            aggr_out = tf.reduce_mean(aggr_out, 1)

        if self.use_bias:
            aggr_out += self.bias
        return aggr_out
예제 #7
0
 def call(self, node_embeddings, adjacency_lists, training=True):
     node_embeddings = self.drop_out1(node_embeddings, training=training)
     x = tf.nn.relu(self.conv1(GNNInput(node_embeddings, adjacency_lists)))
     x = self.drop_out2(x, training=training)
     x = self.conv2(GNNInput(x, adjacency_lists))
     return tf.math.softmax(x, -1)