PyTorch torch.set_deterministic_algorithm_enabled function
Pytorch torch Reference Manual
torch.set_deterministic_algorithm_enabledIt is a function in PyTorch used to set deterministic algorithms. It sets whether to enable deterministic algorithms; when enabled, each run will produce the same result.
Function definition
torch.set_deterministic_algorithm_enabled(enabled, mode='warn')
Usage example
Example
import torch
# Set to enable deterministic algorithms
torch.set_deterministic_algorithm_enabled(True)
# Check whether it is enabled
print(f"Is deterministic: {torch.are_deterministic_algorithms_enabled()}")
# Disable deterministic algorithms
torch.set_deterministic_algorithm_enabled(False)
print(f"Is deterministic: {torch.are_deterministic_algorithms_enabled()}")
# Set to enable deterministic algorithms
torch.set_deterministic_algorithm_enabled(True)
# Check whether it is enabled
print(f"Is deterministic: {torch.are_deterministic_algorithms_enabled()}")
# Disable deterministic algorithms
torch.set_deterministic_algorithm_enabled(False)
print(f"Is deterministic: {torch.are_deterministic_algorithms_enabled()}")
Other extensions