Created
August 24, 2023 22:16
-
-
Save Infinitusvoid/ce152c28e1d0e8b74f34aa8440d5243e to your computer and use it in GitHub Desktop.
PyTorch : How to seed rand, custom seed ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
# Set the random seed | |
RANDOM_SEED = 42 | |
torch.manual_seed(RANDOM_SEED) | |
random_tensor_A = torch.rand(3, 4) | |
print(random_tensor_A) | |
torch.manual_seed(RANDOM_SEED) | |
random_tensor_B = torch.rand(3, 4) | |
print(random_tensor_B) | |
print(random_tensor_A == random_tensor_B) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment