提交 539bcf94 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Change type of config.unittests.rseed so it accepts the value "random", as…

Change type of config.unittests.rseed so it accepts the value "random", as THEANO_UNITTEST_SEED did.
上级 d6f6e9ff
import unittest
import numpy
import theano.tensor as T
from theano.configparser import config, AddConfigVar, IntParam
from theano.configparser import config, AddConfigVar, StrParam
import os, sys
AddConfigVar('unittests.rseed',
"Seed to use for randomized unit tests",
IntParam(666))
"Seed to use for randomized unit tests. Special value 'random' means using a seed of None.",
StrParam(666))
def fetch_seed(pseed=None):
"""
Returns the seed to use for running the unit tests.
If an explicit seed is given, it will be used for seending numpy's rng.
If not, it will try to get a seed from the THEANO_UNITTEST_SEED variable.
If THEANO_UNITTEST_SEED is set to "random", it will seed the rng. with None,
If an explicit seed is given, it will be used for seeding numpy's rng.
If not, it will use config.unittest.rseed (its default value is 666).
If config.unittest.rseed is set to "random", it will seed the rng with None,
which is equivalent to seeding with a random seed.
If THEANO_UNITTEST_SEED is not defined, it will use a default seed of 666.
Useful for seeding RandomState objects.
>>> rng = numpy.random.RandomState(unittest_tools.fetch_seed())
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论