提交 dbfbfb8c authored 作者: Tanjay94's avatar Tanjay94

Fixed rebase error.

上级 71262429
...@@ -1215,8 +1215,6 @@ def eigvalsh(a, b, lower=True): ...@@ -1215,8 +1215,6 @@ def eigvalsh(a, b, lower=True):
return Eigvalsh(lower)(a, b) return Eigvalsh(lower)(a, b)
<<<<<<< HEAD
<<<<<<< HEAD
def matrix_power(M, n): def matrix_power(M, n):
result = 1 result = 1
for i in xrange(n): for i in xrange(n):
...@@ -1254,11 +1252,11 @@ def norm(x,ord): ...@@ -1254,11 +1252,11 @@ def norm(x,ord):
elif ord == 1: elif ord == 1:
return tensor.max(tensor.sum(abs(x), 0)) return tensor.max(tensor.sum(abs(x), 0))
elif ord == -1: elif ord == -1:
z = tensor.sum(abs(x),0) return tensor.min(tensor.sum(abs(x),0))
return tensor.min(z) else:
else: raise ValueError(0)
raise ValueError(0) elif ndim > 2:
raise NotImplementedError
class lstsq(theano.Op): class lstsq(theano.Op):
def __eq__(self, other): def __eq__(self, other):
......
...@@ -32,7 +32,7 @@ from theano.sandbox.linalg.ops import (cholesky, ...@@ -32,7 +32,7 @@ from theano.sandbox.linalg.ops import (cholesky,
spectral_radius_bound, spectral_radius_bound,
imported_scipy, imported_scipy,
Eig, Eig,
inv_as_solve inv_as_solve,
norm norm
) )
......
...@@ -32,7 +32,7 @@ from theano.tensor import (_shared, wvector, bvector, autocast_float_as, ...@@ -32,7 +32,7 @@ from theano.tensor import (_shared, wvector, bvector, autocast_float_as,
alloc, as_tensor_variable, tensor_from_scalar, ARange, autocast_float, alloc, as_tensor_variable, tensor_from_scalar, ARange, autocast_float,
clip, constant, default, dot, clip, constant, default, dot,
dmatrix, dscalar, dvector, eq, eye, fill, flatten, inverse_permutation, dmatrix, dscalar, dvector, eq, eye, fill, flatten, inverse_permutation,
tensor4permute_row_elements, Flatten, fmatrix, fscalars, grad, tensor4, permute_row_elements, Flatten, fmatrix, fscalars, grad,
inplace, iscalar, matrix, minimum, matrices, maximum, mul, neq, inplace, iscalar, matrix, minimum, matrices, maximum, mul, neq,
Reshape, row, scalar, scalars, second, smallest, stack, sub, Tensor, Reshape, row, scalar, scalars, second, smallest, stack, sub, Tensor,
tensor_copy, tensordot, TensorType, Tri, tri, tril, triu, unbroadcast, tensor_copy, tensordot, TensorType, Tri, tri, tril, triu, unbroadcast,
...@@ -6923,6 +6923,16 @@ class T_swapaxes(unittest.TestCase): ...@@ -6923,6 +6923,16 @@ class T_swapaxes(unittest.TestCase):
x = theano.tensor.matrix() x = theano.tensor.matrix()
x.swapaxes(0,1) x.swapaxes(0,1)
def test_numpy_compare(self):
rng = numpy.random.RandomState(utt.fetch_seed())
A = tensor.matrix("A", dtype=theano.config.floatX)
Q = swapaxes(A, 0, 1)
fn = function([A], [Q])
a = rng.rand(4, 4).astype(theano.config.floatX)
n_s = numpy.swapaxes(a, 0, 1)
t_s = fn(a)
assert numpy.allclose(n_s, t_s)
class T_Power(): class T_Power():
def test_numpy_compare(self): def test_numpy_compare(self):
...@@ -6953,12 +6963,12 @@ class T_Power(): ...@@ -6953,12 +6963,12 @@ class T_Power():
def test_numpy_compare(self): def test_numpy_compare(self):
rng = numpy.random.RandomState(utt.fetch_seed()) rng = numpy.random.RandomState(utt.fetch_seed())
A = tensor.matrix("A", dtype=theano.config.floatX) A = tensor.matrix("A", dtype=theano.config.floatX)
Q = swapaxes(A, 0, 1) Q = power(A, 2)
fn = function([A], [Q]) fn = function([A], [Q])
a = rng.rand(4, 4).astype(theano.config.floatX) a = rng.rand(4, 4).astype(theano.config.floatX)
n_s = numpy.swapaxes(a, 0, 1) n_p = numpy.power(a, 2)
t_s = fn(a) t_p = fn(a)
assert numpy.allclose(n_s, t_s) assert numpy.allclose(n_s, t_s)
""" """
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论