torch.manual_seed(args.seed) #为CPU设置种子用于生成随机数,以使得结果是确定的
if args.cuda:
torch.cuda.manual_seed(args.seed)#为当前GPU设置随机种子;如果使用多个GPU,应该使用torch.cuda.manual_seed_all()为所有的GPU设置种子。
---------------------
作者:Florence_Janie
来源:优快云
原文:https://blog.youkuaiyun.com/qq_34690929/article/details/79923602
版权声明:本文为博主原创文章,转载请附上博文链接!
pytorch---之torch.manual_seed()
最新推荐文章于 2025-07-21 00:31:23 发布