提交 7ccfbb01 authored 作者: nouiz's avatar nouiz

Merge pull request #461 from lamblin/fix_test_usmm_tol

Fix tolerance in Usmm test.
...@@ -833,14 +833,13 @@ class UsmmTests(unittest.TestCase): ...@@ -833,14 +833,13 @@ class UsmmTests(unittest.TestCase):
y_size = (100, 200) y_size = (100, 200)
z_size = (x_size[0], y_size[1]) z_size = (x_size[0], y_size[1])
self.x = numpy.asarray(numpy.random.binomial(1, 0.5, x_size), self.rng = numpy.random.RandomState(seed=utt.fetch_seed())
self.x = numpy.asarray(self.rng.binomial(1, 0.5, x_size),
dtype=theano.config.floatX) dtype=theano.config.floatX)
self.y = numpy.asarray(numpy.random.uniform(-1, 1, y_size), self.y = numpy.asarray(self.rng.uniform(-1, 1, y_size),
dtype=theano.config.floatX) dtype=theano.config.floatX)
self.z = numpy.asarray(numpy.random.uniform(-1, 1, z_size), self.z = numpy.asarray(self.rng.uniform(-1, 1, z_size),
dtype=theano.config.floatX) dtype=theano.config.floatX)
utt.seed_rng()
self.rng = numpy.random.RandomState(seed=utt.fetch_seed())
def test(self): def test(self):
def mat(format, name, dtype): def mat(format, name, dtype):
...@@ -896,13 +895,16 @@ class UsmmTests(unittest.TestCase): ...@@ -896,13 +895,16 @@ class UsmmTests(unittest.TestCase):
z - a * theano.sparse.dot(x, y), z - a * theano.sparse.dot(x, y),
mode=mode) mode=mode)
# In DebugMode there is a strange difference with complex # In DebugMode there is a strange difference with complex
# So we raise a little the threashold a little. # So we raise a little the threshold a little.
try: try:
orig = theano.tensor.basic.float64_rtol orig_atol = theano.tensor.basic.float64_atol
theano.tensor.basic.float64_rtol = 1e-5 orig_rtol = theano.tensor.basic.float64_rtol
theano.tensor.basic.float64_atol = 1e-7
theano.tensor.basic.float64_rtol = 1e-6
f_a_out = f_a(a_data, x_data, y_data) f_a_out = f_a(a_data, x_data, y_data)
finally: finally:
theano.tensor.basic.float64_rtol = orig theano.tensor.basic.float64_atol = orig_atol
theano.tensor.basic.float64_rtol = orig_rtol
assert _allclose(f_a_out, f_b_out, rtol=1e-5) assert _allclose(f_a_out, f_b_out, rtol=1e-5)
topo = f_a.maker.env.toposort() topo = f_a.maker.env.toposort()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论