Skip to content

Seed Comment #9

Description

@Max-ChenFei

Hi, thanks for work. I try to improve the reproducibility, but the comment in the json file seems not consistent with the code.

"seed" : -1, // random seed, seed <0 represents randomization not used

EMDiffuse/core/util.py

Lines 45 to 60 in 79c8045

""" set random seed, gl_seed used in worker_init_fn function """
if seed >= 0 and gl_seed >= 0:
seed += gl_seed
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
np.random.seed(seed)
random.seed(seed)
''' change the deterministic and benchmark maybe cause uncertain convolution behavior.
speed-reproducibility tradeoff https://pytorch.org/docs/stable/notes/randomness.html '''
if seed >= 0 and gl_seed >= 0: # slower, more reproducible
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
else: # faster, less reproducible
torch.backends.cudnn.deterministic = False
torch.backends.cudnn.benchmark = True

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions