提交 929bb073 authored 作者: Frederic's avatar Frederic

pep8

上级 5f58b6fc
......@@ -185,6 +185,7 @@ def test_inverse_grad():
r = rng.randn(4, 4)
tensor.verify_grad(matrix_inverse, [r], rng=numpy.random)
def test_rop_lop():
mx = tensor.matrix('mx')
mv = tensor.matrix('mv')
......@@ -442,6 +443,7 @@ def test_spectral_radius_bound():
ok = True
assert ok
class test_Solve(utt.InferShapeTester):
def setUp(self):
super(test_Solve, self).setUp()
......@@ -474,10 +476,12 @@ class test_Solve(utt.InferShapeTester):
dtype=config.floatX)],
self.op_class)
class test_Eig(utt.InferShapeTester):
op_class = Eig
op = eig
dtype = 'float64'
def setUp(self):
super(test_Eig, self).setUp()
self.rng = numpy.random.RandomState(utt.fetch_seed())
......@@ -494,6 +498,7 @@ class test_Eig(utt.InferShapeTester):
# S must be square
[S],
self.op_class)
def test_eval(self):
import math
A = theano.tensor.matrix(dtype=self.dtype)
......@@ -501,18 +506,20 @@ class test_Eig(utt.InferShapeTester):
[[1.0], [[1.0]]])
x = [[0, 1], [1, 0]]
w, v = [e.eval({A: x}) for e in self.op(A)]
assert_array_almost_equal(numpy.dot(x,v), w * v)
assert_array_almost_equal(numpy.dot(x, v), w * v)
class test_Eigh(test_Eig):
op = staticmethod(eigh)
def test_uplo(self):
S = self.S
a = theano.tensor.matrix(dtype=self.dtype)
wu, vu = [out.eval({a: S}) for out in self.op(a, 'U')]
wl, vl = [out.eval({a: S}) for out in self.op(a, 'L')]
assert_array_almost_equal(wu, wl)
assert_array_almost_equal(vu*numpy.sign(vu[0,:]),
vl*numpy.sign(vl[0,:]))
assert_array_almost_equal(vu * numpy.sign(vu[0, :]),
vl * numpy.sign(vl[0, :]))
def test_grad(self):
S = self.S
......@@ -521,5 +528,6 @@ class test_Eigh(test_Eig):
utt.verify_grad(lambda x: self.op(x, 'U')[0], [S], rng=self.rng)
utt.verify_grad(lambda x: self.op(x, 'U')[1], [S], rng=self.rng)
class test_Eigh_float32(test_Eigh):
dtype = 'float32'
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论