pytorch设置随机数种子seed
时间:2020-08-05 00:14:00
收藏:0
阅读:251
定义个函数。
def set_seed(seed):
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
np.random.seed(seed)
random.seed(seed)
torch.backends.cudnn.deterministic = True
在程序入口处设置随机数种子。
set_seed(7)
原文:https://www.cnblogs.com/sumuyi/p/13435910.html
评论(0)