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

Fixed rebase error.

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