torch.manual_seed()

torch.manual_seed(args.seed) #为CPU设置种子用于生成随机数,以使得结果是肯定的 if args.cuda: torch.cuda.manual_seed(args.seed)#为当前GPU设置随机种子;若是使用多个GPU,应该使用torch.cuda.manual_seed_all()为全部的GPU设置种子。web
本站公众号
   欢迎关注本站公众号,获取更多信息