When the option.py initialization parameters are written to the log log and written again to the log log, the new content is added below the dividing line.

1. Create a log.txt file and save all parameters initialized in option.py in it

with open(os.path.join(args.save_dir, args.exp_name, args.dataset_name, args.log_dir), "a") as args_log:
	for k, v in sorted(vars(args).items()):
            print('%s: %s ' % (str(k), str(v)))
            args_log.write('%s: %s \n' % (str(k), str(v)))

Display results:
Insert image description here2. Each time the training parameters are saved and the log is written again, new content is added below the dividing line

with open(os.path.join(args.save_dir, args.exp_name, args.dataset_name, args.log_dir), "a") as args_log:
        # 在新日志条目之前添加一个新行
        args_log.write('\n' + '*'*100 + '\n')
        for k, v in sorted(vars(args).items()):
            print('%s: %s ' % (str(k), str(v)))
            args_log.write('%s: %s \n' % (str(k), str(v)))

Display results:
Insert image description here
Reference:Insert image description here

Guess you like

Origin blog.csdn.net/weixin_46669187/article/details/130116049
log
log