Skip to content

Commit

Permalink
Merge pull request #422 from LINGLONGQIAN/patch-1
Browse files Browse the repository at this point in the history
Update set_random_seed()
  • Loading branch information
WenjieDu authored May 24, 2024
2 parents 71f90cc + 1853b0b commit bb46103
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit bb46103

Please sign in to comment.