def prepare_seed(*inputs, **kwinputs):
"""Update ``kwinputs`` with the seed from its value ``random_state``."""
if 'random_state' in kwinputs:
# Get the seed for this batch, assuming np.RandomState instance
seed = kwinputs['random_state'].get_state()[1][0]
# Since we may not be the first operation to use this seed, lets generate a
# a sub seed using this seed
sub_seed_index = kwinputs.get('index_in_batch') or 0
kwinputs['seed'] = get_sub_seed(seed, sub_seed_index)
return inputs, kwinputs
评论列表
文章目录