Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update set_random_seed() #422

Merged
merged 2 commits into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pypots/utils/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import numpy as np
import torch

import random
from .logging import logger

RANDOM_SEED = 2204
Expand All @@ -25,6 +25,9 @@ def set_random_seed(random_seed: int = RANDOM_SEED) -> None:
globals()["RANDOM_SEED"] = random_seed
np.random.seed(random_seed)
torch.manual_seed(random_seed)
random.seed(random_seed)
torch.cuda.manual_seed_all(random_seed)
# torch.backends.cudnn.deterministic = True
logger.info(f"Have set the random seed as {random_seed} for numpy and pytorch.")


Expand Down
Loading