如何修复Google Colab上的tf.flags错误

时间:2019-09-20 16:40:33

标签: python tensorflow google-colaboratory

我的代码在我的系统上运行没有错误,但是在google colab上显示了此错误...

如何解决此问题?

代码:

flags = tf.flags

flags.DEFINE_string("mode", "train", "train/debug/test")

flags.DEFINE_string("target_dir", target_dir, "")
flags.DEFINE_string("log_dir", log_dir, "")
flags.DEFINE_string("save_dir", save_dir, "")
flags.DEFINE_string("train_file", train_file, "")
flags.DEFINE_string("dev_file", dev_file, "")
.
.
.

=========== 错误:

DuplicateFlagError                        Traceback (most recent call last)

<ipython-input-5-52773f56b9d0> in <module>()
     48     os.makedirs(answer_dir)
     49 
---> 50 flags.DEFINE_string("mode", 'train', "prepro/train/debug/test")
     51 
     52 flags.DEFINE_string("target_dir", target_dir, "")

4 frames

/usr/local/lib/python3.6/dist-packages/absl/flags/_flagvalues.py in __setitem__(self, name, flag)
    428         # module is simply being imported a subsequent time.
    429         return
--> 430       raise _exceptions.DuplicateFlagError.from_flag(name, self)
    431     short_name = flag.short_name
    432     # If a new flag overrides an old one, we need to cleanup the old flag's

DuplicateFlagError: The flag 'mode' is defined twice. First from /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py, Second from /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py.  Description from first occurrence: prepro/train/debug/test

0 个答案:

没有答案