Skip to content

Instantly share code, notes, and snippets.

@Infinitusvoid
Created August 24, 2023 22:16
Show Gist options
  • Save Infinitusvoid/ce152c28e1d0e8b74f34aa8440d5243e to your computer and use it in GitHub Desktop.
Save Infinitusvoid/ce152c28e1d0e8b74f34aa8440d5243e to your computer and use it in GitHub Desktop.
PyTorch : How to seed rand, custom seed ?
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