Exemplo n.º 1
0
 def test_non_square_matrix(self):
     rng = np.random.RandomState(utt.fetch_seed())
     A = tensor.matrix("A", dtype=theano.config.floatX)
     Q = matrix_power(A, 3)
     f = function([A], [Q])
     a = rng.rand(4, 3).astype(theano.config.floatX)
     self.assertRaises(ValueError, f, a)
Exemplo n.º 2
0
 def test_non_square_matrix(self):
     rng = np.random.RandomState(utt.fetch_seed())
     A = tensor.matrix("A", dtype=theano.config.floatX)
     Q = matrix_power(A, 3)
     f = function([A], [Q])
     a = rng.rand(4, 3).astype(theano.config.floatX)
     self.assertRaises(ValueError, f, a)
Exemplo n.º 3
0
 def test_numpy_compare(self, n):
     a = np.array([[0.1231101, 0.72381381],
                   [0.28748201, 0.43036511]]).astype(config.floatX)
     A = tensor.matrix("A", dtype=config.floatX)
     A.tag.test_value = a
     Q = matrix_power(A, n)
     n_p = np.linalg.matrix_power(a, n)
     assert np.allclose(n_p, Q.get_test_value())
Exemplo n.º 4
0
    def test_numpy_compare(self):
        rng = np.random.RandomState(utt.fetch_seed())
        A = tensor.matrix("A", dtype=theano.config.floatX)
        Q = matrix_power(A, 3)
        fn = function([A], [Q])
        a = rng.rand(4, 4).astype(theano.config.floatX)

        n_p = np.linalg.matrix_power(a, 3)
        t_p = fn(a)
        assert np.allclose(n_p, t_p)
Exemplo n.º 5
0
    def test_numpy_compare(self):
        rng = np.random.RandomState(utt.fetch_seed())
        A = tensor.matrix("A", dtype=theano.config.floatX)
        Q = matrix_power(A, 3)
        fn = function([A], [Q])
        a = rng.rand(4, 4).astype(theano.config.floatX)

        n_p = np.linalg.matrix_power(a, 3)
        t_p = fn(a)
        assert np.allclose(n_p, t_p)
Exemplo n.º 6
0
 def test_non_square_matrix(self):
     A = tensor.matrix("A", dtype=config.floatX)
     Q = matrix_power(A, 3)
     f = function([A], [Q])
     a = np.array([
         [0.47497769, 0.81869379],
         [0.74387558, 0.31780172],
         [0.54381007, 0.28153101],
     ]).astype(config.floatX)
     with pytest.raises(ValueError):
         f(a)