以供复制。
def reproducibility(chosen_seed):
"""
The is required for reproducible experimentation. It sets the random
generators for the different libraries used to a specific, user chosen
seed.
Input
chosen_seed: int - The seed chosen for this experiment
"""
torch.manual_seed(chosen_seed)
torch.cuda.manual_seed_all(chosen_seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
np.random.seed(chosen_seed)
random.seed(chosen_seed)
网友评论