其他分享
首页 > 其他分享> > 2021-09-26 absl.flags._exceptions.DuplicateFlagError:

2021-09-26 absl.flags._exceptions.DuplicateFlagError:

作者:互联网

运行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’,所以只删除这一个。

标签:26,log,keys,09,absl,flags,exceptions,FLAGS,dir
来源: https://blog.csdn.net/weixin_44682956/article/details/120482460