Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
24 lines (17 sloc) 493 Bytes

Small Tidbits

Set Seed Everywhere

import numpy as np
import torch

def set_seed_everywhere(seed, cuda):(
       """Set the seed for numpy and pytorch

       Args:
           seed (int): the seed to set everything to
           cuda (bool): whether to set the cuda seed as well
    """
    np.random.seed(seed)
    torch.manual_seed(seed)
    if cuda:
        torch.cuda.manual_seed_all(seed)