def testScatterAddGrad(self): x = tf.constant([[1., 2.], [3., 4.], [5., 6.]]) idx = tf.constant([1, 0, 1]) out = mp_ops.scatter_add(x, idx, size=2) with self.test_session(): diff = tf.test.compute_gradient_error(x, [3, 2], out, [2, 2]) self.assertLess(diff, 1e-4)
def testScatterAdd(self): x = tf.constant([[1., 2.], [3., 4.], [5., 6.]]) idx = tf.constant([1, 0, 1]) out = mp_ops.scatter_add(x, idx, size=2) with self.test_session(): self.assertAllEqual([[3., 4.], [6., 8.]], out.eval())
def deg_inv_sqrt(i): deg = mp_ops.scatter_add(edge_weight, edge_index[i], size[i]) return deg ** -0.5