# random, numpy
random.seed(123)
np.random.seed(456)

# torch
torch.manual_seed(1111)
torch.cuda.manual_seed(2222)
torch.cuda.manual_seed_all(3333)
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.enabled = True

# tensorflow
from tfdeterminism import patch
patch()
os.environ['PYTHONHASHSEED'] = str(9999)
tensorflow.set_random_seed(7777)
Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐