def testDotDistance(self): n1 = numpy.array([[1., 2., 3., 4.], [1., 1., 1., 1.]], dtype=numpy.float32) n2 = numpy.array([[5., 6., 7., -8.], [1., 1., 1., 1.]], dtype=numpy.float32) out = self.Run(functions.dot_distance(n1, n2)) testing.assert_allclose(out[0], numpy.array(-numpy.sum(n1 * n2, axis=1)), rtol=TOLERANCE)
def testDotDistance(self): n1 = numpy.array([[1., 2., 3., 4.], [1., 1., 1., 1.]], dtype=numpy.float32) n2 = numpy.array([[5., 6., 7., -8.], [1., 1., 1., 1.]], dtype=numpy.float32) out = self.Run(functions.dot_distance(n1, n2)) testing.assert_allclose( out[0], numpy.array(-numpy.sum(n1 * n2, axis=1)), rtol=TOLERANCE)
def test_dot_distance_with_broadcast(self): n1 = numpy.array([[[1., 2., 3., 4.], [1., 1., 1., 1.]], [[5., 6., 7., 8.], [1., 1., 1., 2.]]], dtype=numpy.float32) n2 = numpy.array([[5., 6., 7., -8.], [1., 1., 1., 1.]], dtype=numpy.float32) out = self.eval_tensor(functions.dot_distance(n1, n2)) testing.assert_allclose(out[0], numpy.array(-numpy.sum(n1 * n2, axis=2)), rtol=TOLERANCE)
def test_dot_distance_with_broadcast(self): n1 = numpy.array([[[1., 2., 3., 4.], [1., 1., 1., 1.]], [[5., 6., 7., 8.], [1., 1., 1., 2.]]], dtype=numpy.float32) n2 = numpy.array([[5., 6., 7., -8.], [1., 1., 1., 1.]], dtype=numpy.float32) out = self.eval_tensor(functions.dot_distance(n1, n2)) testing.assert_allclose( out[0], numpy.array(-numpy.sum(n1 * n2, axis=2)), rtol=TOLERANCE, atol=TOLERANCE)