PyTorch torch.cuda.seed 関数
torch.cuda.seedこれは PyTorch で CUDA のランダムシードを設定するための関数です。現在の CUDA デバイスにランダムシードを設定します(機能は manual_seed と同じです)。
関数定義
torch.cuda.seed()
使用例
例
import torch
# CUDA ランダムシードを設定
if torch.cuda.is_available():
torch.cuda.seed()
x = torch.randn(3, 3).cuda()
print(f"Random tensor on CUDA: {x}")
else:
print("CUDA not available")
# CUDA ランダムシードを設定
if torch.cuda.is_available():
torch.cuda.seed()
x = torch.randn(3, 3).cuda()
print(f"Random tensor on CUDA: {x}")
else:
print("CUDA not available")
その他の拡張
Pytorch torch リファレンスマニュアル