def test_matmul(self): a = np.eye(10) b = np.eye(10) for i in range(10): b[i, i] = i a_s = scipy.sparse.coo_matrix(a) a_t = tensor.SparseMatrix(a_s, info=GraphInfo('a')) b_t = tensor.Constant(b, info=GraphInfo('b')) c_t = a_t @ b_t with self.test_session() as sess: c_t = sess.run(c_t.data) np.testing.assert_almost_equal(c_t, a @ b)
def test_under_variable_scope(self): with tf.variable_scope('scope'): a = tensor.Constant(1.0, 'x') assert a.data.name == 'scope/x:0' assert a.info.scope.name == 'scope'
def test_run(self): value = [1.0, 2.0] a = tensor.Constant(value, 'x') with self.test_session() as sess: result = sess.run(a.data) self.assertFloatArrayEqual(value, result)
def test_name(self): a = tensor.Constant(1.0, 'x') assert a.data.name == 'x:0'