def test_numpy_compare(self): rng = np.random.RandomState(utt.fetch_seed()) M = tensor.matrix("A", dtype=theano.config.floatX) V = tensor.vector("V", dtype=theano.config.floatX) a = rng.rand(4, 4).astype(theano.config.floatX) b = rng.rand(4).astype(theano.config.floatX) A = ( [None, 'fro', 'inf', '-inf', 1, -1, None, 'inf', '-inf', 0, 1, -1, 2, -2], [M, M, M, M, M, M, V, V, V, V, V, V, V, V], [a, a, a, a, a, a, b, b, b, b, b, b, b, b], [None, 'fro', inf, -inf, 1, -1, None, inf, -inf, 0, 1, -1, 2, -2]) for i in range(0, 14): f = function([A[1][i]], norm(A[1][i], A[0][i])) t_n = f(A[2][i]) n_n = np.linalg.norm(A[2][i], A[3][i]) assert _allclose(n_n, t_n)
def test_tensor_input(self): with pytest.raises(NotImplementedError): norm(np.random.rand(3, 4, 5), None)
def test_wrong_type_of_ord_for_matrix(self): with pytest.raises(ValueError): norm([[2, 1], [3, 4]], 0)
def test_non_tensorial_input(self): with pytest.raises(ValueError): norm(3, None)
def test_wrong_type_of_ord_for_vector(self): with pytest.raises(ValueError): norm([2, 1], "fro")