def test_dot(self): with self.test_session(): a = tf.ones([5]) * np.arange(5) b = tf.diag(tf.ones([5])) self.assertAllEqual(dot(a, b).eval(), a.eval()[np.newaxis].dot(b.eval())) self.assertAllEqual(dot(b, a).eval(), b.eval().dot(a.eval()[:, np.newaxis]))
def test_dot(self): with self.test_session(): a = tf.constant(np.arange(5, dtype=np.float32)) b = tf.diag(tf.ones([5])) self.assertAllEqual(dot(a, b).eval(), np.dot(a.eval(), b.eval())) self.assertAllEqual(dot(b, a).eval(), np.dot(b.eval(), a.eval()))
def test_all_finite_raises(self): with self.test_session(): a = np.inf * tf.ones([5]) b = tf.diag(tf.ones([5])) with self.assertRaisesOpError('Inf'): dot(a, b).eval() a = tf.ones([5]) * np.arange(5) b = np.inf * tf.diag(tf.ones([5])) with self.assertRaisesOpError('Inf'): dot(a, b).eval()
def test_dot(self): with self.test_session(): a = tf.ones([5]) * np.arange(5) b = tf.diag(tf.ones([5])) self.assertAllEqual( dot(a, b).eval(), a.eval()[np.newaxis].dot(b.eval())) self.assertAllEqual( dot(b, a).eval(), b.eval().dot(a.eval()[:, np.newaxis]))
def test_all_finite_raises(self): with self.test_session(): a = np.inf * tf.ones([5]) * np.arange(5) b = tf.diag(tf.ones([5])) with self.assertRaisesOpError('Inf'): dot(a, b).eval() a = tf.ones([5]) * np.arange(5) b = np.inf * tf.diag(tf.ones([5])) with self.assertRaisesOpError('Inf'): dot(a, b).eval()
def test_dot(): with sess.as_default(): assert np.all(dot(a, b).eval() == a.eval()[np.newaxis].dot(b.eval())) assert np.all(dot(b, a).eval() == b.eval().dot(a.eval()[:, np.newaxis]))
def test_dot(): with sess.as_default(): assert np.all(dot(a, b).eval() == a.eval()[np.newaxis].dot(b.eval())) assert np.all( dot(b, a).eval() == b.eval().dot(a.eval()[:, np.newaxis]))