Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Setting the random seed does not result in same outputs across runs #109

Open
meganndare opened this issue Mar 20, 2023 · 0 comments
Open

Comments

@meganndare
Copy link

When selecting a manual seed and initiating the same exact command twice using the same exact underlying data, the results are not consistent across runs. I would expect the same exact model outputs when setting the random seed; I see that here the random seed passed into the command appears to be set (https://github.com/facebookresearch/UnsupervisedMT/blob/main/NMT/src/utils.py#L68-L72). I have also tried adding additional methods to remove randomness (see below for my current attempt):

    if params.seed >= 0:
        np.random.seed(params.seed)
        torch.manual_seed(params.seed)
        torch.cuda.manual_seed(params.seed)
        os.environ['PYTHONHASHSEED'] = str(params.seed)
        torch.cuda.manual_seed_all(params.seed)
        torch.backends.cudnn.deterministic = True
        torch.backends.cudnn.benchmark = False
        random.seed(params.seed)
        print('random seed set.')

Has anyone else been able to reproduce the EXACT same results when setting the same random seed? Any line that would be helpful to add in?

Any information would be appreciated. Thanks in advance.

Note: When generating the model run's dump_path I temporarily set Python's random library seed to None and then specify it again to be the hardcoded seed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant