๐บ๐๐๐๐๐
[Pytorch] Fixing Radom Seed ๋ณธ๋ฌธ
# fixing random seed
def seed_everything(seed:int = 1004):
random.seed(seed)
np.random.seed(seed)
os.environ["PYTHONHASHSEED"] = str(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed) # current gpu seed
torch.cuda.manual_seed_all(seed) # All gpu seed
torch.backends.cudnn.deterministic = True # type: ignore
torch.backends.cudnn.benchmark = False
seed = seed_everything(42)
print(f"Setting seed to: {seed}")
print("random:", random.randint(0, 100))
print("numpy:", np.random.randint(0, 100))
print("torch:", torch.randint(0, 100, (1,)).item())
'Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] What is "self" in Python? (2) | 2025.01.07 |
---|---|
[Python] Debugging tool (Pdb) (0) | 2025.01.07 |
[Code] Studying Pytorch for Deep Learning Models (0) | 2025.01.04 |