提交 bd3749d2 authored 作者: Frederic's avatar Frederic

Fix tests due to change to gradient check dtype.

上级 26d6e34a
...@@ -2322,7 +2322,7 @@ class CastTester(utt.InferShapeTester): ...@@ -2322,7 +2322,7 @@ class CastTester(utt.InferShapeTester):
eps = None eps = None
if o_dtype == 'float32': if o_dtype == 'float32':
eps = 7e-4 eps = 1e-2
verify_grad_sparse(Cast(o_dtype), data, eps=eps) verify_grad_sparse(Cast(o_dtype), data, eps=eps)
...@@ -2386,7 +2386,7 @@ class _HVStackTester(utt.InferShapeTester): ...@@ -2386,7 +2386,7 @@ class _HVStackTester(utt.InferShapeTester):
self.op_class(format=out_f, dtype=dtype), self.op_class(format=out_f, dtype=dtype),
self.mat[format], self.mat[format],
structured=False, structured=False,
eps=7e-4) eps=1e-1)
def _hv_switch(op, expected_function): def _hv_switch(op, expected_function):
......
...@@ -117,4 +117,4 @@ def test_conv3d(mode=mode_without_gpu, shared=theano.tensor._shared): ...@@ -117,4 +117,4 @@ def test_conv3d(mode=mode_without_gpu, shared=theano.tensor._shared):
signals = numpy.random.rand(Ns, Ts, C, Hs, Ws).astype('float32') signals = numpy.random.rand(Ns, Ts, C, Hs, Ws).astype('float32')
filters = numpy.random.rand(Nf, Tf, C, Hf, Wf).astype('float32') filters = numpy.random.rand(Nf, Tf, C, Hf, Wf).astype('float32')
utt.verify_grad(conv3d, [signals, filters]) utt.verify_grad(conv3d, [signals, filters], eps=1e-1)
...@@ -3277,18 +3277,18 @@ class T_Join_and_Split(unittest.TestCase): ...@@ -3277,18 +3277,18 @@ class T_Join_and_Split(unittest.TestCase):
self.assertTrue((out == want).all()) self.assertTrue((out == want).all())
def test_join_matrix1(self): def test_join_matrix1(self):
av = numpy.array([[1, 2, 3], [4, 5, 6]], dtype='float32') av = numpy.array([[.1, .2, .3], [.4, .5, .6]], dtype='float32')
bv = numpy.array([[7], [8]], dtype='float32') bv = numpy.array([[.7], [.8]], dtype='float32')
a = self.shared(av) a = self.shared(av)
b = as_tensor_variable(bv) b = as_tensor_variable(bv)
s = join(1, a, b) s = join(1, a, b)
want = numpy.array([[1, 2, 3, 7], [4, 5, 6, 8]], dtype='float32') want = numpy.array([[.1, .2, .3, .7], [.4, .5, .6, .8]],
dtype='float32')
out = self.eval_outputs_and_check_join([s]) out = self.eval_outputs_and_check_join([s])
self.assertTrue((out == want).all()) self.assertTrue((out == want).all())
# assert tensor.grad(join(1,a,b), a
utt.verify_grad(lambda a, b: join(1, a, b), [av, bv], utt.verify_grad(lambda a, b: join(1, a, b), [av, bv],
eps=1.0e-4, rel_tol=1.0e-3, mode=self.mode) mode=self.mode)
def test_join_matrix_dtypes(self): def test_join_matrix_dtypes(self):
if "float32" in self.shared.__name__: if "float32" in self.shared.__name__:
...@@ -3308,7 +3308,7 @@ class T_Join_and_Split(unittest.TestCase): ...@@ -3308,7 +3308,7 @@ class T_Join_and_Split(unittest.TestCase):
grad(s.sum(), b) grad(s.sum(), b)
grad(s.sum(), a) grad(s.sum(), a)
utt.verify_grad(lambda b: join(1, a, b), [bv], utt.verify_grad(lambda b: join(1, a, b), [bv],
eps=1.0e-4, rel_tol=1.0e-3, mode=self.mode) eps=1.0e-2, mode=self.mode)
def test_join_matrix_ints(self): def test_join_matrix_ints(self):
if "float32" in self.shared.__name__: if "float32" in self.shared.__name__:
...@@ -3339,20 +3339,21 @@ class T_Join_and_Split(unittest.TestCase): ...@@ -3339,20 +3339,21 @@ class T_Join_and_Split(unittest.TestCase):
self.assertTrue((out == want).all()) self.assertTrue((out == want).all())
def test_join_matrix1_using_horizontal_stack(self): def test_join_matrix1_using_horizontal_stack(self):
av = numpy.array([[1, 2, 3], [4, 5, 6]], dtype='float32') av = numpy.array([[.1, .2, .3], [.4, .5, .6]], dtype='float32')
bv = numpy.array([[7], [8]], dtype='float32') bv = numpy.array([[.7], [.8]], dtype='float32')
cv = numpy.array([[3, 2, 1], [6, 5, 4]], dtype='float32') cv = numpy.array([[.3, .2, .1], [.6, .5, .4]], dtype='float32')
a = self.shared(av) a = self.shared(av)
b = as_tensor_variable(bv) b = as_tensor_variable(bv)
c = as_tensor_variable(cv) c = as_tensor_variable(cv)
s = horizontal_stack(a, b, c) s = horizontal_stack(a, b, c)
want = numpy.array([[1, 2, 3, 7, 3, 2, 1], [4, 5, 6, 8, 6, 5, 4]], want = numpy.array([[.1, .2, .3, .7, .3, .2, .1],
[.4, .5, .6, .8, .6, .5, .4]],
dtype='float32') dtype='float32')
out = self.eval_outputs_and_check_join([s]) out = self.eval_outputs_and_check_join([s])
self.assertTrue((out == want).all()) self.assertTrue((out == want).all())
utt.verify_grad(lambda a, b: join(1, a, b), [av, bv], utt.verify_grad(lambda a, b: join(1, a, b), [av, bv],
eps=1.0e-4, rel_tol=1.0e-3, mode=self.mode) mode=self.mode)
def test_join_matrixV(self): def test_join_matrixV(self):
"""variable join axis""" """variable join axis"""
......
...@@ -571,7 +571,7 @@ class test_Prod(unittest.TestCase): ...@@ -571,7 +571,7 @@ class test_Prod(unittest.TestCase):
# including zeros, as the case with zeros is important # including zeros, as the case with zeros is important
# (and special cases: 1 zero in the row, more than 1 zero in the row) # (and special cases: 1 zero in the row, more than 1 zero in the row)
x_val = numpy.asarray([[1, 2, 3], [4, 5, 6], [7, 8, 9]], x_val = numpy.asarray([[.1, .2, .3], [.4, .5, .6], [.7, .8, .9]],
dtype='float32') dtype='float32')
# now with verify_grad # now with verify_grad
unittest_tools.verify_grad(Prod(axis=1), [x_val], mode=self.mode) unittest_tools.verify_grad(Prod(axis=1), [x_val], mode=self.mode)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论