zero.random.init¶
-
zero.random.
init
(seed, cudnn_deterministic=True, cudnn_benchmark=False)[source]¶ Set seeds and settings in
random
,numpy
andtorch
.Sets random seed in
random
,numpy.random
,torch
,torch.cuda
and sets settings intorch.backends.cudnn
.- Parameters
- Returns
- if
seed
is set toNone
, the generated seed is returned; otherwise the
seed
argument is returned as is
- if
- Return type
seed
Note
If you don’t want to set the seed by hand, but still want to have a chance to reproduce things, you can use the following pattern:
print('Seed:', zero.random.init(None))
Examples
assert zero.random.init(0) == 0 generated_seed = zero.random.init(None)