【colab pytorch】设置随机种子

为了保证在本机上的可复现性,需要设置随机种子:

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

猜你喜欢

转载自www.cnblogs.com/xiximayou/p/12430310.html
今日推荐