PyTorch torch.use_deterministic_algorithms 関数
torch.use_deterministic_algorithmsは PyTorch において決定論的アルゴリズムを使用するための関数です。可能な場合に決定論的アルゴリズムを使用するかどうかを設定します。
関数定義
torch.use_deterministic_algorithms(enabled, warn_only=False)
使用例
例
import torch
# 決定論的アルゴリズムを有効にする
torch.use_deterministic_algorithms(True)
# 有効かどうかを確認する
print(f"Using deterministic algorithms: {torch.are_deterministic_algorithms_enabled()}")
# 決定論的アルゴリズムを無効にする
torch.use_deterministic_algorithms(False)
print(f"Using deterministic algorithms: {torch.are_deterministic_algorithms_enabled()}")
# 決定論的アルゴリズムを有効にする
torch.use_deterministic_algorithms(True)
# 有効かどうかを確認する
print(f"Using deterministic algorithms: {torch.are_deterministic_algorithms_enabled()}")
# 決定論的アルゴリズムを無効にする
torch.use_deterministic_algorithms(False)
print(f"Using deterministic algorithms: {torch.are_deterministic_algorithms_enabled()}")
その他の拡張機能
Pytorch torch リファレンスマニュアル