def do_setup(deterministic=True):
global _old_python_random_state
global _old_numpy_random_state
global _old_cupy_random_states
_old_python_random_state = random.getstate()
_old_numpy_random_state = numpy.random.get_state()
_old_cupy_random_states = cupy.random.generator._random_states
cupy.random.reset_states()
# Check that _random_state has been recreated in
# cupy.random.reset_states(). Otherwise the contents of
# _old_cupy_random_states would be overwritten.
assert (cupy.random.generator._random_states is not
_old_cupy_random_states)
if not deterministic:
random.seed()
numpy.random.seed()
cupy.random.seed()
else:
random.seed(99)
numpy.random.seed(100)
cupy.random.seed(101)
评论列表
文章目录