torch.manual_seed¶ torch.manual_seed(seed)[source][source]¶ 设置所有设备上生成随机数的种子。返回一个 torch.Generator 对象。 参数: seed(整数)- 所需的种子。值必须在[-0x8000_0000_0000_0000, 0xffff_ffff_ffff_ffff]的范围内。否则,将引发 RuntimeError。负数输入将使用公式 0xffff_ffff_ffff_ffff + 种子映射为正数。 返回类型: 生成器