If I run this code twice:
tf.flags.DEFINE_integer("batch_size", "2", "batch size for training")
I will get this error:
DuplicateFlagError: The flag 'batch_size' is defined twice. First from D:/Python/workspace/FCN_dataset/FCN.tensorflow-master/FCN.py, Second from D:/Python/workspace/FCN_dataset/FCN.tensorflow-master/FCN.py. Description from first occurrence: batch size for training
I know that it's because of I redefine the default value of flag. So how can I clear flags or allow to redefine the flag's default value?
tf.flags.FLAGS.__delattr__()
can delete flags, so define a function to delete all flags:
def del_all_flags(FLAGS):
flags_dict = FLAGS._flags()
keys_list = [keys for keys in flags_dict]
for keys in keys_list:
FLAGS.__delattr__(keys)
Then run:
del_all_flags(tf.flags.FLAGS)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With