| import torch | |
| import numpy as np | |
| import random | |
| def seed_run(seed=42): | |
| torch.manual_seed(seed) | |
| np.random.seed(seed) | |
| random.seed(seed) | |
| if torch.cuda.is_available(): | |
| torch.cuda.manual_seed_all(seed) | |
| torch.backends.cudnn.deterministic = True | |
| torch.backends.cudnn.benchmark = False | |
| def print_args(args): | |
| message = '' | |
| message += '----------------- Options ---------------\n' | |
| for k, v in sorted(vars(args).items()): | |
| message += '{:>25}: {:<30}\n'.format(str(k), str(v)) | |
| message += '----------------- End -------------------' | |
| print(message) |