Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print flag descriptions in Tensorflow?

Google has many examples that use flags. They all have descriptions in the definition. Is there a way I can print these descriptions out to the terminal?

flags = tf.app.flags
FLAGS = flags.FLAGS
flags.DEFINE_boolean('test_mode', False, 'This is the description I want A.')
flags.DEFINE_boolean('cool_mode', True, 'This is the description I want B.')
like image 484
user3155053 Avatar asked Dec 19 '22 21:12

user3155053


2 Answers

The flags module used in TensorFlow is a wrapper around the python-gflags module. To see a list of all flags used in a Python application using python-gflags, you can run it with the -h or --help flag. For example:

$ tensorboard -h
usage: tensorboard [-h] [--logdir LOGDIR] [--debug DEBUG] [--nodebug]
                   [--host HOST] [--port PORT]

optional arguments:
  -h, --help       show this help message and exit
  --logdir LOGDIR  logdir specifies where TensorBoard will look to find
                   TensorFlow event files that it can display. In the simplest
                   case, logdir is a directory containing tfevents files.
                   TensorBoard also supports comparing multiple TensorFlow
                   executions: to do this, you can use directory whose
                   subdirectories contain tfevents files, as in the following
                   example: foo/bar/logdir/
                   foo/bar/logdir/mnist_1/events.out.tfevents.1444088766
                   foo/bar/logdir/mnist_2/events.out.tfevents.1444090064 You
                   may also pass a comma seperated list of log directories,
                   and you can assign names to individual log directories by
                   putting a colon between the name and the path, as in
                   tensorboard
                   --logdir=name1:/path/to/logs/1,name2:/path/to/logs/2
  --debug DEBUG    Whether to run the app in debug mode. This increases log
                   verbosity to DEBUG.
  --nodebug
  --host HOST      What host to listen to. Defaults to allowing remote access,
                   set to 127.0.0.1 to serve only on localhost.
  --port PORT      What port to serve TensorBoard on.
like image 143
mrry Avatar answered Dec 21 '22 10:12

mrry


A tricky way:

print(FLAGS.__dict__['__flags'])

You can find reason in file tensorflow/python/platform/flags.py

like image 35
孙忠汉 Avatar answered Dec 21 '22 09:12

孙忠汉