Skip to content

Instantly share code, notes, and snippets.

View SJCaldwell's full-sized avatar

Shane Caldwell SJCaldwell

View GitHub Profile
@SJCaldwell
SJCaldwell / reproducible.py
Created May 20, 2025 16:15
Striving for reproducibility in pytorch (many seeds)
import random
import numpy as np
def set_seeds(seed=42):
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed) # for multi-GPU
torch.backends.cudnn.deterministic = True