运行testing.py时出现错误:
absl.flags._exceptions.DuplicateFlagError: The flag ‘log_dir’ is defined twice. First from absl.logging, Second from testing.py. Description from first occurrence: directory to write logfiles into
解决方法:在最开始添加代码段
def del_all_flags(FLAGS):
flags_dict = FLAGS._flags()
keys_list = [keys for keys in flags_dict]
print(keys_list)
keys = 'log_dir'
FLAGS.__delattr__(keys)
del_all_flags(tf.app.flags.FLAGS)
用print(keys_list)输出所有keys,[‘logtostderr’, ‘alsologtostderr’, ‘log_dir’, ‘v’, ‘verbosity’, ‘logger_levels’, ‘stderrthreshold’, ‘showprefixforinfo’, ‘run_with_pdb’, ‘pdb_post_mortem’, ‘pdb’, ‘run_with_profiling’, ‘profile_file’…]
我报错的是’log_dir’,所以只删除这一个。