PyTorch torch.are_deterministic_algorithms_enabled 関数
torch.are_deterministic_algorithms_enabledPyTorchで決定性アルゴリズムが有効かどうかを確認するための関数です。Trueを返す場合は決定性アルゴリズムが有効になっていることを示し、毎回実行しても同じ結果が生成されることを意味します。
関数定義
torch.are_deterministic_algorithms_enabled()
使用例
例
import torch
# 決定性アルゴリズムが有効かどうかを確認
is_deterministic = torch.are_deterministic_algorithms_enabled()
print(f"Deterministic algorithms enabled: {is_deterministic}")
# 決定性アルゴリズムを有効に設定
torch.use_deterministic_algorithms(True)
is_deterministic = torch.are_deterministic_algorithms_enabled()
print(f"After setting: {is_deterministic}")
# 決定性アルゴリズムが有効かどうかを確認
is_deterministic = torch.are_deterministic_algorithms_enabled()
print(f"Deterministic algorithms enabled: {is_deterministic}")
# 決定性アルゴリズムを有効に設定
torch.use_deterministic_algorithms(True)
is_deterministic = torch.are_deterministic_algorithms_enabled()
print(f"After setting: {is_deterministic}")
その他の拡張
Pytorch torch リファレンスマニュアル