kk_contour_net_shallow/thesis code/shallow net/functions/set_seed.py

13 lines
308 B
Python
Raw Normal View History

import torch
import numpy as np
def set_seed(seed: int, logger) -> None:
# set seed for all used modules
if logger:
logger.info(f"set seed to {seed}")
torch.manual_seed(seed=seed)
if torch.cuda.is_available():
torch.cuda.manual_seed(seed=seed)
np.random.seed(seed=seed)