提交 1d8ef85d authored 作者: Razvan Pascanu's avatar Razvan Pascanu 提交者: David Warde-Farley

Use utt.get_seed() to give a seed for every random generator.

Conflicts: theano/sandbox/linalg/tests/test_linalg.py
上级 1a0d4a49
...@@ -38,7 +38,7 @@ if 0: ...@@ -38,7 +38,7 @@ if 0:
def test_cholesky(): def test_cholesky():
#TODO: test upper and lower triangular #TODO: test upper and lower triangular
#todo: unittest randomseed #todo: unittest randomseed
rng = numpy.random.RandomState(1234) rng = numpy.random.RandomState(utt.fetch_seed())
r = rng.randn(5,5) r = rng.randn(5,5)
...@@ -60,8 +60,7 @@ if 0: ...@@ -60,8 +60,7 @@ if 0:
def test_inverse_correctness(): def test_inverse_correctness():
#todo: unittest randomseed rng = numpy.random.RandomState(utt.fetch_seed())
rng = numpy.random.RandomState(12345)
r = rng.randn(4,4).astype(theano.config.floatX) r = rng.randn(4,4).astype(theano.config.floatX)
...@@ -79,6 +78,9 @@ def test_inverse_correctness(): ...@@ -79,6 +78,9 @@ def test_inverse_correctness():
assert _allclose(numpy.identity(4), rri), rri assert _allclose(numpy.identity(4), rri), rri
def test_inverse_grad(): def test_inverse_grad():
rng = numpy.random.RandomState(utt.fetch_seed())
r = rng.randn(4, 4)
tensor.verify_grad(matrix_inverse, [r], rng=numpy.random)
rng = numpy.random.RandomState(utt.fetch_seed()) rng = numpy.random.RandomState(utt.fetch_seed())
...@@ -136,7 +138,7 @@ def test_det_grad(): ...@@ -136,7 +138,7 @@ def test_det_grad():
# If scipy is not available, this test will fail, thus we skip it. # If scipy is not available, this test will fail, thus we skip it.
if not use_scipy: if not use_scipy:
raise SkipTest('Scipy is not available') raise SkipTest('Scipy is not available')
rng = numpy.random.RandomState(1234) rng = numpy.random.RandomState(utt.fetch_seed())
r = rng.randn(5,5) r = rng.randn(5,5)
tensor.verify_grad(det, [r], rng=numpy.random) tensor.verify_grad(det, [r], rng=numpy.random)
...@@ -197,4 +199,4 @@ def test_trace(): ...@@ -197,4 +199,4 @@ def test_trace():
ok = True ok = True
assert ok assert ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论