torch.manual_seed()及其作用

含义

torch.manual_seed(parameter) #为CPU设置种子用于生成随机数,以使得结果是确定的
torch.cuda.manual_seed(parameter)#为当前GPU设置随机种
torch.cuda.manual_seed_all(parameter)#如果使用多个GPU,应该使用为所有的GPU设置种子。

其中parameter为int型变量

作用

设置唯一确定随机数种子,确保随机数种子不变,使得程序每次使用random函数均可获得同一随机值

参考By Florence_Janie

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章