import torch
seed = 2018
torch.manual_seed(seed) # 为CPU设置种子用于生成随机数
torch.cuda.manual_seed(seed)#为当前GPU设置随机种子;如果使用多个GPU,应该使用torch.cuda.manual_seed_all()为所有的GPU设置种子。
a=torch.rand([1,5]
pytorch关于随机种子的问题
最新推荐文章于 2022-07-30 20:12:41 发布
import torch
seed = 2018
torch.manual_seed(seed) # 为CPU设置种子用于生成随机数
torch.cuda.manual_seed(seed)#为当前GPU设置随机种子;如果使用多个GPU,应该使用torch.cuda.manual_seed_all()为所有的GPU设置种子。
a=torch.rand([1,5]