(self, inputs)
| 94 | self.renorm = renorm |
| 95 | |
| 96 | def call(self, inputs): |
| 97 | self_embedding, neigh_embedding, adj = inputs |
| 98 | adj = _sparse_ones_like(adj) |
| 99 | if self.renorm: |
| 100 | eye = _sparse_eye(adj.dense_shape[0]) |
| 101 | adj = tf.sparse_concat(1, [eye, adj]) |
| 102 | |
| 103 | if not self.renorm: |
| 104 | from_all = self.dense(neigh_embedding) |
| 105 | from_self = self.dense(self_embedding) |
| 106 | else: |
| 107 | all_embedding = tf.concat([self_embedding, neigh_embedding], 0) |
| 108 | from_all = self.dense(all_embedding) |
| 109 | from_self = from_all[:adj.dense_shape[0], :] |
| 110 | |
| 111 | self_weight = self.self_layer(from_self) |
| 112 | all_weight = self.neigh_layer(from_all) |
| 113 | coefficient = tf.sparse_add(adj * self_weight, |
| 114 | adj * tf.reshape(all_weight, [1, -1])) |
| 115 | coefficient = tf.SparseTensor( |
| 116 | coefficient.indices, tf.nn.leaky_relu(coefficient.values), |
| 117 | coefficient.dense_shape) |
| 118 | coefficient = tf.sparse_softmax(coefficient) |
| 119 | |
| 120 | output = tf.sparse_tensor_dense_matmul(coefficient, from_all) |
| 121 | if not self.renorm: |
| 122 | output = from_self + output |
| 123 | if self.activation: |
| 124 | output = self.activation(output) |
| 125 | return output |
| 126 | |
| 127 | |
| 128 | class AttentionAggregator(layers.Layer): |
nothing calls this directly
no test coverage detected