PyTorch torch.initial_seed 函数
torch.initial_seed 是 PyTorch 中用于返回当前随机种子的函数。
函数定义
torch.initial_seed()
使用示例
实例
import torch
# 设置随机种子
torch.manual_seed(42)
# 获取当前随机种子
current_seed = torch.initial_seed()
print("当前随机种子:", current_seed)
# 设置随机种子
torch.manual_seed(42)
# 获取当前随机种子
current_seed = torch.initial_seed()
print("当前随机种子:", current_seed)

Pytorch torch 参考手册