torch.manual_seed是否包括torch.cuda.manual_seed_all的操作?
如果是,我们可以使用torch.manual_seed来设置种子。否则,我们应该调用这两个函数。
发布于 2021-05-18 11:18:08
是的,torch.manual_seed()确实包括数据自动化系统:
您可以使用
torch.manual_seed()为所有设备( CPU和CPU)添加RNG种子:
发布于 2021-05-18 07:25:56
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)让我相信这些都是必需的种子。
发布于 2022-10-20 03:01:36
是的,torch.manual_seed在内部调用torch.cuda.manual_seed_all。
除了@iacob的答案以外的其他证据可以在PyTorch源代码中找到。
def manual_seed(seed) -> torch._C.Generator:
...
if not torch.cuda._is_in_bad_fork():
torch.cuda.manual_seed_all(seed)
...https://stackoverflow.com/questions/67581281
复制相似问题