Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add functionality to set seed #772

Open
NickleDave opened this issue Aug 26, 2024 · 2 comments
Open

ENH: Add functionality to set seed #772

NickleDave opened this issue Aug 26, 2024 · 2 comments

Comments

@NickleDave
Copy link
Collaborator

We should add functionality to set the seed for torch

This came up because @VinCheetah is having a bit of trouble replicating results from the 2022 eLife TweetyNet paper

A separate question is whether we want to "set the seed for everything", I see some libraries do something like this (from https://gist.github.com/gatheluck/c57e2a40e3122028ceaecc3cb0d152ac)

import os
import random
import numpy as np
import torch

def set_all_seeds(seed):
  random.seed(seed)
  os.environ('PYTHONHASHSEED') = str(seed)
  np.random.seed(seed)
  torch.manual_seed(seed)
  torch.cuda.manual_seed(seed)
  torch.backends.cudnn.deterministic = True

Earlier versions of lightning similarly had a function seed_everything (that AFAICT has since migrated to fabric): https://pytorch-lightning.readthedocs.io/en/1.7.7/api/pytorch_lightning.utilities.seed.html#pytorch_lightning.utilities.seed.seed_everything

but just doing a bare minimum of setting the torch seed will let us control e.g. random initialization of model parameters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

3 participants
@NickleDave and others