Fixed available seeds for reproducibility. Args: seed: [int] Seed value. with_torch: Flag. If true, torch-related seeds are fixed. with_cuda: Flag. If true, torch+cuda-related seeds are fixed
(seed, with_torch=True, with_cuda=True)
| 107 | |
| 108 | |
| 109 | def fix_seeds(seed, with_torch=True, with_cuda=True): |
| 110 | """Fixed available seeds for reproducibility. |
| 111 | |
| 112 | Args: |
| 113 | seed: [int] Seed value. |
| 114 | with_torch: Flag. If true, torch-related seeds are fixed. |
| 115 | with_cuda: Flag. If true, torch+cuda-related seeds are fixed |
| 116 | """ |
| 117 | random.seed(seed) |
| 118 | np.random.seed(seed) |
| 119 | if with_torch: |
| 120 | torch.manual_seed(seed) |
| 121 | if with_cuda: |
| 122 | torch.cuda.manual_seed(seed) |
| 123 | torch.cuda.manual_seed_all(seed) |
| 124 | torch.backends.cudnn.deterministic = True |
| 125 | |
| 126 | |
| 127 | def compute_and_store_final_results( |
nothing calls this directly
no outgoing calls
no test coverage detected