Created
May 25, 2021 07:28
-
-
Save 1pha/8164c171315ba1dfbec389e68b7b2539 to your computer and use it in GitHub Desktop.
Source code for setting every seed same.
This file contains 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
import os | |
import random | |
import numpy as np | |
import torch | |
def seed_everything(seed=42): | |
os.environ['PYTHONHASHSEED'] = str(seed) | |
random.seed(seed) | |
np.random.seed(seed) | |
torch.manual_seed(seed) | |
torch.cuda.manual_seed(seed) | |
torch.backends.cudnn.deterministic = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment