torch随机数 manual_seed

1 import torch
2 seed = 2018
3 torch.manual_seed(seed)
4 torch.cuda.manual_seed(seed)
5 a=torch.rand([1,5])
6 # torch.manual_seed(seed)
7 # torch.cuda.manual_seed(seed)
8 b=torch.rand([1,5])
9 print(a,b)

按上面来得到的随机数不同,加上注释就会得到相同的随机数。

posted @ 2019-03-21 11:35  you-wh  阅读(3740)  评论(1编辑  收藏  举报
Fork me on GitHub