MCPcopy Create free account
hub / github.com/alibaba/euler / call

Method call

tf_euler/python/utils/sparse_aggregators.py:96–125  ·  view source on GitHub ↗
(self, inputs)

Source from the content-addressed store, hash-verified

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
128class AttentionAggregator(layers.Layer):

Callers

nothing calls this directly

Calls 2

_sparse_ones_likeFunction · 0.85
_sparse_eyeFunction · 0.85

Tested by

no test coverage detected