PyTorch torch.cuda.seed 関数


Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

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")

Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

その他の拡張