Created
April 27, 2019 10:18
-
-
Save philip-bl/7b32a9ddf5de0fea6727defcbf055393 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_random_seeds(seed_value=555, device='cuda:0'): | |
'''source https://forums.fast.ai/t/solved-reproducibility-where-is-the-randomness-coming-in/31628/5.''' | |
np.random.seed(seed_value) | |
torch.manual_seed(seed_value) | |
random.seed(seed_value) | |
if device != 'cpu': | |
torch.cuda.manual_seed(seed_value) | |
torch.cuda.manual_seed_all(seed_value) | |
torch.backends.cudnn.deterministic = True | |
torch.backends.cudnn.benchmark = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment