Skip to content

Reproducibility in Minirocket Pytorch version #742

Answered by oguiza
Arderiu asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Arderiu,
You can try it using:

from fastai.torch_core import set_seed
set_seed(123, reproducibility=True)

before you instantiate the model or learner.

Here's the code set_seed uses:

def set_seed(s, reproducible=False):
    "Set random seed for `random`, `torch`, and `numpy` (where available)"
    try: torch.manual_seed(s)
    except NameError: pass
    try: torch.cuda.manual_seed_all(s)
    except NameError: pass
    try: np.random.seed(s%(2**32-1))
    except NameError: pass
    random.seed(s)
    if reproducible:
        torch.backends.cudnn.deterministic = True
        torch.backends.cudnn.benchmark = False

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Arderiu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants