コード例 #1
0
def setRNGSeed(seed):
    #numpy
    np.random.seed(seed)
    #torch
    torch.manual_seed(seed)
    torch.cuda.manual_seed(seed)  # sets on...curent cuda device
    torch.cuda.manual_seed_all(seed)  # sets on all devices in use
    #Pyro...maybe, seems to just set them for torch again...which would make sense
    set_rng_seed(seed)
    print("you are setting cudnn to deterministic, may make things slower")
    logging.info("cudnn is set to deterministic which may slow speed fyi")
    torch.backends.cudnn.deterministic = True
    torch.backends.cudnn.benchmark = False
コード例 #2
0
ファイル: test_properties.py プロジェクト: zyxue/pyro
def get_trace(fn, *args, **kwargs):
    set_rng_seed(123)
    return poutine.trace(fn).get_trace(*args, **kwargs)
コード例 #3
0
ファイル: seed_messenger.py プロジェクト: xidulu/pyro
 def __enter__(self):
     self.old_state = get_rng_state()
     set_rng_seed(self.rng_seed)