MCPcopy Create free account
hub / github.com/JasonLSC/GSCodec_Studio / verify_random_seed

Function verify_random_seed

examples/utils.py:173–214  ·  view source on GitHub ↗

Verify random seed consistency by generating a checksum and save to file Should be called after set_random_seed() Args: result_dir: Directory to save the checksum file Returns: str: MD5 checksum of generated random numbers

(result_dir: str)

Source from the content-addressed store, hash-verified

171 torch.backends.cudnn.allow_tf32 = False
172
173def verify_random_seed(result_dir: str):
174 """
175 Verify random seed consistency by generating a checksum and save to file
176 Should be called after set_random_seed()
177
178 Args:
179 result_dir: Directory to save the checksum file
180
181 Returns:
182 str: MD5 checksum of generated random numbers
183 """
184 import hashlib
185 import os
186
187 # Generate random numbers from different generators
188 test_results = {
189 'python_random': random.random(),
190 'numpy_random': np.random.rand(),
191 'torch_random': torch.rand(1).item(),
192 }
193
194 # Test CUDA random numbers if available
195 if torch.cuda.is_available():
196 test_results['torch_cuda_random'] = torch.cuda.FloatTensor(1).uniform_().item()
197
198 # Generate checksum from results
199 result_str = ""
200 for key in sorted(test_results.keys()):
201 result_str += f"{key}:{test_results[key]:.10f};"
202
203 checksum = hashlib.md5(result_str.encode()).hexdigest()
204
205 # Write checksum to file
206 checksum_file = os.path.join(result_dir, 'seed_checksum.txt')
207 with open(checksum_file, 'w') as f:
208 f.write(checksum)
209
210 print(f"Random seed checksum: {checksum}")
211 print(f"Checksum saved to: {checksum_file}")
212 print("Sample results:", test_results)
213
214 return checksum
215
216
217# ref: https://github.com/hbb1/2d-gaussian-splatting/blob/main/utils/general_utils.py#L163

Callers 2

__init__Method · 0.90
__init__Method · 0.90

Calls 2

writeMethod · 0.80
encodeMethod · 0.45

Tested by

no test coverage detected