当前位置: 首页 > 工具软件 > Manul > 使用案例 >

torch.manual_seed(args.seed) torch.cuda.manul_seed_all(args.seed)和numpy.random.seed()

西门展
2023-12-01

#固定随机种子 args.seed=31
#为CPU设置种子用于生成随机数,以使得结果是确定的
torch.manual_seed(args.seed)
#为所有的GPU设置种子
torch.cuda.manual_seed_all(args.seed)
#没有使用GPU的时候设置的固定生成的随机数
np.random.seed(args.seed)

 类似资料: