UnrecognizedFlagError: Unknown command line flag 'f'

Viewed 29

When I am trying to run the following code in jupyter notebook(for graph clustering) This is my main run file from which I am trying to import the other code snippets and trying to run the entire code.

import tensorflow.compat.v1 as tf  

tf.random.set_seed(1234) 
flags = tf.compat.v1.flags
FLAGS = flags.FLAGS

for name in list(flags.FLAGS):
    delattr(flags.FLAGS,name)
flags.DEFINE_float('learning_rate', 0.001, 'initial learning rate.')

# left to default values in main experiments 
flags.DEFINE_integer('epochs', 2000, 'number of epochs to train.')
#logging, saving, validation settings etc.
flags.DEFINE_integer('print_every', 20, "How often to print training info.")
flags.DEFINE_string('dataset', '20news', 'dataset')
flags.DEFINE_integer('emb', 100, "How often to print training info.")
flags.DEFINE_float('beta',2.0, 'weight for beta loss')
flags.DEFINE_boolean('shareW', False, 'share the w')
  

adjs,xs, ys, cnets,Gs= load_data(FLAGS.dataset,norm=True)
n_networks = len(xs)
n_clusters = [len(np.unique(y)) for y in ys]

The error message that I am getting is:

UnrecognizedFlagError                     Traceback (most recent call last)
Input In [14], in <cell line: 35>()
     30 flags.DEFINE_string('output_dir', './', 'output_dir')
     31 flags.DEFINE_integer('hdim', 128, 'hidden represenation size')
---> 35 adjs,xs, ys, cnets,Gs= load_data(FLAGS.dataset,norm=True)
     36 n_networks = len(xs)
     37 n_clusters = [len(np.unique(y)) for y in ys]

File ~/anaconda3/lib/python3.9/site-packages/tensorflow/python/platform/flags.py:81, in _FlagValuesWrapper.__getattr__(self, name)
     78 # To maintain backwards compatibility, implicitly parse flags when reading
     79 # a flag.
     80 if not wrapped.is_parsed():
---> 81   wrapped(_sys.argv)
     82 return wrapped.__getattr__(name)

File ~/anaconda3/lib/python3.9/site-packages/absl/flags/_flagvalues.py:649, in FlagValues.__call__(self, argv, known_only)
    647 for name, value in unknown_flags:
    648   suggestions = _helpers.get_flag_suggestions(name, list(self))
--> 649   raise _exceptions.UnrecognizedFlagError(
    650       name, value, suggestions=suggestions)
    652 self.mark_as_parsed()
    653 self.validate_all_flags()

UnrecognizedFlagError: Unknown command line flag 'f'

Please, can anyone help me with this. Thanking you in advance.

0 Answers
Related