MCPcopy Create free account
hub / github.com/amazon-science/patchcore-inspection / fix_seeds

Function fix_seeds

src/patchcore/utils.py:109–124  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

107
108
109def 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
127def compute_and_store_final_results(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected