为了保证在本机上的可复现性,需要设置随机种子:
import numpy as np
import torch
np.random.seed(0) torch.manual_seed(0) torch.cuda.manual_seed_all(0) torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False
原文:https://www.cnblogs.com/xiximayou/p/12430310.html